Semaphores
- Due:
- 11:00pm, Friday April 1, 2022
Description
For this assignment we will use semaphores to solve concurrency problems.
Questions
Implement and test a solution to the fork/join problem. See
fork-join.c
for details. Add the callsleep(1)
to the child to ensure it is working.Implement and test a solution to the rendezvous problem. The problem is as follows: you have two threads, each of which are about to enter the rendezvous point in the code. Neither should exit this part of the code before the other enters it. Consider using two semaphores for this task, and see
rendezvous.c
for details.Implement and test a general solution to barrier synchronization. Assume there are two points in a sequential piece of code, called
P1
andP2
. Putting a barrier betweenP1
andP2
guarantees that all threads will executeP1
before any one thread executesP2
. Your task: write the code to implement abarrier()
function that can be used in this manner. It is safe to assume you knowN
(the total number of threads in the running program) and that allN
threads will try to enter the barrier. Again, you should likely use two semaphores to achieve the solution, and some other integers to count things. Seebarrier.c
for details
Turning in the Assignment
For this assignment, you must turn in a zip file of a directory named assignment7.zip
containing the following files:
fork-join.c
rendezvous.c
barrier.c
Submit the zip file to the appropriate folder on D2L.