GATEverse
← GATE CSE 1999

Q20-b

NATMarks unknown

Consider the following solution to the producer-consumer problem using a buffer of size 1. Assume that the initial value of count is 0. Also assume that the testing of count and assignment to count are atomic operations. Producer: Repeat Produce an item; if count = 1 then sleep; place item in buffer. count = 1; Wakeup(Consumer); Forever Consumer: Repeat if count = 0 then sleep; Remove item from buffer; count = 0; Wakeup(Producer); Consume item; Forever; Show that in this solution it is possible that both the processes are sleeping at the same time.

Sign in to save attempts.

Loading…