Clive Wilson wrote:
At 10:20 31/05/2007, you wrote:

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...

It is the same mutex. Condition variables always have a mutex associated with them. When you wait on a CV, the mutex is automatically unlocked by the OS, and when you wake up after the CV is signalled, the OS automatically relocks the mutex before the wait function returns.

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


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

Reply via email to