Task Performance OS

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Name: Jimenez, Justin Bryle T.

Date: 11 | 4 | 22
Section: COE301

TASK PERFORMANCE IN OPERATING SYSTEM

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

From what I understand, the deadlock scenario illustrated above is blocked because each process
(Process P and Q) is executing/holding a resource and also waiting for another resource acquired by
other process. Wherein in order for Process P to acquire Resource B is to wait for Resource B to be
release by other process, the same goes with the situation of Process Q. However, what makes it
complicated is that both processes want both of the resources. As a result, the two processes never
make progress because each is waiting for the resource hold by another process to be able to proceed.

For additional, I visualize the given deadlock situation as:

Process P Process Q

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

If both process P and Q need to get the same resource, then technically both process P and Q would
end up preventing each other from accessing the resource. Therefore, a deadlock could possibly
occur, as the situation involves a conflict in resource needs by two processes.
3. Which concurrency mechanism would you suggest that might prevent the deadlock situation
above?

I suggest Counting Semaphore, as it could possibly prevent the deadlock situation above. A Counting
Semaphore has three operations such as to initialize, decrement, and increment. Decrement blocked
a process, while increment unblocked a process. This kind of concurrency mechanism can be used to
control the access in a resource, so it could not lead to a deadlock. By blocking the access of other
process for a while, letting the other process go first, and once it is done, it will unblock the other
process in order to resume its task. The mechanism, on the other hand, is sort of making it in a
sequence, one-by-one, which could prevent the deadlock situation.

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

Execution Path 2 - Process Q acquires Resource B and then Resource A. Process P executes Resource
A and blocks on a request for A. Process Q then releases Resource B and A, respectively.

Execution Path 3 - Process Q acquires Resource B and then Process P acquires Resource A. As
execution continues, deadlock is inevitable since Process Q will block on Resource A and Process P
will block on Resource B.

Execution Path 4 - Process P acquires Resource A and then Process Q acquires Resource B. As
execution continues, deadlock is inevitable since Process Q will block on Resource A and Process P
will block on Resource B.

Execution Path 5 - Process P acquires Resource A and then Resource B. Process Q executes Resource
B and blocks on a request for B. Process P then releases Resource A and B, respectively.

Execution Path 6 – Process P acquires Resource A and then Resource B. Process P then releases
Resource A and B, respectively.

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

Yes, the execution paths 3 and 4 check all the boxes of the first three conditions for a deadlock to
occur. As per mutual exclusion, only one process can use a resource at a time. In the given illustration,
in execution path 3, Process Q acquires resource B, which is the resource being requested by Process
P in execution path 4. It does not allow the Process P to acquire resource B being hold by Process Q
at the same time. In terms of hold and wait, on the other hand, as the Process Q acquires or hold
resource B, it makes the Process P to be in a waiting state until Process Q is done and release resource
B, which is under the purview of no preemption. As per no preemption, a resource can only be
released once the process holding it completed its task.
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 would rather choose the direct method, as it best fits the given deadlock scenario. As per the
illustration above, there is a Process P waiting for a resource, which is held by the other process, the
Process Q, which is also waiting for the resource held by Process P. Resulting to check all the boxes of
the first three conditions, and therefore should prevent the fourth condition, the circular wait, to
occur because once it takes place, then deadlock will take place reaching the critical section.
Therefore, I am for direct method because it will prevent the occurrence of circular wait through
defining the linear ordering of resource types.

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

Since Process P and Q both want Resource A and B, I suggest Process Initiation Denial as the deadlock
avoidance approach for the given situation. Through Process Initiation Denial, no process can claim
or hold more resources, and it do not start a process if it might deadlock. It only starts a process if the
needs of the current process that holds a resource can be met.

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

I do agree, a deadlock is relative to the number of processes and available resources. As per the
concept of deadlock, a deadlock may occur if processes are in a wait state where each process is
waiting for a resource held by other process, and therefore results to a conflict. The same goes with
the matter of the number of processes and available resources. If the available resources are not
enough for the number of processes who needs to acquire a resource, then it will lead to such conflict
where deadlock may occur.

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 to reconstruct the given diagram in order to eliminate the critical section, the deadlock-
inevitable region would stay at its place, but the processes would not be. Let say the Process Q no
longer want Resource A, only Resource B. Once Process Q is done with its task on Resource B, Process
Q would not be in a wait state and rather releases the resource in an instant and then enabling the
request of Process P on Resource B to proceed. In doing so, it makes Resource B together with
Resource A be categorized as reusable resources where they can safely be used by only one process
at a time. Which, on the other hand, does not cause the two processes stuck in a wait state and also
does not cause to never make progress, as the diagram now is prevented from the conditions and so
eliminates critical section.
Reference:

Jain, P. (2018). Deadlock and method for handling deadlock. Includehelp.com. Retrieved from
https://www.includehelp.com/operating-systems/deadlock-and-method-for-handling-deadlock.aspx

You might also like