ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > ZSTU-(2020-2021)-1 > online discussion >
online discussion -7 Version 0
👤 Author: by writer 2020-11-10 02:22:52
discuss how to prevent the occurrence of a deadlock , and what's the difference between deadlock prevention and deadlock avoidance.

Please login to reply. Login

shatino94163com • 2020-11-10 13:36:43
<h4 class="rtejustify"><strong>                                                                   <span style="text-decoration: underline;"> a) Deadlock Prevention</span></strong></h4>
<p class="rtejustify">    Deadlock prevention algorithms ensure that at least one of the necessary conditions (Mutual exclusion, hold and wait, no preemption and circular wait) does not hold true. However most prevention algorithms have poor resource utilization, and hence result in reduced throughputs.</p>
<p class="rtejustify">Not always possible to prevent deadlock by preventing mutual exclusion (making all resources shareable) as certain resources are cannot be shared safely.</p>
<p class="rtejustify"><span style="text-decoration: underline;">Hold and Wait:</span></p>
<p class="rtejustify">       We will see two approaches, but both have their disadvantages.</p>
<p class="rtejustify">A resource can get all required resources before it start execution. This will avoid deadlock, but will result in reduced throughputs as resources are held by processes even when they are not needed. They could have been used by other processes during this time.</p>
<p class="rtejustify">Second approach is to request for a resource only when it is not holing any other resource. This may result in a starvation as all required resources might not be available freely always.</p>
<p class="rtejustify"><span style="text-decoration: underline;">No preemption:</span></p>
<p class="rtejustify">               We will see two approaches here. If a process request for a resource which is held by another waiting resource, then the resource may be preempted from the other waiting resource. In the second approach, if a process request for a resource which are not readily available, all other resources that it holds are preempted.</p>
<p class="rtejustify">The challenge here is that the resources can be preempted only if we can save the current state can be saved and processes could be restarted later from the saved state.</p>
<p class="rtejustify"><strong>Circular wait</strong></p>
<p class="rtejustify">To avoid circular wait, resources may be ordered and we can ensure that each process can request resources only in an increasing order of these numbers. The algorithm may itself increase complexity and may also lead to poor resource utilization.</p>
<p class="rtejustify">              <strong><span style="text-decoration: underline;">b) Difference between deadlock prevention and deadlock avoidance </span></strong></p>
<p class="rtejustify">           As you saw already, most prevention algorithms have poor resource utilization, and hence result in reduced throughputs. Instead, we can try to avoid deadlocks by making use prior knowledge about the usage of resources by processes including resources available, resources allocated, future requests and future releases by processes. Most deadlock avoidance algorithms need every process to tell in advance the maximum number of resources of each type that it may need. Based on all these info we may decide if a process should wait for a resource or not, and thus avoid chances for circular wait.</p> PostVer 0

Please login to reply. Login

kagenzaclaudiengmailcom • 2020-11-10 13:57:13
<ol>
<li><strong>Deadlock Prevention</strong></li>
</ol>
Before preventing a deadlock first of all we need to know what is a deadlock and its characteristics:

<i><strong>Deadlock </strong></i>is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process.

<strong>Deadlock Characteristics</strong>
<ol>
<li>Mutual Exclusion</li>
<li>Hold and Wait</li>
<li>No preemption</li>
<li>Circular wait</li>
</ol>
We can prevent Deadlock by eliminating any of the above four conditions:

<strong>Eliminate Hold and wait</strong>
<ol>
<li>Allocate all required resources to the process before the start of its execution, this way hold and wait condition is eliminated but it will lead to low device utilization. for example, if a process requires printer at a later time and we have allocated printer before the start of its execution printer will remain blocked till it has completed its execution.</li>
<li>The process will make a new request for resources after releasing the current set of resources. This solution may lead to starvation.</li>
</ol>
<strong>Eliminate No Preemption</strong>
Preempt resources from the process when resources required by other high priority processes.

<strong>Eliminate Circular Wait</strong>
Each resource will be assigned with a numerical number. A process can request the resources increasing/decreasing. order of numbering.
For Example, if P1 process is allocated R5 resources, now next time if P1 ask for R4, R3 lesser than R5 such request will not be granted, only request for resources more than R5 will be granted.

2.  The <strong>main difference</strong> between deadlock prevention and deadlock avoidance is that <strong>deadlock prevention ensures that at least one of the necessary conditions to cause a deadlock will never occur while deadlock avoidance ensures that the system will not enter an unsafe state.</strong> PostVer 0

Please login to reply. Login

804824950qqcom • 2020-11-10 14:31:15
Three techniques to avoid deadlocks:

Locking sequence
Lock time limit
Deadlock detection

The difference between deadlock prevention and deadlock avoidance:
The prevention of deadlock is that the dao system pre-determines some resource allocation strategies, the process du applies for resources according to regulations, and the system allocates according to the pre-defined dao strategy to prevent the occurrence of deadlock.
The avoidance of deadlock is that the system tests resource allocation when the process makes a resource request, and only allocates resources to the process when the system security can be ensured, so that the system is always in a safe state, thereby avoiding deadlock PostVer 0

Please login to reply. Login

1079513613qqcom • 2020-11-10 14:55:26
What is a deadlock

A deadlock is a deadlock (waiting for each other) in which several processes are competing for resources and cannot move forward without the help of external forces. For example, in a computer system with only one printer and one input device, process P1 is occupying the input device and simultaneously requests the use of the printer, but the printer is being occupied by process P2, and P2 requests the use of the input device being occupied by P1 before releasing the printer. Such two processes wait endlessly for each other, neither of which can continue to execute, at which point both processes fall into a deadlock state.

The cause of the deadlock

1. Competition of system resources

The competition of system resources leads to the shortage of system resources and the improper allocation of resources, which leads to deadlock.

2. Improper sequence of process running and advancing

When a process is running, it requests and releases resources in the wrong order, resulting in a deadlock.

There are four necessary conditions for creating a deadlock:

Mutex: a resource can only be used by one process at a time, that is, a resource can only be occupied by one process for a period of time. At this point, if the resource is requested by another process, the requesting process can only wait.

Request and hold conditions: A process has held at least one resource, but has made a new request for a resource that is already occupied by another process. The requesting process is blocked but holds on to the resource it has acquired.

Inalienable condition: The resource acquired by a process cannot be forcibly taken by another process before it is used up, that is, the resource can only be released by the process itself (it can only be released voluntarily).

Cyclic wait condition: A relationship between several processes that form end-to-end cyclic wait resources

These four conditions are necessary for a deadlock, which must be true as long as the system is deadlocked, but not as long as one of the above conditions is not met.

The avoidance and prevention of deadlock:

The basic idea of deadlock avoidance:

The system dynamically checks the resource request that each system can satisfy, and decides whether to allocate the resource according to the check result. If the system may deadlock after the allocation, it will not allocate the resource; otherwise, it will allocate the resource. This is a dynamic strategy to ensure that the system does not enter a deadlock state.

Understanding the cause of a deadlock, and in particular the four necessary conditions for its creation, is the most likely way to avoid, prevent, and release a deadlock. Therefore, in the system design, process scheduling and other aspects of attention to how to make these four necessary conditions do not hold true, how to determine the reasonable allocation of resources algorithm, to avoid the process permanently occupied system resources. Also, prevent processes from occupying resources while they are in a waiting state. Therefore, the allocation of resources should be given a reasonable plan.

The difference between deadlock avoidance and deadlock prevention:

Deadlock prevention is trying to break at least one of the four conditions necessary to cause a deadlock, strictly preventing the appearance of a deadlock, while deadlock avoidance restricts the existence of the conditions necessary to cause a deadlock less strictly, because a deadlock does not necessarily occur even if the conditions necessary to cause a deadlock exist. Deadlock avoidance is to avoid the final occurrence of deadlocks during the operation of the system. PostVer 0

Please login to reply. Login

1224532347qqcom • 2020-11-10 15:00:20
1. The prevention of deadlock DAO refers to the strategy of allocating some resources in advance by determining du in the system. The process applies for resources according to regulations, and the system DAO is allocated according to the policy specified in the pre-edition, so as to prevent the occurrence of deadlock.

2. To avoid deadlock, the system tests the allocation of resources when the process makes an application for resources, and only assigns resources to the process when the security of the system can be ensured, so that the system is in a safe state all the time, so as to avoid deadlock. PostVer 0

Please login to reply. Login

1285795916qqcom • 2020-11-10 15:00:52
邱锐鹏 2018329621199

<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/Screenshot_20201110_150121.jpg"><img class="alignnone size-medium wp-image-8869" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/Screenshot_20201110_150121-158x300.jpg" alt="" width="158" height="300" /></a> PostVer 0

Please login to reply. Login

2470994471qqcom • 2020-11-10 15:06:06
<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/discussion_7.jpg"><img class="alignnone size-medium wp-image-8871" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/discussion_7-300x141.jpg" alt="" width="300" height="141" /></a> PostVer 0

Please login to reply. Login

512858048qqcom • 2020-11-10 15:11:29
<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/1-1-1.png"><img class="alignnone size-medium wp-image-8872" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/1-1-1-194x300.png" alt="" width="194" height="300" /></a> <a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/1-2-1.png"><img class="alignnone size-medium wp-image-8873" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/1-2-1-190x300.png" alt="" width="190" height="300" /></a> PostVer 0

Please login to reply. Login

1119833189qqcom • 2020-11-10 19:10:46
<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/阿巴阿巴-1.jpg"><img src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/阿巴阿巴-1-203x300.jpg" alt="" width="203" height="300" class="alignnone size-medium wp-image-8875" /></a> PostVer 0

Please login to reply. Login

653968106qqcom • 2020-11-11 10:59:55
2018329621008徐天然

<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/OD7-1.jpg"><img class="alignnone size-medium wp-image-8878" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/OD7-1-300x192.jpg" alt="" width="300" height="192" /></a> <a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/OD7-2.jpg"><img class="alignnone size-medium wp-image-8879" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/OD7-2-300x126.jpg" alt="" width="300" height="126" /></a> PostVer 0

Please login to reply. Login

1720650158qqcom • 2020-11-11 11:51:23
<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/d7-1.jpg"><img class="alignnone size-medium wp-image-8884" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/d7-1-300x166.jpg" alt="" width="300" height="166" /></a><a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/d7-2.jpg"><img class="alignnone size-medium wp-image-8885" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/d7-2-300x105.jpg" alt="" width="300" height="105" /></a> PostVer 0

Please login to reply. Login

244766935qqcom • 2020-11-11 22:16:45
<h1><strong>2018329621184 </strong><strong>边凯昂</strong></h1>
<h1><strong>(a)</strong></h1>
<h2><strong>1.Mutual Exclusion</strong></h2>
The mutual-exclusion condition must hold. That is, at least one resource must be nonsharable. Sharable resources do not require mutually exclusive access and thus cannot be involved in a deadlock. Read-only files are a good example of a sharable resource. If several threads attempt to open a read-only file at the same time, they can be granted simultaneous access to the file. A thread never needs to wait for a sharable resource. In general, however, we cannot prevent deadlocks by denying the mutual-exclusion condition, because some resources are intrinsically nonsharable. For example, a mutex lock cannot be simultaneously shared by several threads.
<h2><strong>2.Hold and Wait</strong></h2>
To ensure that the hold-and-wait condition never occurs in the system, we must guarantee that, whenever a thread requests a resource, it does not hold any other resources. One protocol that we can use requires each thread to request and be allocated all its resources before it begins execution. This is, of course, impractical for most applications due to the dynamic nature of requesting resources.

An alternative protocol allows a thread to request resources only when it has none. A thread may request some resources and use them. Before it can request any additional resources, it must release all the resources that it is currently allocated.
<h2><strong>3. No Preemption</strong></h2>
The third necessary condition for deadlocks is that there be no preemption of resources that have already been allocated. To ensure that this condition does not hold, we can use the following protocol. If a thread is holding some resources and requests another resource that cannot be immediately allocated to it (that is, the thread must wait), then all resources the thread is currently holding are preempted. In other words, these resources are implicitly released.

The preempted resource are added to the list of resources for which the thread Is waiting. The thread will be restarted only when it can regain it sold resources, as well as the new ones that it is requesting.
<h2><strong>4.Circular Wait</strong></h2>
The three options presented thus far for deadlock prevention are generally impractical in most situations. However, the fourth and final condition for deadlocks — the circular-wait condition — presents an opportunity for a practical solution by invalidating one of the necessary conditions. One way to ensure that this condition never holds is to impose a total ordering of

all resource types and to require that each thread requests resources in an increasing order of enumeration.
<h1><strong>(b)</strong></h1>
<h1> <strong>the difference between deadlock prevention and deadlock avoidance</strong><strong>:</strong></h1>
<h2><strong>deadlocks Prevention:</strong></h2>
The method is to prevent the deadlock by setting some restrictions to destroy one or more of the four necessary conditions to produce a deadlock. It is easy to implement and widely used, but the restrictions imposed are often too strict, which can lead to a decrease in system resource utilization and throughput.
<h2><strong>deadlock avoidance:</strong></h2>
Deadlocks avoidance is to prevent the system from entering an unsafe state in the dynamic allocation process of resources, so as to avoid deadlocks without taking various restrictive measures in advance to destroy the four necessary conditions for generating deadlocks. This method imposes weak constraints, but it is difficult to implement.
<h2><strong>The difference </strong></h2>
The difference between the deadlock and avoid deadlock prevention, deadlock prevention is to try to break deadlocks at least one of the four necessary conditions, and strictly prevent the occurrence of a deadlock, avoid deadlock is less restrictive deadlocks necessary conditions of existence, because even if the necessary conditions of deadlock, does not necessarily occur deadlock. Deadlock avoidance is to avoid the final occurrence of deadlocks during the operation of the system.

&nbsp; PostVer 0

Please login to reply. Login

cfeshete97gmailcom • 2020-11-13 00:20:02
There are four conditions that are necessary to achieve deadlock:
<ol>
<li><strong>Mutual Exclusion</strong> - At least one resource must be held in a non-sharable mode; If any other process requests this resource, then that process must wait for the resource to be released.</li>
<li><strong>Hold and Wait</strong> - A process must be simultaneously holding at least one resource and waiting for at least one resource that is currently being held by some other process.</li>
<li><strong>No preemption</strong> - Once a process is holding a resource ( i.e. once its request has been granted ), then that resource cannot be taken away from that process until the process voluntarily releases it.</li>
<li><strong>Circular Wait</strong> - A set of processes { P0, P1, P2, . . ., PN } must exist such that every P[ i ] is waiting for P[ ( i + 1 ) % ( N + 1 ) ]. ( Note that this condition implies the hold-and-wait condition, but it is easier to deal with the conditions if the four are considered separately. )</li>
</ol>
deadlock prevention Vs avoidance

<b>Deadlock prevention</b>: We can <b>prevent</b> a <b>deadlock</b> by ensuring that at least one of the condition never holds. <b>Deadlock avoidance</b>: System can avoid a <b>deadlock</b> by ensuring that the system is always in a safe state. A safe state is when there is a safe sequence of processes. PostVer 0

Please login to reply. Login

997371991qqcom • 2020-11-13 11:36:48
The deadlock has four characteristics, they are Mutual Exclusion, Hold and Wait, No preemption and Circular wait. We can prevent Deadlock by elminating any of the above four conditions.

<strong>Eliminate Mutual Exclusion</strong>
It is not possible to dis-satisfy the mutual exclusion because some resources, such as the tape drive and printer, are inherently non-shareable.

<strong>Eliminate Hold and wait</strong>
<ol>
<li>Allocate all required resources to the process before the start of its execution, this way hold and wait condition is eliminated but it will lead to low device utilization. for example, if a process requires printer at a later time and we have allocated printer before the start of its execution printer will remain blocked till it has completed its execution.</li>
<li>The process will make a new request for resources after releasing the current set of resources. This solution may lead to starvation.</li>
</ol>
<strong>Eliminate No Preemption</strong>
Preempt resources from the process when resources required by other high priority processes.

<strong>Eliminate Circular Wait</strong>
Each resource will be assigned with a numerical number. A process can request the resources increasing/decreasing. order of numbering.
For Example, if P1 process is allocated R5 resources, now next time if P1 ask for R4, R3 lesser than R5 such request will not be granted, only request for resources more than R5 will be granted.

&nbsp;

For the difference between deadlock preventation and deadlock avoidance, most deadlock avoidance algorithms need every process to tell in advance the maximum number of resources of each type that it may need. Based on all these info we may decide if a process should wait for a resource or not, and thus avoid chances for circular wait. Whereas, the deadlock preventation algorithms have poor source utilization, and hence result in reduced throughputs. PostVer 0

Please login to reply. Login

997371991qqcom • 2020-11-13 11:38:49
2018329621069 张时敏 PostVer 0

Please login to reply. Login

1730854984qqcom • 2020-11-13 14:28:56
<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/1-1.jpg"><img class="alignnone size-medium wp-image-8895" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/1-1-300x212.jpg" alt="" width="300" height="212" /></a> PostVer 0

Please login to reply. Login

454234624qqcom • 2020-11-16 00:08:17
<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/Online_Disscussion07.jpg"><img class="alignnone size-medium wp-image-8902" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/Online_Disscussion07-238x300.jpg" alt="" width="238" height="300" /></a> PostVer 0

Please login to reply. Login

hokyeejaufoxmailcom • 2020-11-16 16:44:46
<em><strong>How to prevent deadlock?</strong></em>

<strong>Mutual Exclusion: </strong>shared resources such as read-only files do not lead to deadlocks. unfortunately some resources, such as printers and tape drivers, require exclusive access by a single process.

<strong>Hold and Wait: </strong>to prevent the condition processes must be prevented from holding one or more resources while simultaneously waiting for one or more others. There are several possibilities for this: (1) require that all processes request all resources at one time. this can be wasteful of system resources if a process needs one resource early in its execution and does not need some other resource until much late.(2) require that processes holding resources must release them before requesting new resources, and then re-acquire the released resources along with  the new ones in a simple new request. this can be a problem if a process has partially completed an operating using a resource and then fails to get it re-allocated after releasing it. (3)either of the methods described above can lead to starvation if a process requires one or more popular resources.

