This is a continuation of Exercise 4.7 of the text. Now worry about starvation, that is, do the second part.
First, take your original program and run it with command line parameters that show starvation occuring. Explain how you did this, giving the parameters you used.
Then modify your program to prevent starvation and re-run it with the same parameters that gave starvation before. Compare your results.
Describe which of the two approaches to starvation prevention you picked to implement: strict serialization or platooning (batching).
For the purposes of this assignment, you may assume that semaphore queueing is FIFO, that is, successive V(S) calls on a semaphore S will unblock threads in the order that they blocked when they did their P(S) calls.
As in all our programming assignments, use command line arguments to set the simulation parameters, such as the number of males, females, baboons of each type, maximum nap time outside the bathroom, maximum nap time inside the bathroom, etc.
To find the cause of deadlock, remember that a thread blocks when doing a P() on a semaphore with zero value. To find where each thread is blocked in the deadlock, put a System.out.println() before each P() and a System.out.println() after each P() so you can see how far each thread is getting before blocking and see if it is getting past a P().
Animate your program using XtangoAnimator.java. First do the base assignment as specified above and turn it in. Then do an animation of it as a separate program.