Operating Systems 2024-2025 Fall Semester PDF
Document Details
Uploaded by StunnedZirconium852
The Egyptian E-Learning University
2024
Dr. Wafaa Samy, Dr. Hanaa Eissa
Tags
Summary
These notes cover the topic of deadlocks in operating systems. They include sections on the system model, deadlock characterization (including the four necessary conditions for deadlock to occur), methods for handling deadlocks (prevention and avoidance), and a resource-allocation graph example. The document is also part of the operating systems course for the 2024-2025 Fall semester.
Full Transcript
Year: 2024-2025 Fall Semester Operating Systems Dr. Wafaa Samy Dr. Hanaa Eissa Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018 8.1 Modified by Dr. Wafaa Samy ...
Year: 2024-2025 Fall Semester Operating Systems Dr. Wafaa Samy Dr. Hanaa Eissa Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018 8.1 Modified by Dr. Wafaa Samy Chapter 8: Deadlocks (Part 1) Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018 Modified by Dr. Wafaa Samy Outline System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018 8.3 Modified by Dr. Wafaa Samy Deadlock In a multi-programming environment, several threads may compete for a finite number of resources. A thread requests resources; if the resources are not available at that time, the thread enters a waiting state. Sometimes, a waiting thread can never again change state, because the resources it has requested are held by other waiting threads. This situation is called a deadlock. The deadlock is a situation in which every process in a set of processes is waiting for an event that can be caused only by another process in the set. A set of threads is in a deadlocked state when every thread in the set is waiting for an event that can be caused only by another thread in the set. The events with which we are mainly concerned here are resource acquisition and release. Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018 8.4 Modified by Dr. Wafaa Samy System Model System consists of a finite number of resources to be distributed among a number of competing threads. Resource types R1, R2,..., Rm Resources like CPU cycles, memory space, I/O devices, etc. Synchronization tools like mutex locks and semaphores, are resources. Each resource type Ri has Wi instances (e.g. If a system has four CPUs, then the resource type CPU has four instances). Each process utilizes a resource as follows: 1. Request: The thread requests the resource. If the request cannot be granted immediately (for example, if a mutex lock is currently held by another thread), then the requesting thread must wait until it can acquire the resource. The number of resources requested may not exceed the total number of resources available in the system. 2. Use: The thread can operate on the resource. 3. Release: The thread releases the resource after using it. The request and release of resources may be system calls. Examples are the request() and release() of a device, open() and close() of a file, and allocate() and free() memory system calls. Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018 8.5 Modified by Dr. Wafaa Samy Deadlock with Semaphores Data: Definition of the A semaphore S1 initialized to 1 wait() operation: A semaphore S2 initialized to 1 wait(S) { Two processes P1 and P2 while (S