Real time linux
1 / 22

Real Time Linux - PowerPoint PPT Presentation

  • Uploaded on

Real Time Linux. B.Gustafsson European Southern Observatory. ESO Feb 5 2004. ESO. Why Real Time Linux. Investigate the possibility to replace VxWorks on LCU Expensive (licensed) Bad support Present version (Tornado 2.0.2/VxWorks 5.4) has old compiler (gcc 2.7.2, C++ egcs 1.0)

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Real Time Linux' - nola

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Real time linux

Real Time Linux


European Southern Observatory

ESO Feb 5 2004


Why real time linux
Why Real Time Linux

  • Investigate the possibility to replace VxWorks on LCU

    • Expensive (licensed)

    • Bad support

    • Present version (Tornado 2.0.2/VxWorks 5.4) has old compiler (gcc 2.7.2, C++ egcs 1.0)

      • No namespace, limited STL support

      • TAO not supporting native exceptions

    • Tornado 2.2 has gcc 2.96

Real Time Linux

Real time linux

  • 3 Phases

    • Phase 1, feasibility study, finished end of July 2002, report available

    • Phase 2, implementation, finished August 2003

    • Phase 3, test, was performed Oct 2003

  • Implementation is finished. First target CPU Motorola MV2700 (PowerPC), but switched to VMIC 7766, Intel CPU

  • Linux and RTAI installed, ACS working

  • Drivers for CAN, VME and parallel I/O done

  • Booting over network

  • CAN device software and mount control done

Real Time Linux

Real time introduction
Real Time: Introduction

  • Real-time systems are concerned with when things happen as well as what happens. A real-time program must not only produce a correct answer, it must do so "on time." A late answer is a wrong answer.

  • Real-time systems can be further characterized as either "soft" real-time or "hard" real-time.

  • A hard real-time system absolutely must meet its scheduling deadline every time. Failure to meet the deadline may have catastrophic consequences, including loss of life. A fly-by-wire aircraft control system is an example of hard real-time. The control algorithms depend on regular sampling intervals. If sampling is delayed, the algorithm can become unstable.

  • A soft real-time system may cause cosmetic or annoying disturbances, but in general it will be more tolerant of missed deadlines.A video playback system may not look good when missing deadlines, but it should not cause serious damage to a process.

Real Time Linux

Is linux real time
Is Linux Real-Time ?

  • For these several reasons, standard Linux isn't capable of a real-time response:

  • Coarse-grained synchronization.

  • Paging.

  • The scheduler tries to be "fair."

  • Linux reorders requests from multiple processes to make it more efficient.

  • Linux will perform "batch" or "queued" operations to make more efficient use of hardware.

  • Kernel not interruptable

Real Time Linux

Real time linux1
Real Time Linux

  • Two hard real time linux, RTAI and RTLinux

  • RTAI selected

  • RTAI

    • tweaks the Linux interrupt

    • Installs its own scheduler

    • Linux is just another task with low priority

Real Time Linux

The rtai solution
The RTAI solution

  • Whenever Linux tries to disable interrupts, the real-time kernel intercepts the request, records it. and returns to Linux.

  • But, it does not disable interrupts!

  • When a hardware interrupt occurs, the real-time kernel first determines where it is directed:

  • Real-Time Task. Then schedule the task.

  • Linux. Check the software interrupt flag:

    • If enabled, invoke the appropriate Linux interrupt handler.

    • If disabled, note that the interrupt occurred, and deliver it when Linux re-enables interrupts.

Real Time Linux

Real time interrupts
Real Time Interrupts

  • When Real Time services are enabled the interrupt dispatch table is replaced by a "Real Time IDT " table.

  • With the Real Time system in place the mechanism for disabling and enabling interrupts no longer prevent interrupt processing. Linux locks do not prevent the Real Time Scheduler running. Interrupts are now divided into two classes.

  • Real Time interrupts

  • Linux Interrupts

  • The status of Linux Interrupts is now held in an interrupt pending register. A Linux interrupt will be acknowledged and the pending bit set. If the system is running in a Linux context the Interrupt will be serviced as normal. If the system is running in a Real Time Context the Linux interrupt will be serviced when the system returns to normal Linux (after completing all real time tasks).

  • Normal Linux Interrupts cannot preempt Real Time Linux.

  • Real Time Linux can preempt normal Linux and other Real Time Linux tasks of lower priority

