Question: A producer and a consumer threads are sharing a buffer as shown below. The buffer is initialized with blank characters in each position. Semaphores A,
A producer and a consumer threads are sharing a buffer as shown below. The buffer is initialized with blank characters in each position. Semaphores A, B, and C are used to protect the buffer and are initialized properly. After the threads have been running for a while, the buffer appears as shown below and the threads are executing at the location shown by the arrows below. If the last character placed in the buffer was d and the value of semaphore A is 4, answer the questions below.
| a | t | x | y | j | c | b | f | u | d | w | q |
| Consumer | Producer |
| Do other calculations <---------- | P(B) |
| P(A) | P(C) |
| P(C) | Place item in buffer |
| Read item from buffer | V(C) |
| V(C) | do other caclulations <--------- |
| V(B) | V(A) |
a)What was the value of semaphore B when it was initialized? ______________
b)What is the value of semaphore B now? ________________
c)What was the value of semaphore C when it was initialized? _______________
d)Which specific characters, those are still in the buffer, HAVE BEEN READ by the consumer? _________________
Please please not just anwser -- really looking for explanation!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
