CS452 - Real-Time Programming - Spring 2010

Lecture 26 - Reservations

Public Interest Announcements

  1. Final exam

Pathologies

1. Deadlock

2. Livelock (Deadly Embrace)

3. Critical Races

4. Performance

The hardest problem to solve

Priority

The hardest thing to get right

Problems with priority

  1. Priority inversion
  2. One resource, many clients
  3. Tasks try to do too much

Congestion

  1. Too many tasks
  2. Layered abstraction are costly
  3. Access to the train controller

Hardware

  1. Turn on optimization, but be careful
  2. Turn on caches
  3. Size & align calibration tables by size & alignment of cache lines

Reservations

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

  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

The lower level is encoded in the coloured lights you see along the track

Here's how it works

  1. Train asks reservation system for several blocks of track
  2. 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

Feedback Control

Control Concepts

  1. System to be controlled
  2. Time-dependent variables to be controlled
  3. Control parameters
  4. Objectives (goals)
  5. Control algorithm

Fundamental Problem is Noise

We try to set the velocity as we wish,

How do we tame noise?

  1. Measure the real position, y(t), as often as we can
  2. Modify the velocity to reduce y(t) - x(t), the difference of the desired position from the real one.
  3. Example: v(t) = B(t-t0) - C(y(t) - x(t))

Suppose we can measure continuously and instantaneously. Then

This looks pretty good, BUT

There is always a Time Lag

At time t, we really know y(t-D), where D is an inevitable time lag. Now what happens?

  1. u(t) = d(y(t) - x(t)) / dt = - C(y(t-D) - x(t)). This is pretty intractable.
  2. However, we should know the lag, or the average lag, or whatever, and we can solve
  3. d(y(t) - x(t)) / dt = - C(y(t-D) - x(t-D))
  4. Hypothesize a solution of the form exp( -zt ) and solve for z
  5. z = C exp( zD ) or log(z) = zD + log(C)
  6. Sometimes there is no real solution

The solution is Predictive Control

Change step 3 to

  1. d(y(t) - x(t)) / dt = - C(y(t-D) + Dv(t) - x(t)), which is close to

    d(y(t) - x(t)) / dt = - C(y(t) - x(t))

  2. And we are back to a solution we like.

There are whole textbooks about different ways of doing predictive control; there are whole journals with articles describing new ways of doing predictive control.

Using predictive a little loosely, predictive control is what you are doing.


Return to: