Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Deadlock Assignment

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

1.

Two types of resources giving examples Consumable resources (resource use consumes): rendezvous call, interrupt, input data item, etc. Reusable resources (not depleted): disk, printer, memory, CPU, file, etc.

2. Fundamental causes of deadlock Mutual Exclusion: At least one resource must be non-shareable. Only one process can use the resource at any given instant of time. Hold and Wait or Resource Holding: A process is currently holding at least one resource and requesting additional resources which are being held by other processes. No Preemption: The operating system must not de-allocate resources once they have been allocated; they must be released by the holding process voluntarily. Circular Wait: A process must be waiting for a resource which is being held by another process, which in turn is waiting for the first process to release the resource. In general, there is a set of waiting processes, P = {P1, P2, ..., PN}, such that P1 is waiting for a resource held by P2, P2 is waiting for a resource held by P3 and so on till PN is waiting for a resource held by P1.

3. Examples of deadlocks that are not related to a computer system environment


A person going down a ladder while another person is climbing up the ladder. Two trains traveling toward each other on the same track. Two carpenters who must pound nails. There is a single hammer and a single bucket of nails. Deadlock occurs if one carpenter has the hammer and the other carpenter has the nails.

4. How can we deal with deadlock Deadlock prevention Ensure deadlock does not happen, ensure at least one of 4 conditions does not occur. Deadlock avoidance Ensure deadlock does not happen, Use information about resource requests to dynamically avoid unsafe situations Deadlock detection and recovery Allow deadlocks, but detect when occur then recover and continue. Ignore

5. Difference between prevention and avoidance Deadlock Prevention:


o

Preventing deadlocks by constraining how requests for resources can be made in the system and how they are handled (system design). The goal is to ensure that at least one of the necessary conditions for deadlock can never hold. Deadlock Avoidance:

The system dynamically considers every request and decides whether it is safe to grant it at this point, The system requires additional apriority information regarding the overall potential use of each resource for each process. Allows more concurrency. Thus the difference between deadlock avoidance and deadlock prevention is a little subtle. Deadlock avoidance refers to a strategy where whenever a resource is requested, it is only granted if it cannot result in deadlock. Deadlock prevention strategies involve changing the rules so that processes will not make requests that could result in deadlock.

6. Examples of strategies for presentation


Deny any of the three necessary conditions Or deny a circular wait from forming Deadlock prevention is a very conservative strategy

7. Bankers safety algorithm

The Banker's safety algorithm is a resource allocation and deadlock avoidance algorithm developed by Edsger Dijkstra that tests for safety by simulating the allocation of predetermined maximum possible amounts of all resources, and then makes a "safe-state" check to test for possible deadlock conditions for all other pending activities, before deciding whether allocation should be allowed to continue. The Banker's safety algorithm is run by the operating system whenever a process requests resources. The algorithm avoids deadlock by denying or postponing the request if it determines that accepting the request could put the system in an unsafe state (one where deadlock could occur). When a new process

enters a system, it must declare the maximum number of instances of each resource type that may not exceed the total number of resources in the system. Also, when a process gets all its requested resources it must return them in a finite amount of time. For the Banker's algorithm to work, it needs to know three things: How much of each resource each process could possibly request How much of each resource each process is currently holding How much of each resource the system currently has available

Resources may be allocated to a process only if it satisfies the following conditions: Request max, else set error condition as process has crossed maximum claim made by it. Request available, else process waits until resources are available

8. solution We have four resource types (A,B,C,D) , the available resources of the system (3 1 1 2)

Process Types P1 P2 P3

Allocation A B C D 1 2 2 1 1 0 3 3 1 1 1 0

Maximum A B C D 3 3 3 2 1 2 3 4 1 1 5 0

Need A B C D 2 1 1 1 0 2 0 1 0 0 4 0

a) The system is in safe state since all the processes will be satisfied with the resources.(Safe Sequence: P1, P2, P3)

b.

Process Types P1 P2 P3

Allocation A B C D 1 2 2 1 1 0 3 3 1 1 1 0

Maximum A B C D 3 3 3 2 1 2 3 4 1 1 5 0

Need A B C D 2 1 1 1 0 3 0 1 0 0 4 0

b) The OS will grant the request since the amount of the requested resources is less than the OS available resources. c) The request of P3 will not be granted with the resources since the available OS resources of type C is less than the requested resources. 9. Available Resources 3 3 2 Process Allocation Maxim um A B C P0 P1 P2 P3 P4 0 1 0 2 0 0 3 0 2 2 1 1 0 0 2 A B C 7 5 3 3 2 2 9 0 2 2 2 2 4 3 3 Need

A B C 7 4 3 1 2 2 6 0 0 0 1 1 4 3 1

a) The system is in safe state. Safe sequence, P1, P3, P4, P0, P2 b) Yes, the request of P1 will be granted since (1 0 2) (3 3 2) Available resources (2, 3, 0) Process Allocation A B C P0 0 1 0 P1 3 0 2 P2 3 0 2 P3 2 1 1 P4 0 0 2 New safe sequence, P1, P3, P4, P0, P2 Maximum A B C 7 3 9 2 4 5 2 0 2 3 3 2 2 2 3 A B C 7 0 6 0 4 4 2 0 1 3 3 0 0 1 1 Need

c) Request for (3,3,0) by P4 not granted since request is greater than the available resources (2,3,0). d) P0, will not be granted because available resource will be reduced to (2, 1, 0) and no process can continue.

10. Yes or No. There are other processes that hold the resource and not allocate them to other processes such as P3 and P2. Processes are in deadlock: P1 R1 P2 R2 P1

11. A system is in a safe state only if there exists a safe sequence of processes. If a system is in safe state, there is no deadlock. 12. Safe sequence o Means resources exist for all processes to complete in some order.

No process is deadlocked, and there exists no possible sequence of future request in which deadlock could occur No process is deadlocked and the current state will not lead to a dead lock state Safe state is where there is at least one sequence that does not result in deadlock

13. No. Because a state to be deadlocked should complete all the processes and resources cycle. 14. Unsafe state can be identified when there is a cycle that indicates there is a deadlock.

FACULTY OF COMPUTING, INFORMATION SYSTEM AND MATHEMATICS BACHEROR IN COMPUTER SCIENC STREAM B CIT 722---OPERATING SYSTEM TUTORIAL 2 SUB-GROUP 4 MEMBERS;

MALLYA, ANGELINA. E ABDULRAHMAN, HALIMA MISIGARO, NICE POMBOMA, JAMES

You might also like