answersLogoWhite

0


Best Answer

yes,wait for graph=WFG,crazy wait!

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Wait for graph and resource allocation graph in deadlocks?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between resource allocation graph and wait for graph?

In Wait for Graph the request edge is a directed edge Pi → Pj which indicates that process Pj is holding a resource that process Pi needs and thus Pi is waiting for Pj to release its lock on that resource. It does not have any allocation edge.In case of Resource Allocation Graph the request edge is a directed edge Pi → Rj which indicates that process Pi is requesting resource Rj. It has an allocation edge from Rj→Pk when the resource Rj is allocated to process Pk.The way the graphs are drawn are also different but both of them are used in deadlock detection.


What is the use of resource allocation and wait for graph and difference between both?

nijera answr thik kore dao na...


What are the deadlock detection algorithms?

Deadlock is a scenario where two or more processes are blocked, each waiting for the other to release the necessary resources to complete their execution. This situation can cause the entire system to become unresponsive, leading to reduced performance and potentially crashing the system. To avoid this, it is essential to have an effective deadlock detection algorithm in place. Several deadlock detection algorithms are used in modern computer systems. These algorithms use different approaches to detect deadlocks, and each algorithm has its strengths and weaknesses. Wait-for Graph Algorithm: The wait-for graph algorithm is a commonly used deadlock detection algorithm. In this algorithm, a directed graph is created, where the nodes represent the processes, and the edges represent the resources they are waiting for. The algorithm checks if there is a cycle in the graph. If there is a cycle, there is a deadlock in the system. The wait-for-graph algorithm has a few limitations. It can only detect deadlocks and does not provide any mechanism to recover from them. Also, the algorithm may only work well in large systems with a few resources. Resource Allocation Graph Algorithm: The resource allocation graph algorithm is another widely used deadlock detection algorithm. This algorithm creates a graph where the nodes represent the processes and the resources they hold or need. The algorithm checks for cycles in the graph. If there is a cycle, there is a deadlock in the system. The resource allocation graph algorithm is easy to implement and provides an efficient way to detect deadlocks. However, the algorithm requires considerable memory to store the graph, and it can be slow in large systems. Banker's Algorithm: The Banker's algorithm is a resource allocation and deadlock avoidance algorithm. In this algorithm, each process is given a maximum limit on the number of resources it can use. The algorithm checks if granting the requested resources will result in a safe state or not. If the state is safe, the resources are allocated to the process. If the condition is unsafe, the process is put on hold. The Banker's algorithm is an efficient way to prevent deadlocks. However, it requires considerable overhead to maintain the system's state, and it may only work well in systems with a few resources. Ostrich Algorithm: The Ostrich algorithm is a dynamic deadlock detection algorithm. This algorithm assumes a process is deadlocked if it does not progress for a specified period. The algorithm periodically checks the progress of each method and detects if any process is deadlocked. The Ostrich algorithm is efficient in detecting deadlocks in dynamic systems. However, it may not work well in systems where the processes are short-lived, and the algorithm may not detect deadlocks that occur over a short period. Timeout-based Algorithm: The timeout-based algorithm is another dynamic deadlock detection algorithm. This algorithm sets a timer for each resource request made by a process. If the requested resource is not allocated within the specified time, the process is assumed to be deadlocked. The timeout-based algorithm is an efficient way to detect deadlocks in dynamic systems. However, the algorithm may not work well in systems where the processes are short-lived, and it may produce false positives if the time-out period is too short.


When does a dead lock occur?

• Deadlocks can occur in any concurrent system where processes wait for each other and a cyclic chain can arise with each process waiting for the next one in the chain. • More specifically, deadlocks can occur in any system that satisfies the four Coffman conditions (due to E. G. Coffman in 1971): 1. Mutual Exclusion Condition: a resource is either assigned to one process or it is available 2. Hold and Wait Condition: processes already holding resources may request new resources 3. No Preemption Condition: only a process holding a resource may release it 4. Circular Wait Condition: two or more processes form a circular chain where each process requests a resource that the next process in the chain holds • Concurrent Java programs may satisfy these conditions, with the object locks/monitors as the resources, so they may deadlock. • We can avoid deadlocks by arranging our program so that one of the Coffman conditions doesn't hold.


