Alignant
Does C have a future ?
It doesn't have a condition variable either :D
Ludovic 'Archivist'
because each camera is on different threads
And? condition_variable is thread safe, it is a synchronization system
Anonymous
each camera has to finish in order for me to move to the next step in the algorithm
Anonymous
And? condition_variable is thread safe, it is a synchronization system
however i could do it with 6 condition variables
Anonymous
or just one which is a semaphore
Alignant
because each camera is on different threads
Would it be enough to have only one thread per each camera?
Ludovic 'Archivist'
however i could do it with 6 condition variables
or just one which is an int, with computation going on when it gets equal to 6
Anonymous
Alignant
well actually each one has 2 threads
It must have like... a thread per a stream or so
Ludovic 'Archivist'
which is what a semaphore is
Exactly, making C++ have semaphores
Anonymous
no it does not have easy ones
Ludovic 'Archivist'
So they don't get the name, but are here
Anonymous
and relies on g++ implementing all operations on ints as atomic ones
Anonymous
or me to use volatile
Anonymous
which is a bad programming practice because it lowers the optimizations around that variable
Ludovic 'Archivist'
or me to use volatile
volatiles are not atomic
Ludovic 'Archivist'
Anonymous
volatiles are not atomic
they are for a real time operating system purpose
Anonymous
it is used a LOT in embedded systems especially with real time oses
Ludovic 'Archivist'
Unless you have a single thread
Alignant
Unless you have a single thread
Where everything is atomic? :D
Ludovic 'Archivist'
Adhi
Alignant
Is that LGBT flag?
Ludovic 'Archivist'
You can consider volatile to work like atomic IF AND ONLY IF a single thread writes to the variable
Anonymous
Anonymous
because for those systems we require basic operations to be atomic
Anonymous
like ints
Anonymous
and so on
olli
Volatile does not make them atomic
Anonymous
Unless you have a single thread
or you are using atomic datastructures like ints
Anonymous
for gcc
Ludovic 'Archivist'
because for those systems we require basic operations to be atomic
volatile do not make anything atomic, they make things updated on time of use
Alignant
because for those systems we require basic operations to be atomic
Yah, and your code would be platform dependent
Ludovic 'Archivist'
atomic instructions use completely different CPU instructions
Ludovic 'Archivist'
ints are not atomic
True, nothing is UNLESS SPECIFIED OTHERWISE
Alignant
I am atomic ^-^
Anonymous
Yah, and your code would be platform dependent
you are working on embedded systems you kindof need to
Anonymous
atomic instructions use completely different CPU instructions
yes however if an instruction takes one clock cycle
Anonymous
it is pretty much completely atomic to execute that instruction
Ludovic 'Archivist'
yes however if an instruction takes one clock cycle
and adding something to a point in RAM takes 2, like any operation over memory out of registers
Alignant
you are working on embedded systems you kindof need to
If you want to reuse your code, you want to make platform dependent parts as small as you can. You don't want all of your software to be platform dependent
Ludovic 'Archivist'
no you just keep it in a register
You don't if it is volatile
Anonymous
if you use the register keyword you do
Ludovic 'Archivist'
furthermore, the CPU pipeline may take up to 5 instructions to propagate a volatile change in memory
Ludovic 'Archivist'
Alignant
You don't if it is volatile
Are volatiles cached in a processor?
Anonymous
then it is not a volatile
volatile just means it is able to be changed at any time
Ludovic 'Archivist'
Anonymous
for basic things like ints it is close enough to atomic that it is considered as cheap atomic variables
Alignant
Register volatiles, anyone? ^^
Ludovic 'Archivist'
if two threads increment a volatile near the same time, only one increment may happen
Ludovic 'Archivist'
Register volatiles, anyone? ^^
means the variable is in register and cannot be optimized away or anything
olli
Aka lost update
Ludovic 'Archivist'
Aka lost update
exactly, this is why we use test_and_set operations
Ludovic 'Archivist'
which are TRULY atomic
Anonymous
can you give me an example of this
Alignant
never had this occur
That's what makes debugging so fun, actually
Anonymous
That's what makes debugging so fun, actually
oh i had one programmer who sent a double pointer to memcpy
Anonymous
and i was wondering why the fuck did the code not work
Anonymous
when i saw that & to the pointer thing i almost shot myself
Anonymous
that guy worked in the field for 20 fucking years
Alignant
I'm not sure what I like more. Having a double pointer or passing it to memcpy :D
Anonymous
THERE IS A REASON I MAKE PEOPLE DO FUCKING UNIT TESTS BEFORE PUSHING THEIR FUCKING CODE
Alignant
Do you have unit tests on embedded systems?
Anonymous
i try to get them to
Anonymous
but it is hard
Anonymous
because they just do not want to FUCKING WRITE UNIT TESTS
Alignant
Yeah, most people I know who do embedded
Alignant
Don't use unit tests
Anonymous
i am not even making them do boost unit tests