|
From: | Jonathan Larmour |
Subject: | Re: [lwip-users] SemSignal gets called on a already signaled semaphore |
Date: | Thu, 31 May 2007 10:20:39 +0100 |
User-agent: | Thunderbird 1.5.0.10 (X11/20070301) |
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 Jifl -- eCosCentric Limited http://www.eCosCentric.com/ The eCos experts Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571 Registered in England and Wales: Reg No 4422071. ------["The best things in life aren't things."]------ Opinions==mine
[Prev in Thread] | Current Thread | [Next in Thread] |