This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: condition variables and mutexes


"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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]