Professional Documents
Culture Documents
UNIT3 Complete
UNIT3 Complete
UNIT III
The Deadlock Problem
A 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
P0 P1
wait (A); wait(B)
wait (B); wait(A)
Pi requests instance
Pi of Rj
Rj
Pi is holding an instance of Rj
Pi
Rj
12/08/21 MD ISMAIL MJCET EED 7
Example of a Resource Allocation
Graph
P1 R1 P2 R3 P3 R2 P1
P2 R3 P3 R2 P2
Two cycles exist
P1,P2&P3 are Deadlocked
P1 R1 P3 R2 P1
There is cycle but no
Deadlock
Sequence <P1, P2, …, Pn> is safe if for each Pi, the resources
that Pi can still request can be satisfied by currently available
resources + resources held by all the Pj, with j<i.
If Pi resource needs are not immediately available, then Pi can wait until
all Pj have finished.
When Pj is finished, Pi can obtain needed resources, execute, return
allocated resources, and terminate.
When Pi terminates, Pi+1 can obtain its needed resources, and so on.
Detection algorithm
Recovery scheme
2) If need is greater than available, next process need is taken for comparison.
3) In the above example, need of process PI is (7, 4, 3) and available is (3, 3, 2).
Need > = Available ie False
So system will move for next process.
Figure A
12/08/21 MD ISMAIL MJCET EED 50
Use of Access Matrix
If a process in Domain Di tries to do “op” on object
Oj, then “op” must be in the access matrix.
Figure B
Trap Door
Specific user identifier or password that circumvents normal
security procedures.
Could be included in a compiler.
Stack and Buffer Overflow
Exploits a bug in a program (overflow either the stack or
memory buffers.)