1 / 16

Mutual Exclusion

Mutual Exclusion. Critical Section Problem. acquire(c) CriticalSection c release(c) Critical Section correctness Mutual Exclusion: safety (ME1) Deadlock-Freedom: progress (ME2a) Starvation-Freedom: fairness (ME2b) [Happens-Before Ordering (ME3)]. Algorithms. Centralized algorithm

hailey
Download Presentation

Mutual Exclusion

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. Mutual Exclusion

  2. Critical Section Problem acquire(c) CriticalSection c release(c) • Critical Section correctness • Mutual Exclusion: safety (ME1) • Deadlock-Freedom: progress (ME2a) • Starvation-Freedom: fairness (ME2b) • [Happens-Before Ordering (ME3)]

  3. Algorithms • Centralized algorithm • Distributed algorithm • Token Ring algorithm

  4. Centralized Algorithm • Leader process grants access • Requests queued in order received • Three types of messages: • Request(P,c) – Process P requests CS c • Acquire(P,c) – Leader grants P access to c • Release(P,c) – P is done with CS c

  5. Example – Centralized Alg (1/3) 1 0 2 Acquire(1,c) Request(1,c) 3 CS process c 1

  6. Example – Centralized Alg (2/3) 1 0 2 Request(2,c) 3 Queue for c Request(2,c) CS process c 1

  7. Example – Centralized Alg (3/3) 1 0 2 Release(1,c) Acquire(2,c) 3 Queue for c Request(2,c) CS process c 1 CS process c 2

  8. Token Ring Algorithm • Organize processes in (logical) ring • Initialize – pass first process token • Token continually passed around the ring • Acquire CS when receiving token • If CS not needed, pass token along • When releasing CS, pass token to successor

  9. Distributed Algorithm • No leader process • Need total order on messages • Broadcast all messages • Lamport’s timestamps • Two message types: • request(P,c,ts) – P requests CS c at time ts • acquire(P,Q,c) – Q permits P to enter c • P acquires c – all proc permit P to enter c

  10. Example – Distributed Alg (1/7) Wanted 1 Request(1,c,8) Request(1,c,8) Acquire(1,0,c) 0 2 Released Request(1,c,8) Released Acquire(1,3,c) 3 Released

  11. Example – Distributed Alg (2/7) Wanted Acquire from 0,3 1 Request(1,c,8) Acquire(1,0,c) 0 2 Released Released Acquire(1,3,c) 3 Released

  12. Example – Distributed Alg (3/7) Acquire from 0,3 1 Request(2,c,6) Request(1,c,8) Wanted 0 2 Released Request(2,c,6) Released Request(2,c,6) 3 Released

  13. Example – Distributed Alg (4/7) Acquire from 0,3 1 Request(2,c,6) Wanted Request(1,c,8) Acquire from 0,3 0 2 Released Acquire(2,0,c) Wanted Acquire(2,3,c) 3 Released

  14. Example – Distributed Alg (5/7) Acquire from 0,3 1 Request(2,c,6) Wanted Request(1,c,8) 0 2 Released Acquire from 0,3 Wanted Queue Request(1,c,8) Receives request 3 Released

  15. Example – Distributed Alg (6/7) Acquire from 0,3 1 Request(2,c,6) Wanted Acquire(2,1,c) 0 2 Released Acquire from 0,3 Receive request Wanted Queue Request(1,c,8) 3 Released

  16. Example – Distributed Alg (7/7) Acquire from 0,3 1 Enters CS Wanted Acquire(1,2,c) 0 2 Released Wanted Queue Request(1,c,8) Held Released 3 Released

More Related