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

OS2

Uploaded by

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

OS2

Uploaded by

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

1.

Examples of reusable resources are processors, I/O channels, main


and secondary memory, devices, and data structures such as files,
databases, and semaphores.
Examples of consumable resources are interrupts, signals,
messages, and
information in I/O buffers.F
2. Mutual exclusion.
Only one process may use a resource at a time.
Hold and wait.
A process may hold allocated resources while awaiting assignment
of others.
No preemption.
No resource can be forcibly removed from a process holding it
3. The four necessary conditions for a deadlock situation are mutual
exclusion, no preemption, hold and wait and circular set.
4. The hold-and-wait condition can be prevented by requiring that a
process request all of its required resources at one time,
and blocking the process until all requests
can be granted simultaneously
5. 1. if a process holding certain resources is denied a further request,
that process must release its original resources and, if necessary,
request them again together with the additional resource.
2. if a process requests a resource that is currently held by another
process, the OS may preempt the second process and require it to
release its resources.
6. The circular-wait condition can be prevented by defining a linear
ordering of resource types.

If a process has been allocated resources of type R, then it may


subsequently request only those resources of types following R in
the ordering.
7. Deadlock prevention constrains resource requests to prevent at
least one of the our conditions of deadlock; this is either done
indirectly, by preventing one of the three necessary policy
conditions (mutual exclusion, hold and wait, no preemption), or
directly, by preventing circular wait.

Deadlock avoidance allows


the three necessary conditions, but makes judicious choices to
assure that the
deadlock point is never reached.

Deadlock detection, requested resources are


granted to processes whenever possible.; periodically, the operating
system
performs an algorithm that allows it to detect the circular wait
condition.

1. Mutual exclusion: Only one car can occupy a given quadrant of the
intersection at a time.

Hold and wait: No car ever backs up; each car in the intersection
waits until the quadrant in front of it is available.

No preemption: No car is allowed to force another car out of its way.

Circular wait: Each car is waiting for a quadrant of the intersection


occupied by another car.
2. Prevention: Hold-and-wait approach: Require that a car request both
quadrants that it needs and blocking the car until both quadrants
can be granted. No preemption approach: releasing an assigned
quadrant is problematic, because this means backing up, which may
not be possible if there is another car behind this car. Circular-wait
approach: assign a linear ordering to the quadrants.

Avoidance: The algorithms discussed in the chapter apply to this


problem. Essentially, deadlock is avoided by not granting requests
that might lead to deadlock.

Detection: The problem here again is one of backup.


3. 1. Q acquires B then A, then releases B and A. When P resumes
execution, it will be able to acquire both resources.

2. Q acquires B 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.

3. Q acquires B then P acquires A. Deadlock is inevitable, because as


execution proceeds, Q will block on A and P will block on B.

4. P acquires A then Q acquires B. Deadlock is inevitable, because as


execution proceeds, Q will block on A and P will block on B.
5. P acquires A 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.

6. P acquires A then B, then releases A and B. When Q resumes


execution, it will be able to acquire both resources.
4. If Q acquires B and A before P requests A, then Q can use these two
resources and then release them, allowing A to proceed. If P
acquires A before Q requests A, then at most Q can proceed to the
point of requesting A and then is blocked. However, once P releases
A, Q can proceed. Once Q releases B, A can proceed.
5. Creating the process would result in the state:

Process Max Hold Claim Free


1 70 45 25 25
2 60 40 20
3 60 15 45
4 60 25 35
There is sufficient free memory to guarantee the termination of
either P1 or P2. After

that, the remaining three jobs can be completed in any order.

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