<strong>No Preemption: </strong>Preemption of process resource allocations can prevent this condition of deadlocks, when it is possible.
<ul>
<li>One approach is that if a process is forced to wait when requesting a new resource, then all other resources previously held by this process are implicitly released, ( preempted ), forcing this process to re-acquire the old resources along with the new resources in a single request, similar to the previous discussion.</li>
<li>Another approach is that when a resource is requested and not available, then the system looks to see what other processes currently have those resources <em>and</em> are themselves blocked waiting for some other resource. If such a process is found, then some of their resources may get preempted and added to the list of resources for which the process is waiting.</li>
<li>Either of these approaches may be applicable for resources whose states are easily saved and restored, such as registers and memory, but are generally not applicable to other devices such as printers and tape drives.</li>
</ul>
<strong>Circular Wait: </strong>
<ul>
<li>One way to avoid circular wait is to number all resources, and to require that processes request resources only in strictly increasing ( or decreasing ) order.</li>
<li>In other words, in order to request resource Rj, a process must first release all Ri such that i &gt;= j.</li>
<li>One big challenge in this scheme is determining the relative ordering of the different resources</li>
</ul>
<em><strong>Difference between deadlock avoidance and deadlock prevention:</strong></em>

The <strong>main difference</strong> between deadlock prevention and deadlock avoidance is that <strong>deadlock prevention ensures that at least one of the necessary conditions to cause a deadlock will never occur while deadlock avoidance ensures that the system will not enter an unsafe state.</strong> PostVer 0

Please login to reply. Login

1210775967qqcom • 2020-11-16 20:52:55
<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/Online_discussion-7..jpg"><img class="alignnone size-medium wp-image-8906" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/Online_discussion-7.-300x129.jpg" alt="" width="300" height="129" /></a> <a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/Online_discussion-7.jpg"><img class="alignnone size-medium wp-image-8907" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/11/Online_discussion-7-282x300.jpg" alt="" width="282" height="300" /></a> PostVer 0

Please login to reply. Login

2031115154qqcom • 2020-11-17 09:33:43
Four conditions must be met for a deadlock: 1. Multiple concurrent processes compete for <strong>resources that must be mutually exclusive(mutual exclusion)</strong>; 2. The resources acquired by the process<strong> cannot be forcibly taken away</strong> by other processes before it is used up, so smart Active release<strong>(no preemptive)</strong>; 3. <b>Hold and wait</b>;  4. There is a <strong>cyclic waiting chain</strong> of process resources<strong>(circular wait)</strong>
As long as any one of the above 4 conditions can be destroyed, deadlock will not occur.
<strong>The difference between deadlock prevention and deadlock avoidance</strong>: Deadlock prevention is a static solution strategy that<strong> destroys one or more of the four necessary conditions caused by deadlock</strong>; deadlock avoidance is a dynamic solution strategy, it use some method to <strong>prevent the system from entering an unsafe state</strong>, thereby avoiding deadlock. The similarity between the two is that they do not allow deadlock to occur. PostVer 0

Please login to reply. Login

chipusilesgmailcom • 2020-11-17 14:44:24
The main difference between deadlock prevention and deadlock avoidance is that deadlock prevention ensures that at least one of the necessary conditions to cause a deadlock will never occur while deadlock avoidance ensures that the system will not enter an unsafe state.

&nbsp;

Deadlock occurs when there are multiple processes. Each process holds a resource while waiting for a resource held by another process. Thus, this kind of situation is a deadlock. A system can go to a deadlock state when mutual exclusion, hold and wait, no preemption, and circular wait conditions occur simultaneously. Here, deadlock prevention and deadlock avoidance are two mechanisms related to deadlocks.

&nbsp;

Key Areas Covered
<ol>
<li>What is Deadlock Prevention</li>
</ol>
– Definition, Functionality
<ol start="2">
<li>What is Dead Avoidance</li>
</ol>
– Definition, Functionality
<ol start="3">
<li>Difference Between Deadlock Prevention and Deadlock Avoidance</li>
</ol>
– Comparison of Key Differences

&nbsp;

Key Terms

Deadlock, Deadlock Avoidance, Deadlock Prevention

&nbsp;

Difference Between Deadlock Prevention and Deadlock Avoidance - Comparison Summary

&nbsp;

What is Deadlock Prevention

