Professional Documents
Culture Documents
Concurrency: Mutual Exclusion and Synchronization: Ninth Edition, Global Edition by William Stallings
Concurrency: Mutual Exclusion and Synchronization: Ninth Edition, Global Edition by William Stallings
Concurrency:
Mutual Exclusion
and
Synchronization
Ninth Edition, Global Edition
By William Stallings
Multiple
Applications
Structured
Invented to Applications Operating
allow processing System
time to be
shared among
Structure
Extension of
active modular design
applications and structured
programming OS themselves
implemented
as a set of
processes or
threads
Copyright © 2018 Pearson Education, Ltd. All Rights Reserved.
Table
5.1
Some Key
Terms
Related
to
Concurren
cy
Scheduling
Pearson
Copyright © 2018 Education, Ltd. All Rightspolicies
Reserved. of the OS
Difficulties of
Concurrency
Sharing of global resources
Difficult for the OS to manage the
allocation of resources optimally
Difficult to locate programming errors
as results are not deterministic and
reproducible
Protect the data and physical resources of each process against unintended
interference by other processes
•Starvation
•Timing of process
may be affected Process
Interactio
Processes indirectly Cooperation by •Results of one •Mutual exclusion
aware of each other sharing process may depend n
(e.g., shared object) on information •Deadlock (renewable
obtained from others resource)
Event Flags
it.
A memory word used as a synchronization mechanism. Application
Concurren
code may associate a different event with each bit in a flag. A thread
can wait for either a single event or a combination of events by cy
checking one or multiple bits in the corresponding flag. The thread is
blocked until all of the required bits are set (AND) or until at least
one of the bits is set (OR).
Mailboxes/Messages A means for two processes to exchange information and that may be
used for synchronization.
Mechanis
Spinlocks Mutual exclusion mechanism in which a process executes in an
infinite loop waiting for the value of a lock variable to indicate
ms
availability.
Table 5.5
Design Characteristics of Message Systems for
Interprocess Communication and Synchronization
Copyright © 2018 Pearson Education, Ltd. All Rights Reserved.
Synchronization
Table 5.6
State of the Process Queues for Program of Figure
Copyright © 2018 Pearson Education, Ltd. All Rights Reserved. 5.26
Copyright © 2018 Pearson Education, Ltd. All Rights Reserved.
Summary
Mutual exclusion: software
approaches Monitors
Dekker’s algorithm Monitor with signal
Peterson’s algorithm Alternate model of monitors
with notify and broadcast
Principles of concurrency
Race condition Message passing
OS concerns Synchronization
Process interaction
Addressing
Requirements for mutual
exclusion Message format
Queueing discipline
Mutual exclusion: hardware
support Mutual exclusion
Interrupt disabling
Readers/writers problem
Special machine instructions
Readers have priority
Semaphores Writers have priority
Mutual exclusion
Copyright Producer/consumer
© 2018 problem
Pearson Education, Ltd. All Rights Reserved.