A backpackers hotel has a bathroom with multiple showers so that many people can use it at once. The hotel follows traditional practice by allowing either men or women to use the bathroom, but not both at once. Thus when one or more women are in the bathroom, other women may enter but no men, and vice-versa.
A sign on the door of the bathroom with a sliding marker indicates which of the three possible states the bathroom is in:
Empty
Women present
Men present
Write the following procedures: woman_wants_to_enter, man_wants_to_enter,
woman_leaves, man_leaves, using counters and sychronisation techniques to ensure that the correct behaviour will occur.
Is your solution fair and correct? If so describe how it is fair and correct, otherwise describe the limitations to your solution.