Question: 5 Readers-writers problem Consider the solution below for the readers-writers problem. Reader code: do { wait (mutex); Writer code: do { wait (rw_mutex); read_count++;
5 Readers-writers problem Consider the solution below for the readers-writers problem. Reader code: do { wait (mutex); Writer code: do { wait (rw_mutex); read_count++; if (read_count == 1) wait (rw_mutex); signal (mutex); /* reading is performed */ wait (mutex); /* writing is performed */ signal (rw_mutex); while (true); read count; if (read_count == 0) signal (rw_mutex); signal (mutex); } while (true); Answer the following questions. (a) (4pts.) Specify the type of the semaphores: binary or counting? YOUR ANSWER: mutex (b) (4 pts.) What is the initial value of the semaphores? YOUR ANSWER: mutex rw_mutex rw_mutex (c) (12 pts.) Is this solution fair for writer processes? Discuss if starvation is possible.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
