Professional Documents
Culture Documents
Chapter 8 Concurrency-P1
Chapter 8 Concurrency-P1
Operating
S t
Systems: Mutual Exclusion
Internals
and Design
and Synchronization
Principles
p
Seventh
S h Edi
Edition
i
By William Stallings
Operating System design is concerned
with the management of processes and
threads:
Multiprogramming
Multiprocessing
p g
Distributed Processing
• Multiprogramming:
The management of multiple processes
within a uniprocessor system
• Multiprocessing :
The management of multiple processes
within a multiprocessor
• Distributed processing:
The management of multiple processes
executingg on multiple,
p distributed computer
p
systems.
C
Concurrency encompasses a host off
design
g issues,, including
g communication
among processes, sharing of and competing
for resources (such as memory
memory, files
files, and I/O
access), synchronization of the activities of
multiple processes
processes, and allocation of
processor time to processes.
Uniprocessor–
p the relative speed
p of execution of
processes cannot be predicted
depends
p on activities of other processes
p
the way the OS handles interrupts
schedulingg p
policies of the OS
Difficulties of Concurrency
There is no way to
There iis no way to
Th k
know which
hi h process You don’t
Y d ’ know
k
know before a will continue whether another
process decrements immediately on a process is waiting so
a semaphore
h uniprocessor
i system
t th number
the b off
whether it will when two processes unblocked processes
block or not are running may be zero or one
concurrently
S
Semaphore
h Primitives
P i ii
Bi
Binary S
SemaphorePrimitives
h Pi ii
.A q
queue is used to hold processes
p waitingg on the semaphore
p
Strongg Semaphores
p
• the process that has been blocked the longest is
released from the queue first (FIFO)
Weak Semaphores
• the order in which processes are removed from the
q e e is not specified
queue
Here processes A, B, and C depend on
a result from process D D.
Initially (1), A is running; B, C, and D are
ready; and the semaphore count is 1,
indicating that one of D’sD s results is
available.
When A issues a semWait instruction on
semaphore
p s , the semaphore
p
decrements to 0, and A can continue to
execute; subsequently it rejoins the ready
queue.