COMP 409 Lecture Notes - Lecture 7: Posix Threads, Linearizability, Per Brinch Hansen

29 views6 pages

Document Summary

Whoever shows up first will wait for the second. Drawbacks of semaphores: wrap up two abstractions: mutual exclusion and signaling, 2 ideas together in semaphores, p(), v() (cid:314) separate, fragile. Last time: clh locks, blocking solutions, sleep/wake, semaphores. Dijkstra, per brinch hansen: package data, all the operations on that data, mutually exclusive, the only way to accessing the data class monitor { private int d1, d2, synchronized void foo() { synchronized void bar() { All rights reserved: condition variable, always associated with a monitor (mutex, we can have more than one (in pthreads) Can only be invoked inside a monitor (holding a sync block) In the monitor: (cid:313: notify(): wakes, wait(): give up monitor and sleep (atomic, note that a thread that is woken cannot continue on until it has reacquired a lock. T0 synchronized m() { if ( ) wait() // release lock. Release lock and sleep are atomic in condition variables.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers