Homework 6

¡Supera tus tareas y exámenes ahora con Quizwiz!

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.

How can the circular-wait condition be prevented?

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. Alternatively, 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.

How can the hold-and-wait condition be prevented?

In deadlock prevention we can adopt a policy that eliminates one of the conditions. In our case of the intersection we can install a stop light that will control this situation. Int deadlock avoidance we can make the appropriate dynamic choices based on the current state of resources. In this example all cars are said to be going straight. Here the drivers could make a dynamic choice of allowing north and south cars to go first and then east and west bound cars to go. In deadlock detection we constrain resource requests to prevent at least one of the four conditions of deadlock. One way to do this is put varying number of speed bumps for each lane leading up to the intersection. In doing so you slow the arrival of the cars and allow them to get to the intersection at different times.

Show how each of the techniques of prevention, avoidance, and detection can be applied to Figure 6.1.

1. Mutual exclusion. Only one process may use a resource at a time. No process may access a resource unit that has been allocated to another process. 2. Hold and wait. A process may hold allocated resources while awaiting assignment of other resources. 3. No preemption. No resource can be forcibly removed from a process holding it.

What are the three conditions that must be present for deadlock to be possible?

With deadlock detection, requested resources are granted to processes whenever possible. Periodically, the OS performs an algorithm that allows it to detect the circular wait condition In deadlock prevention, we constrain resource requests to prevent at least one of the four 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 a decision is made dynamically whether the current resource allocation request will, if granted, potentially lead to a deadlock. Deadlock avoidance thus requires knowledge of future process resources requests.

What is the difference among deadlock avoidance, detection, and prevention?

YES, safe. 25 units will be left after the allocation for P4, so there is sufficient memory to guarantee the termination of either P1 or P2. After that, the remaining three jobs can be completed in any order. NO, unsafe. 15 units will be left after the allocation for P4, so there is insufficient memory to guarantee the termination of any process.

Consider a system with a total of 150 units of memory, allocated to three processes as shown: Process Max Hold 1 70 45 2 60 40 3 60 15 Apply the banker's algorithm to determine whether it would be safe to grant each of the following requests. If yes, indicate a sequence of terminations that could be guaranteed possible. If no, show the reduction of the resulting allocation table. A fourth process arrives, with a maximum memory need of 60 and an initial need of 25 units. A fourth process arrives, with a maximum memory need of 60 and an initial need of 35 units.

reusable resources include processors, I/O channels, main and secondary memory, devices, and data structures such as files, databases, and semaphores. consumable resources are interrupts, signals, messages, and information in I/O buffers.

Give examples of reusable and consumable resources

Process path #3) Q acquires B and then releases B. Then Q acquires A and then releases A. So, deadlock cannot occur. Process path #4) P acquires B and then releases B. Then P acquires A and then releases A. So, deadlock cannot occur.

It was stated that deadlock cannot occur for the situation reflected in Figure 6.3. Justify that statement.

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.

List two ways in which the no-preemption condition can be prevented.

The lanes, intersection, and quadrants the cars pass through can be considered the resource and the process can be viewed as the cars Mutual Exclusion: Only one process may use a resource at a time. No process may access a resource unit that has been allocated to another process. For our case: only one car can pass through the intersection at a time. No other car may access a quadrant or lane that has been allocated to another car. Hold and Wait: A process may hold allocated resources while awaiting assignment of other resources. For our case: a car may hold the intersection while waiting assignment of other lanes or quadrants. No Preemption: No resource can be forcibly removed from a process holding it. For our case: no lane can be forcibly removed from a car holding it. Circular Wait: A closed chain of processes exists, such that each process holds at least one resource needed by the next process in the chain. For our case: A closed chain of cars exists, such that each car holds at least one lane or quadrant needed by the next car in the chain.

Show that the four conditions of deadlock apply to Figure 6.1a


Conjuntos de estudio relacionados

Exam #3 Marketing and Technology

View Set

LING 1 Homework 1 Question Compilation

View Set

MKTG 470 Final Study Guide Part 3

View Set

Questions missed from MOCK SERIES 7

View Set

EMU Nutrition of the lifetime Final study guide

View Set

MHR 749-CH. 12-THE ROLES OF GOVERNMENTS AND UNIONS IN COMPENSATION

View Set