Week 6
Lecture Notes
Semaphores
- Ben-Ari Ch 6
- slides: PDF
- begin: Dining Philosophers
- Code walk: Dining UPC Philosophers
- Version 1: busy waiting with
upc_lock_attempt() - Version 2: deadlocking with
upc_lock()
Class exercise
- The Hungry Birds (handout) PDF
- split binary semaphores
- where for binary semaphores s1 and s2:
0 <= s1+s2 <= 1
- technique: pass the baton
Monitors
- Marc's Lecture Notes: PDF
- Ben-Ari Ch 7
- begin slide 146
- Dr. Seuss on Deadlock:
- Semaphores vs. Monitors
| Semaphore | Monitor |
|---|---|
wait may or may not block | waitC always blocks |
signal always has an effect | signalC has no effect if queue is empty |
signal unblocks an arbitrary blocked process | signalC unblocks the process at the head of the queue |
| a process unblocked by signal can resume execution immediately | a process unblocked by signalC must wait for the signaling process to leave monitor |
Midterm Programming Assignment
- Dining UPC Philosophers PDF
- Note: version 3 is required (sorry for any confusion!)
- it can definitely be implemented with busy waiting
- the challenge is whether it can be implemented without busy waiting!
- Assigned: Thu, Feb 19
- Due: Tue, Mar 3, 11:59pm (Tue before Spring break)