Académique Documents
Professionnel Documents
Culture Documents
Event Ordering
Mutual Exclusion
Atomicity
Concurrency Control
Deadlock Handling
Election Algorithms
Reaching Agreement
Operating System Concepts – 7th Edition, Apr 11, 2005 18.2 Silberschatz, Galvin and Gagne ©2005
Chapter Objectives
Operating System Concepts – 7th Edition, Apr 11, 2005 18.3 Silberschatz, Galvin and Gagne ©2005
Event Ordering
Operating System Concepts – 7th Edition, Apr 11, 2005 18.4 Silberschatz, Galvin and Gagne ©2005
Relative Time for Three Concurrent Processes
Operating System Concepts – 7th Edition, Apr 11, 2005 18.5 Silberschatz, Galvin and Gagne ©2005
Implementation of →
Operating System Concepts – 7th Edition, Apr 11, 2005 18.6 Silberschatz, Galvin and Gagne ©2005
Distributed Mutual Exclusion (DME)
Assumptions
z The system consists of n processes; each process Pi resides
at a different processor
z Each process has a critical section that requires mutual
exclusion
Requirement
z If Pi is executing in its critical section, then no other process Pj
is executing in its critical section
We present two algorithms to ensure the mutual exclusion
execution of processes in their critical sections
Operating System Concepts – 7th Edition, Apr 11, 2005 18.7 Silberschatz, Galvin and Gagne ©2005
DME: Centralized Approach
Operating System Concepts – 7th Edition, Apr 11, 2005 18.8 Silberschatz, Galvin and Gagne ©2005
DME: Fully Distributed Approach
Operating System Concepts – 7th Edition, Apr 11, 2005 18.9 Silberschatz, Galvin and Gagne ©2005
DME: Fully Distributed Approach (Cont.)
Operating System Concepts – 7th Edition, Apr 11, 2005 18.10 Silberschatz, Galvin and Gagne ©2005
Desirable Behavior of Fully Distributed Approach
2 x (n – 1)
Operating System Concepts – 7th Edition, Apr 11, 2005 18.11 Silberschatz, Galvin and Gagne ©2005
Three Undesirable Consequences
Processes that have not entered their critical section must pause
frequently to assure other processes that they intend to enter the
critical section
z This protocol is therefore suited for small, stable sets of
cooperating processes
Operating System Concepts – 7th Edition, Apr 11, 2005 18.12 Silberschatz, Galvin and Gagne ©2005
Token-Passing Approach
Operating System Concepts – 7th Edition, Apr 11, 2005 18.13 Silberschatz, Galvin and Gagne ©2005
Atomicity
Operating System Concepts – 7th Edition, Apr 11, 2005 18.14 Silberschatz, Galvin and Gagne ©2005
Two-Phase Commit Protocol (2PC)
The protocol involves all the local sites at which the transaction
executed
Operating System Concepts – 7th Edition, Apr 11, 2005 18.15 Silberschatz, Galvin and Gagne ©2005
Phase 1: Obtaining a Decision
Operating System Concepts – 7th Edition, Apr 11, 2005 18.16 Silberschatz, Galvin and Gagne ©2005
Phase 1 (Cont.)
Operating System Concepts – 7th Edition, Apr 11, 2005 18.17 Silberschatz, Galvin and Gagne ©2005
Phase 2: Recording Decision in the Database
Operating System Concepts – 7th Edition, Apr 11, 2005 18.18 Silberschatz, Galvin and Gagne ©2005
Failure Handling in 2PC – Site Failure
Operating System Concepts – 7th Edition, Apr 11, 2005 18.19 Silberschatz, Galvin and Gagne ©2005
Failure Handling in 2PC – Coordinator Ci Failure
If an active site contains a <commit T> record in its log, the T must
be committed
If an active site contains an <abort T> record in its log, then T must
be aborted
If some active site does not contain the record <ready T> in its log
then the failed coordinator Ci cannot have decided to
commit T
z Rather than wait for Ci to recover, it is preferable to abort T
All active sites have a <ready T> record in their logs, but no
additional control records
z In this case we must wait for the coordinator to recover
z Blocking problem – T is blocked pending the recovery of site Si
Operating System Concepts – 7th Edition, Apr 11, 2005 18.20 Silberschatz, Galvin and Gagne ©2005
Concurrency Control
Operating System Concepts – 7th Edition, Apr 11, 2005 18.21 Silberschatz, Galvin and Gagne ©2005
Locking Protocols
Operating System Concepts – 7th Edition, Apr 11, 2005 18.22 Silberschatz, Galvin and Gagne ©2005
Single-Coordinator Approach
A single lock manager resides in a single chosen site, all lock and
unlock requests are made a that site
Simple implementation
Possibility of bottleneck
Operating System Concepts – 7th Edition, Apr 11, 2005 18.23 Silberschatz, Galvin and Gagne ©2005
Majority Protocol
Operating System Concepts – 7th Edition, Apr 11, 2005 18.24 Silberschatz, Galvin and Gagne ©2005
Biased Protocol
Operating System Concepts – 7th Edition, Apr 11, 2005 18.25 Silberschatz, Galvin and Gagne ©2005
Primary Copy
Operating System Concepts – 7th Edition, Apr 11, 2005 18.26 Silberschatz, Galvin and Gagne ©2005
Timestamping
Operating System Concepts – 7th Edition, Apr 11, 2005 18.27 Silberschatz, Galvin and Gagne ©2005
Generation of Unique Timestamps
Operating System Concepts – 7th Edition, Apr 11, 2005 18.28 Silberschatz, Galvin and Gagne ©2005
Deadlock Prevention
Operating System Concepts – 7th Edition, Apr 11, 2005 18.29 Silberschatz, Galvin and Gagne ©2005
Timestamped Deadlock-Prevention Scheme
Operating System Concepts – 7th Edition, Apr 11, 2005 18.30 Silberschatz, Galvin and Gagne ©2005
Wait-Die Scheme
Operating System Concepts – 7th Edition, Apr 11, 2005 18.31 Silberschatz, Galvin and Gagne ©2005
Would-Wait Scheme
Operating System Concepts – 7th Edition, Apr 11, 2005 18.32 Silberschatz, Galvin and Gagne ©2005
Deadlock Detection
Operating System Concepts – 7th Edition, Apr 11, 2005 18.33 Silberschatz, Galvin and Gagne ©2005
Two Local Wait-For Graphs
Operating System Concepts – 7th Edition, Apr 11, 2005 18.34 Silberschatz, Galvin and Gagne ©2005
Global Wait-For Graph
Operating System Concepts – 7th Edition, Apr 11, 2005 18.35 Silberschatz, Galvin and Gagne ©2005
Deadlock Detection – Centralized Approach
Operating System Concepts – 7th Edition, Apr 11, 2005 18.36 Silberschatz, Galvin and Gagne ©2005
Detection Algorithm Based on Option 3
Operating System Concepts – 7th Edition, Apr 11, 2005 18.37 Silberschatz, Galvin and Gagne ©2005
The Algorithm
Operating System Concepts – 7th Edition, Apr 11, 2005 18.38 Silberschatz, Galvin and Gagne ©2005
Local and Global Wait-For Graphs
Operating System Concepts – 7th Edition, Apr 11, 2005 18.39 Silberschatz, Galvin and Gagne ©2005
Fully Distributed Approach
Operating System Concepts – 7th Edition, Apr 11, 2005 18.40 Silberschatz, Galvin and Gagne ©2005
Augmented Local Wait-For Graphs
Operating System Concepts – 7th Edition, Apr 11, 2005 18.41 Silberschatz, Galvin and Gagne ©2005
Augmented Local Wait-For Graph in Site S2
Operating System Concepts – 7th Edition, Apr 11, 2005 18.42 Silberschatz, Galvin and Gagne ©2005
Election Algorithms
Operating System Concepts – 7th Edition, Apr 11, 2005 18.43 Silberschatz, Galvin and Gagne ©2005
Bully Algorithm
Operating System Concepts – 7th Edition, Apr 11, 2005 18.44 Silberschatz, Galvin and Gagne ©2005
Bully Algorithm (Cont.)
Operating System Concepts – 7th Edition, Apr 11, 2005 18.45 Silberschatz, Galvin and Gagne ©2005
Bully Algorithm (Cont.)
Operating System Concepts – 7th Edition, Apr 11, 2005 18.46 Silberschatz, Galvin and Gagne ©2005
Ring Algorithm
Assumes that the links are unidirectional, and that processes send
their messages to their right neighbors
Operating System Concepts – 7th Edition, Apr 11, 2005 18.47 Silberschatz, Galvin and Gagne ©2005
Ring Algorithm (Cont.)
1. If this is the first elect message it has seen or sent, Pi creates a new
active list with the numbers i and j
) It then sends the message elect(i), followed by the message
elect(j)
2. If i ≠ j, then the active list for Pi now contains the numbers of all the
active processes in the system
) Pi can now determine the largest number in the active list to
identify the new coordinator process
3. If i = j, then Pi receives the message elect(i)
) The active list for Pi contains all the active processes in the
system
) Pi can now determine the new coordinator process.
Operating System Concepts – 7th Edition, Apr 11, 2005 18.48 Silberschatz, Galvin and Gagne ©2005
Reaching Agreement
Operating System Concepts – 7th Edition, Apr 11, 2005 18.49 Silberschatz, Galvin and Gagne ©2005
Faulty Communications
Operating System Concepts – 7th Edition, Apr 11, 2005 18.50 Silberschatz, Galvin and Gagne ©2005
Faulty Communications (Cont.)
Operating System Concepts – 7th Edition, Apr 11, 2005 18.51 Silberschatz, Galvin and Gagne ©2005
Faulty Processes (Byzantine Generals Problem)
Operating System Concepts – 7th Edition, Apr 11, 2005 18.52 Silberschatz, Galvin and Gagne ©2005
Faulty Processes (Cont.)
Operating System Concepts – 7th Edition, Apr 11, 2005 18.53 Silberschatz, Galvin and Gagne ©2005
End of Chapter 18