answersLogoWhite

0

  • ignore the problem altogether ie. ostrich algorithm it may occur very infrequently, cost of detection/prevention etc may not be worth it.
  • detection and recovery
  • avoidance by careful resource allocation
  • prevention by structurally negating one of the four necessary conditions.
Deadlock PreventionDifference from avoidance is that here, the system itself is build in such a way that there are no deadlocks.

Make sure atleast one of the 4 deadlock conditions is never satisfied.

This may however be even more conservative than deadlock avoidance strategy.

  • Attacking Mutex condition
  • never grant exclusive access. but this may not be possible for several resources.
  • Attacking preemption
  • not something you want to do.
  • Attacking hold and wait condition
  • make a process hold at the most 1 resource at a time.
  • make all the requests at the beginning. All or nothing policy. If you feel, retry. eg. 2-phase locking
  • Attacking circular wait
  • Order all the resources.
  • Make sure that the requests are issued in the correct order so that there are no cycles present in the resource graph.

    Resources numbered 1 ... n. Resources can be requested only in increasing order. ie. you cannot request a resource whose no is less than any you may be holding.

Deadlock AvoidanceAvoid actions that may lead to a deadlock.

Think of it as a state machine moving from 1 state to another as each instruction is executed.

Safe State

Safe state is one where

  • It is not a deadlocked state
  • There is some sequence by which all requests can be satisfied.

To avoid deadlocks, we try to make only those transitions that will take you from one safe state to another. We avoid transitions to unsafe state (a state that is not deadlocked, and is not safe) eg.

Total # of instances of resource = 12

(Max, Allocated, Still Needs)

P0 (10, 5, 5) P1 (4, 2, 2) P2 (9, 2, 7) Free = 3 - Safe

The sequence is a reducible sequence

the first state is safe.

What if P2 requests 1 more and is allocated 1 more instance?

- results in Unsafe state

So do not allow P2's request to be satisfied.

Banker's Algorithm for Deadlock Avoidance

When a request is made, check to see if after the request is satisfied, there is a (atleast one!) sequence of moves that can satisfy all the requests. ie. the new state is safe. If so, satisfy the request, else make the request wait.

How do you find if a state is safen process and m resources

Max[n * m]

Allocated[n * m]

Still_Needs[n * m]

Available[m]

Temp[m]

Done[n]

while () {

Temp[j]=Available[j] for all j

Find an i such that

a) Done[i] = False

b) Still_Needs[i,j] <= Temp[j]

if so {

Temp[j] += Allocated[i,j] for all j

Done[i] = TRUE}

}

else if Done[i] = TRUE for all i then state is safe

else state is unsafe

}

Detection and RecoveryIs there a deadlock currently?

One resource of each type (1 printer, 1 plotter, 1 terminal etc.)

  • check if there is a cycle in the resource graph. for each node N in the graph do DFS (depth first search) of the graph with N as the root In the DFS if you come back to a node already traversed, then there is a cycle. }

Multiple resources of each type

  • m resources, n processes
  • Max resources in existence = [E1, E2, E3, .... Em]
  • Current Allocation = C1-n,1-m
  • Resources currently Available = [A1, A2, ... Am]
  • Request matrix = R1-n,1-m
  • Invariant = Sum(Cij) + Aj = Ej
  • Define A <= B for 2 vectors, A and B, if Ai <= Bi for all i
  • Overview of deadlock detection algorithm,

    Check R matrix, and find a row i such at Ri < A.

    If such a process is found, add Ci to A and remove process i from the system.

    Keep doing this till either you have removed all processes, or you cannot remove any other process.

    Whatever is remaining is deadlocked.

    Basic idea, is that there is atleast 1 execution which will undeadlock the system

Recovery
  • through preemption
  • rollback
    • keep checkpointing periodically
    • when a deadlock is detected, see which resource is needed.
    • Take away the resource from the process currently having it.
    • Later on, you can restart this process from a check pointed state where it may need to reacquire the resource.
  • killing processes
    • where possible, kill a process that can be rerun from the beginning without illeffects
User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Computer Science

What is the exact difference between interrupt handling and exception handling?

interrupt handling is the process of handling a break or interrupt called by a program where as exception handling is for handling some exceptional conditions that'll occur when a program is running


When the total cost of computer processing may exceed other methods when the processing volume is small discuss this statement?

WikiAnswers will not do your homework for you. Nor will we write critiques, essays, discussion papers, reports or summaries. This is considered cheating. We will, however, assist you should your questions be specific.


What is the difference between deadlock preventation and dead lock detection?

The difference is exactly what you have just stated: deadlock prevention is used to stop deadlocks before they happen (to prevent them), while deadlock detection is used to figure out when a process has deadlocked (to detect it).


What type management has to enhance the constructor or destructor that are fails means explain in the root cause generic methods?

When constructors or destructors fail, it often indicates issues related to resource management, such as memory leaks or improper handling of dynamic resources. To enhance these methods, developers can implement exception handling to manage failures gracefully and ensure proper cleanup of resources. Additionally, using smart pointers or RAII (Resource Acquisition Is Initialization) principles can help automatically manage resource lifetimes, reducing the likelihood of such failures. Investigating the root cause often involves analyzing resource allocation patterns and ensuring that all resources are appropriately initialized and released.


What is the PPM of air handling unit?

Planned Preventative Maintenanceschedule of tasks that keep the air handling unit efficient, daily/month/yearly etc.

Related Questions

What deadlock handling strategy is being used in windows?

windows ignores deadlocks as handling them is much expensive and causes performance overhead


How do you override Ford Transit deadlocks?

How do you override ford transit deadlocks?


What are the four aspects of data handling?

discuss the aspect of data


What are two methods for handling bad debts?

The two methods for handling bad debts are, the specific write-off method and the allowance method.


How do you perform recovery from deadlocks?

we do not know :(


What were the purification methods used in the olden days?

Discuss the purification methods used in the olden days


Discuss significance of material handling warehousing in distribution network planning?

yu


Who breaks electoral college deadlocks?

uhkhkhkjhkhiuhujkhkkjhjkhjkhjkhjkhjkhkjhjkhjk


Can deadlocks be prevented?

By good programming practice, deadlocks can be avoided (but not altogether eliminated) by locking tables in the same order each time. Have an ordered list of access by tables and then go down the tables in order.


List the methods of handling solid waste?

bury it, burn it or to recycle it


What is the deadlock handling of solaris?

Solaris uses a combination of deadlock detection and prevention mechanisms to handle deadlocks in its operating system. It employs a resource allocation graph to detect deadlocks and can terminate or preempt processes to resolve them. Additionally, Solaris implements a timeout for resource requests, allowing processes to release resources if they cannot acquire them within a certain timeframe. This proactive approach helps maintain system stability and ensures that resources are allocated efficiently.


What are the proper disposal methods for handling poo in a box?

Proper disposal methods for handling waste in a litter box include scooping out solid waste daily, disposing of it in a sealed bag, and cleaning the box with soap and water regularly.