Copy the code for the program that uses semaphores based on pipes into your directory. criticalsection2.c Build and run the program.
Is this implementation of semaphores sufficient to solve the Dining Philosophers problem? Write a program for the dining philosophers using semaphores based on pipe operations. You might use: philosophers.c Build and test it.
Copy Rochkind’s implementation of semaphores based on UNIX System V semaphore sets sem_ops.h Use these semaphores in the critical section problem of question 1.
Now change the program so that the critical section is to increment an integer counter, and report the thread id and new counter value.
Now change the program so that there are two types of threads: Writers, who increment the counter, and Readers who just read it.
To increase concurrency, we could allow any number of reader threads access at the same time. Writers will still need exclusive access. Write the program - a semaphore solution to the Readers and Writers problem.
Check that you haven’t left any semaphores around on the system. Remove them if you have.