Machine-translated by Google. Questions are authored in English.
Top

Discussion

The bounded buffer or producer-consumer pattern needs

  • A.no synchronisation, the buffer being fixed in size
  • B.two semaphores, counting free and filled slots
  • C.one binary semaphore shared by producer and consumer
  • D.a recursive mutex taken by both parties

Answer: B

One semaphore counts empty slots and blocks the producer when the buffer is full; the other counts full slots and blocks the consumer when it is empty. A mutex is added where several producers or consumers share the structure.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.