04 Task Performance 1 BALT

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Task Performance

Concurrency and Deadlocks:

1. Describe the deadlock scenario illustrated above based on your understanding. (5 points)
a. There are 2 process P and Q compete for resources A and B. Each resource only can use
by 1 process. The process P get and hold the resource B and wait the resource A
available, at the same time the process Q get and hold the resource A while waiting
resource B available. And this condition it cause deadlock because both processes need
use resource A and B at the same time, the process P not willing to let go the resource B
same as the process Q.
2. What do you think would happen if both Process P and Q need to get the same resource? (5
points)
a. The execution dynamics as well as the application's properties affect whether or not
deadlock occurs. Figure 1 depicts this circumstance. Some thought should persuade you
that stalemate cannot occur regardless of the relative duration of the two procedures.
The displayed joint progress diagram can be used to trace the execution history of two
processes that share resources. If more than two processes fought for the same
resource, a three-dimensional graphic would be required. The fundamentals of lethal
areas and stalemate would remain the same.
3. Which concurrency mechanism would you suggest that might prevent the deadlock situation
above? Rationalize your answer. (5 points)
a. The counting semaphore and the binary semaphore, I believe, has the potential to
prevent deadlock. This form of Semaphore employs a count to aid in the acquisition and
release of tasks several times. If the starting count is zero, a counting semaphore in the
inaccessible state must be generated. It can be used to control access to a given
resource consisting of a finite number of instances. Each process that wishes to use a
resource performs a wait operation on the semaphore. When the count for the
semaphore goes to 0, all resources are being used. And the process that wish to use a
resource will block until the count becomes greater than 0.
4. Define in detail the Execution Paths 2 to 6. (5 items x 3 points)
a. Example: Execution Path 1–Process Q acquires Resource B and then Resource A. Process
Q then releases Resource B and A, respectively.
i. Execution Path 2:Q acquires B and then A. P executes and blocks on a request
for A. Q releases B and A. When P resumes execution, it will be able to acquire
both resources.
ii. Execution Path 3:Q acquires B and then P acquires A. Deadlock is inevitable,
because as execution proceeds, Q will block on A and P will block on B.
iii. Execution Path 4:P acquires A and then Q acquires B. Deadlock is inevitable,
because as execution
iv. Execution Path 5:P acquires A and then B. Q executes and blocks on a request
for B. P releases A and B. When Q resumes execution, it will be able to acquire
both resources.
v. Execution Path 6:P acquires A and then B and then releases A and B. When Q
resumes execution
5. Do Execution Paths 3 and 4 encompass the first three conditions for a deadlock to occur? Explain
your answer. (5 points)
a. It encompassed the first three conditions for a stalemate to occur. A resource can only
be held by one process at a time due to mutual exclusion. To put it another way, if a
process P3 is holding or consuming a resource R at a given time, another process P4
cannot do so at the same time. Process P4 can make a request for resource R, but it can't
use it at the same time as process P3.
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)
a. To avoid a deadlock, a direct approach may be preferable. It will prevent the fourth
condition, the cyclic wait, from occurring. The first three requirements are required, but
not sufficient, for an easy deadlock to arise. The fourth criterion is necessary for a
stalemate to occur. It is a possible outcome of the first three requirements. Deadlock
may also be defined as an unsolved cyclic wait, therefore avoiding it directly is
preferable.
7. Which deadlock avoidance approach would you suggest for the given situation above and why?
(5 points)
a. I would recommend the Resource Allocation Denial, which does not grant an
incremental resource request to a process if it may result in deadlock. Known as the
banker's algorithm. The current distribution of resources to processes is reflected in the
system's state. A safe state is defined as one in which at least one series of resource
allocations to processes does not result in a stalemate. An unsafe condition is one that is
not safe.
8. Would you agree that deadlock is relative to the number of processes and available resources in
an operating system? Why or why not? (5 points)
a. I agree that the amount of processed and available resources in an operating system
determines the stalemate. A deadlock arises when a group of processes is halted
because one process is holding a resource while another process acquires another
resource. Deadlocks are a common problem in multiprocessing systems, parallel
computing, and distributed systems, where software and hardware locks are employed
to arbitrate shared resources and perform process synchronization.
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. (5 points)
a. To avoid the stalemate, I will use alternate logic to diagram. Assume that P does not
require both resources at the same time, resulting in this form for the two processes.
Removing some resource that is obstructing path 3 and path 4 will successfully resolve
the impasse. Unlike the first diagram, which required the resource A before the resource
B, getting A and then releasing A and then releasing B entails altering the desired
resource.

You might also like