27-JAN-2004
Lecture Outline
Note: Only topics are listed here, make sure you
see class notes for details
- Anoop Gupta
Synchronization
- Independent Vs Cooperating
Processes
We will deal with cooperating processes in this course
- Why support cooperative processes?
- Share resources
- Construct System in modular
fashion
- Do things faster
- Cooperating requires
synchronization?
- e.g. Two processes sharing
account balance
void
deposit (int amount) {
balance += amount;
}
- Implemented as sequence of
assembly instructions
- What happens if two processes make deposit at
same time?
- What will be the final balance?
- Race condition
- Avoiding race conditions
- Critical Section
- Atomic operations
- Critical Sections
Requirements
(Conditions to be satisfied)
- Mutual Exclusion
- Progress
(Deadlock-free)
- Bounded (Starvation-free)
Desirable Properties
- Efficient
-
Fair
- Simple
- Solutions to
Critical Section Problem
- Attempt 1 (using a boolean
lock)
- Attempt 2 (using 2 boolean
locks, one for each process)
- Attempt 3 (using turn)
- Final
Attempt (Combining attempt 2 and 3)
- Locks
- lock.acquire()
- lock.release()
CS 537 - Introduction to Operating Systems (Spring
2004) Anoop
Gupta