At 10:20 31/05/2007, you wrote:
Matthias Weisser wrote:
Hi
After playing around with my echo server I saw a strange behavior of my
sys_sem_signal() implementation. I have implemented the semaphores as
binary mutexes. Now I see that one of the semaphores is created with a
initial count of 0 then signaled and then signaled again. Can this be
ignored as I expect or indicates it another bug in my port?

Semaphores and mutexes are not identical. Especially, as in this case, when the semaphores are counting semaphores, not binary. But you can abstract it using mutexes and condition variables, and a variable to represent the semaphore count.

So waiting on a semaphore would mean:
lock mutex
while (count==0)
  wait on condition variable
count--
unlock mutex

And posting a semaphore:
lock mutex
count++
signal condition variable
unlock mutex

Jonathan,

As a clarification of the above example, is the intention for the mutex used by the semaphore pend to be the same as the one used by the semaphore post? I imagine not, otherwise the pend would wait on the condition variable with the mutex locked, therefore preventing a post from occurring...

Kind regards,

Clive Wilson



_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to