CS452 - Real-Time Programming - Spring 2008

Lecture 6 - Tasks

Questions & Comments

  1. Lab will be ready some time during the week-end for: Assignment 2 (aka 1)

Kernel of a Real-time Operating System


What Does the Kernel Provide



Communication has two sides

  1. sharing information
  2. handshaking

We use Send/Receive/Reply (SRR) to do both.

  1. Send blocks
  2. Receive blocks: is synchronous with the call to send
  3. Reply doesn't block: is synchronous with the return from send



  1. Between tasks
  2. With internal events
  3. With external events


Kernel maintains a task descriptor (TD) for each created task. That is, to create a task the kernel must allocate a TD and initialize it. The TD normall contains

  1. The task's stack pointer, which contains

    all ready to be reloaded whenever the task next runs.

  2. Possibly the return value for when the task is next activated
  3. The task's parent
  4. The task's state

Possible states of the task

  1. Active: running or about to run
  2. Ready: can run if scheduled
  3. Blocked: waiting for something to happen


Kernel Structure

The kernel is just a function like any other, but which runs forever.

kernel( ) {
  initialize( );
    request = getNextRequest( );
    handle( request );

There are two other ways of writing the kernel, which are both equivalent to the one above.

  initialize( );
  exit-kernel( );
  request = determine-request( );
  handle( request );
  exit-kernel( );


  initialize( );
  exit-kernel( );
  handle( CREATE );
  exit-kernel( );
  and so on;

The first one is the most common. It hides all the interesting stuff inside

int getNextRequest( ) {
  active = schedule( ); //active is a pointer to a TD
  activate( active );
  return determine-request( active ); //the active task doesn't change

What's inside activate( active )?

How do you get the right PC into the interrupt vector? Two ways.

Return to: