Question: EXERCISE # 2 An implementation of a circular FIFO queue for multiple producers and consumers are attached in the appendix ( it is the one

EXERCISE #2
An implementation of a circular FIFO queue for multiple producers and consumers are attached in the appendix (it is the one we designed in our lecture). Regarding the implementation:
Question #1: Is it necessary to have "wait (mutex)" and "signal(mutex)" in the producer processes? If NO, explain why not. If YES, explain why we need them.
Question #2: Is there any merit in using two different "mutex semaphore" (one for the producers and the other for the consumers)? If yes, describe what is the merit? If not, why not?
Question #3: Is the implementation "starvation free" for both producers and consumers? If NO, explain why it is not. If YES, explain why we it is.
APPENDIX:
\table[[#define N 100,// the queue size],[shared memory int CFQ [N];,??? the circular FIFO queue],[shared memory int TOP =0;,??? pointer to the top of the queue],[shared memory int TAIL =0;,??? pointer to the tail of the queue],[,// a mutex semaphore],[semaphore mutex =1;,// a counting semaphore],[semaphore empty =N;,/ counting semaphore],[semophore full =0;,]]
void producer (void)
1
int new item; // place holder for a new item to insert
while (TRUE)
I
new item = produce new item (); // generate a new item
wait (empty):
woit (mutex);
// make sure the queue is NOT full
// I should be the only one
insert(CFQ, TAIL, new item); // insert the new itern to the queue
TAL=(TAL+1)%N;,?? update the Top pointer
signal(mutex); ,// t am done!
signal(full); full
 EXERCISE #2 An implementation of a circular FIFO queue for multiple

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!