But this would be a bad idea why practice problem 116

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fer to be empty with a È operation on semaphore empty. After the producer writes the item to the buffer, it informs the consumer that there is now a valid item with a Î operation on full. Conversely, the consumer thread waits for a valid item with a È operation on full. After reading the item, it signals that the buffer is empty with a Î operation on empty. The impact at run-time is that the producer and consumer ping-pong back and forth, as shown in Figure 11.21. 11.5 Synchronizing Threads with Mutex and Condition Variables As an alternative to È and Î operations on semaphores, Pthreads provides a family of synchronization operations on mutex and condition variables. In general, we prefer semaphores over their Pthreads counterparts because they are more elegant and simpler to reason about. However, there are some useful synchronization patterns, such as timeout waiting, that are impossible to implement with semaphores. Thus, it is worthwhile to have some facility with the Pthreads operations. I...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online