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

comp30112 concurrency
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

COMP30112: Concurrency

Topic 9: Termination Detection

Alan Williams

Room 2.107, email: alanw@cs.man.ac.uk

February 2007

1 / 8

slide-2
SLIDE 2

The Problem

  • Task requires a set of n processes to complete the job

2 / 8

slide-3
SLIDE 3

The Problem

  • Task requires a set of n processes to complete the job

(variations possible!)

2 / 8

slide-4
SLIDE 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

slide-5
SLIDE 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

slide-6
SLIDE 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

slide-7
SLIDE 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

slide-8
SLIDE 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

slide-9
SLIDE 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

slide-10
SLIDE 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

slide-11
SLIDE 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

slide-12
SLIDE 12

Termination Detection Algorithm

  • Reference: Dijkstra, Feijen and van Gasteren: Derivation
  • f a Termination Detection Algorithm for Distributed
  • Computation. Information Processing Letters, volume 16,

1983 pages 217–219, North-Holland.

3 / 8

slide-13
SLIDE 13

Termination Detection Algorithm

  • Reference: Dijkstra, Feijen and van Gasteren: Derivation
  • f 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

slide-14
SLIDE 14

Termination Detection Algorithm

  • Reference: Dijkstra, Feijen and van Gasteren: Derivation
  • f 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

slide-15
SLIDE 15

Termination Detection Algorithm

  • Reference: Dijkstra, Feijen and van Gasteren: Derivation
  • f 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

slide-16
SLIDE 16

Termination Detection Algorithm

  • Reference: Dijkstra, Feijen and van Gasteren: Derivation
  • f 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

slide-17
SLIDE 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

slide-18
SLIDE 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

slide-19
SLIDE 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

slide-20
SLIDE 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

slide-21
SLIDE 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

slide-22
SLIDE 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

slide-23
SLIDE 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

slide-24
SLIDE 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

slide-25
SLIDE 25
  • Rule 4: Initiate a new probe: pass a white token; set

process colour to white

5 / 8

slide-26
SLIDE 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

slide-27
SLIDE 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

slide-28
SLIDE 28

6 / 8

slide-29
SLIDE 29

7 / 8

slide-30
SLIDE 30

Termination Example

* = active process

  • 1. Initially P2 active, all other

processes passive You Do It: Apply Termination Detection Algorithm

8 / 8

slide-31
SLIDE 31

Termination Example

* = active process

  • 1. Initially P2 active, all other

processes passive

8 / 8

slide-32
SLIDE 32

Termination Example

* = active process

  • 2. P2 sends message to P1:

both P1, P2 active

8 / 8

slide-33
SLIDE 33

Termination Example

* = active process

  • 3. P2 passive; P1 sends

message to P3: both P1, P3 active

8 / 8

slide-34
SLIDE 34

Termination Example

* = active process

  • 4. P1 passive; P3 active

8 / 8

slide-35
SLIDE 35

Termination Example

* = active process

  • 5. P3 active

8 / 8

slide-36
SLIDE 36

Termination Example

* = active process

  • 6. P3 active

8 / 8

slide-37
SLIDE 37

Termination Example

* = active process

  • 7. P3 becomes passive; all

processes passive

8 / 8