0% found this document useful (0 votes)
9 views2 pages

Deadlock Scenarios in Concurrency Management

Hci activity

Uploaded by

lynxcoderias
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)
9 views2 pages

Deadlock Scenarios in Concurrency Management

Hci activity

Uploaded by

lynxcoderias
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

CODERIAS, VINCENT A.

BSIT 2-A

Task Performance
Concurrency and Deadlocks

1. Describe the deadlock scenario illustrated above based on your


understanding. (5 points)

 Both Process P and Process Q are stuck in a deadlock because they both need
resources A and B to proceed. Process P has Resource A but is waiting for
Resource B, while Process Q has Resource B but is waiting for Resource A,
causing both processes to be unable to move forward. This deadlock is depicted in
the “deadlock-inevitable” section of the diagram.

2. What do you think would happen if both Process P and Q need to get the
same resource? (5 points)

 When both P and Q get the same resource, one of them will be granted access
while the other will be forced to wait. Without proper resource allocation control,
they may end up deadlocked, each waiting for the other indefinitely.

3. Which concurrency mechanism would you suggest that might prevent the
deadlock situation above? Rationalize your answer. (5 points)

 To prevent deadlock, resource ordering can be employed by establishing a specific


order for processes to request resources. For instance, if both processes P and Q
require Resources A and B, they should request them in a predetermined order,
such as A first and then B. This approach helps avoid circular waiting, which is a
primary contributor to deadlocks.
4. Define in detail the Execution Paths 2 to 6. (5 items x 3 points)

Execution Path 2: P gets Resource A, and Q gets Resource B. Now both are waiting for
the other resource.
Execution Path 3: Both P and Q are stuck in deadlock, each holding one resource and
waiting for the other.
Execution Path 4: Same as Path 3, both processes are still stuck.
Execution Path 5: If P releases Resource A and tries to get B, while Q holds A, deadlock
might still happen.
Execution Path 6: P might release Resource A but continue waiting for Resource B, while
Q waits for A, leading to deadlock.

5. Do Execution Paths 3 and 4 encompass the first three conditions for a


deadlock to occur? Explain your answer. (5 points)

Answer:
Yes, Execution Paths 3 and 4 encompass the first three conditions for a deadlock
1. Mutual Exclusion: Only one process can possess a resource at any given time.
2. Hold and Wait: Process P holds Resource A and is waiting for Resource B, while
Process Q holds Resource B and is waiting for Resource A.
3. No Preemption: Neither process can seize the resource from the other.

You might also like