![](images/graphics/blank.gif)
Bài giảng Hệ điều hành nâng cao - Chapter 18: Distributed Coordination
lượt xem 5
download
![](https://tailieu.vn/static/b2013az/templates/version1/default/images/down16x21.png)
Bài giảng Hệ điều hành nâng cao - Chapter 18: Distributed Coordination giúp bạn đọc nắm được quá trình phối hợp phân phối, thứ tự sự kiện, số nguyên tử số, các thuật toán,...Đây là tài liệu tham khảo thuộc chuyên ngành Công nghệ thông tin.
Bình luận(0) Đăng nhập để gửi bình luận!
Nội dung Text: Bài giảng Hệ điều hành nâng cao - Chapter 18: Distributed Coordination
- Chapter 18: Distributed Coordination Operating System Concepts – 8th Edition Operating System Concepts – 8th Edition 18.1 Silberschatz, Galvin and Gagne ©2009
- Chapter 18: Distributed Coordination s Event Ordering s Mutual Exclusion s Atomicity s Concurrency Control s Deadlock Handling s Election Algorithms s Reaching Agreement Operating System Concepts – 8th Edition 18.2 Silberschatz, Galvin and Gagne ©2009
- Chapter Objectives s To describe various methods for achieving mutual exclusion in a distributed system s To explain how atomic transactions can be implemented in a distributed system s To show how some of the concurrency-control schemes discussed in Chapter 6 can be modified for use in a distributed environment s To present schemes for handling deadlock prevention, deadlock avoidance, and deadlock detection in a distributed system Operating System Concepts – 8th Edition 18.3 Silberschatz, Galvin and Gagne ©2009
- Event Ordering s Happened-before relation (denoted by ) q If A and B are events in the same process, and A was executed before B, then A B q If A is the event of sending a message by one process and B is the event of receiving that message by another process, then A B q If A B and B C then A C Operating System Concepts – 8th Edition 18.4 Silberschatz, Galvin and Gagne ©2009
- Relative Time for Three Concurrent Processes Operating System Concepts – 8th Edition 18.5 Silberschatz, Galvin and Gagne ©2009
- Implementation of s Associate a timestamp with each system event q Require that for every pair of events A and B, if A B, then the timestamp of A is less than the timestamp of B s Within each process Pi a logical clock, LCi is associated q The logical clock can be implemented as a simple counter that is incremented between any two successive events executed within a process 4 Logical clock is monotonically increasing s A process advances its logical clock when it receives a message whose timestamp is greater than the current value of its logical clock s If the timestamps of two events A and B are the same, then the events are concurrent q We may use the process identity numbers to break ties and to create a total ordering Operating System Concepts – 8th Edition 18.6 Silberschatz, Galvin and Gagne ©2009
- Distributed Mutual Exclusion (DME) s Assumptions q The system consists of n processes; each process Pi resides at a different processor q Each process has a critical section that requires mutual exclusion s Requirement q If Pi is executing in its critical section, then no other process Pj is executing in its critical section s We present two algorithms to ensure the mutual exclusion execution of processes in their critical sections Operating System Concepts – 8th Edition 18.7 Silberschatz, Galvin and Gagne ©2009
- DME: Centralized Approach s One of the processes in the system is chosen to coordinate the entry to the critical section s A process that wants to enter its critical section sends a request message to the coordinator s The coordinator decides which process can enter the critical section next, and its sends that process a reply message s When the process receives a reply message from the coordinator, it enters its critical section s After exiting its critical section, the process sends a release message to the coordinator and proceeds with its execution s This scheme requires three messages per critical-section entry: q request q reply q release Operating System Concepts – 8th Edition 18.8 Silberschatz, Galvin and Gagne ©2009
- DME: Fully Distributed Approach s When process Pi wants to enter its critical section, it generates a new timestamp, TS, and sends the message request (Pi, TS) to all other processes in the system s When process Pj receives a request message, it may reply immediately or it may defer sending a reply back s When process Pi receives a reply message from all other processes in the system, it can enter its critical section s After exiting its critical section, the process sends reply messages to all its deferred requests Operating System Concepts – 8th Edition 18.9 Silberschatz, Galvin and Gagne ©2009
- DME: Fully Distributed Approach (Cont.) s The decision whether process Pj replies immediately to a request(Pi, TS) message or defers its reply is based on three factors: q If Pj is in its critical section, then it defers its reply to Pi q If Pj does not want to enter its critical section, then it sends a reply immediately to Pi q If Pj wants to enter its critical section but has not yet entered it, then it compares its own request timestamp with the timestamp TS 4 If its own request timestamp is greater than TS, then it sends a reply immediately to Pi (Pi asked first) 4 Otherwise, the reply is deferred Operating System Concepts – 8th Edition 18.10 Silberschatz, Galvin and Gagne ©2009
- Desirable Behavior of Fully Distributed Approach s Freedom from Deadlock is ensured s Freedom from starvation is ensured, since entry to the critical section is scheduled according to the timestamp ordering q The timestamp ordering ensures that processes are served in a first-come, first served order s The number of messages per critical-section entry is 2 x (n – 1) This is the minimum number of required messages per critical-section entry when processes act independently and concurrently Operating System Concepts – 8th Edition 18.11 Silberschatz, Galvin and Gagne ©2009
- Three Undesirable Consequences s The processes need to know the identity of all other processes in the system, which makes the dynamic addition and removal of processes more complex s If one of the processes fails, then the entire scheme collapses q This can be dealt with by continuously monitoring the state of all the processes in the system s Processes that have not entered their critical section must pause frequently to assure other processes that they intend to enter the critical section q This protocol is therefore suited for small, stable sets of cooperating processes Operating System Concepts – 8th Edition 18.12 Silberschatz, Galvin and Gagne ©2009
- Token-Passing Approach s Circulate a token among processes in system q Token is special type of message q Possession of token entitles holder to enter critical section s Processes logically organized in a ring structure s Unidirectional ring guarantees freedom from starvation s Two types of failures q Lost token – election must be called q Failed processes – new logical ring established Operating System Concepts – 8th Edition 18.13 Silberschatz, Galvin and Gagne ©2009
- Atomicity s Either all the operations associated with a program unit are executed to completion, or none are performed s Ensuring atomicity in a distributed system requires a transaction coordinator, which is responsible for the following: q Starting the execution of the transaction q Breaking the transaction into a number of subtransactions, and distribution these subtransactions to the appropriate sites for execution q Coordinating the termination of the transaction, which may result in the transaction being committed at all sites or aborted at all sites Operating System Concepts – 8th Edition 18.14 Silberschatz, Galvin and Gagne ©2009
- Two-Phase Commit Protocol (2PC) s Assumes fail-stop model s Execution of the protocol is initiated by the coordinator after the last step of the transaction has been reached s When the protocol is initiated, the transaction may still be executing at some of the local sites s The protocol involves all the local sites at which the transaction executed s Example: Let T be a transaction initiated at site Si and let the transaction coordinator at Si be Ci Operating System Concepts – 8th Edition 18.15 Silberschatz, Galvin and Gagne ©2009
- Phase 1: Obtaining a Decision s Ci adds record to the log s Ci sends message to all sites s When a site receives a message, the transaction manager determines if it can commit the transaction q If no: add record to the log and respond to Ci with q If yes: 4 add record to the log 4 force all log records for T onto stable storage 4 send message to Ci Operating System Concepts – 8th Edition 18.16 Silberschatz, Galvin and Gagne ©2009
- Phase 1 (Cont.) s Coordinator collects responses q All respond “ready”, decision is commit q At least one response is “abort”, decision is abort q At least one participant fails to respond within time out period, decision is abort Operating System Concepts – 8th Edition 18.17 Silberschatz, Galvin and Gagne ©2009
- Phase 2: Recording Decision in the Database s Coordinator adds a decision record or to its log and forces record onto stable storage s Once that record reaches stable storage it is irrevocable (even if failures occur) s Coordinator sends a message to each participant informing it of the decision (commit or abort) s Participants take appropriate action locally Operating System Concepts – 8th Edition 18.18 Silberschatz, Galvin and Gagne ©2009
- Failure Handling in 2PC – Site Failure s The log contains a record q In this case, the site executes redo(T) s The log contains an record q In this case, the site executes undo(T) s The contains a record; consult Ci q If Ci is down, site sends query-status T message to the other sites s The log contains no control records concerning T q In this case, the site executes undo(T) Operating System Concepts – 8th Edition 18.19 Silberschatz, Galvin and Gagne ©2009
- Failure Handling in 2PC – Coordinator Ci Failure s If an active site contains a record in its log, the T must be committed s If an active site contains an record in its log, then T must be aborted s If some active site does not contain the record in its log then the failed coordinator Ci cannot have decided to commit T q Rather than wait for Ci to recover, it is preferable to abort T s All active sites have a record in their logs, but no additional control records q In this case we must wait for the coordinator to recover q Blocking problem – T is blocked pending the recovery of site Si Operating System Concepts – 8th Edition 18.20 Silberschatz, Galvin and Gagne ©2009
![](images/graphics/blank.gif)
CÓ THỂ BẠN MUỐN DOWNLOAD
-
Bài giảng Hệ điều hành nâng cao - Chapter 3: Processes
54 p |
140 |
15
-
Bài giảng Hệ điều hành nâng cao - Chapter 5: CPU Scheduling
67 p |
135 |
14
-
Bài giảng Hệ điều hành nâng cao - Chapter 11: File System Implementation
63 p |
203 |
14
-
Bài giảng Hệ điều hành nâng cao - Chapter 19: Real - Time Systems
24 p |
102 |
13
-
Bài giảng Hệ điều hành nâng cao - Chapter 6: Process Synchronization
72 p |
213 |
11
-
Bài giảng Hệ điều hành nâng cao - Chapter 12: Mass - Storage Systems
57 p |
177 |
10
-
Bài giảng Hệ điều hành nâng cao - Chapter 10: File - System Interface
43 p |
102 |
10
-
Bài giảng Hệ điều hành nâng cao - Chapter 2: Operating - System Structures
54 p |
179 |
9
-
Bài giảng Hệ điều hành nâng cao - Chapter 13: I/O Systems
42 p |
163 |
9
-
Bài giảng Hệ điều hành nâng cao - Chapter 1: Introduction
48 p |
144 |
8
-
Bài giảng Hệ điều hành nâng cao - Chapter 4: Threads
45 p |
138 |
8
-
Bài giảng Hệ điều hành nâng cao - Chapter 21: The Linux System
62 p |
151 |
7
-
Bài giảng Hệ điều hành nâng cao - Chapter 14: Protection
29 p |
79 |
6
-
Bài giảng Hệ điều hành nâng cao - Chapter 17: Distributed - File Systems
29 p |
91 |
6
-
Bài giảng Hệ điều hành nâng cao - Chapter 20: Multimedia Systems
33 p |
130 |
6
-
Bài giảng Hệ điều hành nâng cao - Chapter 22: Windows XP
64 p |
93 |
6
-
Bài giảng Hệ điều hành nâng cao - Chapter 16: Distributed System Structures
36 p |
105 |
4
![](images/icons/closefanbox.gif)
![](images/icons/closefanbox.gif)
Chịu trách nhiệm nội dung:
Nguyễn Công Hà - Giám đốc Công ty TNHH TÀI LIỆU TRỰC TUYẾN VI NA
LIÊN HỆ
Địa chỉ: P402, 54A Nơ Trang Long, Phường 14, Q.Bình Thạnh, TP.HCM
Hotline: 093 303 0098
Email: support@tailieu.vn
![](https://tailieu.vn/static/b2013az/templates/version1/default/js/fancybox2/source/ajax_loader.gif)