This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: condition variables and mutexes
- To: "Trenton D. Adams" <tadams at theone dot dnsalias dot com>
- Subject: Re: [ECOS] condition variables and mutexes
- From: Robin Farine <acnrf at dial dot eunet dot ch>
- Date: 10 Aug 2001 17:38:47 +0200
- Cc: <ecos-discuss at sources dot redhat dot com>
- References: <001301c121ac$2276d830$090110ac@TRENT>
"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