CS452 - Real-Time Programming - Spring 2012

Lecture 1 - Introduction

Pubilc Service Annoucements

  1. Due date for assignment 0/1
  2. Combination to trains lab
  3. Ubuntu 10.10
  4. How to compile and run your first program

Practical Details: pdf


Embedded Systems

Most of the mediation between the internal representations and the real-world is done by embedded systems

Development Model

Two box model

Development cycle

Problem one

Problem two


What is real-time programming?

Actually real-world programming, which means

What is important for real-time?

  1. Throughput
  2. Response time

In cs452 we take guaranteed response time as the defining quality of real-time computation.


Serial I/O

Uses a device called a UART,


Busy Waiting

This is used to synchronize with an external event, minimizing response time.

#define FOREVER for( ; ; )
FOREVER {
   while( !ready( ) ) ;
   do-it( );
}

or in another form

FOREVER {
   if ( ready( ) ) do-it( );
}

Sometimes you only want to do the thing once, as you do when putting a character on a serial line.

#define UART1_BASE        0x808c0000
#define UART_DATA_OFFSET        0x00    // low 8 bits
#define UART_FLAG_OFFSET        0x18    // low 8 bits
#define TXFF_MASK               0x20    // Transmit buffer full

        flags = (int *)( UART1_BASE + UART_FLAG_OFFSET );
        data = (int *)( UART1_BASE + UART_DATA_OFFSET );
        while( ( *flags & TXFF_MASK ) ) ;
        *data = c;

Worst case response time

From the time that the ready bit sets until the first instruction of do-it is executed

The problem with busy-waiting

What if the CPU has to two things at once?

E.g.,

  1. collect bytes coming in a serial port
  2. maintain a clock

Unless the rate of bytes coming in and rate of clock ticks are identical

you are guaranteed to lose something sooner or later.


Return to: