CSCE 311 FALL 2017 Process Coordination Name: Due 1. Consider a version of the b
ID: 3595725 • Letter: C
Question
CSCE 311 FALL 2017 Process Coordination Name: Due 1. Consider a version of the bounded buffer problem in which there are one producer process (Pi) and two consumer processes (P2 and Ps) all sharing the same buffer. Assume that the size of the buffer is n 4, and that we start with a completely empty buffer. The structure of P. P2, and P, as well as the semaphores and buffer is shown below: / structure of P1 / do ( / structure of P2&P3;/ do ( wait (ful1) wait (mutex) nextp buffer[out] out- (out + 1) % n signal (mutex) signal (empty) tem O item 1 item 2 item3 produce an item in nextp wait (empty) wait (mutex) buffer(in]- nextp in = (in + 1) n signal (mutex) signal (full) in consume item in nextp 0 4. 0 full out empty mutex while(1) while (1) Assume a preemptive scheduler and that all processes start in the ready queue at the same time in the order from head to tail, P3, P2, and Pl (P3 at the head of the queue). Let the process priorities be: P3 -1,P2 = 1, and P1=2. Draw the contents of the indices "in" and "out", as well as the state of the semaphores and the contents of the buffer after 2 items have been consumed. In the case of the buffers, simply notate each item with the name of the process that accessed it last.Explanation / Answer
RQ->P2-P1->P3
P2: Full: -1 => P2 blocks
P1: Produce item
P3: Full: -2 => P3 blocks
P1: MT: 3, mux: 0, item: P1, in: 1, mux: 1, Full=-1 unblocks
P3: mux: 0, item: P3, Out:1, mux: 1, MT: 4
P1: produce item
P3: consume item
P1: MT 3, mux: 0, item1: P1, in: 2, mux: 1, Full: 0 unblock P2
P3: Full: -1, P3 blocks
P2: mux: 0, item1: P2, out: 2, mux: 1, MT: 4
P1: produce item
P2: consume item
P3
Item 0
P2
Item 1
Item 2
Item 3
2
in
2
out
4
empty
-1
full
1
mutex
P3
Item 0
P2
Item 1
Item 2
Item 3