Deadlock prevention is the mechanism to ensure that at least one of the necessary conditions for deadlock can never occur. Usually, it is impossible to implement deadlock prevention. To prevent a deadlock situation, it is not necessary to know the number of all existing resources, availability and requests. Non-blocking synchronization algorithms and serializing tokens are some deadlock prevention algorithms. Furthermore, the resource allocation for deadlock prevention is conservative.

&nbsp;

What is Deadlock Avoidance

A system is safe when it is possible to allocate resources to all processes in some order without causing a deadlock. Deadlock is the mechanism to ensure that the system does not enter an unsafe state. In other words, it ensures that the system does not have a deadlock. To avoid a system from reaching an unsafe state, the system should know about the number of existing resources, availability and requests.

&nbsp;

Difference Between Deadlock Prevention and Deadlock Avoidance

&nbsp;

The most common technique to avoid deadlock is the banker’s algorithm. It helps to find a safe path to execute all the processes. Also, this algorithm considers the total resources and current requested resources.

&nbsp;

Furthermore, in addition to deadlock prevention and avoidance, there is another mechanism called deadlock detection. It detects a deadlock before or after it occurs.

&nbsp;

Difference Between Deadlock Prevention and Deadlock Avoidance

Definition

Deadlock prevention is the mechanism to ensure that at least one of the necessary conditions for deadlock can never occur. On the other hand, deadlock avoidance is the mechanism to ensure that the system does not enter an unsafe state. Thus, this is the main difference between deadlock prevention and deadlock avoidance.

&nbsp;

Information

In deadlock prevention, the system does not require information of the existing resources, resource availability and resource requests whereas, in deadlock avoidance, the system requires information on the existing resources, resource availability and resource requests to find whether the system is in a safe or unsafe state. Hence, this is another difference between deadlock prevention and deadlock avoidance.

&nbsp;

Algorithms

Non-blocking synchronization algorithms and serializing tokens are some deadlock prevention algorithms while Banker’s algorithm is the most common deadlock avoidance algorithm.

&nbsp;

Resources

Moreover, the state of resources is an important difference between deadlock prevention and deadlock avoidance. In deadlock prevention, all resources are requested at once while, in deadlock avoidance, the requests for resources are manipulated until at least one safe path is found.

&nbsp;

Conclusion

In brief, deadlock is a situation that occurs due to a set of processes in which each process holds a resource and waits to acquire a resource held by another process in the set. Deadlock prevention and deadlock avoidance are two mechanisms related to deadlocks. The main difference between deadlock prevention and deadlock avoidance is that the deadlock prevention ensures that at least one of the necessary conditions to cause a deadlock will never occur, while deadlock avoidance ensures that the system will not enter an unsafe state. PostVer 0

Please login to reply. Login

wx287_oz26ft1wt2_isbggtha4lgepaasa • 2020-12-08 14:02:11
The deadlock has four characteristics, they are Mutual Exclusion, Hold and Wait, No preemption and Circular wait. We can prevent Deadlock by elminating any of the above four conditions. Eliminate Mutual Exclusion It is not possible to dis-satisfy the mutual exclusion because some resources, such as the tape drive and printer, are inherently non-shareable. Eliminate Hold and wait

Allocate all required resources to the process before the start of its execution, this way hold and wait condition is eliminated but it will lead to low device utilization. for example, if a process requires printer at a later time and we have allocated printer before the start of its execution printer will remain blocked till it has completed its execution.

The process will make a new request for resources after releasing the current set of resources. This solution may lead to starvation.

Eliminate No Preemption Preempt resources from the process when resources required by other high priority processes. Eliminate Circular Wait Each resource will be assigned with a numerical number. A process can request the resources increasing/decreasing. order of numbering. For Example, if P1 process is allocated R5 resources, now next time if P1 ask for R4, R3 lesser than R5 such request will not be granted, only request for resources more than R5 will be granted. For the difference between deadlock preventation and deadlock avoidance, most deadlock avoidance algorithms need every process to tell in advance the maximum number of resources of each type that it may need. Based on all these info we may decide if a process should wait for a resource or not, and thus avoid chances for circular wait. Whereas, the deadlock preventation algorithms have poor source utilization, and hence result in reduced throughputs. PostVer 0

Please login to reply. Login

1079513613qqcom • 2020-12-15 13:39:19
Three techniques to avoid deadlocks: Locking sequence Lock time limit Deadlock detection The difference between deadlock prevention and deadlock avoidance: The prevention of deadlock is that the dao system pre-determines some resource allocation strategies, the process du applies for resources according to regulations, and the system allocates according to the pre-defined dao strategy to prevent the occurrence of deadlock. The avoidance of deadlock is that the system tests resource allocation when the process makes a resource request, and only allocates resources to the process when the system security can be ensured, so that the system is always in a safe state, thereby avoiding deadlock PostVer 0

