CS452 - Real-Time Programming - Spring 2009

Lecture 22 - Task Structure

Task Structure: Destroy

8. Static versus Dynamic Task Structure

Recovering from errors

Why are C++ compilers so slow? Why are their executables to big?




Three things are hard about Destroy

  1. cleaning up in constant time
  2. re-using resources in constant time
  3. Create may not be very fast

9. The Detective

Simple Events

The notifier is a task that waits on events.

You could call a notifier a detective,

Complex Events

In an application there is likely to be lots of waiting on combinations of events.

We use the detective to discover that a complex event has occurred.


Code could be

  Send( part1 );
  Send( part2 );
  Send( master );


Code above doesn't work! Try instead

// InitializeDB;
// Create workers and synchronize;
// Synchronize with client;
  Receive( *requester, request );
  if ( request.type == CLIENT ) {
    parsedRequest = parse( request );
    if ( happened( parsedRequest, DB ) ) Reply( requester );
    else enqueue( parsedRequest );
  else if (request.type == WORKER ) {
    updateDB ( request );
    Reply( requester );
    foreach ( queuedRequest )
      if ( happened( parsedRequest, DB ) ) {
        dequeue( parsedRequest );
        Reply( client );

This is the code of a detective.


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

Who is the client of the detective

  1. Initiator of a normal action
  2. Housekeeper of the system who will clean up pathologies (Idletask?))

Return to: