SLIDE 17 2/4/13 17
Jan 31, 2013 Ding Yuan, ECE344 Operating System 33
Summarize Where We Are
- Goal: Use mutual exclusion to protect critical sections of
code that access shared resources
- Method: Use locks (spinlocks or disable interrupts)
- Problem: Critical sections can be long
acquire(lock) … Critical section … release(lock) Disabling Interrupts:
Should not disable interrupts
for long periods of time
Can miss or delay important
events (e.g., timer, I/O) Spinlocks:
Threads waiting to acquire
lock spin in test-and-set loop
Wastes CPU cycles Longer the CS, the longer
the spin
Greater the chance for lock
holder to be interrupted
If you only remember one thing from this lecture…
- When you have concurrency & shared resources,
protect your critical region with synchronization primitives (e.g., locks, semaphore (next
lecture), etc.)
- You don’t want to go to that crazy intersection in Russia.
Jan 31, 2013 Ding Yuan, ECE344 Operating System 34