Presentation is loading. Please wait.

Presentation is loading. Please wait.

Group Mutual Exclusion & Hadzilacos Algorithm

Similar presentations


Presentation on theme: "Group Mutual Exclusion & Hadzilacos Algorithm"— Presentation transcript:

1 Group Mutual Exclusion & Hadzilacos Algorithm
COSC6490A Zhenyu Pan York University 2007

2 GME Dependency Jan-19 GME and H Algorithm

3 Problem ME N processes iterate repeatedly two sections of code: a possibly non-terminating NCS and a terminating CS. To provide a synchronization algorithm in the form of a trying and an exit protocol before and after the CS: ==================== non-critical section (NCS) trying protocol [Doorway Code + Waiting Loops] critical section (CS) exit protocol so that the following properties hold: Jan-19 GME and H Algorithm

4 ME Properties & Assumption
P1: Mutual Exclusion (ME). No two processes are in CS at the same time. P2: Deadlock-Freedom (DF). If a set of processes are in trying protocol, then eventually at least one enters CS. P3: Lockout-Freedom (LF). Every process in trying protocol eventually enters CS. P4: First-Come-First-Served (FCFS). When a process wants to enter CS, it first executes the doorway code of the trying protocol. If Pi exits the doorway before Pj enters the doorway, then Pi enters CS before Pj enters CS. Assumptions: Software approach, shared variables; No test-set instructions or semaphore support. Jan-19 GME and H Algorithm

5 GME Problem & Properties
Definition: A process wishing to enter CS requests a “session”. Processes that request different sessions cannot be in CS simultaneously, but processes that request the same session can. Properties: P1: Mutual Exclusion (ME). If two processes are in CS at the same time, then they request the same session. P2: Deadlock-Freedom (DF). P3: Lockout-Freedom (LF). P4: First-Come-First-Served (FCFS). P5: Concurrent Entering (CE). If some processes request a same session and no process requests a different session, then they enter CS concurrently. Jan-19 GME and H Algorithm

6 Composition Theorem Theorem: ME/DF algorithm + FCFS/DF algorithm => ME+ FCFS +DF algorithm. Theorem: FCFS and DF imply LF. Jan-19 GME and H Algorithm

7 ME Burns-Lamport Algorithm
Each process sets its bit to indicate its interest in entering CS Phase 1: tests the bits of lower-numbered processes. If any of them is true, it gives up and restarts. otherwise, it proceeds to the next phase. Phase 2: tests the bits of higher-numbered processes. If any of them is true, it waits, but never gives up and restarts. Theorem: The Burns-Lamport algorithm satisfies ME and DF. Jan-19 GME and H Algorithm

8 Embedded Lycklama-Hadzilacos Algorithm
Theorem: Lycklama-Hadzilacos Algorithm satisfy DF, ME, LF, FCFS. Jan-19 GME and H Algorithm

9 Embedded Lycklama-Hadzilacos Algorithm
Snapshot trick: turni: indicates the current iteration of Pi; It has 2 bits; the state cycles through 00, 01, 11, and 10. S[ ]: is the snapshot of other processes’ turn[ ]. First reads other processes' turn[ ] and stores them in the snapshot S[ ]; Second increments its turni. Jan-19 GME and H Algorithm

10 Informal Explanation of FCFS
In the waiting operation of the trying protocol, Pi waits for Pj for one of two reasons: 1. Deadlock waiting: Pj is in the doorway (cj = true). This is ensure that Pi’s doorway overlaps with at most one Pj’s doorway. 2. FCFS waiting: (a) Pj left the doorway and not left CS yet, vj = true (b) Pj left the doorway before Pi enters it, S[j] = turnj Jan-19 GME and H Algorithm

11 Informal Explanation of DL
If there is a deadlock, it will happen in this while loop. turni has 2 bits, 4 states, to avoid deadlock Jan-19 GME and H Algorithm

12 Embedded Hadzilacos Algorithm
Theorem: Hadzilacos Algorithm satisfies DF, ME, LF, FCFS, CE. Jan-19 GME and H Algorithm

13 Informal Explanation of FCFS
FCFS Waiting. Pi waits for Pj until: Pj is in the NCS (Session[j] = 0) ; Pj requests the same session as Pi (Session[j] = mysession); FCFS does not require Pi to wait for Pj (Turn[j] != turn-snap[j] or Bypass[i,j] = true). Jan-19 GME and H Algorithm

14 Informal Explanation of FCFS
(Bypass[i,j] = true) is to avoid deadlock: A fast Pj can enter the CS repeatedly, each time over-passing a slow-moving Pi, and Pj requests the same session as Pi. After 4 times, Pj then requests a different session, it is possible that Pi will find (Turn[j] = turn-snap[j]), then it wait forever. Bypass[i,j] provides the mechanism that enables Pi to detect this circumstance. Jan-19 GME and H Algorithm

15 Informal Explanation of ME
Burns-Lamport algorithm with 2 modifications: Phase 1: If Pi finds any process interest in CS, it gives up and restarts. => If Pi finds any process which request a different session and interest in CS, it gives up and restarts. Phase 2: Pi keeps on waiting for any process interested in CS. Pi keeps on waiting for any process request a different session and interest in CS. Jan-19 GME and H Algorithm

16 Thank You! ??? Jan-19 GME and H Algorithm


Download ppt "Group Mutual Exclusion & Hadzilacos Algorithm"

Similar presentations


Ads by Google