In the last reading, we read about the need for synchronization and were introduced to one mechanism for providing it: semaphores. In this reading we’ll get a more in-depth look at how we may use semaphores in our concurrent programs. We’ll also look at another basic synchronization primitive, the barrier, that will be useful for your final project.
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.
pthread_barrier_wait
function.The following objectives should be mastered by each student DURING and FOLLOWING the class session through active work and practice.
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.
Complete the following C code to initialize the barrier such that it has the default barrier attributes and would require five threads to reach that barrier before any of them could pass.
pthread_barrier_t the_more_the_barrier;
// Write a line of code to initialize the barrier
How does a binary semaphore differ from a counting semaphore?
Part A: Give an example of a problem that could be modeled as a producer-consumer problem, beyond those examples described in the book.
Part B: Repeat Part A, except for the readers-writers problem.