CS452 - Real-Time Programming - Spring 2011

Lecture 24 - Reservations

Pubilic Service Announcement

  1. Project proposals.

Sensor Attribution

For each train there is a set of predictions

  1. The primary prediction: if the world is perfect train n will trigger sensor X between t1 & t2.
  2. One or more secondary predictions, having one of the two following forms
  3. Attribute a sensor hit to train n if it fulfils one of train n's predictions.
  4. What if two trains are making the same prediction?

This works fine once you have trains moving. How do you get them moving?

Starting the next train

  1. Start it slowly, you don't know where it is.
  2. When it hits a sensor immediately get it a reservation until the next block ended by a sensor, plus one sensor.
  3. Conclude that you know where the train is when it hits the predicted sensor.


Somebody has been doing something right for the last century. The answer is reservations.

Two Level Train Control

The two levels are completely independent of one another.

Upper Level System

  1. Train asks despatcher for a route
  2. Despatcher provides a route that he/she thinks to be conflict free
  3. Train follows the route, reporting back to the despatcher as landmarks (sensors) are passed.

Lower Level System (LLS)

The LLS is (mostly) encoded in the coloured lights you see along the track

Here's how the LLS works.

For every section of track the LLS receives one bit of data

And for every turn-out the LLS receives one bit

Consider one light facing a specific direction.

You can't implement a two level system.


The functionality of the LLS must be part of your reservation system. That is,

A Typical Reservation System

Hard Conditions

  1. **Every train must have a reservation for the block it occupies.
  2. **Every train must travel at a low enough velocity that it can stop before the end of the blocks it has reserved.
  3. **Every train should reserve enough to handle single sensor or (exclusive) single switch errors.
  4. 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

  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
  3. Reservation system grants the blocks if they are available

An Interesting Tit-bit That Doesn't Concern You

Real trains are long and sometimes occupy several blocks at once. How does the engineer know that the end of a train is clear of a switch?

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

  1. One train following another
  2. Two trains on a collision course
  3. There are one or more switches in the path

Return to: