Question: Starting with the test-and-test_and_set lock of Figure 13.8, implement busy-wait code that will allow readers to access a data structure concurrently. Writers will still need
Starting with the test-and-test_and_set lock of Figure 13.8, implement busy-wait code that will allow readers to access a data structure concurrently. Writers will still need to lock out both readers and other writers. You may use any reasonable atomic instruction(s) (e.g., LL/SC). Consider the issue of fairness. In particular, if there are always readers interested in accessing the data structure, your algorithm should ensure that writers are not locked out forever.
Figure 13.8:

type lock = Boolean := false; procedure acquire lock(ref L: lock) while not test and set(L) while L -- nothing -- spin procedure release lock(ref L: lock) L:= false
Step by Step Solution
3.27 Rating (162 Votes )
There are 3 Steps involved in it
ANSWER type lock Boolean false type readerslock Integer 0 procedure acquirelockref L lock while ... View full answer
Get step-by-step solutions from verified subject matter experts
