Synchronization in the classical readers and writers problem can be achieved…
PYQ GATE 2007
Synchronization in the classical readers and writers problem can be achieved through use of semaphores. In the following incomplete code for readers-writers problem, two binary semaphores mutex and wrt are used to obtain synchronization
wait (wrt)
writing is performed
signal (wrt)
wait (mutex)
readcount = readcount + 1
if readcount = 1 then S1
S2
reading is performed
S3
readcount = readcount - 1
if readcount = 0 then S4
signal (mutex)
The values of S1, S2, S3, S4, (in that order) are
- A.
signal (mutex), wait (wrt), signal (wrt), wait (mutex)
- B.
signal (wrt), signal (mutex), wait (mutex), wait (wrt)
- C.
wait (wrt), signal (mutex), wait (mutex), signal (wrt)
- D.
signal (mutex), wait (mutex), signal (mutex), wait (mutex)
Attempted by 380 students.
Sign up free to check your answer
Sign up freeLoading lesson…

