0% found this document useful (0 votes)
194 views

Deadlock Exercise & Answer

The document discusses process synchronization and deadlocks. It explains independent and cooperating processes, race conditions, critical section problems and solutions using semaphores. Four conditions for deadlock are given: mutual exclusion, hold and wait, no pre-emption, and circular wait. Methods to avoid deadlocks include restricting resource requests and using a deadlock avoidance algorithm. Two examples of resource allocation graphs are analyzed to identify potential deadlocks.

Uploaded by

Ng JZ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
194 views

Deadlock Exercise & Answer

The document discusses process synchronization and deadlocks. It explains independent and cooperating processes, race conditions, critical section problems and solutions using semaphores. Four conditions for deadlock are given: mutual exclusion, hold and wait, no pre-emption, and circular wait. Methods to avoid deadlocks include restricting resource requests and using a deadlock avoidance algorithm. Two examples of resource allocation graphs are analyzed to identify potential deadlocks.

Uploaded by

Ng JZ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

NAME: NG JUN KAI

Process Synchronization, Deadlock Exercise

INSTRUCTION: ANSWER ALL QUESTIONS.

a) Explain independent process and cooperating process.


Independent process: process cannot affect or be affected by the other
processes executing in the system.
cooperating process: process can affect or be affected by the other processes
executing in the system.

b) Explain race condition.


A synchronization problem between two processes vying for the same resource.

c) Explain critical section problem and explain its solution.


1. Critical section problem
a. Each process has critical section segment of code and when one
process in critical section, no other may be in its critical section.
b. Each process must ask permission to enter critical section in entry
section, may follow critical section with exit section, then remainder
section.
2. solution
a. Mutual Exclusion
i. If process Pi is executing in its critical section, then no other
processes can be executing in their critical sections .
b. Progress
i. If no process is executing in its critical section and there exist
some processes that wish to enter their critical section, then the
selection of the processes that will enter the critical section next
cannot be postponed indefinitely.
c. Bounded Waiting
i. A bound must exist on the number of times that other processes
are allowed to enter their critical sections after a process has
made a request to enter its critical section and before that request
is granted.

d) Explain semaphore and how its implemented?


Synchronization tool that does not require busy waiting by sharing data item that
may contain either binary or non-negative integer values and is used to provide
mutual exclusion
e) Give FOUR (4) conditions for deadlock to happen.
Mutual exclusion: only one process at a time can use a resource.
Hold and wait: a process holding at least one resource is waiting to acquire
additional resources held by other processes.
No pre-emption: a resource can be released only voluntarily by the process
holding it, after that process has completed its task.
Circular wait: there exists a set {P0, P1, …, Pn} of waiting processes such that
P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is
held by P2, …, Pn–1 is waiting for a resource that is held by Pn, and Pn is
waiting for a resource that is held by P0.

f) Explain, how deadlock can be avoided.


Restrain the ways request can be made to prevent mutual exclusion and hold
and wait problem. Disable pre-emption and avoid circular wait by the four
approach which is requires that the system has some additional a prior
information available, each process declare the maximum number of resources
of each type that it may need, use deadlock-avoidance algorithm dynamically
examines the resource-allocation state to ensure that there can never be a
circular-wait condition and let resource-allocation state defined by the number of
available and allocated resources, and the maximum demands of the processes

g) Consider the system resource allocation graphs below and answer the following:

i Does the above allocation graph contain a deadlock? Explain.


No, because no circular wait exists.
ii Assume now that P2 also demands Resource R1. Does this allocation graph
contain a deadlock? Explain.
Yes, because all four characteristics of deadlock exist.
h) Describe the following resource allocation graph:

R1  P2 P2 hold resource R1
P1  R1 P1 request resource R1
R4  P1 P1 hold resource R4
P2  R4 P2 request resource R4
R4  P3 P3 hold resource R4
R2  P3 P3 hold resource R2
P3  R3 P3 request resource R3
R2  P4 P4 hold resource R2
R3  P4 P4 hold resource R3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy