[ECOS] condition variables and mutexes

Robin Farine acnrf@dial.eunet.ch
Fri Aug 10 08:39:00 GMT 2001


"Trenton D. Adams" <tadams@theone.dnsalias.com> writes:

> Do I have to do the "while buffer empty" part if I've only got one
> consumer thread?  Because I figured the condition variable would only
> get signaled once each round, and the buffer would never be empty except
> for when the transmit thread is waiting on the condition variable.  No?

If you have exactly one producer and one consumer then you can a simple solution
that uses a ring buffer and a cardinal semaphore that counts the items in the
buffer. The producer waits for the semaphore and uses the buffer's in_index
while the consumer uses the out_index and signals the semaphore.

[...]

Robin



More information about the Ecos-discuss mailing list