Beruflich Dokumente
Kultur Dokumente
EXAMPLES:
"It takes money to make money". You can't get a job without experience; you can't get experience without a job. BACKGROUND: The cause of deadlocks: Each process needing what another process has. This results from sharing resources such as memory, devices, links. Under normal operation, a resource allocations proceed like this: 1. Request a resource (suspend until available if necessary ). 2. Use the resource. 3. Release the resource.
In a multiprogramming system, processes request resources. If those resources are being used by other processes then the process enters a waiting state. However, if other processes are also in a waiting state, we have
deadlock.
The formal definition of deadlock is as follows:
A set of processes is in a deadlock state if every process in the set is waiting for an event (release) that can only be caused by some other process in the same set.
waits deadlocked!
A process must request a resource before using it. It must release the resource after using it.
A process cannot request a number more than the total number of resources available in the systemA set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.
Example System has 2 tape drives. P1 and P2 each hold one tape drive and each needs another one.
Example semaphores A and B, initialized to 1
P1 wait(B) wait(A)
Process
Pi requests instance of Rj Pi
Rj
Pi is holding an instance of Rj Pi
Rj
R3 Assigned to P3
P2 Requests P3
A deadlock occurs if and only if the following four conditions hold in a system simultaneously: !
Mutual Exclusion
No Preemption
Circular Wait
Mutual Exclusion
At least one of the resources is non-sharable (that is; only a limited number of processes can use it at a time and if it is requested by a process while it is being used by another one, the requesting process has to wait until the resource is released.).
A deadlock occurs if and only if the following four conditions hold in a system simultaneously: !
No Preemption
No resource can be preempted before the holding process completes its task with that resource
Circular Wait
There exists a set of processes: {P1, P2, ..., Pn} such that P1 is waiting for a resource held by P2 P2 is waiting for a resource held by P3 ... Pn-1 is waiting for a resource held by Pn Pn is waiting for a resource held by P1
A deadlock occurs if and only if the following four conditions hold in a system simultaneously: !
If we have prior knowledge of how resources will be requested, it's possible to determine if we are entering an "unsafe" state. Possible states are: deadlock - no forward progress can be made. Unsafe state - A state that may allow deadlock. Safe state - A state is safe if a sequence of processes exist such that there are enough resources for the first to finish, and as each finishes and releases its resources there are enough for the next to finish. The rule is simple: if a request allocation would cause an unsafe state, do not honor that request. NOTE: all deadlocks are unsafe, but all unsafes are NOT deadlocks.
NOTE: all deadlocks are unsafe, but all unsafes are NOT deadlocks
UNSAFE
DEADLOCK
SAFE
If a system has no deadlock prevention and no deadlock avoidance scheme, then it needs a
deadlock detection
scheme
with
from the deadlock state must be applied. There are various ways for
recovery: Allocate one resource to several processes, by violating mutual
exclusion.
Preempt some resources from some of the deadlocked processes. Abort one or more processes in order to break the deadlock.
ANY QUESTIONS?
END OF CHAPTER
4.0 RESOURCE MANAGEMENT 4.1 Understand Processor Management Explain the role of control blocks and interrupts in the dispatching 4.1.1 process. 4.1.2 Describe the various types of scheduling processes: a. Long-term scheduling b. Medium-term scheduling c. Short-term scheduling