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

Plattech TP

The document describes a deadlock scenario between two processes (P and Q) competing for two resources (A and B). It analyzes different execution paths where the processes acquire the resources. Paths 3 and 4 lead to deadlock as P and Q each hold one resource needed by the other. To prevent deadlock, the document suggests using counting semaphores to control access to resources or redesigning the resource allocation graph to remove the cyclic dependencies between processes.

Uploaded by

Lance Batac
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Plattech TP

The document describes a deadlock scenario between two processes (P and Q) competing for two resources (A and B). It analyzes different execution paths where the processes acquire the resources. Paths 3 and 4 lead to deadlock as P and Q each hold one resource needed by the other. To prevent deadlock, the document suggests using counting semaphores to control access to resources or redesigning the resource allocation graph to remove the cyclic dependencies between processes.

Uploaded by

Lance Batac
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Instructions:

Analyze the illustrations below. Then, answer the following items. Search for related literature and/or
relative studies that would support your answers. Cite your references accordingly. (55 points)

1. Describe the deadlock scenario illustrated above based on your understanding. (5 points)
 There are 2 process P and Q to 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
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.
2. What do you think would happen if both Process P and Q need to get the same resource? (5
points)
 Deadlock is only inevitable if the joint progress of two processes creates a path that
enters the fatal region. A deadlock will most likely occur in this scenario if the two
processes want to get the same resources. As we can see on the diagram, the path 3
and path 4 both leads to the same resources therefore both of them will try to compete
with each other resulting into a deadlock situation.
3. Which concurrency mechanism would you suggest that might prevent the deadlock situation
above? Rationalize your answer. (5 points)
 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.
 In simpler terms, you lock part of the section for the path 3 to let the path 4 take the
resources and then after the path 4 is done taking resources, path 3 will be release from
its lock state to get the resources or data that it wants to access. With this method, we
can stop the processes into getting in a deadlock state.

4. Define in detail the Execution Paths 2 to 6. (5 items x 3 points)


Example: Execution Path 1 – Process Q acquires Resource B and then Resource A. Process Q
then releases Resource B and A, respectively.
 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. (5 points)
 It encompassed the first three conditions for a deadlock to occur. Mutual Exclusion,
resource can be held by only one process at a time. For example path 3 is using the
resources then the path 4 also want to access it, the path 4 can make a request to
access it but cannot use the resources simultaneously.

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
example, path 3 can hold two resources A and B 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 path 3 is using some resource, then path 4 can't forcefully
take that resource.

6. If you are to implement deadlock prevention before the processes above reach the critical
section, would it be an indirect method or an indirect method? Why? (5 points)
 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?
(5 points)
 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.

8. Would you agree that deadlock is relative to the number of processes and available resources in
an operating system? Why or why not? (5 points)
 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 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. (5 points)
 If I were to reconstruct the diagram, I would make it like this to avoid deadlock

 I will use alternative logic 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.
References
 Chapter 6 concurrency: Deadlock and starvation - ppt download. SlidePlayer. (n.d.).
Retrieved November 5, 2022, from https://slideplayer.com/slide/5239913/

 Deadlock prevention - jenkov.com. (n.d.). Retrieved November 4, 2022, from


https://jenkov.com/tutorials/java-concurrency/deadlock-prevention.html

 Singhal, A. (2019, April 26). Akshay Singhal. Gate Vidyalay. Retrieved November 5, 2022,
from https://www.gatevidyalay.com/resource-allocation-graph-deadlock-detection/

 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

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


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

You might also like