Consumer Process before Removing an Item from the Buffer
Similar to producers, consumers can only use the product when it is produced.
Given, M = 1, E = n and F =0
Here, semaphore M is for mutual exclusion, semaphore E is for empty space in the buffer, and semaphore F is
used to define the space filled by the producer.
code for producer side:
while (true)
{
Produce()
Wait(E)
Wait(M)
Append()
Signal(M)
Signal(F)
}
Code for consumer side:
while (true) {
Wait(F)
Wait(M)
Consume()
Signal(M)
Signal(E)
}
Summary:
The producer and consumer processes share the following variables: Int n, Semaphore M=1 Semaphore E=n Semaphore F=0. The consumer process must execute ____ and before removing an item from the buffer. (a) signal(M), signal(F) , (b) signal(M), wait(F), (c) Signal(F), wait(M), (d) wait(F), wait(M)
Before removing an item from the buffer, the consumer process must run wait(F), wait(M), and.
Comments
write a comment