I have a systems programming problem. Its a group of small programs that interact with each other to implement a mutual exclusion problem. I was wondeing if somebody could comment them to help me understand them better. Would be very much appreciated.

They are toilets shared by boys and girls. However, at any time only boys or only girls may be in the toilets. (Mary runs a strict establishment and does not want any funny business going on in her toilets.) Mary's rules on using the toilets are simple. A boy can enter iff:

The toilets are empty or
The toilets are occupied by boys and a toilet is available
A girl can enter iff:
The toilets are empty or
The toilets are occupied by girls and a toilet is available
However, there is a caveat. In the interest of fairness, if one sex has been waiting a long time while the other hogs the toilets then a bouncer must intervene. The bouncer allows no one to enter until the toilets have emptied. He then allows the waiting sex to enter.

instead of bouncer she employs this software

>>I was wondeing if somebody could comment them to help me understand them better.
Comment it yourself and you will understand it even more.