Please login to reply. Login

450766287qqcom • 2020-12-22 13:48:59
<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/12/os7.png"><img src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/12/os7-300x67.png" alt="" width="300" height="67" class="alignnone size-medium wp-image-9195" /></a> PostVer 0

Please login to reply. Login

shatino94163com • 2020-12-22 14:33:34
<ol>
<li><strong>Deadlock Prevention</strong></li>
</ol>
Before preventing a deadlock first of all we need to know what is a deadlock and its characteristics: <i><strong>Deadlock </strong></i>is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process. <strong>Deadlock Characteristics</strong>
<ol>
<li>Mutual Exclusion</li>
<li>Hold and Wait</li>
<li>No preemption</li>
<li>Circular wait</li>
</ol>
We can prevent Deadlock by eliminating any of the above four conditions: <strong>Eliminate Hold and wait</strong>
<ol>
<li>Allocate all required resources to the process before the start of its execution, this way hold and wait condition is eliminated but it will lead to low device utilization. for example, if a process requires printer at a later time and we have allocated printer before the start of its execution printer will remain blocked till it has completed its execution.</li>
<li>The process will make a new request for resources after releasing the current set of resources. This solution may lead to starvation.</li>
</ol>
<strong>Eliminate No Preemption</strong> Preempt resources from the process when resources required by other high priority processes. <strong>Eliminate Circular Wait</strong> Each resource will be assigned with a numerical number. A process can request the resources increasing/decreasing. order of numbering. For Example, if P1 process is allocated R5 resources, now next time if P1 ask for R4, R3 lesser than R5 such request will not be granted, only request for resources more than R5 will be granted. 2.  The <strong>main difference</strong> between deadlock prevention and deadlock avoidance is that <strong>deadlock prevention ensures that at least one of the necessary conditions to cause a deadlock will never occur while deadlock avoidance ensures that the system will not enter an unsafe state.</strong> PostVer 0

Please login to reply. Login

1119833189qqcom • 2021-01-05 00:20:57
Deadlock Prevention: Make sure the system never enters a Deadlock state.

Deadlock Avoidance: Prior to use, only processes without Deadlock are allowed to request resources.

Deadlock detection and Recovery: Repair occurs after a working system is detected and is in a Deadlock state.

Let go: Deadlocks are handled by the application process itself.
The difference between deadlock avoidance and deadlock prevention is so small that it can be understood as a special case of deadlock prevention. Deadlock prevention strategies are attempts to design a way to exclude the possibility of deadlock. There are two types of deadlock prevention strategies:

Indirect deadlock prevention means preventing any of the first three necessary conditions from occurring

Direct deadlock prevention method, that is, prevent loop wait conditions occur.

The deadlock avoidance policy ensures that the deadlock point is never reached by allowing three necessary conditions to exist. PostVer 0

Please login to reply. Login

chipusilesgmailcom • 2021-01-06 15:12:53
Prevention of deadlock occurrence
<p class="rtejustify">via the following</p>
<p class="rtejustify"><strong>Mutual Exclusion</strong></p>
<p class="rtejustify">Not always possible to prevent deadlock by preventing mutual exclusion (making all resources shareable) as certain resources are cannot be shared safely.</p>
<p class="rtejustify"><strong>Hold and Wait</strong></p>
<p class="rtejustify">We will see two approaches, but both have their disadvantages.</p>
<p class="rtejustify">A resource can get all required resources before it start execution. This will avoid deadlock, but will result in reduced throughputs as resources are held by processes even when they are not needed. They could have been used by other processes during this time.</p>
<p class="rtejustify">Second approach is to request for a resource only when it is not holing any other resource. This may result in a starvation as all required resources might not be available freely always.</p>
<p class="rtejustify"><strong>No </strong><b>pre-emption</b></p>
<p class="rtejustify">We will see two approaches here. If a process request for a resource which is held by another waiting resource, then the resource may be pre-empted from the other waiting resource. In the second approach, if a process request for a resource which are not readily available, all other resources that it holds are pre-empted.</p>
<p class="rtejustify">The challenge here is that the resources can be pre-empted only if we can save the current state can be saved and processes could be restarted later from the saved state.</p>
<p class="rtejustify"><strong>Circular wait</strong></p>
<p class="rtejustify">To avoid circular wait, resources may be ordered and we can ensure that each process can request resources only in an increasing order of these numbers. The algorithm may itself increase complexity and may also lead to poor resource utilization.</p>
<p class="rtejustify">the differences between deadlock prevention and deadlock avoidance is</p>
<p class="rtejustify"></p>

