117 other synchronization errors 597 each peer thread

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: t functions, respectively. 11.4.5 Signaling With Semaphores We saw in the previous section how semaphores can be used for sharing. But semaphores can also be used for signaling. In this scenario, a thread uses a semaphore operation to notify another thread when some condition in the program state becomes true. A classic example is the producer-consumer interaction shown in Figure 11.18. A producer thread and a consumer thread share a buffer with Ò slots. The producer thread repeatedly produces new items and inserts them in the buffer. The consumer thread repeatedly removes items from the buffer and then consumes them. Other variants allow different combinations of single and multiple producers and consumers. Producer-consumer interactions are common in real systems. For example, in a multimedia system, the producer might encode video frames while the consumer decodes and renders them on the screen. The purpose of the buffer is to reduce jitter in the video stream caused by data-dependent...
View Full Document

Ask a homework question - tutors are online