Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 41

RT Linux

A Real Time Approach of Linux

What is real-time? realCorrectness of output depends on timing as well as result Hard vs. soft real-time realAre Windows and Linux real-time? real-

Real time Introduction Definitions


Real Time System is one where the correctness of a computation is a function of both the result of the computation and the time at which the computation is delivered  Soft RT occasionally allowed to miss deadlines (eg. Updating a video display)  Hard RT Meeting the deadline is absolutely critical (eg. Rocket controller)

Typical RTS

RTOS Vs. GPOS

RTOS
 

needs deterministic timing behavior Works under worst case assumptions

GPOS
 

high throughput and fairness Optimizes for the average case

Hence, the design objectives of the OSs are different

Incompatibility with Timesharing Systems


Timesharing systems try to optimize average case but RT systems must consider worst case. Contradictory design goals for the two what is good for the average case tends to deteriorate the worst case. A classic example is virtual memory and demand paging.

Two Types of Real Time OS


Hard Real Time
Meeting the deadline is absolutely critical


Soft Real Time


Occasionally allowed to miss deadlines


E.g. Rocket controller

E.g. Updating a video display

So what happens in the case a Hard Real Time System does not meet a deadline? Failure!

Hard versus Soft


HARD: miss a deadline and youre in trouble! (planes, trains, factory control, nuclear facilities, ...) SOFT: try to meet deadlines, but if not, system still works, although with degraded performance (multimedia, thermostat, ...) FIRM: late results are worthless, but you are not in trouble

Why RTOS?
Interactive embedded systems require real time scheduling Some legacy OS can provide some of this functionality BUT they are too big to run on an embedded systems

Real Time OS problem


A RTOS needs to be fast and predictable: so it needs to be small and precisely designed. Modern RT applications need networking stacks, GUI, databases, file systems, development environments, web servers, and so on: So the operating system needs to have many features Hard to estimate service time. Both requirements are hardly satisfied at the same time.

Desirable Real-Time Kernel Features


Multitasking
Priority-based preemptive scheduling

Inter-task synchronization and communication


Semaphores, mailboxes, event-flags ...

Basic memory management Interrupt handling Timer handling, time management Implementable on small deeply embedded systems

Defects In Linux As An RTOS

Real ti e I tr ti Li x as g RT platf r
Excellent stability and efficiency Source code availability Active license, and substantial user base. Linux can run on the most widely available computers Linux has all features of a modern UNIX system: (X Window, graphical user interface toolkits, networking, databases, programming languages, debuggers, and a variety of applications). It is embeddable and is able to perform efficiently using relatively small amounts of RAM and other computer resources.

Real ti e I tr ti Li x as g RT platf r
In short, Linux has the potential to make an excellent development platform for a wide variety of applications, including those involving real-time processing. real-

Defects of Linux
Linux scheduling algorithms are not designed for realrealtime tasks. Linux scheduling is unpredictable. Linux Timer resolution is coarse, 10 ms. Linux Kernel is Non-preemptible . NonLinux disables interrupts used for coarse-grained coarsesynchronization. Linux uses virtual memory. Linux reorders requests for efficiency (e.g., for disk I/O).

Can Linux provide real-time guarantees? real-- No!!


Linux  non-preemptible kernel nonA system call might take long time to complete


Coarse timer resolution


Tasks can be released only with 10ms precision

Virtual memory
Introduces unpredictable amount of delays

Variable priority
Each task is assigned a priority which varies over the time; this is to achieve fairness

Real time Introd ction


Why is Lin x Uns itable for Hard RT ? Unpredictable scheduling depends on system load. Time resolution NonNon-preemptible kernel Disabling of interrupt during critical sections Use of virtual memory

Real Time Linux- An LinuxIntroduction

What is RTLinux ? ..
To support hard real time applications, the Linux kernel is modified by introducing a layer between the hardware and the standard Linux kernel. RTRT-Linux is a hard realrealtime kernel that runs Linux or BSD as an idle task, whenever there are no real-time demands. real-

RTRT-Linux
Additi nal layer between Linux al kernel and hardware.


Small real time kernel Linux kernel.

exists with

RTRT-Linux is module oriented. Decouples the mechanisms of realrealtime kernel from the general purpose kernel.

POSIX 1003.1b Standard


For soft RT features in UNIX It requires the following
    

Preemptive priority scheduling Locking of virtual pages into memory RealReal-time signals Improved IPC Improved timers