<h4 class="rtejustify"><strong>Deadlock avoidance</strong></h4>
<p class="rtejustify">As you saw already, most prevention algorithms have poor resource utilization, and hence result in reduced throughputs. Instead, we can try to avoid deadlocks by making use prior knowledge about the usage of resources by processes including resources available, resources allocated, future requests and future releases by processes. Most deadlock avoidance algorithms need every process to tell in advance the maximum number of resources of each type that it may need. Based on all these info we may decide if a process should wait for a resource or not, and thus avoid chances for circular wait.</p>
<p class="rtejustify">If a system is already in a safe state, we can try to stay away from an unsafe state and avoid deadlock. Deadlocks cannot be avoided in an unsafe state. A system can be considered to be in safe state if it is not in a state of deadlock and can allocate resources upto the maximum available. A safe sequence of processes and allocation of resources ensures a safe state. Deadlock avoidance algorithms try not to allocate resources to a process if it will make the system in an unsafe state. Since resource allocation is not done right away in some cases, deadlock avoidance algorithms also suffer from low resource utilization problem.</p>
<p class="rtejustify">A resource allocation graph is generally used to avoid deadlocks. If there are no cycles in the resource allocation graph, then there are no deadlocks. If there are cycles, there may be a deadlock. If there is only one instance of every resource, then a cycle implies a deadlock. Vertices of the resource allocation graph are resources and processes. The resource allocation graph has request edges and assignment edges. An edge from a process to resource is a request edge and an edge from a resource to process is an allocation edge. A calm edge denotes that a request may be made in future and is represented as a dashed line. Based on calm edges we can see if there is a chance for a cycle and then grant requests if the system will again be in a safe state.</p>
<p class="rtejustify">and</p>

<h4 class="rtejustify"><strong>Deadlock Prevention</strong></h4>
<p class="rtejustify">Deadlock prevention algorithms ensure that at least one of the necessary conditions (Mutual exclusion, hold and wait, no pre-emption and circular wait) does not hold true. However most prevention algorithms have poor resource utilization, and hence result in reduced throughputs.</p>
&nbsp; PostVer 0

Please login to reply. Login

2736689890qqcom • 2021-01-06 20:57:55
2018329621239-严宇豪
What is Deadlock Prevention
Deadlock prevention is the mechanism to ensure that at least one of the necessary conditions for deadlock can never occur. Usually, it is impossible to implement deadlock prevention. To prevent a deadlock situation, it is not necessary to know the number of all existing resources, availability and requests. Non-blocking synchronization algorithms and serializing tokens are some deadlock prevention algorithms. Furthermore, the resource allocation for deadlock prevention is conservative.

What is Deadlock Avoidance
A system is safe when it is possible to allocate resources to all processes in some order without causing a deadlock. Deadlock is the mechanism to ensure that the system does not enter an unsafe state. In other words, it ensures that the system does not have a deadlock. To avoid a system from reaching an unsafe state, the system should know about the number of existing resources, availability and requests. PostVer 0

Please login to reply. Login

1403861656qqcom • 2021-01-06 22:15:18
Deadlocks are mainly caused by:

(1) Because of insufficient system resources.

(2) The sequence of process operation is not appropriate.

(3) Improper allocation of resources. PostVer 0

Please login to reply. Login

439731491qqcom • 2021-01-07 21:29:23
<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2021/01/01.png"><img class="size-medium wp-image-9323 aligncenter" src="http://www.yvsou.com/wp-content/uploads/sites/30/2021/01/01-300x188.png" alt="" width="300" height="188" /></a> <a href="http://www.yvsou.com/wp-content/uploads/sites/30/2021/01/02.png"><img class="size-medium wp-image-9324 aligncenter" src="http://www.yvsou.com/wp-content/uploads/sites/30/2021/01/02-300x81.png" alt="" width="300" height="81" /></a> PostVer 0

Please login to reply. Login

962305148qqcom • 2021-01-07 22:22:53
<h2><strong>2018329621064_邢杰焰</strong></h2>
1. The prevention of deadlock DAO refers to the strategy of allocating some resources in advance by determining du in the system. The process applies for resources according to regulations, and the system DAO is allocated according to the policy specified in the pre-edition, so as to prevent the occurrence of deadlock. 2. To avoid deadlock, the system tests the allocation of resources when the process makes an application for resources, and only assigns resources to the process when the security of the system can be ensured, so that the system is in a safe state all the time, so as to avoid deadlock. PostVer 0

Please login to reply. Login

Reversion History

Loading...
No reversions found.