lecture05

lecture05 - CS140 - Winter 2008 - Handout #5 Past & Present...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS140 - Winter 2008 -Handout±#5 1 Mendel Rosenblum CS 140: Operating Systems Lecture 5: Deadlocks ± Have looked at two constraints: mutual exclusion constraint between two events is a requirement that they not overlap in time » enforced using scheduling, locks, semaphores, monitors precedence constraint between two events is a requirement that one completes before the other » (usually) enforced using scheduling or semaphores ± Synchronization primitive ordering: atomic instructions can implement locks, locks can implement semaphores (lock + integer counter) or monitors (one implicit lock), and vice versa (of course) ± Today! Deadlock: what to do when many threads and no progress Deadlock: parallelism’s pox ± Graphically, caused by a directed cycle in inter-thread dependencies e.g., T1 holds resource R1 and is waiting on R2, T2 holds R2 and is waiting on R1 No progress possible. Even simple cases can be non-trivial to diagnose. t1 t2 t3 t4 Deadlock example ± Given two threads, what sequence of calls cause the following to deadlock? /* transfer x dollars fro m a to b */ void transfer(account *a, account *b, int x) P(a->sema); P(b->sema): a->balance += x; b->balance -= x; V(a->sema); V(b->sema ); transfer(?,?) t1 transfer(?,?) t2 Deadlock generalized ± Does deadlock require locks? No. Just circular constraints. Example: consider two threads that send and receive data
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/24/2008 for the course CS 140 taught by Professor Rosenblum during the Winter '08 term at Stanford.

Page1 / 3

lecture05 - CS140 - Winter 2008 - Handout #5 Past & Present...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online