0% found this document useful (0 votes)
127 views

Task Performance Deadlocks

This document discusses deadlocks that can occur when multiple processes compete for shared resources. It provides examples of how deadlocks can arise when two processes, P and Q, each request resources already held by the other. It also discusses potential concurrency mechanisms like semaphores that could prevent such deadlock situations from occurring.

Uploaded by

andres tabaldo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views

Task Performance Deadlocks

This document discusses deadlocks that can occur when multiple processes compete for shared resources. It provides examples of how deadlocks can arise when two processes, P and Q, each request resources already held by the other. It also discusses potential concurrency mechanisms like semaphores that could prevent such deadlock situations from occurring.

Uploaded by

andres tabaldo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

TASK PERFORMANCE: CONCURRENCY AND DEADLOCKS

1. Describe the deadlock scenario illustrated above based on your understanding.

A deadlock is the permanent immobilization of a group of processes that compete


for system resources or interact with one another. A group of processes is blocked in
anticipation of an event that can only be triggered by another set of stopped processes.
The deadlock is permanent, and there is no effective way to break it.

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?

Whether or not deadlock occurs is determined by the execution dynamics as well as


the application's characteristics. This condition is depicted in Figure Some consideration
should persuade you that stalemate cannot occur regardless of the relative time of the
two operations.

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

deadlock situation above?

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.

It can be used to control access to a given resource consisting of a finite number


of instances. Each process that wishes to use a resource performs a wait () operation on
the semaphore. When the count for the semaphore goes to 0, all resources are being
used. And the process that wish to use a resource will block until the count becomes
greater than 0.

Operating systems often distinguish between counting and binary semaphores.


The value of counting semaphore can range over an unrestricted domain and the binary
semaphore also known as mutex locks which provide mutual exclusion can range only
between 0 and 1. Binary semaphores are used to deal with critical-section problem for
multiple processes as n processes share a semaphore mutex initialized to 1. Because
semaphores need not be acquired and released by the same thread, they can be used
for asynchronous event notification (such as in signal handlers). And, because
semaphores contain state, they can be used asynchronously without acquiring a mutex
lock as is required by condition variables. However, semaphores are not as efficient as
mutex locks.

4. Define in detail the Execution Paths 2 to 6.

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.

It encompassed the first three conditions for a deadlock to occur. Mutual


Exclusion, resource can be held by only one process at a time. In other words, if a process
P3 is using some resource R at a particular instant of time, then some other process P4
can't hold or use the same resource R at that particular instant of time. The process P4
can make a request for that resource R but it can't use that resource simultaneously with
process P3.

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.

No preemption, resource can't be preempted from the process by another process,


forcefully. For example, if a process P3 is using some resource R, then some other
process P4 can't forcefully take that resource. If it is so, then what's the need for various
scheduling algorithm. The process P4 can request for the resource R and can wait for
that resource to be freed by the process P3.

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?

I agree that the deadlock is dependent on the quantity of processed and


accessible resources in an operating system. A deadlock occurs when a collection of
processes is stalled because one process is holding a resource and waiting for another
resource to be acquired by another process. In multiprocessing systems, parallel
computing, and distributed systems, where software and hardware locks are used to

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.

A deadlock occurs in an operating system when a process or thread enters a


waiting state because a requested system resource is held by another waiting process,
which in turn is waiting for another resource held by another waiting process. When a
process is unable to modify its state indefinitely because the resources required by it are
being consumed by another waiting process, the system is said to be in a deadlock.

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:

Deadlock. (2012, December 27). Deadlock.


http://blackandwhitecomputer.blogspot.com/2012/12/deadlock.html.

SI411: Deadlock. (n.d.). SI411: Deadlock.


https://www.usna.edu/Users/cs/crabbe/SI411/current/concurrency/deadlock.html.

Db2 11 - Performance - Concurrency And Locks Defined. (n.d.). Db2 11 - Performance -


Concurrency and locks defined. https://www.ibm.com/docs/en/db2-for-
zos/11?topic=concurrency-locks.

Introduction Of Deadlock In Operating System - GeeksforGeeks. (2015, June 20).


GeeksforGeeks. https://www.geeksforgeeks.org/introduction-of-deadlock-in-operating-
system/.

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.

Deadlock Prevention. (n.d.). Deadlock Prevention.


http://boron.physics.metu.edu.tr/ozdogan/OperatingSystems/summer2004/week6/node5
.html.

Deadlock Avoidance In Operating System - Studytonight. (n.d.). Deadlock Avoidance in


Operating System - Studytonight. https://www.studytonight.com/operating-
system/deadlock-avoidance-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)

You might also like