Assignment X: Synchronization with Semaphores

Objectives

In this assignment you will be implementing solutions to a number of different concurrency problems in the spirit of those found in The Little Book of Semaphores. For each solution you will typically need to use at least one semaphore (and associated patterns presented in class), but may also use the Lightswitch type defined in the book/slides. If convenient, you may use the signal(N) semaphore API discussed in class, and may also assume that threads blocked on a semaphore are unblocked in FIFO order.

Before each solution, clearly indicate all the (global) variables shared between the different threads and their initial values.

Concurrent Programming Problems

1. The ARC

At the ARC, a policy is instituted which requires that there be at least three tutors present before students seeking help are admitted. Also, there must be at least 1 tutor present for every 5 students seeking help.

For the purposes of this problem, tutors and students are considered "active" when they start executing their critical sections (which should be clearly marked in your solution), and are no longer active when they finish executing their code.

2. WTF

Waltz, Tango, Foxtrot.

3.