DOC PREVIEW
U of I CS 425 - LECTURE 5

This preview shows page 1-2-24-25 out of 25 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Computer Science 425 Distributed SystemsWhy Mutual Exclusion?Slide 3Mutual ExclusionRefresher - SemaphoresSlide 6How are semaphores used?Distributed Mutual Exclusion: Performance Evaluation CriteriaAssumptionsCentralized Control of Mutual ExclusionToken Ring ApproachTimestamp Approach: Ricart & AgrawalaRicart and Agrawala’s algorithmSlide 14Slide 15Timestamp Approach: Maekawa’s AlgorithmMaekawa’s algorithm – part 1Maekawa’s algorithm – part 2Maekawa’s Algorithm - AnalysisRaymond’s Token-based ApproachExample:Raymond’s Token-based ApproachRaymond’s Token-based ApproachSlide 23AnalysisSummary 2002, M. T. Harandi and J. Hou (modified : I. Gupta) Lecture 7- 1Lecture 7- 1Computer Science 425Distributed SystemsComputer Science 425Distributed SystemsLecture 5Mutual ExclusionSection 12.2 2002, M. T. Harandi and J. Hou (modified : I. Gupta) Lecture 7- 2Lecture 7- 2Why Mutual Exclusion?Why Mutual Exclusion?•Bank Database: Think of two simultaneous deposits of $10,000 into your bank account, each from one ATM. –Both ATMs read initial amount of $1000 concurrently from the bank server–Both ATMs add $10,000 to this amount (locally at the ATM)–Both write the final amount to the server–What’s wrong? 2002, M. T. Harandi and J. Hou (modified : I. Gupta) Lecture 7- 3Lecture 7- 3Why Mutual Exclusion?Why Mutual Exclusion?•Bank Database: Think of two simultaneous deposits of $10,000 into your bank account, each from one ATM. –Both ATMs read initial amount of $1000 concurrently from the bank server–Both ATMs add $10,000 to this amount (locally at the ATM)–Both write the final amount to the server–What’s wrong?•The ATMs need mutually exclusive access to your account entry at the server (or, to executing the code that modifies the account entry) 2002, M. T. Harandi and J. Hou (modified : I. Gupta) Lecture 7- 4Lecture 7- 4Critical section problem: Piece of code (at all clients) for which we need to ensure there is at most one client executing it at any point of time. Solutions: Semaphores, mutexes, etc. in local operating systems Message-passing-based protocols in distributed systems: enter() the critical section AccessResource() in the critical section exit() the critical section  Distributed mutual exclusion requirements: Safety – At most one process may execute in CS at any time Liveness – Every request for a CS is eventually granted Ordering (desirable) – Requests are granted in FIFO orderMutual Exclusion Mutual Exclusion 2002, M. T. Harandi and J. Hou (modified : I. Gupta) Lecture 7- 5Lecture 7- 5Refresher - SemaphoresRefresher - Semaphores•To synchronize access of multiple threads to common data structures•Semaphore S=1;Allows two operations–wait(S) (or P(S)): while(1){ // each execution of the while loop is atomic if (S > 0) S--; break;}–signal(S) (or V(S)): S++; // atomic–Each while loop execution and S++ are each atomic operations 2002, M. T. Harandi and J. Hou (modified : I. Gupta) Lecture 7- 6Lecture 7- 6Refresher - SemaphoresRefresher - Semaphores•To synchronize access of multiple threads to common data structures•Semaphore S=1;Allows two operations–wait(S) (or P(S)): while(1){ // each execution of the while loop is atomic if (S > 0) S--; break;}–signal(S) (or V(S)): S++;–Each while loop execution and S++ are each atomic operationsenter()exit() 2002, M. T. Harandi and J. Hou (modified : I. Gupta) Lecture 7- 7Lecture 7- 7How are semaphores used?How are semaphores used?semaphore S=1;ATM1:wait(S); // enter// critical sectionobtain bank amount;add in deposit;update bank amount;signal(S); // exitextern semaphore S;ATM2wait(S); // enter// critical sectionobtain bank amount;add in deposit;update bank amount;signal(S); // exitOne Use: Mutual Exclusion – Bank ATM example 2002, M. T. Harandi and J. Hou (modified : I. Gupta) Lecture 7- 8Lecture 7- 8Distributed Mutual Exclusion:Performance Evaluation CriteriaDistributed Mutual Exclusion:Performance Evaluation Criteria•Bandwidth: the total number of messages sent in each entry and exit operation.•Client delay: the delay incurred by a process at each entry and exit operation (when no other process is waiting)•Synchronization delay: the time interval between one process exiting the critical section and the next process entering it (when there is only one process waiting)•These translate into throughput -- the rate at which the processes can access the critical section, i.e., x processes per second.(these definitions more correct than the ones in the textbook) 2002, M. T. Harandi and J. Hou (modified : I. Gupta) Lecture 7- 9Lecture 7- 9AssumptionsAssumptions•For all the algorithms studied, we make the following assumptions:–Each pair of processes is connected by reliable channels (such as TCP). Messages are eventually delivered to recipients’ input buffer in FIFO order.–Processes do not fail. 2002, M. T. Harandi and J. Hou (modified : I. Gupta) Lecture 7- 10Lecture 7- 10A central coordinator (master or leader) Is appointed or elected Grants permission to enter CS & keeps a queue of requests to enter the CS. Ensures only one process at a time can access the CS Separate handling of different CS’s Operations (token gives access to CS)To enter a CS Send a request to the coord & wait for token.On exiting the CS Send a message to the coord to release the token.Upon receipt of a request, if no other process has the token, the coord replies with the token; otherwise, the coord queues the request.Upon receipt of a release message, the coord removes the oldest entry in the queue (if any) and replies with a token. Features:  Safety, liveness and order are guaranteed  It takes 3 messages per entry + exit operation. Client delay: one round trip time (request + grant) Synchronization delay: one round trip time (release + grant)  The coordinator becomes performance bottleneck and single point of failure.Centralized Control of Mutual Exclusion Centralized Control of Mutual Exclusion 2002, M. T. Harandi and J. Hou (modified : I. Gupta) Lecture 7- 11Lecture 7- 11Processes are organized in a logical ring: pi has a communication channel to p(i+1)mod (n+1).Operations:Only the process holding the token can enter the CS. To enter the critical section, wait for the token. To exit the CS, the process sends the token onto its neighbor. If a process does


View Full Document

U of I CS 425 - LECTURE 5

Documents in this Course
Lecture 8

Lecture 8

23 pages

TIPS

TIPS

3 pages

The Grid

The Grid

41 pages

Lecture 4

Lecture 4

27 pages

Lecture 4

Lecture 4

20 pages

The Grid

The Grid

41 pages

Multicast

Multicast

23 pages

LECTURE

LECTURE

34 pages

Load more
Download LECTURE 5
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE 5 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE 5 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?