1.5 KiB
Lift Simulator
Implementation Details:
Added Semaphores:
-
Print statement wrapped in a semaphore, to control printing to the console. (There is a possibility that the console print position could be changed if the currently printing thread was interrupted)
-
Added a
queueInteraction
semaphore to thefloor_info
struct. The idea of this is that only one lift-call button can be pressed at a time; this prevents more than one person in the queue interacting with the lift. -
addToStop
added to thelift_thread
- this semaphore communicates if the lift is currently adding someone. Used primarily to prevent the lift moving while still loading someone (which would cause an non-loaded person to be unloaded). Very unlikely that this would occur, due to the number of statements that need executing first, but still could potentially occur -
targetLiftSelect
allows a lift to set itself as the target lift on a specific floor for a person thread. The person thread releases this semaphore when they load.
Added Variables:
targetLift[]
added to keep track of the currently set target lift for a floor. Used in conjunction with semaphore4
.
Other Changes:
-
Added a
POPULATION
preprocessor definition that will print the current counts of people on each floor, and the current floor positions of all people threads. Useful for detecting if someone is stuck. -
Changed the speed definitions to allow a wider range of values
-
Added an explicit definition for
true
so that it may compile in Windows i.e.
#define true TRUE