This web page is organized in way that is useful during my lecture, instead of ppt slides.
reader[i:1..M]:: do true → ‹nr := nr+1› ... read ... (*) ‹nr := nr-1› od |
writer[i:1..N]:: do true → ‹nw := nw+1› ... write ... (*) ‹nw := nw-1› od |
Required invariant at (*) RW:
(nr = 0 or nw = 0) and nw ≤ 1
Modify the atomic statements so that the above is guaranteed. Additionally, all the familiar requirements (progress, no turns, ...) must be satisfied.
reader[i:1..M]:: do true → ‹await nw == 0 → nr := nr+1› ... read ... (*) ‹nr := nr-1› od |
writer[i:1..N]:: do true → ‹await nr = 0 and nw = 0 → nw := nw+1› ... write ... (*) ‹nw := nw-1› od |
2012 Prabhaker Mateti