Deadlock Flashcards
Difference between deadlock prevention and deadlock avoidance
Deadlock prevention ensures atleast one of the conditions will never occur, whereas deadlock avoidance ensures the system will not enter a non safe state
Four conditions
Mutual exclusion
No pre-emption
Hold and wait
Circular wait
Mutual extension problem/solution
Resources are not shareable, only one process can user a resource at a time
Solution:
Share resources but some can’t be shared e.g. printer
No pre-emotion problem/solution
Only the process can release the resource
Solution: Use time quantum method - allocate time to each process to access the resources and once the time is up the resource will be released
Hold and wait problem/solution
Process is holding one resource and waiting for another
Solution: Try not to hold and wait - give processes the resources before it starts
Circular wait problem/solution
All processes are waiting for resources
Solution: Number the resources so that the process can request the resources in increasing order
What causes a deadlock
When two or more processes block each other by holding locks on resources that another process needs
Safe state
= no deadlock
The process allocated to the resource has completed successfully without problems
Unsafe state
= possibility of deadlock
Bankers Algorithm
Illustration
Why don’t Windows designers use deadlock avoidance and prevention
In modern o/s it’s almost impossible for a deadlock to occur because the os scheduler makes sure that all competing tasks gets a fair share of access to different resources
PCB
Process control block is the data structure maintained by the o/s which is indicated by the process ID. It keeps all the information needed to keep track of the process e.g.
- process ID (unique ID)
- process state (current state)
- process privileges (grants access to resources)
- pointer (points to parent process)