Task Performance Deadlocks
Task Performance Deadlocks
There are 2 process P and Q compete for resources A and B. Each resource only
can use by 1 process. The process P get and hold the resource B and wait the resource
A available , at the same time the process Q get and hold the resource A while waiting
resource B available. And this condition it cause deadlock because both processes need
This study source was downloaded by 100000832685269 from CourseHero.com on 11-08-2022 20:19:06 GMT -06:00
https://www.coursehero.com/file/117315394/Task-Performance-Deadlockspdf/
use resource A and B at the same time, the process P not willing to let go the resource B
same as the process Q.
Deadlock is a situation where two or more processes are waiting for each other. For
example, let us assume, we have two processes P1 and P2. Now, process P1 is holding
the resource R1 and is waiting for the resource R2. At the same time, the process P2 is
having the resource R2 and is waiting for the resource R1. So, the process P1 is waiting
for process P2 to release its resource and at the same time, the process P2 is waiting for
process P1 to release its resource. And no one is releasing any resource. So, both are
waiting for each other to release the resource. This leads to infinite waiting and no work
is done here. This is called Deadlock.
2. What do you think would happen if both Process P and Q need to get the same
resource?
The joint progress diagram, as illustrated, can be used to track the execution history
of two processes that share resources. A higher-dimensional graphic would be necessary
if more than two processes competed for the same resource. The principles of deadly
regions and impasse would stay unchanged.
3. Which concurrency mechanism would you suggest that might prevent the
The utilization of semaphore when connection with a waiting queue may result in
satiation, in which two additional processes wait eternally for an event that can only be
triggered by one of the waiting processes. When this happens, the process is deadlocked.
This study source was downloaded by 100000832685269 from CourseHero.com on 11-08-2022 20:19:06 GMT -06:00
https://www.coursehero.com/file/117315394/Task-Performance-Deadlockspdf/
The counting semaphore and the binary semaphore, I believe, has the potential to prevent
deadlock. This form of Semaphore employs a count to aid in the acquisition and release
of tasks several times. If the starting count is zero, a counting semaphore in the
inaccessible state must be generated.
There are 2 process P and Q compete for resources A and B. Each resource only
can use by 1 process. The process P get and hold the resource B and wait the resource
A available , at the same time the process Q get and hold the resource A while waiting
resource B available. And this condition it cause deadlock because both process need
use resource A and B at the same time, the process P not willing to let go the resource B
same as the process Q.
This study source was downloaded by 100000832685269 from CourseHero.com on 11-08-2022 20:19:06 GMT -06:00
https://www.coursehero.com/file/117315394/Task-Performance-Deadlockspdf/
Some time we also use the Joint Progress Diagram to illustrate the two-process
competing the resource. In the joint progress diagram, we have 6 path of process Q and
P get resources:
Path 2: Q acquires B and then A. P executes and blocks on a request for A. Q releases
B and A. When P resumes execution, it will be able to acquire both resources.
Path 3: Q acquires B and then P acquires A. Deadlock is inevitable, because as execution
proceeds, Q will block on A and P will block on B.
Path 4: P acquires A and then Q acquires B. Deadlock is inevitable, because as execution
Path 5: P acquires A and then B. Q executes and blocks on a request for B. P releases
A and B. When Q resumes execution, it will be able to acquire both resources.
Path 6: P acquires A and then B and then releases A and B. When Q resumes execution.
5. Do Execution Paths 3 and 4 encompass the first three conditions for a deadlock
to occur? Explain your answer.
The gray-shaded area in the figure above, which can be referred to as a fatal
region, applies to the commentary on paths 3 and 4. If an execution path enters this fatal
region, then deadlock is inevitable. Note that the existence of a fatal region depends on
the logic of the two processes. However, deadlock is only inevitable if the joint progress
of the two processes creates a path that enters the fatal region.
Hold and Wait, process can hold a number of resources at a time and at the same
time, it can request for other resources that are being held by some other process. For
This study source was downloaded by 100000832685269 from CourseHero.com on 11-08-2022 20:19:06 GMT -06:00
https://www.coursehero.com/file/117315394/Task-Performance-Deadlockspdf/
example, a process P3 can hold two resources RA and RB and at the same time, it can
request some resource that is currently held by process P4.
6. If you are to implement deadlock prevention before the processes above reach
the critical section, would it be an indirect method or a direct method? Why?
In this way, the system will prevent any deadlock condition from occurring, the
system will ensure that at least one of the four deadlock requirements is violated. Because
we are preventing any one of four situations from occurring by employing various tactics.
These methods can be highly expensive. As a result, you should only use deadlock
prevention in situations when there is a significant change in the system if deadlock
occurs.
To avoid a deadlock, a direct approach may be preferable. It will prevent the fourth
condition, the cyclic wait, from occurring. The first three requirements are required, but
not sufficient, for an easy deadlock to arise. The fourth criterion is necessary for a
stalemate to occur. It is a possible outcome of the first three requirements. Deadlock may
also be defined as an unsolved cyclic wait, therefore avoiding it directly is preferable.
7. Which deadlock avoidance approach would you suggest for the given situation
above and why?
This study source was downloaded by 100000832685269 from CourseHero.com on 11-08-2022 20:19:06 GMT -06:00
https://www.coursehero.com/file/117315394/Task-Performance-Deadlockspdf/
This strategy provides for the three required circumstances of stalemate but makes
prudent decisions to ensure that the deadlock point is never reached. It supports more
concurrent operations than avoidance detection. A dynamic judgement is made as to
whether the present resource allocation request, if approved, may potentially lead to
stalemate. It necessitates an understanding of future process demands.
I would recommend the Resource Allocation Denial, which does not grant an
incremental resource request to a process if it may result in deadlock. Known as the
banker's algorithm. The current distribution of resources to processes is reflected in the
system's state. A safe state is defined as one in which at least one series of resource
allocations to processes does not result in a stalemate. An unsafe condition is one that is
not safe.
Defining the terms state and safe state. Consider a system that has a set number
of processes and resources. A process may have zero or more resources assigned to it
at any moment. The current distribution of resources to processes is reflected in the
system's state. As a result, the state is made up of the two vectors, Resource and
Available, as well as the two matrices, Claim and Allocation, that were previously created.
A safe state is defined as one in which at least one series of resource allocations to
processes does not result in a stalemate (i.e., all the processes can be run to completion).
Of course, a hazardous condition is one that is not safe.
8. Would you agree that deadlock is relative to the number of processes and
available resources in an operating system? Why or why not?
This study source was downloaded by 100000832685269 from CourseHero.com on 11-08-2022 20:19:06 GMT -06:00
https://www.coursehero.com/file/117315394/Task-Performance-Deadlockspdf/
arbitrate shared resources and perform process synchronization, deadlocks are a
prevalent problem.
9. If you are asked to reconstruct the progress diagram above to eliminate the
critical section, which is the deadlock-inevitable region, which aspect(s) or
area(s) would you modify? Explain how the modification eliminates the
deadlock.
I will use alternative logic to diagram to prevent the deadlock. Suppose that P does
not need both resources at the same time so that the two processes have this form.
Removing some resource that blocking the way of the path 3 and path 4 will successfully
remove the deadlock. Get A and released A then Get B and released B means changing
the want resource unlike from the first diagram, get A and get B then release A release B
which requiring the resource A before the resource B.
This study source was downloaded by 100000832685269 from CourseHero.com on 11-08-2022 20:19:06 GMT -06:00
https://www.coursehero.com/file/117315394/Task-Performance-Deadlockspdf/
References:
What Are Deadlock Handling Techniques In Operating System?. (n.d.). What are
Deadlock handling techniques in Operating System?.
https://afteracademy.com/blog/what-are-deadlock-handling-techniques-in-operating-
system.
What Is Semaphore? Binary, Counting Types With Example. (2021, November 1).
Guru99. https://www.guru99.com/semaphore-in-operating-system.html.
This study source was downloaded by 100000832685269 from CourseHero.com on 11-08-2022 20:19:06 GMT -06:00
https://www.coursehero.com/file/117315394/Task-Performance-Deadlockspdf/
Powered by TCPDF (www.tcpdf.org)