You are on page 1of 3

Paul Cyhrill S.

Monotilla 11/13/2022
BSIT 303

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


- When several processes that compete for system resources or communicate with one another
become immobile and trapped, a deadlock occurs. An event that can only occur when another
group of processes is stopped is made possible by stopping a group of processes. There is no
way to break the impasse because it cannot be fixed. Two processes, P and Q, attempt to
obtain the same resources, A and B. Each resource can only be used by one process at once.
While waiting for resource A to become available, process P obtains and holds resource B,
and process Q obtains and holds resource A while resource B is being made available.
Resources A and B are required concurrently by both processes, and process P, like process
Q, does not want to give up resource B. A standstill results from this condition.
2. What do you think would happen if both Process P and Q need to get the same resource?
- Depending on how the application is used and what its properties are, deadlock may or may
not occur. The figure makes this clear. You should be able to see that there cannot be a
standstill, regardless of how long one procedure is in comparison to another. The joint
progress diagram depicted can be used to track changes over time between two processes that
share resources. A three-dimensional graphic would be required if there were more than two
steps. They would remain trapped even if they both attempted to access the identical
sounding places. Deadlocks and dangerous areas would continue to function in the same way.
3. Which concurrency mechanism would you suggest that might prevent the deadlock situation
above?
- The counting semaphore is more user-friendly and easier to grasp, thus I believe you should
use it. All that occurs when a process is blocked and unblocked 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.
- Both pathways are indeed blocked because they satisfy the first three requirements of mutual
exclusion, hold and wait, and absence of preemption. This indicates that while one process
may retain a resource and may ask another process for a resource, it is not permitted to
forcibly take a resource from another process.

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?
- The indirect approach would be used by me because it is more effective and has a broader
scope. I could use this technique to prevent even a single stalemate. It is also simple to handle
things indirectly rather than trying to halt loops and wait times by handing each resource to
only one process.
7. Which deadlock avoidance approach would you suggest for the given situation above and why?
- In order to prevent a stalemate from occurring, this approach considers the three conditions
that must be accomplished. It supports more concurrent operations than avoidance detection.
If the current request for resource allocation is approved, the likelihood of a deadlock is
assessed immediately. It is necessary to be aware of any potential process requirements.

I advise using the Resource Allocation Denial, which specifies that a process's incremental
resource request won't be approved if it might result in a deadlock. What the banker's
algorithm is is well known. The system's state reveals how resources are currently allocated
to processes. A safe state is one in which no process is stopped by at least one distribution of
resources. Something is risky if it is dangerous.

What the terms "unsafe state" and "safe state" signify Imagine a system with a predetermined
quantity of resources and processes. A process may be provided 0 resources at any given time
or additional resources. The system's state reveals how resources are currently allocated to
processes. The two matrices, Claim and Allocation, as well as the previously constructed
vectors, Resource and Available, make up the state. To be deemed safe, a process must avoid
deadlock at least once during resource allocation (i.e., all the processes can be run to
completion). In actuality, a hazardous situation is one that is perilous.
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, because deadlock slows down unnecessary processes, it is comparable to the number of
processes and the number of resources available. By allowing one function to wait while the
other processes or threads carry on, the deadlock ensures that the software is secure and
proper.
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 believe that most people believe Routes 3 and 4 have the highest chance of becoming
stranded in the area. I would alter the execution of these routes. To make room for it, I would
halt the process until ways 3 and 4 are free. The latency of path 3 would matter and prevent
the process from finishing on time because the process is run based on its resources.

You might also like