Distributed Mutual Exclusion q Introduction q Ricart and
Distributed Mutual Exclusion q Introduction q Ricart and Agrawala's algorithm q Raymond's algorithm This presentation is based on the book: “Distributed operating-systems & algorithms” by Randy Chow and Theodore Johnson Operating Systems, 2012, Danny Hendler & Roie Zivan 1
Distributed mutual exclusion: introduction q Distributed mutual exclusion required (e. g. ) for transaction processing on replicated data q We assume there are no failures o Processors do not fail o Communication links do not fail q It is easy to implement mutual exclusion using totally-ordered timestamps o The first algorithm we show may use Lamport's timestamps Operating Systems, 2012, Danny Hendler & Roie Zivan 2
Ricart and Agrawal's algorithm: high-level ideas q When you want to enter your CS o Record your timestamp o Ask everyone else whether they “permit” q When asked for a permission o Halt response if in CS o Halt response if in entry code with a smaller timestamp (we need total order between timestamps) o Otherwise, “permit” q Upon exit from CS o Send halted responses (if any) Operating Systems, 2012, Danny Hendler & Roie Zivan 3
Ricart and Agrawal's algorithm: data-structures Per processor variables timestamp current_time Timestamp my_timestamp integer reply_pending boolean is. Requesting boolean reply_deferred[M] Operating Systems, 2012, Danny Hendler & Roie Zivan Processor’s current Lamport timestamp 4
Ricart and Agrawal's algorithm: data-structures Per processor variables timestamp current_time Timestamp my_timestamp integer reply_pending boolean is. Requesting boolean reply_deferred[M] Operating Systems, 2012, Danny Hendler & Roie Zivan The timestamp of the processor’s current request 5
Ricart and Agrawal's algorithm: data-structures Per processor variables timestamp current_time Timestamp my_timestamp integer reply_pending boolean is. Requesting boolean reply_deferred[M] Operating Systems, 2012, Danny Hendler & Roie Zivan The number of permissions that the processor still need to collect before entering the CS 6
Ricart and Agrawal's algorithm: data-structures Per processor variables timestamp current_time Timestamp my_timestamp integer reply_pending boolean is. Requesting boolean reply_deferred[M] True iff this processor is requesting or using the CS Operating Systems, 2012, Danny Hendler & Roie Zivan 7
Ricart and Agrawal's algorithm: data-structures Per processor variables timestamp current_time Timestamp my_timestamp integer reply_pending boolean is. Requesting boolean reply_deferred[M] Entry j is true iff this processor deferred replying to processor j’s request Operating Systems, 2012, Danny Hendler & Roie Zivan 8
Ricart and Agrawal's algorithm: entry-code Request_CS: 1 my_timstamp current_time 2 is. Requesting TRUE 3 Reply_pending M-1 4 for every other processor j 5 send(REMOTE_REQUEST; my_timestamp) 6 wait until reply_pending = 0 Operating Systems, 2012, Danny Hendler & Roie Zivan Set the (Lamport) timestamp of my request 9
Ricart and Agrawal's algorithm: entry-code Request_CS: 1 my_timstamp current_time 2 is. Requesting TRUE 3 reply_pending M-1 4 for every other processor j 5 send(REMOTE_REQUEST; my_timestamp) 6 wait until reply_pending = 0 Operating Systems, 2012, Danny Hendler & Roie Zivan Mark that this processor is requesting entry to CS 10
Ricart and Agrawal's algorithm: entry-code Request_CS: 1 my_timstamp current_time 2 is. Requesting TRUE 3 reply_pending M-1 4 for every other processor j 5 send(REMOTE_REQUEST; my_timestamp) 6 wait until reply_pending = 0 Operating Systems, 2012, Danny Hendler & Roie Zivan Need to receive replies from all other processors 11
Ricart and Agrawal's algorithm: entry-code Request_CS: 1 my_timstamp current_time 2 is. Requesting TRUE 3 reply_pending M-1 4 for every other processor j 5 send(REMOTE_REQUEST; my_timestamp) 6 wait until reply_pending = 0 Request permission from all other processors Operating Systems, 2012, Danny Hendler & Roie Zivan 12
Ricart and Agrawal's algorithm: entry code Request_CS: 1 my_timstamp current_time 2 is. Requesting TRUE 3 reply_pending M-1 4 for every other processor j 5 send(REMOTE_REQUEST; my_timestamp) 6 wait until reply_pending = 0 When all other processors reply – may enter the CS Operating Systems, 2012, Danny Hendler & Roie Zivan 13
Ricart and Agrawal's algorithm: monitoring CS_monitoring: Wait until a REMOTE_REUQUEST or REPLY message is received REMOTE_REQUEST(sender; request_time) 1. Let j be the sender of the REMOTE_REQUEST message 2. if (not is_requesting or my_timestamp > request_time) 3. send(j, REPLY) 4. else 5. reply_deferred[j]=TRUE Listener thread to respond to protocol messages at all times REPLY 4. reply_pending-1 Operating Systems, 2012, Danny Hendler & Roie Zivan 14
Ricart and Agrawal's algorithm: monitoring CS_monitoring: Wait until a REMOTE_REUQUEST or REPLY message is received REMOTE_REQUEST(sender; request_time) 1. Let j be the sender of the REMOTE_REQUEST message 2. if (not is_requesting or my_timestamp > request_time) 3. send(j, REPLY) 4. else 5. reply_deferred[j]=TRUE Upon receipt of remote request REPLY 4. reply_pending-1 Operating Systems, 2012, Danny Hendler & Roie Zivan 15
Ricart and Agrawal's algorithm: monitoring CS_monitoring: Wait until a REMOTE_REUQUEST or REPLY message is received REMOTE_REQUEST(sender; request_time) 1. Let j be the sender of the REMOTE_REQUEST message 2. if (not is_requesting or my_timestamp > request_time) 3. send(j, REPLY) 4. else 5. reply_deferred[j]=TRUE If should grant processor j’th request REPLY 4. reply_pending-1 Operating Systems, 2012, Danny Hendler & Roie Zivan 16
Ricart and Agrawal's algorithm: monitoring CS_monitoring: Wait until a REMOTE_REUQUEST or REPLY message is received REMOTE_REQUEST(sender; request_time) 1. Let j be the sender of the REMOTE_REQUEST message 2. if (not is_requesting or my_timestamp > request_time) 3. send(j, REPLY) 4. else 5. reply_deferred[j]=TRUE Send reply to processor j REPLY 4. reply_pending-1 Operating Systems, 2012, Danny Hendler & Roie Zivan 17
Ricart and Agrawal's algorithm: monitoring CS_monitoring: Wait until a REMOTE_REUQUEST or REPLY message is received REMOTE_REQUEST(sender; request_time) 1. Let j be the sender of the REMOTE_REQUEST message 2. if (not is_requesting or my_timestamp > request_time) 3. send(j, REPLY) 4. else 5. reply_deferred[j]=TRUE REPLY 4. reply_pending-1 Operating Systems, 2012, Danny Hendler & Roie Zivan Otherwise, defer replying to this request 18
Ricart and Agrawal's algorithm: monitoring CS_monitoring: Wait until a REMOTE_REUQUEST or REPLY message is received REMOTE_REQUEST(sender; request_time) 1. Let j be the sender of the REMOTE_REQUEST message 2. if (not is_requesting or my_timestamp > request_time) 3. send(j, REPLY) 4. else 5. reply_deferred[j]=TRUE REPLY 4. reply_pending-1 Upon receiving a reply, decrement reply_pending Operating Systems, 2012, Danny Hendler & Roie Zivan 19
Ricart and Agrawal's algorithm: exit section Release_CS_monitoring: 1. is_requesting false 2. For j=1 through M (other than this processor's ID) 3. if reply_deferred[i]=TRUE 4. send(j, REPLY) 5. reply_deferred[j]=FALSE Operating Systems, 2012, Danny Hendler & Roie Zivan No longer requesting CS 20
Ricart and Agrawal's algorithm: exit section Release_CS_monitoring: 1. is_requesting false 2. For j=1 through M (other than this processor's ID) 3. if reply_deferred[i]=TRUE 4. send(j, REPLY) 5. reply_deferred[j]=FALSE For each processor awaiting a reply from this processor, send reply and mark that there are no more deferred replies. Operating Systems, 2012, Danny Hendler & Roie Zivan 21
Ricart and Agrawal's algorithm: comments What is the number of messages required for each passage through the critical section? 2(M-1) messages. Let's see a more message-efficient algorithm… Operating Systems, 2012, Danny Hendler & Roie Zivan 22
Distributed Mutual Exclusion q Introduction q Ricart and Agrawala's algorithm q Raymond's algorithm Operating Systems, 2012, Danny Hendler & Roie Zivan 23
Raymond's algorithm: high-level ideas q There is a single token in the system o Only the holder of the token may enter the CS q Processors communicate by using a static tree structure o Requests for the token are sent o The token itself is sent when available and requested q Processors maintain FIFO request queues to prevent starvation q At most a logarithmic number of messages per entry Operating Systems, 2012, Danny Hendler & Roie Zivan 24
Raymond's algorithm: high-level ideas (cont'd) q Algorithm invariant: tree is always oriented towards token holder Token holder Operating Systems, 2012, Danny Hendler & Roie Zivan 25
Raymond's algorithm: data-structures Per processor variables Boolean token_holder Boolean in. CS current_dir requests_queue Operating Systems, 2012, Danny Hendler & Roie Zivan True iff this processor currently holds the token 26
Raymond's algorithm: data-structures Per processor variables Boolean token_holder Boolean in. CS current_dir requests_queue Operating Systems, 2012, Danny Hendler & Roie Zivan True iff this processor is currently in the critical section 27
Raymond's algorithm: data-structures Per processor variables Boolean token_holder Boolean in. CS current_dir requests_queue The neighbor that is in the direction of the token (or self if this processor holds the token) Operating Systems, 2012, Danny Hendler & Roie Zivan 28
Raymond's algorithm: data-structures Per processor variables Boolean token_holder Boolean in. CS current_dir requests_queue FIFO queue holding IDs of neighbors from which requests for the token arrived (may also contain self) Operating Systems, 2012, Danny Hendler & Roie Zivan 29
Raymond's algorithm: entry and exit code Request_CS: 1 If not token_holder 2 if requests_queue. is. Empty( ) 3 send(current_dir, REQUEST) 4 requests_queue. enqueue(self) 5 wait until token_holder is true 6 in. CS true If this processor currently holds the token it immediately enters CS. Otherwise… Release_CS: 7. in. CS false 8. If not requests_queue. is. Empty( ) 9. current_dir requests_queue. dequeue( ) 10. send(current_dir, TOKEN) 11. token_holder false 12. if not requests_queue. is. Empty( ) 13. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan 30
Raymond's algorithm: entry and exit code Request_CS: 1 If not token_holder 2 if requests_queue. is. Empty( ) 3 send(current_dir, REQUEST) 4 requests_queue. enqueue(self) 5 wait until token_holder is true 6 in. CS true If requests queue is empty, send a request for the token. (If queue is non-empty, a request for the token was already sent. ) Release_CS: 7. in. CS false 8. If not requests_queue. is. Empty( ) 9. current_dir requests_queue. dequeue( ) 10. send(current_dir, TOKEN) 11. token_holder false 12. if not requests_queue. is. Empty( ) 13. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan 31
Raymond's algorithm: entry and exit code Request_CS: 1 If not token_holder 2 if requests_queue. is. Empty( ) 3 send(current_dir, REQUEST) 4 requests_queue. enqueue(self) 5 wait until token_holder is true 6 in. CS true Enqueue ‘self’ to requests queue since this request is on behalf of this processor Release_CS: 7. in. CS false 8. If not requests_queue. is. Empty( ) 9. current_dir requests_queue. dequeue( ) 10. send(current_dir, TOKEN) 11. token_holder false 12. if not requests_queue. is. Empty( ) 13. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan 32
Raymond's algorithm: entry and exit code Request_CS: 1 If not token_holder 2 if requests_queue. is. Empty( ) 3 send(current_dir, REQUEST) 4 requests_queue. enqueue(self) 5 wait until token_holder is true 6 in. CS true When token_holder is set, this processor Release_CS: has the token and may enter the CS 7. in. CS false 8. If not requests_queue. is. Empty( ) 9. current_dir requests_queue. dequeue( ) 10. send(current_dir, TOKEN) 11. token_holder false 12. if not requests_queue. is. Empty( ) 13. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan 33
Raymond's algorithm: entry and exit code Request_CS: 1 If not token_holder 2 if requests_queue. is. Empty( ) 3 send(current_dir, REQUEST) 4 requests_queue. enqueue(self) 5 wait until token_holder is true 6 in. CS true Release_CS: 7. in. CS false 8. If not requests_queue. is. Empty( ) 9. current_dir requests_queue. dequeue( ) 10. send(current_dir, TOKEN) 11. token_holder false 12. if not requests_queue. is. Empty( ) 13. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan No longer in critical section 34
Raymond's algorithm: entry and exit code Request_CS: 1 If not token_holder 2 if requests_queue. is. Empty( ) 3 send(current_dir, REQUEST) 4 requests_queue. enqueue(self) 5 wait until token_holder is true 6 in. CS true Release_CS: 7. in. CS false 8. If not requests_queue. is. Empty( ) 9. current_dir requests_queue. dequeue( ) 10. send(current_dir, TOKEN) 11. token_holder false 12. if not requests_queue. is. Empty( ) 13. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan If requests are waiting… 35
Raymond's algorithm: entry and exit code Request_CS: 1 If not token_holder 2 if requests_queue. is. Empty( ) 3 send(current_dir, REQUEST) 4 requests_queue. enqueue(self) 5 wait until token_holder is true 6 in. CS true Release_CS: 7. in. CS false 8. If not requests_queue. is. Empty( ) 9. current_dir requests_queue. dequeue( ) 10. send(current_dir, TOKEN) 11. token_holder false 12. if not requests_queue. is. Empty( ) 13. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan Dequeue the next hop for the earliest request and send the TOKEN to it. Also, update orientation of the token. 36
Raymond's algorithm: entry and exit code Request_CS: 1 If not token_holder 2 if requests_queue. is. Empty( ) 3 send(current_dir, REQUEST) 4 requests_queue. enqueue(self) 5 wait until token_holder is true 6 in. CS true Release_CS: 7. in. CS false 8. If not requests_queue. is. Empty( ) 9. current_dir requests_queue. dequeue( ) 10. send(current_dir, TOKEN) 11. token_holder false 12. if not requests_queue. is. Empty( ) 13. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan This processor no longer holds token 37
Raymond's algorithm: entry and exit code Request_CS: 1 If not token_holder 2 if requests_queue. is. Empty( ) 3 send(current_dir, REQUEST) 4 requests_queue. enqueue(self) 5 wait until token_holder is true 6 in. CS true Release_CS: 7. in. CS false 8. If not requests_queue. is. Empty( ) 9. current_dir requests_queue. dequeue( ) 10. send(current_dir, TOKEN) 11. token_holder false 12. if not requests_queue. is. Empty( ) 13. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan If there are more requests in this processor’s queue, send another request for the token 38
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender 8. send(current_dir, TOKEN) 9. token_holder false 10. else 11. if requests_queue. is. Empty() 12. send(current_dir, REQUEST) 13. requests_queue. enqueue(sender) TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan Listener thread to respond to protocol messages at all times 39
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender 8. send(current_dir, TOKEN) 9. token_holder false 10. else 11. if requests_queue. is. Empty() 12. send(current_dir, REQUEST) 13. requests_queue. enqueue(sender) TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan Upon a request. If current processor holds token… 40
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender 8. send(current_dir, TOKEN) 9. token_holder false 10. else 11. if requests_queue. is. Empty() 12. send(current_dir, REQUEST) 13. requests_queue. enqueue(sender) TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan If current processor in CS then request must wait, enqueue the direction of requesting processor 41
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender 8. send(current_dir, TOKEN) 9. token_holder false 10. else 11. if requests_queue. is. Empty() 12. send(current_dir, REQUEST) 13. requests_queue. enqueue(sender) TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan Otherwise current processor holds the token but is not in CS, hence requests queue is empty. Send token to where the request came from, mark that current processor no longer holds token, and the new orientation of the otken… 42
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender Otherwise current processor does not hold the token… 8. send(current_dir, TOKEN) 9. token_holder false 10. else 11. if requests_queue. is. Empty() 12. send(current_dir, REQUEST) 13. requests_queue. enqueue(sender) TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan 43
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender If requests queue is empty, send request in the 8. send(current_dir, TOKEN) direction of the token… 9. token_holder false 10. else 11. if requests_queue. is. Empty() 12. send(current_dir, REQUEST) 13. requests_queue. enqueue(sender) TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan 44
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender 8. send(current_dir, TOKEN) 9. token_holder false 10. else Enqueue the direction of this request… 11. if requests_queue. is. Empty() 12. send(current_dir, REQUEST) 13. requests_queue. enqueue(sender) TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan 45
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender 8. send(current_dir, TOKEN) 9. token_holder false 10. else 11. if requests_queue. is. Empty() Upon the arrival of the token… 12. send(current_dir, REQUEST) 13. requests_queue. enqueue(sender) TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan 46
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender 8. send(current_dir, TOKEN) 9. token_holder false 10. else 11. if requests_queue. is. Empty() 12. send(current_dir, REQUEST) Dequeue oldest request and set new 13. requests_queue. enqueue(sender) orientation of the token to its direction TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan 47
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender 8. send(current_dir, TOKEN) 9. token_holder false 10. else 11. if requests_queue. is. Empty() 12. send(current_dir, REQUEST) 13. requests_queue. enqueue(sender) TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan If request was by this processor, mark that it currently has the token and may enter the CS 48
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender 8. send(current_dir, TOKEN) 9. token_holder false 10. else 11. if requests_queue. is. Empty() 12. send(current_dir, REQUEST) 13. requests_queue. enqueue(sender) TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan Otherwise, send the token in the direction of the request 49
Raymond's algorithm: monitoring Monitor_CS: 1 while (true) 2 wait for a REQUEST or a TOKEN message REQUEST 3. if token_holder 4. if in. CS 5. requests_queue. enqueue(sender) 6. else 7. current_dir sender 8. send(current_dir, TOKEN) 9. token_holder false 10. else 11. if requests_queue. is. Empty() 12. send(current_dir, REQUEST) 13. requests_queue. enqueue(sender) TOKEN 14. current_dir requests_queue. dequeue( ) 15. if current_dir = self 16. token_holder true 17. else 18. send(current_dir, TOKEN) 19. if not requests_queue. is. Empty( ) 20. send(current_dir, REQUEST) Operating Systems, 2012, Danny Hendler & Roie Zivan If the queue is non-empty, send another request for the token 50
Raymond's algorithm: execution scenario Operating Systems, 2012, Danny Hendler & Roie Zivan 51
- Slides: 51