





















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The process of resource allocation in operating systems and the potential issue of deadlock. It explains how semaphores can be used to synchronize resource allocation and the multiple resource allocation problem that can lead to deadlock. An example of deadlock and defines the general concept of deadlock. It also outlines the disadvantages of deadlock and the conditions that lead to deadlock. The document then introduces methods for dealing with deadlock, including prevention, avoidance, and detection and recovery.
Typology: Lecture notes
1 / 61
This page cannot be seen from the preview
Don't miss anything!






















































Spring 2018
Chapter 7
Resource Allocation and Deallocation When a process needs resources, it will normally follow the sequence:
Multiple Resource Allocation Problem Several processes may compete for multiple resources If the allocation of multiple resources to processes is not done with proper synchronization, deadlock might occur This waiting state is much more involved than starvation
Deadlock Problem A state of the computer system is which: A set of blocked (suspended) processes Each process holding one or more resources Processes waiting to acquire one or more resources held by other processes
Deadlock – General Definition A set of processes is in a deadlock state when every processes in the set is waiting for an event that can only be caused by another process in the set. The events of interest are: allocations of resources release of resources The resources are: CPU cycles, memory spaces, files, I/O devices in the computer system.
Disadvantage Of Deadlock Deadlocked processes can never complete execution because they are waiting indefinitely System resources are tied up because they are held by deadlocked processes. Deadlocks are undesirable because they normally slow down a system
Deadlock Result Both processes are blocked, they cannot proceed.
Conditions For Deadlock A deadlock arises if four conditions hold simultaneously in a system: 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.
About These Conditions These conditions are necessary but not sufficient for deadlock to occur.
A resource allocation graph shows the relationships between processes and resources. It consists of the following components: A set of processes P = { P0, P1, …., Pi,…., Pn } A set of resource types, R = { R0, R1, …,Rj, ..,Rm } A set of directed edges
Resource Allocation Graph with Cycle
Analysis Resource Allocation Graph If the graph contains no cycles, no deadlock exists. If the graph contain cycles if each resource type has only 1 instance, then a deadlock exists. otherwise, a deadlock may exist.
Handling Deadlocks General approaches, the OS can: Ensure that the system will never enter a deadlock state. Allow the system to enter a deadlock state and then recover. Ignore the problem and pretend that deadlocks never occur in the system.