Unit 4 - Deadlock Prevention
Unit 4 - Deadlock Prevention
OPERATING SYSTEM
UNIT 4
Deadlock Prevention
Content
• Deadlock prevention
• Deadlock avoidance
SKASC 2
Deadlock Prevention
Invalidate one of the four necessary conditions for deadlock:
• The current state of the system is called safe if it is possible for the
operating system to allow all current user to complete their jobs within a
finite time.
• Again it is assumed that tape drives are the only resource requested by
users.
• If user 5 for example has been allocated four tape drives then
loan(5)=4.
CONTD..
• If for example, user 7 has a maximum need of six tape drives and a
current loan of four tape drives, then we have
• Claim(7)=max(7)-loan(7) = 6-4=2
• Then a is equal to t minus the sum of the loans to the various users.
CONTD..
• A safe state is one in which total resource situation is such that all
users would eventually be able to finish.
• STATE:1
SAFE STATE
• User(2) currently has a loan of four tape drivers and eventually need a max of
six or 2 additional drives.
• The system has 12 drives of which currently in use and 2 are available.
• If user(2) return six, then 3 may be given to user(1), who may then finish and
return 4 tape drives to the system
• The system may give three to user(3). Who may now also finish. Thus the key
to a state being safe is that there is at least one way for all users to finish
UNSAFE STATE
• STATE 2:
CURRENT LOAN MAXIMUM NEED
USER(1) 8 10
USER(2) 2 5
USER(3) 1 3
AVAILABLE 1
• Here 11 of the system’s 12 tape drivers are currently in use and only
one drive is available for allocation.
• The state is know to be safe does not imply that all future states will be
safe.
• Our resource allocation policy must carefully consider before all
resources granting them.
• Suppose user(3) requests an additional resources if the system were to
grant this request then the new state would be
CURRENT LOAN MAXIMUM NEED
USER(1) 1 4
USER(2) 4 6
USER(3) 6 8
AVAILABLE 1
• Certainly state is not necessarily deadlocked . But state has gone from a
safe one to an unsafe state. One resources is available .
• Request denied – user holds any allocated resources and wait for a
finite time.
CLICK HERE
SKASC 24
THANK YOU
SKASC 25