You are on page 1of 4

Kian Kyle Guilaran Date Created:08/11/2022

BSIT303

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

A deadlock happens when a group of processes that compete for system resources or talk to
each other get stuck and can't move. A group of processes are stopped so that an event that can only
happen when another group of processes are stopped can happen. The deadlock can't be fixed, and
there's no way to get out of it. P and Q are two processes that try to get A and B, which are the same
resources. Only one process can use each resource at a time. Process P gets and holds resource B while
waiting for resource A to become available, while process Q gets and holds resource A while waiting for
resource B to become available. Both processes need resources A and B at the same time, and process
P, like process Q, doesn't want to give up resource B. This situation leads to a standstill.

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

Whether or not deadlock happens depends on how the application is run and what its
properties are. This is shown by the figure. No matter how long one procedure is compared to the other,
you should be able to see that there can't be a stalemate. The pictured joint progress diagram can be
used to see how two processes that share resources have changed over time. If there are more than two
steps, you would need a three-dimensional graphic. If they both tried to get the same sounding areas,
they would still be stuck. Both a deadly region and a deadlock would still work the same way.

3. Which concurrency mechanism would you suggest that might prevent the deadlock situation
above?

I think you should use the counting semaphore because it is easier to understand and simple to
use. When blocking a process and unblocking it, all that happens is an increment or a decrement.

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

Execution Paths 1- Process Q acquires Resource B and then Resource A. Process Q then releases
Resource B and A, respectively.

Execution Paths 2- Process Q gets Resource B, then acquires A while Process P gets Resource A. Process
Q then releases resource B and A.

Execution Paths 3- Process Q get resource B while Process P get A. Deadlock occurs because resource A
is being utilized by Process P that is needed by Process Q to proceed.
Execution Paths 4- Process P gets resource A while Process Q gets resource B. Deadlock occurs because
resource B is used by Process Q that is needed by Process P to proceed.

Execution Paths 5- Process P takes resource A and B while Process Q executes and P waits. Process P
then releases A and B.

Execution Paths 6- Process P takes resource A and B, then releases A and B sequentially, all this while

Q waits.

5. Do Execution Paths 3 and 4 encompass the first three conditions for a deadlock to occur? Explain
your answer.

Yes, both paths are stuck because they meet the first three conditions, which are mutual
exclusion, hold and wait, and no preemption. This means that one process can hold a resource, and that
process can ask another process for another resource, but it can't take another resource from another
process by force.

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?


I'd use the indirect method because it's more efficient and has a wider reach. I could stop a
single deadlock from happening by using this method. Instead of trying to stop loops and wait times by
giving each resource to only one process, it is also easy to do things in an indirect way.

7. Which deadlock avoidance approach would you suggest for the given situation above and why? (5

points)

This method takes into account the three things that must happen for a stalemate to happen, so
that the situation doesn't get stuck. In comparison to avoidance detection, it supports more concurrent
operations. The chance of a deadlock if the current request for resource allocation is approved is
evaluated on the fly. It requires knowing what the process requirements might be.

I recommend using the Resource Allocation Denial, which says that an incremental resource request
from a process won't be granted if it could cause a deadlock. It is well-known what the banker's
algorithm is. The status of the system shows how resources are being given to processes at the moment.
A safe state is one in which at least one round of resource distribution does not stop any process. When
something is dangerous, it is risky.

Unsafe state and safe state: what they mean. Think about a system that has a set number of processes
and resources. At any given time, either zero or more resources can be given to a process. The status of
the system shows how resources are being given to processes at the moment. So, the state is made up
of the two matrices, Claim and Allocation, and the two vectors, Resource and Available, that were built
before. At least one round of allocating resources can't end in a deadlock for a process to be considered
safe (i.e., all the processes can be run to completion). In fact, a dangerous situation is one that is unsafe.

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, the deadlock is similar to the number of processes and the number of available resources
because it slows down processes that don't need to be done. The deadlock makes sure that the program
is safe and correct by letting one method wait while the other processes or threads continue.

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 think people think that Routes 3 and 4 are the most likely to get stuck in the area. I would
change how these routes are carried out. I would stop the process until way 3 to way 4 is free so that
there is room for it. Because the process is run based on its resources, the latency of path 3 would make
a difference and keep the process from finishing on time.
References:

GeeksforGeeks. (2021, November 26). Concurrency in Operating System.


https://www.geeksforgeeks.org/concurrency-in-operating-system/

Operating System Design/Concurrency/Deadlock - Wikibooks, open books for an open world. (n.d.).
https://en.wikibooks.org/wiki/Operating_System_Design/Concurrency/Deadlock

Concurrency - Deadlock. (2020, April 8). Datacadamia - Data and Co.


https://datacadamia.com/data/concurrency/deadlock

Wikipedia contributors. (2022, October 25). Deadlock. Wikipedia.


https://en.wikipedia.org/wiki/Deadlock

You might also like