OS Unit-3 23-24
OS Unit-3 23-24
1/55
Operating Systems - Unit-III February 24, 2024 1 / 55
Unit-III Syllabus
2/55
Operating Systems - Unit-III February 24, 2024 2 / 55
Interprocess Communication Basic Concepts
Interprocess Communication
3/55
Operating Systems - Unit-III February 24, 2024 3 / 55
Interprocess Communication Basic Concepts
Communication Models
4/55
Operating Systems - Unit-III February 24, 2024 4 / 55
Interprocess Communication Basic Concepts
Cooperating Processes
5/55
Operating Systems - Unit-III February 24, 2024 5 / 55
Interprocess Communication Producer-Consumer Problem
Producer-Consumer Problem
6/55
Operating Systems - Unit-III February 24, 2024 6 / 55
Interprocess Communication Producer-Consumer Problem
7/55
Operating Systems - Unit-III February 24, 2024 7 / 55
Interprocess Communication Producer-Consumer Problem
8/55
Operating Systems - Unit-III February 24, 2024 8 / 55
Interprocess Communication IPC-Shared Memory
9/55
Operating Systems - Unit-III February 24, 2024 9 / 55
Interprocess Communication IPC-Message Passing
10/55
Operating Systems - Unit-III February 24, 2024 10 / 55
Interprocess Communication IPC-Message Passing
11/55
Operating Systems - Unit-III February 24, 2024 11 / 55
Interprocess Communication IPC-Message Passing
12/55
Operating Systems - Unit-III February 24, 2024 12 / 55
Interprocess Communication IPC-Message Passing
Direct Communication
13/55
Operating Systems - Unit-III February 24, 2024 13 / 55
Interprocess Communication IPC-Message Passing
Indirect Communication
14/55
Operating Systems - Unit-III February 24, 2024 14 / 55
Interprocess Communication IPC-Message Passing
Indirect Communication
15/55
Operating Systems - Unit-III February 24, 2024 15 / 55
Interprocess Communication Pipes
Pipes in OS
Pipes
17/55
Operating Systems - Unit-III February 24, 2024 17 / 55
Interprocess Communication Pipes
Ordinary Pipes
Ordinary Pipes allow communication in standard producer-consumer
style
Producer writes to one end (the write-end of the pipe)
Consumer reads from the other end (the read-end of the pipe)
Ordinary pipes are therefore unidirectional
Require parent-child relationship between communicating processes
Named Pipes
19/55
Operating Systems - Unit-III February 24, 2024 19 / 55
Interprocess Communication Pipes
Pipes-Unix
20/55
Operating Systems - Unit-III February 24, 2024 20 / 55
System Model
System Model
21/55
Operating Systems - Unit-III February 24, 2024 21 / 55
Deadlock Characterization
Deadlock Characterization
22/55
Operating Systems - Unit-III February 24, 2024 22 / 55
Deadlock Characterization
23/55
Operating Systems - Unit-III February 24, 2024 23 / 55
Deadlock Characterization
Resource-Allocation Graph
24/55
Operating Systems - Unit-III February 24, 2024 24 / 55
Deadlock Characterization
25/55
Operating Systems - Unit-III February 24, 2024 25 / 55
Deadlock Characterization
Basic Facts
26/55
Operating Systems - Unit-III February 24, 2024 26 / 55
Methods of Handling Deadlocks
27/55
Operating Systems - Unit-III February 24, 2024 27 / 55
Methods of Handling Deadlocks Deadlock Prevention
Deadlock Prevention
28/55
Operating Systems - Unit-III February 24, 2024 28 / 55
Methods of Handling Deadlocks Deadlock Prevention
No Preemption –
If a process that is holding some resources requests another resource
that cannot be immediately allocated to it, then all resources currently
being held are released
Preempted resources are added to the list of resources for which the
process is waiting
Process will be restarted only when it can regain its old resources, as
well as the new ones that it is requesting
Circular Wait – impose a total ordering of all resource types, and
require that each process requests resources in an increasing order of
enumeration
29/55
Operating Systems - Unit-III February 24, 2024 29 / 55
Methods of Handling Deadlocks Deadlock Avoidance
Deadlock Avoidance
30/55
Operating Systems - Unit-III February 24, 2024 30 / 55
Methods of Handling Deadlocks Deadlock Avoidance
SafeState
31/55
Operating Systems - Unit-III February 24, 2024 31 / 55
Methods of Handling Deadlocks Deadlock Avoidance
Basic Facts
32/55
Operating Systems - Unit-III February 24, 2024 32 / 55
Methods of Handling Deadlocks Deadlock Avoidance
33/55
Operating Systems - Unit-III February 24, 2024 33 / 55
Methods of Handling Deadlocks Deadlock Avoidance
Avoidance Algorithms
34/55
Operating Systems - Unit-III February 24, 2024 34 / 55
Methods of Handling Deadlocks Deadlock Avoidance
35/55
Operating Systems - Unit-III February 24, 2024 35 / 55
Methods of Handling Deadlocks Deadlock Avoidance
Resource-Allocation Graph
36/55
Operating Systems - Unit-III February 24, 2024 36 / 55
Methods of Handling Deadlocks Deadlock Avoidance
37/55
Operating Systems - Unit-III February 24, 2024 37 / 55
Methods of Handling Deadlocks Deadlock Avoidance
38/55
Operating Systems - Unit-III February 24, 2024 38 / 55
Methods of Handling Deadlocks Deadlock Avoidance
Banker’s Algorithm
Multiple instances
Each process must a priori claim maximum use
When a process requests a resource it may have to wait
When a process gets all its resources it must return them in a finite
amount of time
39/55
Operating Systems - Unit-III February 24, 2024 39 / 55
Methods of Handling Deadlocks Deadlock Avoidance
40/55
Operating Systems - Unit-III February 24, 2024 40 / 55
Methods of Handling Deadlocks Deadlock Avoidance
Safety Algorithm
41/55
Operating Systems - Unit-III February 24, 2024 41 / 55
Methods of Handling Deadlocks Deadlock Avoidance
42/55
Operating Systems - Unit-III February 24, 2024 42 / 55
Methods of Handling Deadlocks Deadlock Avoidance
Example (Cont.)
44/55
Operating Systems - Unit-III February 24, 2024 44 / 55
Methods of Handling Deadlocks Deadlock Avoidance
Example (Cont.)
45/55
Operating Systems - Unit-III February 24, 2024 45 / 55
Methods of Handling Deadlocks Deadlock Detection
Deadlock Detection
46/55
Operating Systems - Unit-III February 24, 2024 46 / 55
Methods of Handling Deadlocks Deadlock Detection
47/55
Operating Systems - Unit-III February 24, 2024 47 / 55
Methods of Handling Deadlocks Deadlock Detection
49/55
Operating Systems - Unit-III February 24, 2024 49 / 55
Methods of Handling Deadlocks Deadlock Detection
Detection Algorithm
51/55
Operating Systems - Unit-III February 24, 2024 51 / 55
Methods of Handling Deadlocks Deadlock Detection
Example (Cont.)
52/55
Operating Systems - Unit-III February 24, 2024 52 / 55
Methods of Handling Deadlocks Deadlock Detection
Detection-Algorithm Usage
53/55
Operating Systems - Unit-III February 24, 2024 53 / 55
Methods of Handling Deadlocks Deadlock Detection
54/55
Operating Systems - Unit-III February 24, 2024 54 / 55
Methods of Handling Deadlocks Deadlock Detection
55/55
Operating Systems - Unit-III February 24, 2024 55 / 55