Question: 1. (20 pts) Consider the reader-writer program to access a shared variable V using semaphores: initialize semaphores wrt and mutex to 1 each; initialize integer

1. (20 pts) Consider the reader-writer program to

1. (20 pts) Consider the reader-writer program to access a shared variable V using semaphores: initialize semaphores wrt and mutex to 1 each; initialize integer rcnt :=0; reader; (i = 1,2, ...,K) writer; (j = 1,2,.. M forever forever wait(mutex); wait(wrt); rcnt := rcnt + 1; write on V; if (rcnt = 1) signal(wrt). wait(wrt); signal(mutex); read V; wait(mutex); rcnt := rcnt - 1; if (rcnt = 0) signal(wrt); signal(mutex). This program implements a 'strict reader preference policy, i.e., regardless of how long a writer has been waiting to access V, a new reader can start accessing V at the earliest opportunity as allowed by reader-writer synchronization constraints. To avoid starvation of writers, we may implement a 'limited reader preference policy that allows no more than N, new read accesses on V when a writer is waiting and a reader is currently accessing V (where N, > 1). A: Modify the above program to implement the 'limited reader preference policy. Indicate the worst case wait time of a writer? B

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 General Management Questions!