CS452 - Real-Time Programming - Spring 2012

Lecture 27 - Demos, Reservations

Public Service Annoucements

  1. Final exam date: 9.00 August 7 to 11.30 August 9
  2. The gold standard for milestone 2 is

A Typical Reservation System

A reservation system is not the only way to keep trains from hitting one another.

The reservation system described below is not the only reservation system that works. I created it to illustrate the type of problems you must solve in order to keep trains from colliding.

In past terms, students have succeeded using

Reducing the need for communication with the train controller by doing more computation on the CPU consistenly outperform.

Hard Conditions

Needed to avoid collisions

  1. **Every train must have a reservation for the track it occupies.
  2. **Every train must travel at a low enough velocity that it can stop before the end of the track it has reserved.
  3. **Every train should reserve enough to handle single sensor or (exclusive) single switch errors.
  4. **No piece of track should ever be reserved by more than one train.

Soft Conditions

Needed to keep the trains moving

  1. Every train must release blocks it no longer occupies and will not occupy in the immediate future.
  2. Every reservation held by a train must be contiguous
  3. Trains should release unneeded blocks in front of themselves if they slow down or stop.

Who enforces these conditions?

There is a situation in which the conditions cannot be enforced?

Here's how it works in theory

  1. Train gets a route from the route finder, and looks ahead along the route.
  2. Train asks reservation system for several blocks of track along the route
  3. Reservation system grants the blocks if they are available

Here's one way for it to work in practice

  1. A train receives a reservation that will allow it to travel at its desired speed for one or more blocks.
  2. Each time the train leaves a block it frees the reservation it had for that block.
  3. Before reaching the end of the blocks on which it can travel at speed, it requests an extention of its reservation.
  4. If the request is granted AND it can stop within the reservation, it continues travelling at speed.

Reservation Implementation

You might decide that reservation negotiation will take place every time the train receives a sensor report.

Every time a train receives a sensor report it does its reservation procedure

  1. Release the reservation just vacated
  2. Test stopping within the reservation at the next request time (sensor report).
  3. If okay, finished
  4. If no, how much do I need beyond my current reservation?
  5. Request what's needed, possibly more
  6. Reservation server gives as much as it can
  7. Train rechecks stopping condition using the complete reservation.
  8. If okay, finished
  9. If no, either

    or

Comment. We like slowing down, which we consider to be a more intelligent and aesthetic response to following a slow train than stop-start driving.


Problems I Have Seen More than Once

Common Multi-train Tracking Problems

  1. Two trains waiting on the same sensor report
  2. Spurious sensor reports that a train is actually expecting.
  3. Permanently malfunctioning turn outs
  4. Permanently malfunctioning sensors

Useful debugging aids

  1. Alter the track graph from the prompt.
  2. Simulate sensor-triggering from the prompt.
  3. From a low level log events that change track state.

Common Reservation System Problems

  1. System freezes
  2. Reservations are not released.
  3. Reservation leap-frogging

Useful debugging aids

  1. Insert/remove reservations by hand from the prompt
  2. Query reservations (and who holds them) from the prompt
  3. Track map showing reservations in real-time.
  4. Trains can get sensor reports only for sensors with the reservations they hold.
  5. Enforce in the reservation server that all reservations must be contiguous.

Common Route-Finding/Following Bugs

  1. Train derails on turn-out after train changes direction
  2. Train derails on turn-out as turn-out switches
  3. Switch turn-outs too late
  4. Train collides with stationary train

Useful debugging aids

All the above, plus

  1. Add/subtract switches, sections of track from graph by hand from the prompt
  2. By modifying the route-finder you can confine all routes to a subset of the tracks.

Early Signs of Problems

Frequent train finding. (You should not be refinding trains every time they stop.)


Return to: