Then the producer executes a P operation on the mutex semaphore. The mutex
semaphore is there to make sure that the producer and consumer cannot simultaneously add and consume items,
for that would lead to elusive errors of synchronization. When the producer succeeds and produces a new item,
the producer executes a V operation on the mutex semaphore to release control of the group of items to be
consumed, and a V operation on the full semaphore. The full semaphore keeps a count of the items
waiting to be consumed, and the consumer will test that semaphore with a P operation before trying to consume
an item.
When the consumer is ready to do something with the items provided by the producer, the consumer executes
a P operation on the full semaphore to be sure that something is there to consume. If so, the consumer
does not block, and instead goes on to test the mutex semaphore using the P operation. If the P operation on
the mutex semaphore does not block, it means that the consumer has exclusive access to the set of items
ready to be consumed. After the consumer removes an item from the set, the consumer releases the
mutex semaphore by executing a V operation on the mutex. The consumer then increments the count of
additional items permitted to be in the set of items to be consumed, by executing a V operation on the
empty semaphore.
Pages:
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293