For both questions use Semaphore.java as the semaphore implementation.
nconsumer processes share a buffer with
bslots. The producer can deposit messages only into empty slots in the buffer and every message deposited by the producer has to be fetched by all
nconsumers before the slot can be reused. Furthermore each consumer is to receive the messages in the order they were deposited. However, different consumers can receive message at different times. Implement your solution in Java using semaphores for synchronization. Your solution must be in a file named
assign2_q16b.java(and hence the main class should be
assign2_q16b). In comments in your code include a statement of the invariant and key assertions to help explain your solution.
eatingbe a Boolean array;
eating[i]is true if
Philosopher[i]is eating, and is false otherwise. Use the technique of passing the baton to ensure that your solution is deadlock-free and avoids starvation (i.e., if a philosopher wants to eat, eventually he gets to without making any assumptions about the fairness of the Semaphores). In comments in the code include a global invariant and other relevant assertions. Implement your solution in Java in a file named
Please submit your solutions using web submit.
Last modified: Mon 2004.02.16 at 22:10 NST by Dennis Peters