"the management of multiple processes within a single computer

Concurrency
Modern OS central themes

Multiprogramming
"the management of
multiple processes
within a single computer
 Distributed processing
system"
"the management of
multiple processes
executing on multiple,
distributed computer
systems"
Fundamental to both themes is concurrency
The concept of concurrency
Processes are concurrent if they exist at the
same time
 Processes that are either interleaved or
overlapped in time to yield the appearance
of simultaneous execution

P1
P2
P3
time
A simple example

A program to provide character echo: input
character from keyboard and output
character on display
repeat
parbegin
out:= in;
output (out, display);
input (in, keyboard)
parend
This program will
work or not depending
on the sequence the
concurrent operations
take place
(copy is wrong)
How to implement concurrency

Programming language structures and
mechanisms
–

most programs can be decomposed in at least
three processes: input, process, output
Operating systems structures and
mechanisms
process interaction
– mutual exclusion
–
Process Interaction
Degree of Awareness
Relationship
Influence one process
has on another
Control problems
unaware
competition
results idependent
mutual exclusion
timing may be affected deadlock (renewable)
starvation
indirectly aware
cooperation- sharing
results may depend
mutual exclusion
timing may be affected deadlock (renewable)
starvation coherence
directly aware
cooperationcommunication
results may depend
deadlock (consumable)
timing may be affected starvation
Competition for resources

Mutual exclusion
critical resources (nonsharable)
– a process manages each critical resource
–

Deadlock
a process is holding a critical resource (c1) and waiting
for another critical resource (c2)
– another process is holding (c2) and waiting for (c1)
–

Starvation
–
one process is never granted access to a critical
resource for other processes always get higher priority
(and access) to the critical resource
Mutual exclusion requirements
only one process at a time is allowed access to a
critical resource
 a process that halts in a noncritical section should
not affect others
 a process should not be allowed to deadlock or
starve
 no delays should occur when a process requires a
critical resource no others are using
 a process remains in its critical section for a finite
time only

Technical: Dekker and Peterson algorithms,
and Dijkstra semaphores
Monitors
" a concurrency construct that contains both the
data and procedures to perform allocation of a
particular serially reusable shared resource or
group of resources"
 only one process is allowed to enter the monitor
 if a process calls the monitor and a resource is
already allocated the monitor calls wait (outside of
monitor)
 when a process releases a resource the monitor calls
signal (and grants the resource to a process waiting
for it)
 it gives priority to waiting versus new

Deadlock
"the permanent blocking of a set of processes
that either compete for systems resources or
communicate with each other"
 resources

reusable (not depleted with use)
– consumable (produced and consumed)
–

conditions for deadlock
mutual exclusion
– hold-and-wait
– no preemption
– circular wait (deadly embrace)
–
Deadlock management
Principle
Resource allocation schemas
policy
advantages
disadvantages
Prevention
conservative
request all
processes with
inefficient, delays
resources at once single burst of
process initiation
activity
preemption
resources whose preempts more than
state can be saved necessary,
and restored easily needs to be
restarted
resource
problem solved by
design
ordering
preempts without
need
Detection
very liberal
invoked periodically does not delay
to test deadlock
process initiation
preemption losses
Avoidance
midway between
conservative and
liberal
search to find at
no preemption
least one safe path needed
resources must be
known, long
blockings