
CS 414 : Operating Systems
UNIVERSITY OF VIRGINIA
Department of Computer Science
Fall 2005
Topic 3: Cooperating Processes and Synchronization
Synchronization: using atomic operations to ensure correct cooperation between processes.
The ‘‘Too Much Milk’’ problem:
Person A Person B
3:00 Look in fridge. Out of milk.
3:05 Leave for store.
3:10 Arrive at store. Look in fridge. Out of milk.
3:15 Leave store. Leave for store.
3:20 Arrive home, put milk away. Arrive at store.
3:25 Leave store.
3:30 Arrive home. OH, NO!
One of the most important things in synchronization is to figure out what you want to achieve.
In the given problem: somebody gets milk, but we don’t get too much milk.
Mutual exclusion: Mechanisms that ensure that only one person or process is doing certain
things at one time (others are excluded). E.g. only one person goes shopping at a time.
Critical section: A section of code, or collection of operations, in which only one process may
be executing at a given time. E.g. shopping.
— 3.1 —