Linux only partially conforms to the above. (mlock and setsched system calls)

RT Linux Introduction Goals


Achieve hard RT performance. High level of timer precision in scheduling. To provide low interrupt latency. Customized scheduling. Minimal changes to the Linux kernel so that the full range of OS services are available.

RT Linux Introduction Background


RTRT-Linux is developed and supported by FSMLabs. RT-Linux began life as a research FSMLabs. RTproject at the New Mexico Institute of Technology (NMT). RT-Linux is an open-source RTopenproduct. RT-Linux-specific components are RT-Linuxreleased under the GPL, and Linux components released under the standard Linux license. The source code is freely distributed.

RT Linux Introduction Backgrond - Cont


The most-current stable version of RTLinux mostV3.0, offers a POSIX style application programming interface (API), runs on x86, PowerPC and Alpha processors and supports SMP (x86 and PPC).

RT Linux Introduction Approach


RTRT-Linux a version of the Linux Operating System, its a hard real-time operating system realthat runs Linux as its lowest priority execution thread. The Linux thread is made completely preemptible so that real time threads and interrupt handlers are never delayed by non-real nontime operations Prevents disabling of interrupts by Linux.

RT Linux Introduction Structure


Linux Process 1 Linux Process 2

Linux Kernel

An RT - Process

Real Time Kernel

RT Linux Introduction Approach Cont


RealReal-time tasks in RT-Linux can RTcommunicate with Linux processes via shared memory or using a FIFO. Thus, realrealtime applications can make use of all the powerful, non-real-time services of Linux, non-realincluding:
     

Networking Graphics Windowing systems Data analysis packages Linux device drivers, and Standard POSIX API.

Real Time Linux


Real time Linux Project:
     

UTIME RTRT-Linux Platform Kurt Platform RED Linux RTAI Linux/RK(from Mac/RK)

Embedded Linux Projects




MiniRTL
Extension to RT Linux

 

ELKS Project HAHA-Linux (High Availability) VME Linux Project

RTLinux Features
 

RealReal-time scheduling algorithm. Predictable delays.




By its small size and limited operations.

 

Finer timer resolution. Preemptible kernel.


 

The RTLinux executive is itself nonpreemptible. Its routine are very small and fast, this does not cause big delays. Interrupts from Linux are disabled.

No virtual memory.

Architecture of RT Linux

Linux Kernel
User Processes

System libraries Device drivers


I/O

Linux kernel
Hardware Interrupts

Hardware

RTRT-Linux: Design Criteria


To provide timing reliability to the Linux Kernel. Linux Kernel is unpredictable because of:
   

Scheduling algorithms (maximize throughput) Device Drivers. Uninterruptible System Calls. Use of interrupt disabling procedures.

When is Hard Real-Time Realneeded?


Hard vs. Soft Real-Time Real

Hard RT always guarantees exact timing ClosedClosed-loop control systems Stimulus/response systems Robotics, Animatronics Industrial equipment Neural, fuzzy and adaptive systems Hard Real-Time extensions can degrade OS Realperformance of non time-critical applications time-

Hard Real-Time applications Real 

Examples
  

However:


RTLinux: The Real Time Linux


Goals
  

maintain compatibility with GNU/Linux handle tasks with hard-real time constrains hardsimplicity and reliability of the RT
tradeoff: ease of use

Approach
 

realreal-time microkernel Linux kernel is running as lowest priority task in the real-time schedule realrealreal-time applications are written as microkernel modules microkernel is transparent to regular application

RTLinux: Microkernel
Microkernel


IS a thin layer of abstraction PROVIDES an interface for hardware interrupts and API for realreal-time tasks MEDIATES requests to/from hardware

RTLinux: Microkernel (cont.)


Components
     

Processor clock control RealReal-Time scheduler POSIXPOSIX-like interface to device drivers RealReal-Time FIFOs Shared memory buffers POSIXPOSIX-like IPC
Blocking mutexes Semaphores

 

SourceSource-level debugger support Serial port interface

RTLinux: Microkernel Details


Scheduler


Preemptive, priority based Reason: saves too much state, not fast enough Stack is used instead Linux thread does not directly receive them The microkernel stops passing them to the Linux thread However, real-time tasks can receive them real-

Hardware context switch is not used


 

RT kernel handles hardware interrupts




When Linux wants to disable interrupts


 

You might also like