One approach to avoid deadlocks is to require each transacti

One approach to avoid deadlocks is to require each transaction to announce all the locks it wants at the beginning, and to either grant all these locks or deny them all and make the transaction wait. Does this approach avoid deadlocks due to locking? Either explain why or give an example of a deadlock that can arise ?

Solution

Deadlock : Deadlock is a situation in multithreading oprating system in which all the running threads are depend on one another for completion or wants to access the resources which are in control of another thread(s).

Conditions for deadlocks -
1) Mutual exclusion: No resource can be shared by more than one process at a time.
2) Hold and wait: There must exist a process that is holding at least one resource and is waiting to acquire additional resources that are currently being held by other processes.
3) No preemption: A resource cannot be preempted.
4) Circular wait: There is a cycle in the wait-for graph.

Strategies for handling deadlocks -
1) Deadlock prevention: Prevents deadlocks by restraining requests made to ensure that at least one of the four deadlock conditions cannot occur.

2) Deadlock avoidance: Dynamically grants a resource to a process if the resulting state is safe. A state is safe if there is at least one execution sequence that allows all processes to run to completion.

3) Deadlock detection and recovery: Allows deadlocks to form; then finds and breaks them.

when the scheduler is going to start a process it can look at the resources available right now and see if it can satisfy the demand of process.if the scheduler can\'t ensure that it will be able grant all the requested resources then it does not start the transaction. in this way this approach can help to avoid the deadlock condition.

 One approach to avoid deadlocks is to require each transaction to announce all the locks it wants at the beginning, and to either grant all these locks or deny

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site