Resource-Request Algorithm for Process?

Let Request i be the request vector for process Pi. If Request [i, j] = k, then process Pi wants k instances of resource type Rj. When a request for resources is made by process Pi, the following actions are taken: 1. If Request i < Need i, go to step 2. Otherwise, raise an error condition, since the process has exceeded its maximum claim. 2. If Request i  Available, go to step 3. Otherwise, Pi must wait, since the resources are not available. 3. Have the system pretend to have allocated the requested resources to process Pj by modifying the state as follows: Available: = Available – Request i; Allocation i := Allocation + Request i; Need i := Need i – Request i; If the resulting Resource-allocation State is safe, the transaction is completed and process Pi is allocated its resources. However, if the new state is unsafe, then Pi must wait for Request i and the old resource-allocation state is restored.


How can the circular wait condition be prevented?

Circular wait prevention consists of allowing processes to wait for resources, but ensure that the waiting can't be circular. One approach might be to assign a precedence to each resource and force processes to allocate resources in order of increasing precedence. That is to say that if a process holds some resources, and the highest precedence of these resources is m, then this process cannot request any resource with precedence smaller than m. This forces resource allocation to follow a particular and non-circular ordering, so circular wait cannot occur.


Can deadlock be resolved without selecting a victim?

Yes, deadlock can be resolved by avoiding the conditions that lead to it, breaking the circular wait, or using deadlock prevention techniques like resource allocation graph, timeouts, or priority-based techniques. In some cases, deadlock can also be prevented by ensuring a single thread holds all resources simultaneously or by using a deadlock detection algorithm to preemptively handle it.


What is hold and wait condition?

A process or thread holding a resource while waiting to get hold of another resource


What is deadlock in OS?

