1 / 27

Termination Detection

Termination Detection. Goal. Study the development of a protocol for termination detection with the help of invariants. Termination Detection. Rules: A process is either active or passive An active process can become passive at any time

sonja
Download Presentation

Termination Detection

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Termination Detection

  2. Goal • Study the development of a protocol for termination detection with the help of invariants.

  3. Termination Detection • Rules: • A process is either active or passive • An active process can become passive at any time • A passive process can become active only if it receives an computation message • Only active processes can send computation messages. All processes can receive them

  4. A system is said to be terminated if • All processes are passive • No application messages are in transit • We distinguish between computation messages and messages sent for detecting termination. Any process can send and receive them. These messages do not change the status of a process

  5. Application • A solution for termination detection allows one to ensure that all tasks in a system are indeed complete, even though the tasks may create additional tasks that are run at other processors in the system

  6. Observation • Termination detection is a stable property • Once true, it remains true forever • Detecting such properties is important for many problems including • Garbage collection • Deadlock detection

  7. We will consider two algorithms • Based on the idea of diffusion • Based on the idea of global snapshot • We will study these aspects later.

  8. Approach 1: Dijkstra Scholten • Assumptions • Initially one process is active • No failures, lost messages etc.

  9. Each process j maintains a variable P.j that is its parent in the tree • At root, P.root = root • Initially for all other processes, • P.j = NULL

  10. Predicate in Invariant (1) • The set of active processes form a tree • True in the initial state • Ensure that this remains true during computation

  11. When a Process becomes active • Consider the case when j changes from Passive to Active • It must be the case that j received a computation message from some process, say k • P.j = k • Become active

  12. Action (1) P.j = NULL  j receives a message from k  P.j = k, j becomes active

  13. When a Process Becomes Passive • Consider the case when j changes from Active to Passive • It must be the case that j has no children

  14. Action (2) P.j = NULL  j receives a message from k  P.j = k, j becomes active j is active  j wants to become passive  j has no children  j becomes passive, P.j = NULL

  15. Problem? • Does not deal with messages.

  16. Predicate in Invariant (2) • The set of active processes form a tree • If j is passive then all messages it sent have been received • True initially • Preserve this predicate during computation

  17. Action (3) • Maintain a variable oc.j that denotes the number of messages that j has sent and are not yet acknowledged

  18. Action (2) corrected P.j = NULL  j receives a message from k  P.j = k, j becomes active j is active  j wants to become passive  j has no children  oc.j = 0  j becomes passive, P.j = NULL

  19. The actions on previous slide can be used to implement termination detection. • Consider second action j is active  j wants to become passive  j has no children  oc.j = 0  j becomes passive, P.j = NULL • Is it possible to drop ` j has no children’ from the guard?

  20. Answer • We could if we guarantee that • oc.j = 0  j has no children • Same as • j has children  oc.j > 0 • Could be achieved if the child does not respond to at least one of parent’s message (first one?) • Thus, checking oc.j is 0 sufficient

  21. Action (3) P.j = NULL  j receives a message from k  P.j = k, j becomes active(Don’t send ack to this message) j is active  j wants to become passive  j has no children  oc.j = 0  j becomes passive, P.j = NULL; send ack to parent j is active  j receives a message from k  Send ack to k Other simple actions for maintaining oc.j

  22. Summarizing Approach 1 • Goal • Active processes form a rooted tree • If process kactivates j then j sets its parent to k • If a process is passive, all messages it sent have been received • Acknowledge each message (at some time) • A process becomes passive only when all its children are passive; in other words, force a process to wait for its children to become passive. • This is achieved if the children do not send an acknowledgment for the first message received from the parent until they become passive.

  23. Actions • Passive  Active • If j is passive and receives a computation message from k then • P.j = k • Become active

  24. Actions • Active  Active • If j is active and receives a computation message from l • Send an acknowledgment

  25. Actions • Message send • If j wants to send message (it must be active) • oc.j ++ • (Number of outstanding acknowledgments is increased) • Acknowledgement receive • oc.j = oc.j – 1

  26. Actions • Active  passive • If j wants to be passive and oc.j = 0 • Send an acknowledgment to P.j (Observe that the first message from parent was not immediately acknowledged) • Become passive • If j is the root then declare termination

  27. Diffusing Computation • Crucial for various applications • General outline • root(?) sends the diffusion message • Every node that receives the diffusion message for the first time forwards it to its neighbors • First node from which diffusion is received is called parent • All subsequent diffusion messages are acknowledged • Upon receiving acknowledgements form all neighbors, a node completes the diffusion and sends acknowledgment to parent • When root completes the diffusion, the diffusion computation is complete • We will see application of diffusion computation later in the class.

More Related