comp30112 concurrency
play

COMP30112: Concurrency Topic 9: Termination Detection Alan Williams - PowerPoint PPT Presentation

COMP30112: Concurrency Topic 9: Termination Detection Alan Williams Room 2.107, email: alanw@cs.man.ac.uk February 2007 1 / 8 The Problem Task requires a set of n processes to complete the job 2 / 8 The Problem Task requires a set of


  1. COMP30112: Concurrency Topic 9: Termination Detection Alan Williams Room 2.107, email: alanw@cs.man.ac.uk February 2007 1 / 8

  2. The Problem • Task requires a set of n processes to complete the job 2 / 8

  3. The Problem • Task requires a set of n processes to complete the job (variations possible!) 2 / 8

  4. The Problem • Task requires a set of n processes to complete the job (variations possible!) • processes communicate via synchronous one-to-one message-passing 2 / 8

  5. The Problem • Task requires a set of n processes to complete the job (variations possible!) • processes communicate via synchronous one-to-one message-passing (more variations possible!) 2 / 8

  6. The Problem • Task requires a set of n processes to complete the job (variations possible!) • processes communicate via synchronous one-to-one message-passing (more variations possible!) • each process is active or passive 2 / 8

  7. The Problem • Task requires a set of n processes to complete the job (variations possible!) • processes communicate via synchronous one-to-one message-passing (more variations possible!) • each process is active or passive • active processes can generate and send messages 2 / 8

  8. The Problem • Task requires a set of n processes to complete the job (variations possible!) • processes communicate via synchronous one-to-one message-passing (more variations possible!) • each process is active or passive • active processes can generate and send messages • active or passive processes can receive messages 2 / 8

  9. The Problem • Task requires a set of n processes to complete the job (variations possible!) • processes communicate via synchronous one-to-one message-passing (more variations possible!) • each process is active or passive • active processes can generate and send messages • active or passive processes can receive messages • an inactive process becomes active on receiving a message 2 / 8

  10. The Problem • Task requires a set of n processes to complete the job (variations possible!) • processes communicate via synchronous one-to-one message-passing (more variations possible!) • each process is active or passive • active processes can generate and send messages • active or passive processes can receive messages • an inactive process becomes active on receiving a message • The task is complete when all processes are inactive 2 / 8

  11. The Problem • Task requires a set of n processes to complete the job (variations possible!) • processes communicate via synchronous one-to-one message-passing (more variations possible!) • each process is active or passive • active processes can generate and send messages • active or passive processes can receive messages • an inactive process becomes active on receiving a message • The task is complete when all processes are inactive Problem: How to determine when task is finished?? 2 / 8

  12. Termination Detection Algorithm • Reference : Dijkstra, Feijen and van Gasteren: Derivation of a Termination Detection Algorithm for Distributed Computation . Information Processing Letters, volume 16, 1983 pages 217–219, North-Holland. 3 / 8

  13. Termination Detection Algorithm • Reference : Dijkstra, Feijen and van Gasteren: Derivation of a Termination Detection Algorithm for Distributed Computation . Information Processing Letters, volume 16, 1983 pages 217–219, North-Holland. • algorithm + derivation only 3 pages 3 / 8

  14. Termination Detection Algorithm • Reference : Dijkstra, Feijen and van Gasteren: Derivation of a Termination Detection Algorithm for Distributed Computation . Information Processing Letters, volume 16, 1983 pages 217–219, North-Holland. • algorithm + derivation only 3 pages • use a token to detect termination by ‘probing’ processes 3 / 8

  15. Termination Detection Algorithm • Reference : Dijkstra, Feijen and van Gasteren: Derivation of a Termination Detection Algorithm for Distributed Computation . Information Processing Letters, volume 16, 1983 pages 217–219, North-Holland. • algorithm + derivation only 3 pages • use a token to detect termination by ‘probing’ processes • connect processes in a ring: process i + 1 passes token to process i (process 0 passes token to process n − 1 ) 3 / 8

  16. Termination Detection Algorithm • Reference : Dijkstra, Feijen and van Gasteren: Derivation of a Termination Detection Algorithm for Distributed Computation . Information Processing Letters, volume 16, 1983 pages 217–219, North-Holland. • algorithm + derivation only 3 pages • use a token to detect termination by ‘probing’ processes • connect processes in a ring: process i + 1 passes token to process i (process 0 passes token to process n − 1 ) • process 0 initiates the probe and signals completion 3 / 8

  17. Algorithm Rules Probe starts and finishes with token at process 0. Processes and token have colour: all start coloured white • Rule 0 : 4 / 8

  18. Algorithm Rules Probe starts and finishes with token at process 0. Processes and token have colour: all start coloured white • Rule 0 : – keep/accept token while process active 4 / 8

  19. Algorithm Rules Probe starts and finishes with token at process 0. Processes and token have colour: all start coloured white • Rule 0 : – keep/accept token while process active – accept/pass token while process passive 4 / 8

  20. Algorithm Rules Probe starts and finishes with token at process 0. Processes and token have colour: all start coloured white • Rule 0 : – keep/accept token while process active – accept/pass token while process passive • Rule 1 : Set process colour to red if it sends a message to a process with higher index 4 / 8

  21. Algorithm Rules Probe starts and finishes with token at process 0. Processes and token have colour: all start coloured white • Rule 0 : – keep/accept token while process active – accept/pass token while process passive • Rule 1 : Set process colour to red if it sends a message to a process with higher index • Rule 2 : 4 / 8

  22. Algorithm Rules Probe starts and finishes with token at process 0. Processes and token have colour: all start coloured white • Rule 0 : – keep/accept token while process active – accept/pass token while process passive • Rule 1 : Set process colour to red if it sends a message to a process with higher index • Rule 2 : – A red (passive) process passes a red token 4 / 8

  23. Algorithm Rules Probe starts and finishes with token at process 0. Processes and token have colour: all start coloured white • Rule 0 : – keep/accept token while process active – accept/pass token while process passive • Rule 1 : Set process colour to red if it sends a message to a process with higher index • Rule 2 : – A red (passive) process passes a red token – A white (passive) process passes the same colour token as input 4 / 8

  24. Algorithm Rules Probe starts and finishes with token at process 0. Processes and token have colour: all start coloured white • Rule 0 : – keep/accept token while process active – accept/pass token while process passive • Rule 1 : Set process colour to red if it sends a message to a process with higher index • Rule 2 : – A red (passive) process passes a red token – A white (passive) process passes the same colour token as input • Rule 3 : For Process 0: if token or process are red, initiate a new probe 4 / 8

  25. • Rule 4 : Initiate a new probe: pass a white token; set process colour to white 5 / 8

  26. • Rule 4 : Initiate a new probe: pass a white token; set process colour to white • Rule 5 : On passing token, a process sets colour to white 5 / 8

  27. • Rule 4 : Initiate a new probe: pass a white token; set process colour to white • Rule 5 : On passing token, a process sets colour to white Done when Process 0 is passive, white, and receives a white token. 5 / 8

  28. 6 / 8

  29. 7 / 8

  30. Termination Example 1. Initially P 2 active, all other processes passive * = active process You Do It: Apply Termination Detection Algorithm 8 / 8

  31. Termination Example 1. Initially P 2 active, all other processes passive * = active process 8 / 8

  32. Termination Example 2. P 2 sends message to P 1 : both P 1 , P 2 active * = active process 8 / 8

  33. Termination Example 3. P 2 passive; P 1 sends message to P 3 : both P 1 , P 3 active * = active process 8 / 8

  34. Termination Example 4. P 1 passive; P 3 active * = active process 8 / 8

  35. Termination Example 5. P 3 active * = active process 8 / 8

  36. Termination Example * = active process 6. P 3 active 8 / 8

  37. Termination Example * = active process 7. P 3 becomes passive; all processes passive 8 / 8

Recommend


More recommend