CMU CS 15410 - Lecture (42 pages)

Previewing pages 1, 2, 3, 20, 21, 40, 41, 42 of 42 page document View the full content.
View Full Document

Lecture



Previewing pages 1, 2, 3, 20, 21, 40, 41, 42 of actual document.

View the full content.
View Full Document
View Full Document

Lecture

228 views

Lecture Notes


Pages:
42
School:
Carnegie Mellon University
Course:
Cs 15410 - Operating System Design and Implementation
Operating System Design and Implementation Documents

Unformatted text preview:

15 410 Arguably less wrong Synchronization 3 Sep 22 2004 Dave Eckhardt Bruce Maggs 1 L10a Synch 15 410 F 04 Road Map Two Fundamental operations Atomic instruction sequence Voluntary de scheduling 1 15 410 F 04 Outline Synch 1 Two building blocks Three requirements for mutual exclusion Algorithms people don t use for mutual exclusion Synch 2 How mutual exclusion is really implemented Synch 2 Condition variables 1 Under the hood The atomic sleep problem Semaphores monitors overview 15 410 F 04 Voluntary de scheduling The Situation You hold lock on shared resource But it s not in the right mode Action sequence 1 Unlock shared resource Write down wake me up when Go to sleep until resource changes state 15 410 F 04 What not to do while reckoning mutex lock scenario lk if date 1906 04 18 hour 5 reckoning true else mutex unlock scenario lk wreak general havoc mutex unlock scenario lk 1 15 410 F 04 What not to do Why is this wrong 1 Make sure you understand See previous two lectures Do not do this in P2 or P3 15 410 F 04 Arguably Less Wrong 1 while reckoning mutex lock scenario lk if date 1906 04 18 hour 5 reckoning true else mutex unlock scenario lk sleep 1 wreak general havoc mutex unlock scenario lk 15 410 F 04 Arguably less wrong Don t do this either How wrong is a while What s the problem 1 N 1 times it s much too short Nth time it s much too long It s wrong every time We don t really want a duration We want to wait for a condition 15 410 F 04 Something is missing Mutex protects shared state Also encapsulates interfering code sequence as object Good How can we sleep for the right duration Get an expert to tell us Encapsulate the right duration 1 into a condition variable object 15 410 F 04 Once more with feeling mutex lock scenario lk while cvar wait on cond wait scenario lk cvar wreak general havoc locked mutex unlock scenario lk 1 15 410 F 04 wait on if y 1906 return new year else if m 4 return new month else if d 18 return new day else if h 5 return new hour else



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Lecture 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 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?