CS452 - Real-Time Programming - Spring 2017

Lecture 22 - Anthropomorphic Programming

Public Service Annoucements

  1. First Train Control demo on Thursday, 29 July.
  2. On Monday the 19th we decided that

6. The Detective

Simple Events

A simple notifier is a task that waits on events.

A Courier is a task that waits on messages. A Worker is a task that waits on results.

We could call any one of these three tasks a detective,

But they are restricted to detecting things that are very simple, and our train application requires the detection of complex events.

Complex Events

Inside the server code for serial I/O we detected more complex events, especially when transmitting. For example, when transmitting TO THE TRain we needed to find the conjunction (AND) of

In doing serial I/O we made this information available within a task that was coordinating a collection of tasks, but we could just as easily have retreived the information from three separate tasks using code like the following.
	Send( detector1, event1, ... );
	Send( detector2, event2, ... );
	Send( detector3, event3, ... );
When this code completes all three events have occurred. The detection is easy because conjunction (AND) is easy.

Disjunction, OR, on the other hand is hard. For it we need the special properties of Receive, because it has the ability to accept a message from two or more different sources. For the detective, we think of the sources as workers.

A typical example where a detective is needed is a time out. When a train is travelling toward a sensor you have an idea of when you expect it to arrive, and you know that if it hasn't arrived by the time you must do something to rescue the train. How is this done? A detective that searches for time outs has two workers,

If the sensor trigger comes first the detective responds with "success" and ignores the delay detector. If the delay comes first, the detective responds with "time out" and ignores the sensor report. ("Ignores" means that the the message is received and ignored.)

How does a time-out detective work?


We can say that an event has not happened yet.

Only at the end of the universe can we say that an event simply has not happened.

Time-outs are needed for NOT: how to do them is shown above.

Who is the client of the detective

  1. Initiator of a normal action

7. Housekeeper

Housekeeper of the system who will detect, and possibly clean up pathologies.

How to give a demo.

You are in charge; don't forget it.

General: stay in control.

Don't leave dead air.

There are two of you.

Plan what you are going to do and who will do it.

When you are planning what to say try thinking about these questions.

Make sure that the things you are going to show actually work.

Keep a copy of an executable that was working before you start the next debugging step. (This can profitably be said more than once!)

How to get back in control

Sorted by amount of force applied, least first.

Inhale loudly.

Start setting up the next demo and explaining it.

If nothing else work talk over the person who is speaking. I will respond to you.

We exclude other students from your demo to remove one distraction that makes staying in charge harder.

8. The Grim Reaper

Most often pathologies are handled by destroying one or more tasks, the recreating them. Destroying is usually done in the context of programming conventions. One convention followed here is that when tasks work together as a unit task creation is done internally with one master task directly or indirectly creating all tasks in the unit. Then

Resources must be returned for reuse. Some are easy.

Others are hard. Suppose a task owns a piece of track. It must be given back or your project won't survive very much task destruction. How do we keep the time for this process bounded above?

Return to: