from Bjoern Doebel :
Are you just having a problem understanding the observed values or is there a real problem that you are running into? If the latter, could you provide a small example program so that we can reproduce it here?
That's a real problem. I use several producer (08 and others) and one consumer (03) around a queue. I observed state 4, 5 and 6. This is anoying because semaphore_down exits as my queue is empty. At the begining I looked for some memory overflow into my code... But I found the scenario above which could explain this strange state.
I tried a little change into archindep.h and the problem doesn't appear anymore. However, I find it very dirty and uncomplete because asm.h and generic should be also changed. As I don't know very well semaphore, maybe there are some case broken ?
Marc
--- include/archindep.h (revision 230) +++ include/archindep.h (working copy) @@ -54,7 +54,7 @@ L4_INLINE int l4semaphore_down_timed(l4semaphore_t * sem, unsigned timeout) { - int old,tmp,ret; + int old,pending,tmp,ret; l4_umword_t dummy; l4_msgdope_t result;
@@ -66,6 +66,7 @@ do { old = sem->counter; + pending = sem->pending tmp = old - 1; } /* retry if someone else also modified the counter */ @@ -73,7 +74,7 @@ (l4_uint32_t)old, (l4_uint32_t)tmp));
- if (tmp < 0) + if (pending || (tmp < 0)) { /* we did not get the semaphore, block */ ret = l4_ipc_call(l4semaphore_thread_l4_id,