Renamed logic.md and turned it into documentation
This commit is contained in:
parent
164ba99e95
commit
34af9e7527
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
assignment2.exe
|
||||
assignment2
|
||||
assignment2.zip
|
||||
|
17
details.md
Normal file
17
details.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Lift Simulator
|
||||
## Implementation Details:
|
||||
### Added Semaphores:
|
||||
1. **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)
|
||||
|
||||
2. Added a `queueInteraction` semaphore to the `floor_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.
|
||||
3. `addToStop` added to the `lift_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
|
||||
4. `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:
|
||||
1. `targetLift[]` added to keep track of the currently set target lift for a floor. Used in conjunction with semaphore `4`.
|
||||
|
||||
### Other Changes:
|
||||
1. 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.
|
||||
|
||||
2. Changed the speed settings to allow a wider range of debug values
|
41
logic.md
41
logic.md
@ -1,41 +0,0 @@
|
||||
# Logic
|
||||
## Details:
|
||||
***Stylised text in <span style="color:green">green</span> represents the actual lift metaphor***
|
||||
|
||||
***<span style="color:red">Red</span> represents significant changes to the program***
|
||||
## Initial State:
|
||||
* Lifts all at the bottom of the building
|
||||
* People all outside the building
|
||||
* not waiting on an arrow
|
||||
* not in a lift
|
||||
|
||||
## Loop:
|
||||
### *These are performed simulataneously, with a thread for each instance*
|
||||
---
|
||||
* ### Lift Thread - *this is a black-box as far as the metaphor goes*
|
||||
1. While there are people to unload at this floor, unload them
|
||||
2. Call `get_into_lift(Lift, Direction)`, to load people from the apporopriate waiting queue (up | down) from the current floor
|
||||
3. Redraw
|
||||
3. Change position
|
||||
* `get_into_lift()`
|
||||
1. Fetch the correct semaphor for our queue
|
||||
2. Get the number of waiting people on that queue
|
||||
3. While there are people waiting:
|
||||
1. If the lift is empty, change our direction to the supplied direction
|
||||
* <span style="color:red">A semaphore is used before the conditional to help ensure the correct value of `in progress` transfers is correct</span>
|
||||
2. While the lift is not full, and we have people waiting:
|
||||
* <span style="color:red">Keep track of the number of `in progress` waiting people</span>
|
||||
1. Add a person to the lift.
|
||||
2. Redraw the waiting queue
|
||||
3. Remove the person from the waiting queue
|
||||
4. Signal person to actually get into the lift
|
||||
|
||||
---
|
||||
* ### Person Thread - *this is modelled around the actual metaphor*
|
||||
1. Choose a floor to enter
|
||||
2. Decide if the floor is above or below the current position
|
||||
3. Add ourselves to the appropriate move (up | down) group <span style="color:green">Press the `call elevator` button</span>
|
||||
4. <span style="color:green">Wait for the lift to arrive</span> *on the appropriate spot (up | down); no metaphor for this concept*
|
||||
5. Enter the lift that is waiting
|
||||
6. Move to the waiting group for the target floor <span style="color:green">Press the target floor button</span>
|
||||
7. Wait until the lift reaches our destination floor and leave when it is our turn to exit.
|
Loading…
x
Reference in New Issue
Block a user