CS452 - Real-Time Programming - Spring 2009

Lecture 20 - Task Structure

Task Structure

1. Proprietor with a Notifier

Proprietor `owns' a service, which usually means a resource.

Proprietor Code

Notifier Code

Notes

  1. Notifier is usually of higher priority than server
  2. When, and by whom, do interrupts get turned on & off
  3. Who coordinates hardware ownership?

2. Using a Courier

Simplest is best

  1. Notifier
  2. Courier
  3. Server

How does this work?

  1. Acceptance of data by Server
  2. Courier is empty, blocked on Notifier
  3. Event arrives, Notifier receives
  4. Courier acquires data, blocks on Server
  5. Event arrives, Notifier blocks on courier
  6. Acceptance of data by Server

This gets you through a bottleneck where no more than two events come too fast.

Another possible arrangement for initialization

Distributed gating


3. Warehouse

Add buffer before courier and server.

  1. Notifier
  2. Warehouse, a kind of server
  3. Courier
  4. Server

This structure clears up problems when the notifier runs too fast for the server.

  1. Warehouse can put packages into cartons.
  2. Lag between data in hardware and server operating on it is increasing.

The problem is that the server is doing too much work, and the system is stuck at a lower priority while it is done.

Two issues:

  1. Handles bottlenecks of all sizes.

    Define `bottleneck'.

  2. Server could be buffered on the other side

    Called a secretary.


4. Specialization

When there is a constant in a problem,

Example

One of your serial ports is always connected to the train

How to take advantage of this

The tension between specialization and generality


5. Secretary

Think about the Server's send queue. It might have

Possible solutions

  1. Send queue priorities
  2. Ration access to clients using

Possible code

Secretary

initialize
synchronize
FOREVER {
  request = Receive( ... )
  switch ( request.type ) {
  case COURIER:
    status = FREE;
    waitingResult = request;
    Reply ( waiter, waitingResult );
    if ( !empty( requestQ ) ) {
      { waiter, waitingRequest } = dequeue( requestQ );
      Reply( courier, waitingRequest );
      status = BUSY;
    }
    break;
  case CLIENT:
    if ( status == BUSY ) {
      enqueue( requester, request );
    } else {
      Reply( courier, request );
      waiter = requester;
      status = BUSY;
    }
    break;
  }
}


6. The Administrator

If there are too many requests,

If the problem is not transient, but occurs occasionally because a couple of things happen to occur at once

An administrator does not do work itself,


Return to: