Chapter 8 Operating Systems

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Explain the four necessary conditions for a deadlock.

Mutual exclusion, Hold and wait, No preemption, Circular wait.

Is it possible to have a deadlock involving only one single process? Explain your answer.

No. There is no dead-lock because there is only one process and hence no condition about Mutual Exclusion.

List three examples of deadlocks that are not related to a computer-system environment.

• Two cars crossing a single-lane bridge from opposite directions. • A person going down a ladder while another person is climbing up the ladder. • Two trains traveling toward each other on the same track.

Answer the following questions using the banker's algorithm: A. What is the content of the matrix Need? B. Is the system in a safe state? C. If a request from process P1 arrives for (0, 4, 2, 0), can the request be granted immediately?

(a) P0 :0000,P1 :0750,P2 :1002,P3 :0020,P4 :0642 (b) Yes. With Available being equal to (1,5, 2, 0), either process P0 or P3 could run. Once process P3 runs, it releases its resources, which allow all other existing processes to run. (c) Yes, it can. This results in the value of Available being (1, 1, 0, 0). One ordering of processes that can finish is P0, P2, P3, P1, and P4.

Consider a system consisting of m resources of the same type, being shared by n processes. Resources can be requested and released by processes only one at a time. Show that the system is deadlock free if the following two conditions hold: A. The maximum need of each process is between 1 and m resources B. The sum of all maximum needs is less than m+n.

...Proof: Suppose N = Sum of all Need(i), A = Sum of all Allocation(i), M = Sum of all Max(i). Use contradiction to prove. Assume this system is not deadlock free. If there exists a deadlock state, then A = m because there's only one kind of resource and resources can be requested and released only one at a time. From condition b, N + A = M < m + n. So we get N + m < m + n. So we get N < n. It shows that at least one process i that Need(i) = 0. From condition a, Pi can release at least 1 resource. So there are n-1 processes sharing m resources now, condition a and b still hold. Go on the argument, no process will wait permenently, so there's no deadlock.

Consider the following resource-allocation policy. Requests and releases for resources are allowed at any time. If a request for resources cannot be satisfied because the resources are not available, then we check any processes that are blocked, waiting for resources. If they have the desired resources, then these resources are taken away from them and are given to the requesting process. The vector of resources for which the process is waiting is increased to include the resources that were taken away. For example, consider a system with three resource types and the vector Available initialized to (4,2,2). If process P0 asks for (2,2,1), it gets them. If P1 asks for (1,0,1), it gets them. Then, if P0 asks for (0,0,1), it is blocked (resource not available). If P2 now asks for (2,0,0), it gets the available one (1,0,0) and one that was allocated to P0 (since P0 is blocked). P0's Allocation vector goes down to (1,2,1), and its Need vector goes up to (1,0,1). A. Can deadlock occur? If you answer "yes", give an example. If you answer "no", specify which necessary condition cannot occur. B. Can indefinite blocking occur? Explain your answer.

A. Deadlock cannot occur because preemption exists. B. Yes. A process may never acquire all the resources it needs if they are continuously preempted by a series of requests.

Consider a system consisting of four resources of the same type that are shared by three processes, each of which needs at most two resources. Show that the system is deadlock-free.

Yes, this system is deadlock-free. Proof by contradiction. Suppose the system is deadlocked. This implies that each process is holding one resource and is waiting for one more. Since there are three processes and four resources, one process must be able to obtain two resources. This process requires no more resources and, therefore it will return its resources when done.


संबंधित स्टडी सेट्स

Chapter 46 - Nursing Care of the Child With an Alteration in Cellular Regulation

View Set

4. Project Integration Management

View Set

Male Reproductive System Science Test (Study this one)

View Set

Psych 101: Thinking and Problem Solving

View Set

HLTH405-S5A-202120 Nutrition for Fitness & Sports ~ Module 1-4

View Set

APUSH CHAP 9 + 10 AP CLASSROOM ANSWERS

View Set