27-JAN-2004

Lecture Outline

Note: Only topics are listed here, make sure you see class notes for details
- Anoop Gupta

Synchronization


  1. Independent Vs Cooperating Processes
    We will deal with cooperating processes in this course
  2. Why support cooperative processes?
    - Share resources
    - Construct System in modular fashion
    - Do things faster
  3. 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
  4. Avoiding race conditions
    - Critical Section
    - Atomic operations
  5. Critical Sections
    Requirements (Conditions to be satisfied)
    - Mutual Exclusion
    - Progress (Deadlock-free)
    - Bounded (Starvation-free)
    Desirable Properties
    - Efficient
    - Fair
    - Simple
  6. 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)

  7. Locks
    - lock.acquire()
    - lock.release()

CS 537 - Introduction to Operating Systems (Spring 2004)                                                                                Anoop Gupta