Deadlock Flashcards
what is deadlock
Infinite waiting is called as deadlock.
when does deadlock occur
-> mutual exclusion: only one process can access the resource at a given time.
-> hold and wait: having one resource and waiting for the other.
->no-preemption: one process cannot preempt in between.
-> circular wait: it should have one resource and wait for the other which is acquired by another process.
methods to handle deadlock
-> read files can be accessed by many process.
->when ever a process wants a resource make sure it is not holding any other resource.
->if one process is not able to get the resource it needs then it should preempt the resources it is holding.
->ensure proper ordering of resource allocation that is both the process try to acquire R1 first then R2.
bankers algorithm
when a process request a resource make sure that the os will be able to allocate all the resources it needs which is safe state then only allocate the resources.
deadlock recovery
Process termination:
-> abort all the process that are causing deadlock
-> abort process one by one till deadlock is removed.
Resource Preemption
-> remove some resources and give it to other process to avoid deadlock.