Principles of Operating Systems: 2. Processes
Principles of Operating Systems: 2. Processes
CS 446/646 2. Processes
a. Process Description & Control b. Threads c. Concurrency d. Deadlocks
Deadlock principles: diagrams and graphs Deadlock prevention: changing the rules Deadlock avoidance: optimizing the allocation Deadlock detection: recovering after the facts
2/28/2006
154
2.d Deadlocks
Deadlock principles: diagrams and graphs
Illustration of a deadlock
2/28/2006 CS 446/646 - Principles of Operating Systems - 2. Processes
155
2.d Deadlocks
Deadlock principles: diagrams and graphs
Illustration of a deadlock
two processes, P and Q, compete for two resources, A and B each process needs exclusive use of each resource Process P
A required
Process Q
... Get B ... Get A ... Release B ... Release A ...
Competing processes
B required
B required
A required
2/28/2006
156
2.d Deadlocks
Deadlock principles: diagrams and graphs
Process Q
... Get B ... Get A ... Release B ... Release A ...
Happy scheduling 1
B required
B required
A required
2/28/2006
157
2.d Deadlocks
Deadlock principles: diagrams and graphs
Process Q
... Get B ... Get A ... Release B ... Release A ...
Happy scheduling 2
B required
B required
A required
2/28/2006
158
2.d Deadlocks
Deadlock principles: diagrams and graphs
Process Q
... Get B ... Get A ... Release B ... Release A ...
B required
B required
deadlock
A required
2.d Deadlocks
Deadlock principles: diagrams and graphs
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
2.d Deadlocks
Deadlock principles: diagrams and graphs
2.d Deadlocks
Deadlock principles: diagrams and graphs
Process Q
... Get B ... Get A ... Release B ... Release A ...
Competing processes
B required
B required
A required
2/28/2006
162
2.d Deadlocks
Deadlock principles: diagrams and graphs
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
163
2.d Deadlocks
Deadlock principles: diagrams and graphs
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
RAGs
2/28/2006 CS 446/646 - Principles of Operating Systems - 2. Processes 164
2.d Deadlocks
Deadlock principles: diagrams and graphs
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
A deadlocks RAG
2/28/2006 CS 446/646 - Principles of Operating Systems - 2. Processes 165
2.d Deadlocks
Deadlock principles: diagrams and graphs
= Deadlock!
2/28/2006 CS 446/646 - Principles of Operating Systems - 2. Processes 166
2.d Deadlocks
Deadlock principles: diagrams and graphs
2.d Deadlocks
Deadlock prevention: changing the rules
2.d Deadlocks
Deadlock avoidance: optimizing the allocation
2/28/2006
169
2.d Deadlocks
Deadlock avoidance: optimizing the allocation
2/28/2006
170
2.d Deadlocks
Deadlock avoidance: optimizing the allocation
(a)
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
2.d Deadlocks
Deadlock avoidance: optimizing the allocation
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
(c)
2.d Deadlocks
Deadlock avoidance: optimizing the allocation
Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition).
(b) unsafe
2/28/2006
potential for deadlock (we dont know how long Ri will be kept) thus, (b) is an unsafe state: Determination of an unsafe state dont allow (b) to CS 446/646 - Principles of Operating Systems - 2. Processes happen 173
2.d Deadlocks
Deadlock detection: recovering after the facts
2/28/2006
174
2/28/2006
175
2/28/2006
176
2/28/2006
177