Beruflich Dokumente
Kultur Dokumente
Chapter 5
Process Management
Learning Objectives
Several causes of system deadlock
The difference between preventing and avoiding
deadlocks
How to detect and recover from deadlocks
The concept of process starvation and how to detect
and recover from it
The concept of a race and how to prevent it
The difference between deadlock, starvation, and
race
2
Deadlock
Resource sharing
Memory management and processor sharing
Starvation
Infinite postponement of job
3
Deadlock (continued)
More serious than starvation
Affects entire system
Affects more than one job
Not just a few programs
Deadlock (continued)
File requests
Databases
Dedicated device allocation
Multiple device allocation
Spooling
Disk sharing
Network
6
Deadlock remains
Until one program withdrawn or
Until one program forcibly removed and file released
11
Deadlock sequence
14
Spooling
Process
Disk accepts output from several users
Acts as temporary storage for output
Output resides in disk area until printer accepts job data
15
16
Direction of arrows
Indicates message flow
Deadlock sequence
All available buffer space fills
17
18
Deadlock sequence
Neither I/O request satisfied
Device puts request on hold while attempting to fulfill
other request for each request
Livelock results
19
20
Mutual exclusion
Resource holding
No preemption
Circular wait
Resolving deadlock
Removal of one condition
21
Resource holding
Holding resource and not releasing it
Waiting for other job to retreat
No preemption
Lack of temporary reallocation of resources
22
23
Modeling Deadlocks
Directed graphs
Circles represent processes
Squares represent resources
Solid arrow from resource to process
Process holding resource
25
26
27
28
29
30
31
32
33
34
Avoidance
Avoid deadlock if it becomes probable
Detection
Detect deadlock when it occurs
Recover gracefully
Recovery
Resume system normalcy quickly and gracefully
35
Resource holding
Bypassed if jobs request every necessary resource at
creation time
Multiprogramming degree significantly decreased
Idle peripheral devices
36
Circular wait
39
40
41
42
43
Scheduling suffers
Result of poor utilization
Jobs kept waiting for resource allocation
44
Detection algorithm
Remove process using current resource and not
waiting for one
Remove process waiting for one resource class
Not fully allocated
Go back to step 1
Repeat steps 1 and 2 until all connecting lines removed
45
46
47
49
50
Starvation
Job execution prevented
Waiting for resources that never become available
Results from conservative resource allocation
Example
The dining philosophers by Dijkstra
Starvation avoidance
Implement algorithm tracking how long each job
waiting for resources (aging)
Block new jobs until starving jobs satisfied
51
Starvation (continued)
52
Starvation (continued)
53
Summary
Operating system
Dynamically allocates resources
Avoids deadlock and starvation
Prevention
Remove simultaneous occurrence of one or more
conditions
System will become deadlock-free
Prevention algorithms
Complex algorithms and high execution overhead
54
Summary (continued)
Avoid deadlocks
Clearly identify safe and unsafe states
Keep reserve resources to guarantee job completion
Disadvantage
System not fully utilized
No prevention support
System must detect and recover from deadlocks
Detection relies on selection of victim
55