What is deadlock?
What is deadlock? How can it be avoided? How can it be resolved once it occurs?
Re: What is deadlock?
Deadlock :- This is an inter-blocking that occurs when two processes want to access at shared variables mutually locked. For example, let A and B two locks and P1 and P2 two processes: P1: lock A P2: lock B P1: lock B (so P1 is blocked by P2) P2: lock A (so P2 is blocked by P1) Process P1 is blocked because it is waiting for the unlocking of B variable by P2. However P2 also needs the A variable to finish its computation and free B. So we have a deadlock.
It can avoided by one of the following options
1. All the resources are allocated to a process when it starts and cannot request for new resources.
2. When requesting for more resource the other resources cannot be held up by any processes.
3. Avoid the cyclic request of resources in a wait for graph.
You can resolve cycle deadlocks by killing the cheapest process, the one that acquired its lock last or locked for the shortest amount of time.
|All times are GMT +5.5. The time now is 09:29.|