Practice mode Operating Systems

In the bounded-buffer producer-consumer problem with n slots using semaphores mutex, empty and full, what are their initial values?

Correct answer D. mutex = 1, empty = n, full = 0

Explanation

mutex guards the buffer, so it starts at 1 to let one process in. empty counts free slots and starts at n because the buffer is empty, and full counts filled slots and starts at 0. The producer waits on empty before inserting and signals full afterwards; the consumer does the reverse. Swapping the initial values of empty and full would make the consumer read slots that hold nothing.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.