Question: The structure of a writer process do { wait(rw_mutex); ... /* writing is performed */ ... signal(rw_mutex); } while (true); The structure of a reader
The structure of a writer process
do { wait(rw_mutex);
... /* writing is performed */
...
signal(rw_mutex);
} while (true);
The structure of a reader process
do { wait(mutex); read count++; if (read_count == 1)
wait(rw_mutex);
signal(mutex);
... /* reading is performed */
...
wait(mutex); read count--; if (read_count == 0)
signal(rw_mutex);
signal(mutex);
} while (true);
Shared Data
Data set
Semaphore rw_mutex initialized to 1
Semaphore mutex initialized to 1
Integer read_count initialized to 0
Assume: currently there is a Reader process R1 that is reading the data; firstly a Writer process W1 comes and then another Reader process R2 comes; what W1 and R1 will do? Please explain your answer based on the code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
