What should be the values of blanks 1, 2, 3 to synchronization classical reader and writer algorithm?
(a) up(mutex), up(mutex), W = 1.
(b) down(mutex), up(mutex), W = 1.
(c) down(mutex), up(mutex), R >= 1 or W = 1.
(d) up(mutex), up(mutex), R >= 1 or W = 1.
Answer:
Option d is correct.
Explanation:
For 1
When W == 1 condition satisfy that mean one writer is already in the database so, we have no up(mutex) again and go back.
So, the answer is up(mutex).
For 2
When W == 1 not satisfies then the writer is not in the database. So, the reader can go inside the database and increase R = R + 1. And up the mutex i.e, up (mutex).
So, the answer is up(mutex).
For 3
In what condition writer up (mutex) and go back to the previous statement. Obviously when more than one reader or one writer is inside the database.
So, condition will be R >= 1 or W = 1.
So, option d is correct.