ECE 391 Lecture 8: Locks and Parallelism
Document Summary
Synchronization issues five hungry philosophers (represents 5 pieces of code) five chopsticks. Protocols take left chopstick (or wait) take right chopstick (or wait) eat release right chopstick release left chopstick digest repeat problem? deadlock! everyone will be waiting and nothing will move forward (eating) How about the following protocol? take left chopstick (or wait) if right chopstick is free, take it else release left chopstick and start over eat release right release left digest repeat. Ece 391 - lect page 1 occasionally you need multiple locks, or multiple chopsticks in this case. Getting synchronization correct can be hard (there"s no hard set steps, it will always be difficult) it"s the focus of several research communities. On uniprocessor mentally insert handler code between every pair of adjacent instructions ask whether anything bad can happen if so, prevent with cli/sti. Let"s give it a level of functions instead of instructions, but the problem with interrupts is that they can occur anytime.