Assigment
Assigment
A deadlock is a condition in operating systems where two or more processes are unable to proceed
with execution because each is waiting for a resource held by another process. This leads to a state
where no process can continue.
Characteristics of Deadlock:
1. Mutual Exclusion:
o A process holds at least one resource and waits to acquire additional resources held
by other processes.
o Example: Process A holds Resource 1 and waits for Resource 2, which is held by
Process B.
3. No Preemption:
4. Circular Wait:
o A circular chain of processes exists where each process holds a resource needed by
the next process.
o Example: Process A waits for B's resource, B waits for C's resource, and C waits for
A's resource.
P1 --> R1
^ |
| v
R2 <-- P2
2. Banker's Algorithm
The Banker's Algorithm is a deadlock avoidance algorithm that checks resource allocation before
granting requests to ensure the system remains in a safe state.
Important Terms:
Formula:
1. Check Availability:
2. Safety Sequence:
3. Resource Allocation:
Example:
Request --> Available Resources --> Safety Check --> Safe State?
| |
No Yes
| |
Rollback Allocate
When deadlock prevention is not possible, systems implement mechanisms to detect and recover
from deadlocks.
Deadlock Detection:
2. Cycle Detection:
3. Detection Algorithm:
P1 --> R1 --> P2
P2 --> R2 --> P3
P3 --> R3 --> P1
1. Process Termination:
2. Resource Preemption:
3. Rollback:
1. Deadlock Prevention:
2. Deadlock Avoidance:
3. Deadlock Detection:
4. Deadlock Recovery:
Summary: