665 B

Logic

Initial State:

  • Lifts all at the bottom of the building
  • People all outside the building
    • not waiting on an arrow
    • not in a lift

State 1:

These are performed simulataneously


  • Lift Thread
    1. Lift waits for a short amount of time (to allow people to enter the building)
    2. If no one is in the lift, it calls get_into_lift()
    3. get_into_lift() checks if someone is waiting on the up arrow semaphore
    4. Two things must then happen:
      • First, the lift must update the lift that currently is on that floor
      • Second, the lift must signal to a passenger that it may enter.

  • Person Thread 1.