Deadlock - Occurs when resources needed by one process are held by some other waiting process. Deadlock not only occurs in OS. Kansas state legislature in the early 20th century passed the following legislation: "When two trains approach each other at a crossing, both shall come to a full stop and neither shall start up again until the other has gone. " Assume we have the following operating system: 1. Finite number of resources to be distributed among some number of competing processes 2. Resources may be of several types and there may be several instances of each 3. When a process requests a resource any instance of that resource will satisfy the process 4. Processes can a. request a resource b. use the resource c. release the resource 5. A set of processes is in a deadlock state when every process in the set is waiting for an event that can be caused only by another process in the set. a. Same resource type - three tape drives, three processes request a tape drive then they each request another. Dining philosophers request chopsticks held by another. b. Different resource type - process A has a printer process B has a file, Each requests the other's resource. Four Necessary Conditions for Deadlock 1. Mutual exclusion: At least one resource is not sharable, i.e. can only be used by one process at a time 2. Hold and wait: A process holds at least one resource and requests resources held by other processes 3. No preemption: resource cannot be preempted, it must be voluntarily released by the process. 4. Circular wait: Given a set of processes { P1, P2, P3, …Pn} P1 has a resource needed by P2, P2 has a resource needed by P3, …, Pn has a resource needed by P1. System resource-allocation graph G = (V,E) where V is a set of vertices and E is a set of edges. The set of vertices is partitioned into Processes and Resources. A resource-allocation graph is a directed graph where an edge from process Pi to resource Ri indicates that Pi has requested Ri (request edge). An edge from Ri to Pi indicates that Ri has been allocated to Pi (assignment edge). When drawing the graph, processes are represented by circles and resources by squares. Multiple instances of a resource are represented by a dot in the square. When a process requests a resource a request edge is drawn. When the resource is allocated, the resource edge becomes an assignment edge. Resource edges points to the resource square, but assignment edges are from the dots within the square. P1P2P3R1R2R3R4Resource allocation graph, no deadlock If the graph contains no cycles, then there is no deadlock If the graph contains a cycle then a deadlock condition may exist. P1P2P3R1R2R3R4Resource allocation graph with deadlock. P1P2P4P3R1R2Resource allocation graph with cycle and no deadlock. P4 can release an instance of R2 and P3 will be assigned the resource How can we handle deadlocks? 1. Try to prevent them from happening 2. After system is deadlocked employ some mechanism to detect the deadlock and then recover from deadlock. 3. Ignore the problem, theoretically rare, and pretend deadlocks never occur (UNIX) Since deadlocks are infrequent this may be cheaper alternative Deadlock Prevention - Make sure one of the 4 necessary conditions for deadlock doesn't hold. 1. Mutual Exclusion - some resources are sharable. Some cannot be shared or be made sharable. A printer can be used by only one process at a time. 2. Hold and Wait - Whenever a process requests one resource make sure it is not holding another resource. · method 1 - request all resources before it begins execution, · method 2 - request resources only when process has none, it may request some resources, use them and then release all resources. · Downside - method 1 - assume process needs to copy file from tape to disk and then print. It will be holding printer entire time even though it needs it only at the end. · Downside method 2 - process can request tape and disk, release these and then request printer. Only if file remains on disk!! No guarantee. · Poor resource utilization, chance of starvation 3. No Preemption- · method 1 - process holds resources and needs another resource that is not in use. Process must release all resources, then waits on released resources in addition to the needed one · method 2 - check if resources are available when requested, if so allocate them. If not check if they are allocated to another process that is waiting for resources. If so, preempt the desired resources from the waiting process and allocate them to the requesting process. If the requested resource is not available, then the process waits. It can then be preempted by another process in the same way. 4. Circular Wait · Place an ordering on the resource types. Processes have to request resources in increasing order of numbering · Alternately, when a process requests a resource of a lower number, resources of higher number are deallocated. deadlock prevention can have the side effect of reduced system throughput and low device utilization. Deadlock Avoidance Processes declare in advance what its maximum resource usage will be. Use this a priori information about a process' resource needs to make sure a system never enters deadlock. (deadlock avoidance approach) Dynamically makes sure that the circular wait conditions doesn't exist. Def. A system is in a safe state if it can allocate resources to each process, in some order and avoid deadlock. A system is a safe system if there exists a safe sequence. A sequence of processes is a safe sequence for the current allocation state if for each Pi, the resources that Pi can still request can be satisfied by the currently available resources plus the resources held by all the Pj, with j satisfies the safety condition. If we are in the above state and grant P2 1 more tape drive the system is no longer safe. Resource-Allocation Graph Algorithm Used only when there is one instance of each resource. Request edges, assignment edges, new edge called claim edge. Claim edge from process to resource indicate process may request that resource some time in the future. Represented by a dashed arrow. Direction is the same as a request edge. When process requests resource, claim edge becomes request edge. When process releases a resource, assignment edge becomes claim edge. P1P2R1R22 If a process requests a resource, the request can be granted only if converting the request edge to an assignment edge does not result in a cycle in the graph. Safe, but if P2 were to request R2 then we would not be in a safe state Banker's Algorithm Used for multiple resource instances. 1. Processes must declare maximum instances of each resource that it will need. Number can't exceed the total number of resources in the system 2. Process will be allocated resources only if this results in a safe state. Otherwise process waits until some other process releases resources. Given two vectors (arrays), X and Y of length n, X


Is it possible to occur deadlock in one process during rsource allocation?

No. This follows directly from the hold-and-wait condition. Raj Gopal Mishra (India)


What is mutual exclusion in operating systems?

Mutual Exclusion is the concept of restricting access to a shared resource. When multiple processes perform operations on a single resource then they might corrupt it. Its the operating systems' responsibility to make sure that this does not happen. There are many methods that can be used to implement mutual exclusion such as semaphores, monitors, etc. Mutual exclusion has the following properties. Safety: No two processes must use the shared resource at the same time. (Should not be in the critical section at the same time.) Liveliness: There should not be deadlocks and a process comes out of the critical section after some time. Fairness: A process wanting to use critical section must only wait some time.


Is gold a non-renewable resource?

Gold could be considered a renewable resource if you have 300 million years to wait around. Effectively it is non-renewable.