CS452 - Real-Time Programming - Spring 2012

Lecture 26 - Demos, Reservations

Public Service Annoucements

  1. Final exam date
  2. Comments from yesterday's demo

Sensor Attribution

Predictions work fine once you know where the trains are. How do you find them at the beginning?

How might you do this for multiple trains?

Starting the next train

  1. Stop the previous trains in convenient places
  2. Start start this train slowly, you don't know where it is.
  3. When it hits a sensor
  4. Conclude that you know where the train is when it hits the predicted sensor.

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 problems you must solve when you are keeping 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 should be contiguous

Who enforces these conditions?

There is a situation in which these 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 it continues travelling at speed.

    Otherwise it starts slowing down so that it stops before the end of its reservation.

Reservation Implementation

You might grant reservations as follows:

Every time a train receives a sensor report it does its reservation procedure
  1. Release the reservation I just vacated
  2. If I give a stop signal at the next sensor can I stop within my reservation?
  3. If yes, 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 yes, finished
  9. If no, stop, or slow down so that the stopping condition is yes.

Return to: