0% found this document useful (0 votes)
22 views3 pages

04 Task Performance 1 - ARG Plat Tech

Uploaded by

Lil Uzi Bitch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

04 Task Performance 1 - ARG Plat Tech

Uploaded by

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

Task Performance

Concurrency and Deadlocks


Objective(s):

At the end of the exercise, the students should be able to:

• Assess the common concurrency mechanisms; and


• Analyze the deadlock prevention and avoidance strategies as well as the detection approach.

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)
➢ The diagram shows two processes, P and Q, each needing two resources: A and B. A
deadlock happens when P has taken B and is waiting for A, while Q has taken A and is
waiting for B. Since each process is holding one resource and waiting for the other,
they’re stuck and can’t move forward.
2. What do you think would happen if both Process P and Q need to get the same resource?
➢ If both processes try to get the same resource at the same time, one process would
have to wait until the other finishes using it. If each process holds one resource and
waits for the other, they could end up in deadlock. This shows the need for a method to
control access to resources to avoid both processes getting stuck.
3. Which concurrency mechanism would you suggest that might prevent the deadlock situation
above? Rationalize your answer.
➢ I would suggest using a Mutex Lock. A mutex lock makes sure that only one process can
use a resource at a time. This would stop both processes from holding onto one
resource and waiting forever for the other. With a mutex, each process has to release
the resource it’s holding before the other process can use it. This prevents the circular
waiting that causes deadlock and keeps things running smoothly.
4. Define in detail the Execution Paths 2 to 6. (5 items x 3 points)
• Execution Path 2: Process P acquires Resource A, and Q acquires Resource B. Now each
one has one resource and is waiting for the other resource.
• Execution Path 3: Process P requests Resource A but has to wait, while Q already has
Resource A and waits for B, causing a deadlock.
• Execution Path 4: Process Q acquires Resource B and then request A, which P has,
resulting in a deadlock as both wait for each other.
• Execution Path 5: Process P acquires Resource B, then releases it, then acquires
Resource A without any deadlock.
• Execution Path 6: Process Q acquires Resource A, then releases it, then gets B without
any deadlock.
5. Do Execution Paths 3 and 4 encompass the first three conditions for a deadlock to occur?
Explain your answer.

• Yes, Execution Paths 3 and 4 illustrate the first three necessary conditions for deadlock:

• Mutual Exclusion: Both processes require exclusive access to the resources.


• Hold and Wait: Each process holds one resource while waiting for the other.
• No Preemption: Neither process can forcibly take the required resource from the other.

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?
• I would choose a direct method. Deadlock prevention directly stops the conditions that
lead to deadlock from happening in the first place. For example, I could enforce an order
in which resources are requested or ensure that a process only requests all the
resources it needs at once. This way, I directly prevent situations where both processes
are waiting for each other.
7. Which deadlock avoidance approach would you suggest for the given situation above and why?
• I would suggest using the resource allocation denial approach. This method avoids
deadlock by only granting resource requests if doing so won’t lead to a deadlock. It
makes decisions based on whether giving a process more resources will keep the system
in a safe state. In other words, it’s dynamic and allows more concurrency, as each
request is evaluated on the spot. This approach is helpful here because it allows both
processes to run without needing to deny them from starting entirely. However, it
requires knowing each process’s maximum resource needs in advance, having a fixed
number of resources, and no process exiting while holding resources.

8. Would you agree that deadlock is relative to the number of processes and available resources in
an operating system? Why or why not?
• Yes, I agree. Deadlock depends on how many processes and resources there are. When
there are many processes and limited resources, there's a higher chance of deadlock
because more processes are likely to compete for the same resources. With fewer
processes or more resources, the chances of a deadlock decrease because there’s less
competition for resources.
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.
• To eliminate the critical section (the deadlock-inevitable region) in the execution path, I
would adjust the way processes P and Q request resources to avoid circular waiting.
Here’s how I would modify the execution paths:

Adjusted Execution Path without Deadlock:

• Execution Path for Process P:


o Step 1: P requests and acquires Resource A.
o Step 2: P then requests and acquires Resource B.
o Step 3: P uses both resources, then releases both A and B.
• Execution Path for Process Q:
o Step 1: Q also requests Resource A first. If A is already taken by P, QQQ
will wait until A is available instead of holding any resource.
o Step 2: Once A is available, Q acquires A and then requests Resource
BBB.
o Step 3: QQQ uses both resources, then releases A and B.

Reference(s)

https://www.techtarget.com/whatis/definition/deadlock

Platform Technology (Operating Systems) - 04 Handout 1.pdf

You might also like