While parallelism and concurrency can greatly improve the performance of our applications, they also introduce unique problems. In this reading we’ll examine how sharing data can lead to incorrect results for something as basic as incrementing a variable. We’ll see how progress graphs can help identify problematic thread interleavings and get a quick introduction to semaphores, one basic mechanism for helping deal with synchronization errors.
Sections 12.5.0 - 12.5.2 (pp. 995-1002) from the course textbook.
Each student will be responsible for learning and demonstrating proficiency in the following objectives PRIOR to the class meeting. The reading quiz will test these objectives.
sem_wait
and sem_post
functions.The following objectives should be mastered by each student DURING and FOLLOWING the class session through active work and practice.
sem_init
, sem_wait
, and sem_post
.These exercises are geared towards mastering the BASIC learning objectives listed above. You are expected to submit them before class and it is highly recommended that you complete them before attempting the reading quiz.
Part A: In your own words: What is a critical section?
Part B: How can we avoid problems relating to critical sections?
What is the instruction ordering for the progress graph trajectory given below.
For Figure 12.21 in your book, provide one additional safe trajectory and one additional unsafe trajectory.
What is the semaphore invariant?