Starting with the test-and-test_and_set lock of Figure 13.8, implement busy-wait code that will allow readers to access

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 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

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: