System Wilfrid Laurier University
CP386 Final Exam Review
Chapter 6
• Bounded-buffer memory
o Counter set to 0
o Incremented by the producer after produces new buffer
o Decremented by the consumer after it consumes a buffer
o Producer
o Consumer
• Race condition
, o When 2 processes try to manipulate the count variable concurrently
o Synchronization prevents race condition, in order to ensure that only one
process at a time is manipulating the variable
• Critical Section
o Where processes may be changing common variables, updating tables, writing to
files etc
o Solutions to Critical section Problem
▪ Mutual exclusion - When 1 process is in critical section, no other may be
in its critical section
▪ Progress – If no process is in critical section and there exist a process that
wish to enter their critical section, then that process will be selected
▪ Bounded Waiting
, • Petersons Solution (KNOW THE PSEUDOCODE)
o 2 variables are used
▪ Int turn; - Indicates whose turn it is to enter the critical section
▪ Boolean flag[2] – indicates if a process is ready to enter the critical
section
o Not guaranteed to work on modern computer architectures
• Memory Barriers
o When a memory barrier is performed, the system ensures that all loads and
stores are completed before any subsequent load or store operations are
performed
o Strongly ordered - where a memory modification on one processor is
immediately visible to all other processors.
o Weakly ordered - where modifications to memory on one processor may not be
immediately visible to other processors