Saturday, January 12, 2008
Guide to Operation System Part 8
Deadlock
A deadlock is a situation where a group of two or more process/threads each holds at least one resource while making a request on another and all request cannot be satisfied because the requested resource is held by another process that is being blocked or waiting for another resource.
Four Conditions for Deadlock to occur:
- Mutual Exclusive: Once a process has been allocated a particular resource, the threads in the process have exclusive use of the resource. No other processes can use a resource while it is allocated to a process.
- Hold and Wait: A process hold a resource at the same time it requests another one.
- Circular Wait: A situation can rise in which process P1 holds resource R1 while one of its threads requests resource R2, and process P2 while one of its threads requests resource R1.
- No Preemption: Resources can be release only by the explicit action authority.
Four Approaches of managing Deadlock
- Prevention
- Avoidance
- Detection & Recovery
- Manual Intervention
Banker’s Algorithm (Deadlock Avoidance)
When a new process enters the system, it must declare the maximum number of resources it needs. The system will determine whether allocations of these resources will leave system in a safe state. If yes, resources are allocated. If no, the process will wait until some other process release enough resources.
Posted by Zack at 5:40 PM
Archives
Forum
Design Credits
Animation Credits