CS452 - Real-Time Programming - Spring 2011
Lecture 25 - Reservation Bugs
Pubilic Service Announcement
- Project proposals.
- Train availability.
- Second train control demo. `I must have been insane.'
Reservations
A Typical Reservation System
Hard Conditions
- **Every train must have a reservation for the block it occupies.
- **Every train must travel at a low enough velocity that it can stop
before the end of the blocks it has reserved.
- **Every train should reserve enough to handle single sensor or
(exclusive) single switch errors.
- Trains can switch turn-outs only on track they have reserved.
- Possibly, trains can query sensors only on track they have
reserved.
- Every train must release blocks it no longer occupies and will not
occupy in the immediate future
(** failsafe conditions)
Who enforces these conditions?
There is a situation in which these conditions cannot be enforced?
Here's how it works
- Train gets a route from the route finder, and looks ahead along the
route.
- Train has a desired speed (n), with velocity v(n), and a current
velocity (v)
- It is in block b(0).
- The train currently owns enough blocks that if it gets a stop
signal at the beginning of the next block, b(1), it can stop without
over-running its reservation.
- e.g. If v = 0 then the train has only the block it occupies,
b(0), reserved
- Call the last reserved block b(x)
- Train asks reservation system for several blocks of track. How many?
- It would like to be travelling at v(n).
- It needs the next block, b(1), and
- If it starts accelerating towards v(n) it will achieve a
velocity v' at the beginning of b(2), then it needs enough blocks
that it can stop from that speed if it receives a stop signal at
the beginning of b(2).
- Call the last block it needs b(y): y >= x
- It asks for blocks b(x+1) to b(y), which may be zero
- It needs the next block, b(1)
- Blocks usually end at switches and/or sensors
- If you are ending blocks at switches you must know well enough how
enough where the train is to be confident it is completely clear of
the switch.
- Reservation system grants the blocks if they are available
- That is, if b(x+1) to b(y) are unreserved, and the train proceeds
as planned.
- If some are available, but not all, the the ones available are
granted and it is up to the train to modify its speed
accordingly.
Something Essential that You Must Do
Design your reservation system before coding it.
Before coding your reservation system work it out on paper and make sure
that it works for all the generic cases you can think of
- One train following another
- Two trains on a collision course
- There are one or more switches in the path
Problems I Have Seen More than Once
Common Multi-train Tracking Problems
- Two trains waiting on the same sensor report
- One is bound to get inconsistent state
- Should be solved by the reservation system
- Spurious sensor report that a train is actually expecting.
- Most often for a secondary prediction,
- because the temporal window for a secondary prediction can
precede the time window for the primary one.
- Tightening temporal windows helps this
- Could look further ahead so that secondary predictions alway lag
behind primary ones
- Recover from such an error by back-tracking
- Permanently malfunctioning turn outs
- Can't be switched or always derails
- Alter track graph
- Important to be able to alter the track graph from the
prompt
- Permanently malfunctioning sensors
- Usually fail on because of sticking
- Unstick by hand
- Alter track graph and mask reports
- See above for track graph
- Mask at as low a level as possible
- Finding the trains at the beginning
- One at a time
- Move slowly
Useful debugging aids
- Alter the track graph from the prompt.
- Simulate sensor-triggering from the prompt.
Common Reservation System Problems
- System freezes
- Reservations branch out ahead and cover a lot of the track
- Trains give back unneeded reservations as they slow down
- Reservations are not released.
- Usually shows itself only when the project is well advanced
- Looks as though there are phantom trains in the system
- Usually most of a reservation is released, but not all.
- Reservation leap-frogging
- Two trains are approaching one another; each gets a reservation
behind the other. (Badly needs a diagram.)
- Ask for and/or give out reservations in the right order
Useful debugging aids
- Insert/remove reservations by hand from the prompt
- Query reservations (and who holds them) from the prompt
- Track map showing reservations in real-time.
- One partner watches the map while the other observes the trains
- Trains can get sensor reports only for sensors with the reservations
they hold.
- This is likely to be the earliest symptom of a train getting lost.
- Enforce in the reservation server that all reservations must be
contiguous.
- Non-contiguous reservations are an early symptom of reservation
system failure.
Common Route-Finding/Following Bugs
- Train derails on turn-out after train changes direction
- Improve acceleration/deceleration calibration
- Switch turn-outs for both directions of travel
- Train derails on turn-out after turn-out changes direction
- Improve acceleration/deceleration calibration
- Switch switches too late
- Treat command latencies systematically
Useful debugging aids
- Add/subtract switches, sections of track from graph by hand from the
prompt
Return to: