Project Presentation.pptx operating system project presentation
ismailtanoli9876
11 views
19 slides
Jun 28, 2024
Slide 1 of 19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
About This Presentation
This presentation is about operating system and ways to prevent from a deadlock condition
Size: 249.37 KB
Language: en
Added: Jun 28, 2024
Slides: 19 pages
Slide Content
TEAM MATES Muhammad ISMAIL HANIF (8783 ). AHMAD BIN ASMAT (8753). AHMAD ALI KHAN JADOON (8752). AWAIZ ALI (8756). HAMZA GUL (8765).
DEAD LOCK A deadlock happens in operating system when two or more processes need some resource to complete their execution that is held by the other process . Deadlock involves resources needed by two or more processes at the same time that cannot be shared.
DEADLOCK
DEADLOCK
DEADLOCK CONDITIONS Mutual Exclusion. Hold and Wait. No Preemption. Circular Wait.
MUTUAL EXCLUSION There should be a resource that can only be held by one process at a time. In the diagram below, there is a single instance of Resource 1 and it is held by Process 1 only.
MUTUAL EXCLUSION
HOLD AND WAIT A process can hold multiple resources and still request more resources from other processes which are holding them. In the diagram given below, Process 2 holds Resource 2 and Resource 3 and is requesting the Resource 1 which is held by Process 1.
HOLD AND WAIT
NO PREEMPTION A resource cannot be preempted from a process by force. A process can only release a resource voluntarily. In the diagram below, Process 2 cannot preempt Resource 1 from Process 1. It will only be released when Process 1 relinquishes it voluntarily after its execution is complete.
NO PREEMPTION
CIRCULAR WAIT A process is waiting for the resource held by the second process, which is waiting for the resource held by the third process and so on, till the last process is waiting for a resource held by the first process. This forms a circular chain. For example: Process 1 is allocated Resource2 and it is requesting Resource 1. Similarly, Process 2 is allocated Resource 1 and it is requesting Resource 2. This forms a circular wait loop.
CIRCULAR WAIT
HOW TO HANDLE DEAD LOCK Deadlock prevention: The possibility of deadlock is excluded before making requests, by eliminating one of the necessary conditions deadlock . . Deadlock avoidance: Operating system runs an algorithm on requests to check for a safe state. Any request that may result in a deadlock is not granted. . Deadlock detection & recovery: OS detects deadlock by regularly checking the system state, and recovers to a safe state using recovery techniques .
PREVENTION OF MUTUAL EXCLUSION Spooling: It stands for Simultaneous Peripheral Operations online. A Printer has associated memory which can be used as a spooler directory (memory that is used to store files that are to be printed next). In spooling, when multiple processes request the printer, their jobs ( instructions of the processes that require printer access) are added to the queue in the spooler directory. The printer is allocated to jobs on a first come first serve (FCFS) basis. In this way, the process does not have to wait for the printer and it continues its work after adding its job to the queue.
ELIMINITION OF HOLD AND WAIT By eliminating wait : The process specifies the resources it requires in advance so that it does not have to wait for allocation after execution starts. By eliminating hold : The process has to release all resources it is currently holding before making a new request.
ELIMINATION OF NO PREEMPTION By two ways: If a process is holding some resources and waiting for other resources, then it should release all previously held resources and put a new request for the required resources again. The process can resume once it has all the required resources. If a process P1 is waiting for some resource, and there is another process P2 that is holding that resource and is blocked waiting for some other resource. Then the resource is taken from P2 and allocated to P1. This way process P2 is preempted and it requests again for its required resources to resume the task. The above approaches are possible for resources whose states are easily restored and saved, such as memory and registers.
ELIMINATION OF CIRCULAR WAIT To eliminate circular wait, we assign a priority to each resource. A process can only request resources in increasing order of priority . In the example above , process P3 is requesting resource R1 , which has a number lower than resource R3 which is already allocated to process P3 . So this request is invalid and cannot be made, as R1 is already allocated to process P1 .
CONCLUSION Deadlock can be prevented by eliminating any of the four necessary conditions, which are mutual exclusion, hold and wait, no preemption, and circular wait. Mutual exclusion, hold and wait and no preemption cannot be violated practically. Circular wait can be feasibly eliminated by assigning a priority to each resource.