Real Time Linux

Kernel modules
Kernel Modules

  • RTAI processes run as kernel modules

  • Kernel modules are effectively an extension to the kernel that can be introduced into a running system

Real Time Linux

Kernel modules1
Kernel Modules

  • As extensions of the kernel, modules execute at Privilege Level 0 and have access to the kernel's symbol table.

  • A module can execute privileged instructions such as I/O.

  • A module can call any global kernel function.

  • A failure in a module can easily bring down the entire system.

  • A module that fails to install cannot be removed.

  • There's no protection against anything at Privilege Level 0.

Real Time Linux

Real time scheduler
Real Time Scheduler

  • RTAI gives the user a real time scheduler. When triggered from a timer interrupt the Real Time task can be scheduled in a Real Time context if required. NO matter what regular linux is doing.

  • Spinlocks and interrupt masks are no longer honored within the Real Time context. Special Real Time components replace the normal linux components.

  • The basic scheduler is priority based. Other scheduling options are available and, in fact, it is easy to add your own options.

  • Zero is the highest priority and some very large number is the lowest. The lowest is reserved for Linux.

Real Time Linux

The real time timer
The Real Time Timer

  • The core of RTAI lies in its use of the system timer.

  • Normally (under Linux) set to interrupt at a 10 milliSecond interval The timer is modified in two ways.

    • Its period can be adjusted

    • It is served by a real time interrupt handler.

  • When RTAI is "mounted" the timer comes under Real Time Control

Real Time Linux

Managing the timer
Managing the timer

  • RTAI manages the timer in two distinct ways.

    • Periodic

    • Absolute or "one-shot"

  • In Periodic mode the timer is set to interrupt at a fixed, non varying, period. There are no updates to the timer from the scheduler. Periodic mode is available to reduce the significant overhead required to program the timer registers.

  • In One-shot mode the timer is reprogrammed every time the scheduler is called. There is an overhead involved but better time resolution and more adaptable scheduling

Real Time Linux

Real time communications
Real Time Communications

  • Fifos

  • Message Queues

  • RPC processes

  • Shared Memory

  • Fifos and shared memory can be used for communication with user space (Linux)

Real Time Linux

Other system calls
Other system calls

  • Suspend/resume

  • Semaphores

  • Sleep

  • Get time

  • Set priority

Real Time Linux

Rtai pros and cons
RTAI pros and cons

  • Very good real time response

  • All resources avalaible

  • Debugging difficult

  • No Linux system calls available

  • Limited set of system calls

Real Time Linux

Rtai example
RTAI Example


User Process


X-Window System


Linux Kernel

Peripheral Device




Real Time Linux

Rtai in user space
RTAI in User space

  • LXRT (Linux - Real Time ) arose from a desire to make the rich API provided for RTAI kernel modules available to user space tasks. The ease with applications could be crafted using the Kernel API was contrasted with the limited options available within standard user space Linux.

  • In particular task timing and messaging could be considered to be more advanced and easier to use within the RTAI kernel modules.

  • As a result a large section of the kernel RTAI API became available to regular users.

Real Time Linux

Soft and hard real time
Soft and hard real time

  • There are two modes of working with LXRT. Soft real-time allows the user to use the RTAI API but the task is scheduled under the regular linux scheduler. This means that normal linux system calls can be used alongside the additional RTAI calls. The task will make use of the RTAI API but will not execute as a real time task. Hard real-time allows a special lxrt scheduler to steal the task from the normal linux scheduler. This then runs the task in a real time context. Normal Linux System calls are not allowed and the task must have its working space locked in memory.

Real Time Linux

Our approach
Our approach

  • Run ACS under Linux

  • Only put a small part under RTAI

Real Time Linux

Tics abm lcu






Dig. I/O Driver


Dig. I/O board


CAN Driver

CAN bus

Clock Pulse

CAN I/O board

Real Time Linux

Useful links
Useful links




Real Time Linux