CS452 - Real-Time Programming - Fall 2010

Lecture 18 - Task Structure

Public Service Announcements

  1. State machines for UARTS

Task Structure

Serial Server

We are supposed to support

int Get( int port )


int Put( int port, char c )

These are wrappers for sends to one or more serial servers.

How many servers and notifiers?

one server two servers four servers


likely queue

congestion in


likely queue


in notifer



one per channel?

one per direction?

how should they

be paired?



certain queue


in server

likely queue

congestion in


best performance,

most tasks

How should we handle a terminal?


  1. Line editing
  2. Echo



Many other issues come up below as we consider possible task structures.

Anthropomorphic Programming

We all, most programmers included, have effective intuitions about human relations

Tasks are independent entities

Servers and Attendant Tasks

Why do servers need attendant tasks?

1. Proprietor with a Notifier

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

Kernel is handling hardware in this example

Skeleton Notifier Code for a UART

Skeleton Proprietor Code for a UART


  1. Creation pattern is
  2. Notifier is usually of higher priority than server
  3. When, and how, do interrupts get turned on and/or cleared?
  4. Who coordinates hardware ownership?
  5. We have made the code

2. Using a Courier

Simplest is best

Notifier Code

Courier Code

Proprietor Code


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

Remember that all the calls provide error returns. You can/should use them for error recovery

Another possible arrangement for initialization

Distributed gating

3. Using a Warehouse

Add a warehouse between the courier and the notifier.

Notifier Code

Warehouse Code

Courier Code

Proprietor Code


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

Two issues:

  1. Handles bottlenecks of all sizes.

    Define `bottleneck'.

  2. Server could be buffered on the other side

    Called a guard.

What this amounts to is

Server should be lean and hungry

Return to: