1. Trang chủ
  2. » Công Nghệ Thông Tin

Lecture Operating systems: A concept-based approach (2/e): Chapter 16 - Dhananjay M. Dhamdhere

27 100 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 27
Dung lượng 539,81 KB

Nội dung

Chapter 17 - Distributed control algorithms. This chapter describes the notions of correctness of a distributed control algorithm, and presents algorithms for performing five control functions in a distributed OS - mutual exclusion, deadlock handling, leader election, scheduling, and termination detection.

PROPRIETARY MATERIAL. ©  2007 The McGraw­Hill Companies, Inc. All rights reserved. No part of this PowerPoint slide  may be displayed, reproduced or distributed  in any form or by any means, without the prior written permission of the publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw­Hill  for their individual course preparation. If you are a student using this PowerPoint slide, you are using it without permission.  Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 1 Copyright © 2008 Theoretical issues in distributed systems • An OS uses two key notions to organize its operation – Time and state * Time is used to keep track of when an event occurred, or the order in which events occurred * State of processes and resources are used in scheduling and resource allocation – These notions are hard to use in a distributed system * Computers have their own clocks, which might show different times  Hence time is not uniquely known * Computers have memories  So states of entities might be spread throughout the system – We need to develop practical substitutes to these notions Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 2 Copyrightâ2008 Local and global states Definitions Local state * State of an entity, such as a process, CPU, or resource – Global state * Global state of a system at time t is the collection of local states of all entities in it at time instant t – We depict local and global states as follows: * Local state of a process Pk at time t: skt * Global state of the system at time t: St  If a system contains n processes, its state is represented as { s1t, s2t, …, snt } Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— AConceptưBasedApproach,2ed SlideNo:3 Copyrightâ2008 Change of state The state changes as a result of an event – An event could be the sending or receiving of a message – We represent an event as follows: < process state, old state, new state, event description, channel, message >   • Event ei is < Pk, s, s’, send, c, m > Chapter16:Theoreticalissues inDistributedSystems Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:4 Copyrightâ2008 Event Precedence Event precedence indicates which event occurred before or after another event – Precedence is used to know the order in which events occurred * It is called event ordering * ei → ej indicates that event ei precedes ej, i.e., occurred before it – Precedence of events in a process is known – A causal relationship is a cause-and-effect relationship * The event corresponding to a cause occurs before that corresponding to its effect, e.g., sending and receiving of a message * It is used to find precedence of events in different processes – Event precedence is transitive * If ei → ej and ej → ek, then ei → ek Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 5 Copyright © 2008 Event precedence via timing diagram • e23 → e12 because e23 is a send event for m1 and e12 is a receive event • e22 → e23 because both events occur in process P2 • Hence e22 → e12 Similarly e22 → e13, e21 → e12, etc Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 6 Copyright © 2008 Logical Clocks • Background – A ‘global clock’ does not exist – Computers have ‘local clocks’; these clocks can drift apart – So we have a local clock in each process and synchronize local clocks when needed * A process Pi has a local clock LCi * When Pk receives a message from Pi, synchronization is needed if  Time in LCk is smaller than what was the time in LCi when Pi sent the message » This is so because of causal relationship – Such clocks not show ‘real’ time * Hence they are called logical clocks Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:7 Copyrightâ2008 Time-stamps When an event ei occurs in a process Pi – The value of the local clock LCi is called the time-stamp of ei * We represent the time-stamp of ei as ts(ei) – When Pi sends a message m, it copies the time-stamp of the send event in message m Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed SlideNo:8 Copyrightâ2008 Synchronization of Logical Clocks Clock synchronization rules R1: A process Pk increments LCk by when any event occurs in it R2: When Pk receives a message m containing the time-stamp ts(send(m)), Pk undates LCk as follows: LCk = max ( LCk, ts(send(m) + ) Chapter 16: Theoretical issues inDistributedSystems Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:9 Copyrightâ2008 Synchronization of logical clocks • • • The pair associated with an event shows clock times before and after Logical clock in P2 is synchronized when it receives message m1 Logical clock in P1 is synchronized when P1 receives message m3 Logical clocks in P2 is synchronized when P2 receives message m4 Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:10 Copyrightâ2008 Synchronization of vector clocks Each triple is the vector time-stamp of an event • P2 updates VC2[1] when it receives messages m1 and m4 • P3 updates VC3[1] and VC3[2] when it receives message m2 Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 13 Copyright © 2008 Time-stamps using vector clocks • Precedence between events can be determined by comparing their time-stamps – ei precedes ej * If for all k: vts(ei)[k] ≤ vts(ej)[k] but vts(ei)[l] ≠ vts(ej)[l] for some l – ei follows ej * If for all k: vts(ei)[k] ≥ vts(ej)[k] but vts(ei)[l] ≠ vts(ej)[l] for some l – ei, and ej are concurrent * For some k, l : vts(ei)[k] < vts(ej)[k] and vts(ei)[l] > vts(ej)[l] • Vector time-stamps have the following property: – vts(ei) < vts(ej) if and only if ei → ej * Hence use of a pair (local time, process id) provides a total order over events Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 14 Copyright © 2008 The state of a distributed system • The state of a distributed system is the collection of states of individual computer systems, i.e., collection of local states – Local states in the collection may be recorded at different times * Such states may be inconsistent Q: How to ensure consistency of local states? Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 15 Copyright © 2008 The state of a distributed system • If $100 is transferred from account A to B, existing in different nodes, and states of A and B are recorded (a) Account A contains 900 dollars and B contains 300 dollars (b) 800 and 400, (c) 800 and 300 ($100 is in transit) and (d) 900 and 400 Local states in (a), (b) and (c) are mutually consistent In (d), they are not consistent Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 16 Copyright © 2008 Mutual Consistency of local states • Definition – Local states of processes Pk and Pl are mutually consistent if * Every message recorded as ‘received from Pl’ in Pk’s state is recorded as ‘sent to Pk’ in Pl’s state * Every message recorded as ‘received from Pk’ in Pl’s state is recorded as ‘sent to Pl’ in Pk’s state • An algorithm for recording the state of a system should ensure mutual consistency of local states of all processes * It is assumed that any message that has been sent but not yet received by the destination process is ‘in the system’ Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— AConceptưBasedApproach,2ed SlideNo:17 Copyrightâ2008 A distributed computation for state recording Assumptions – Processes communicate over interprocess channels – Each channel is unidirectional and has unlimited buffering capacity Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 18 Copyright © 2008 A timing diagram for the distributed computation • States of the processes are recorded at tP1– tP4 Q: Are these states mutually consistent? Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed SlideNo:19 Copyrightâ2008 A cut of a distributed system A cut in a timing diagram is a curve that connects the points at which states of processes are recorded – Points to the left of the cut in the timing diagram are in the past of the cut – Points to the right are in the future of the cut – A cut represents a consistent state recording of a distributed system if the future of the cut is closed under the precedes relation on events, i.e., under → * That is, if a → b and is an event a in the future of the cut, b also lies in the future of the cut Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed SlideNo:20 Copyrightâ2008 Consistency of a cut Cuts C1 and C2 are consistent; cut C3 is inconsistent • A cut is inconsistent if some message has a backward intersection with it, e.g message P3 → P1 Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed SlideNo:21 Copyrightâ2008 ChandyLamport Algorithm for state recording Features of the algorithm – Channels are assumed to be FIFO * This property is used to identify messages that are in transit over a channel – The state of a process indicates the messages sent and received by it – A special message called a marker is sent to ask a process to record its state * A process receives markers over all channels incident on it  It records the state of the channel over which it received the marker  If it is the first marker received by it, it also records its own state Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed SlideNo:22 Copyrightâ2008 ChandyLamport Algorithm Steps in the algorithm When a process wishes to initiate the state recording * Records its own state and sends markers over all outgoing channels – When process Pj receives a marker over channel Chij * If it is the first marker  Record its own state  Record state of Chij as empty  Send markers over all outgoing channels * Else record the state of the channel to contain messages ( Receivedij – Recorded_receivedij )@ : Receivedij : Messages received over Chij until this instant Recorded_receivedij : Messages recorded as received over Chij in Pj’s state @ Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 23 Copyrightâ2008 Example of the ChandyLamport algorithm P1 sends m1 to P3 at time 0, P3 sends m2 to P2 at time • P1 decides to record state of the system at time • (a), (b), (c) are states at 0, 2+, 5+ Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 24 Copyright © 2008 Recorded states of processes and channels Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— AConceptưBasedApproach,2ed SlideNo:25 Copyrightâ2008 Properties of the recorded state The system may not have been in the recorded state at any time – Example: A recorded state of the system on slide 24 that does not match any actual state of the system Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 26 Copyright © 2008 Uses of the recorded state • Q: What use is the recorded state if it does not match any of the actual states of the system? – A stable property can be detected by using the algorithm repeatedly * A stable property is one that remains true once it becomes true * For example, cycles in WFG or RRAG – It may not be detected in a state recorded after it became true – However, it would be detected in some future state recording Chapter 16: Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed Slide No: 27 Copyright © 2008 ... nodes, and states of A and B are recorded (a) Account A contains 900 dollars and B contains 300 dollars (b) 800 and 400, (c) 800 and 300 ($100 is in transit) and (d) 900 and 400 Local states in (a) ,... interprocess channels – Each channel is unidirectional and has unlimited buffering capacity Chapter 16:  Theoretical issues  in Distributed Systems  Dhamdhere: Operating Systems— A Concept­Based Approach , 2 ed... messages that are in transit over a channel – The state of a process indicates the messages sent and received by it – A special message called a marker is sent to ask a process to record its state

Ngày đăng: 30/01/2020, 03:26

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN