You are on page 1of 2

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

(5 points)

In this deadlock scenario, two processes, P and Q, compete for resources A and B. Each resource can only be
used by one process. Process P obtains and holds resource B at while waiting for resource A to become
available, while process Q obtains and holds resource A while waiting for resource B to become available. And
this scenario leads to a dead end because both process is requesting to use resources A and B at the same
time, and process P doesn't want to give up resource B, just like process Q.

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

There are two general types of resources: reusable resources and consumable resources. Reusable resources
are resources that can be safely used by only one process at a time without exhaustion. The process gets units
of resources and they are released for use by other processes. Data structures such as processors, I / O
channels, main and secondary storage, devices, and files, databases, and semaphores are examples of reusable
resources.

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

For me, the parallel processing mechanism I propose to prevent deadlocks is the condition variable parallel
processing mechanism. It is used to block a process or thread until the -specific condition is true. So this
basically prevents deadlocks in situation. Another approach to above is if resources are requested and
unavailable, the system searches to see other processes that currently have those resources, and if they are
waiting for another resource. Will be blocked. If such a process is found, you can pre-allocate some of its
resources to and add it to the list of resources that the process is waiting for. Both of these approaches can be
applied to resources that can easily save and restore state, such as registers and memory, but usually not to
other devices such as printers and tape drives.

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

 Process Q get B,get A then release B and after that release A


 Process Q get B,get A then the process P want to get A but since Q hold it then have to wait Q
finish then Q release B and A.
 Process Q get resource B and the process P get resource A. --> deadlock
 Process P get resource A and the process Q get resource B --> deadlock
 Process P get A and get b, then the process Q try to get B but since P hold B then wait process P
finish
 Process P get A,get B then release A and after that release B

5. Do Execution Paths 3 and 4 encompass the first three conditions for a deadlock to occur? Explain your
answer
Process Q receives resource B, process P receives resource A & gt; deadlock on path 3 and process P gets
resource A, process Q gets resources B and gt. dead end. These are the execution paths of 3 and 4 because it is
explained here that there ar e three conditions before the deadlocks. Both involve three conditions, so it's up
to you to find a 3 or 4 deadlock path.

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)

If you implement deadlock protection before the process reaches the critical section, the uses the
direct method. This prevents the occurrence of a fourth state and is easier to use circular wait.

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

In the figure above, the deadlock avoidance approach I can suggest is to deny resource allocation.
This is because we know that it is possible in the above situation , so we do not allow the process to
make incremental resource requests if the allocation can lead to a deadlock. There are three
conditions before a deadlock occurs

8. Would you agree that deadlock is relative to the number of processes and available resources in an
operating system? Why or why not?

In my opinion, I agree that deadlocks are related to the number of processes and resources available
in the operating system. This is because we know that there are some multitasking processes and
conditions before we reach the deadlock before we move to the deadlock. This is an opportunity to
wait for available resources before proceeding to a deadlock.

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.

If I were lucky enough to rebuild the process diagram above to remove the critical part, the only thing
I would eliminate is the path this would make a process complicated or critical. like the example in the
table above-, I will delete the area P and Q want A and P and Q want B to reduce the conditions and
make the road easier.

You might also like