Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


Share this Page URL
Help

5.2 Virtual Links Using SEND, RECEIVE, a... > 5.2.7 Implementing a Before-or-After... - Pg. 225

5.2 Virtual Links Using send , receive , and a Bounded Buffer 225 1 2 3 4 5 6 7 procedure acquire (lock reference L) r 1 rsm (L.state) while r 1 5 locked do r 1 rsm (L.state) procedure release (lock reference L) L.state unlocked // read and set lock L // was it already locked? // yes, do it again, till we see it wasn't FIGUre 5.8 acquire and release using rsm . actions: the arbiter guarantees that if two requests arrive at the same time, one of those requests is executed completely before the other begins. Using the rsm instruction, we can implement any other before-or-after action. It is the one essential before-or-after action from which we can bootstrap any other set of before-or-after actions. Using rsm , we can implement acquire and release as shown in Figure 5.8. This implementation follows the single-acquire protocol: if L is locked , then one thread has the lock L ; if L contains unlocked , then no thread has acquired the lock L .