Question: 5 . ( 1 4 % ) Zookeeper. The following pseudo - code lists the implementation of the distributed read / write lock using
Zookeeper.
The following pseudocode lists the implementation of the distributed readwrite lock using Zookeeper only the lock function is shown
Write lock:
n createwrite EPHEMERALSEQUENTIAL
mathrmCoperatornamegetChildren false
if n is lowest znode in C exit
mathrmp znode in C ordered just before n
if existsp true wait for watch event
goto
Read lock:
n createread EPHEMERALSEQUENTIAL
mathrmC getChildren false
if no write znodes lower than n in C exit
mathrmp znode in C ordered just before n
if existsp true wait for event
goto
a The above pseudocode unfortunately is known to have one bug. Can you identify the bug, explain how the bug creates incorrect results, and explain how the bug should be fixed?
b Suppose that the bug in Part a is fixed. Suppose that there are five client requests of the readwrite lock in the following order: Write, Write, Read, Read, and Write. Say lz o o Draw the lock chain of znodes that shows how each lock request monitors the availability of locks.
c We want to modify the above pseudocode, such that a writer can acquire the write lock as long as no writer exists, while a reader can acquire the read lock only when no writer exists. Thus, a writer is always given a higher priority to obtain a lock than any reader. Show how you revise the above pseudocode.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
