35
Real-Time Systems Real-Time Systems Asst. Prof. Dr. Tolga Ayav Department of Computer Engineering İzmir Institute of Technology Embedded Systems Lab

Real-Time Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/RT-Systems-Intro.pdf · Resource management ... Only for those RTLinux-related interrupts, ... real-time interrupt dispatcher,

Embed Size (px)

Citation preview

Real-Time SystemsReal-Time Systems

Asst. Prof. Dr. Tolga AyavDepartment of Computer Engineering

İzmir Institute of TechnologyEmbedded Systems Lab

Agenda

Real-Time Systems RT Scheduling RT Kernels

RT-Linux

RT Executives DACOS

Study of Embedded Systems in COMPENG

İzmir Institute of Technology Embedded Systems Lab

Real-Time

Real-Time system is defined as a system where the correctness of the system depends not only the result of computations but also on the time at which it is produced. Therefore the timetime is the most important item to be managed.

İzmir Institute of Technology Embedded Systems Lab

Various Definitions

Hard, Soft, Firm Real-Time Embedded System Deterministic System Failed System Fault, Error, Failure Safety Critical System Fail-Safe System …

İzmir Institute of Technology Embedded Systems Lab

Real-Time Application

A real-time application is composed of a set of coordinated tasks:

Periodic Tasks: started at regular intervals and has to be completed before some deadline

A-periodic Tasks: appeared irregularly, but within a bounded frequency

Sporadic Tasks: their parameters are completely unknown

İzmir Institute of Technology Embedded Systems Lab

Defining a RT Task

We can use following quintuple to express a task:

b: begin time c: execution time f: frequency of a periodic task d: deadline

İzmir Institute of Technology Embedded Systems Lab

Schedulability

For schedulability, at least the following conditions must be met:

İzmir Institute of Technology Embedded Systems Lab

Task Categories

According to their time criticality:

Hard Real-Time Tasks Soft Real-Time Tasks Non Real-Time Tasks (Background Task)

İzmir Institute of Technology Embedded Systems Lab

Hard Deadline Task

İzmir Institute of Technology Embedded Systems Lab

Safety Critical Task

İzmir Institute of Technology Embedded Systems Lab

Soft Deadline Task

İzmir Institute of Technology Embedded Systems Lab

Task Scheduling

Dynamic Scheduling (Online) Static Scheduling (Offline)

Scheduling

Rate-Monotonic(Static Priority DrivenPreemptive)

Earliest-Deadline-First(Dynamic Priority Driven Preemptive)

AlgorithmArchitectureAdequation

……

İzmir Institute of Technology Embedded Systems Lab

Rate-Monotonic Scheduling (1)

Assumptions: Simple task model: No interprocess communication and all tasks

are periodic Tasks have priorities which are inversly proportional to their

periods. Tasks’ deadlines are equal to their periods. A high priority task may preempt lower priority tasks.

Liu and Layland (1973) proved that for a set of n periodic tasks with unique periods, a feasible schedule that will always meet deadlines exists if the CPU utilization is:

İzmir Institute of Technology Embedded Systems Lab

Rate-Monotonic Scheduling (2)

When number of tasks approaches to infinity, this utilization bound will converge to:

Task Execution Time

Period

τ1 1 8

τ2 2 5

τ3 2 10

Example:

Thus, the system is schedulable

İzmir Institute of Technology Embedded Systems Lab

Earliest-Deadline-First Alg.

Priorities are changed dynamically

Task with the earliest deadline gets the highest priority

Unless RM, utilization may go up to 100%

İzmir Institute of Technology Embedded Systems Lab

Example Scheduling

Three periodic tasks: A, B, C T is period, D is deadline and C is execution time uniprocessor

İzmir Institute of Technology Embedded Systems Lab

RTOS Operating system (OS) is a program that acts as

an intermediary between a user and the computer hardware. The primary goal of an OS is to make the computer system convenient to use and the secondary goal is to use the hardware in efficient manner

İzmir Institute of Technology Embedded Systems Lab

RTOS Requirements

Interrupt handling, guaranteed interrupt response Task (process) management (Support for scheduling of real-

time tasks and preemptive scheduling)

Interprocess communication and synchronization. Time management. Memory management I/O support (Support for communication with peripheral

devices via drivers) High speed data acquisition Resource management (User control of system resources) Error and exception handling

İzmir Institute of Technology Embedded Systems Lab

RTOS Vendors

OS name Vendor OS name Vendor

Chorus Chorus VxWorks WindRiver

ECOS Cygnus Windows CE

Microsoft

EPOC32 Symbian MicroC/OS White Horse Design

OSE Enea AMX Kadak

JavaOS Sun Microsystems

Ariel Micoware

LynxOS Lynx ARTOS Locamation

NucleusPlus Acc. Tech ASP6x DAN enterprise

OS/9 Microware Chimera Robotics

PalmOS 3com CMX CMX company

PSOS+ ISI Diamond 3L

QNX QNX DOS6-XL General Software

RTEMS OAR corp. EOS Etnoteam

VRTX Microtec EUROS Kanet

RT-Linux …

İzmir Institute of Technology Embedded Systems Lab

Linux Architecture

The standard LINUX kernel isn't a real-time kernel Some patches should be applied to fulfill the real-

time requirements

Carte Pulse

HARDWARE

System libraries

Drivers LINUX kernel

Hardware interruptsI/O

User’s task

İzmir Institute of Technology Embedded Systems Lab

RT-Linux Projects RT-Linux is an operating system, in which a small

real-time kernel co-exists with standard Linux kernel The real-time kernel sits between standard Linux kernel and the h/w. The standard Linux kernel sees this real-time layer as actual h/w The real-time kernel intercepts all hardware interrupts.

Only for those RTLinux-related interrupts, the appropriate ISR is run. All other interrupts are held and passed to the standard Linux

kernel as software interrupts when the standard Linux kernel runs.

The real-time kernel assigns the lowest priority to the standard Linux

kernel. Thus the realtime tasks will be executed in real-time Realtime tasks are privileged (that is, they have direct access to

hardware), and they do NOT use virtual memory.

İzmir Institute of Technology Embedded Systems Lab

Real-Time Linux Architecture

Hardware abstraction layer real-time interrupt dispatcher, real-time scheduler Inter processes communication services The patches available are: RTLinux, xenomai and RTAI (Real-Time Application

Interface)

Real-time plugin

System libraries

Linux kernelDrivers

I/O

I/O

Hardware interrupts

Software interrupts

Real Time task

User’s task

Real-time Scheduler

HARDWARE

İzmir Institute of Technology Embedded Systems Lab

RTAI Block Description The software architecture of RTAI is made of:

1 I/F to Linux HW Management (HAL): basically a data structure.

3 basic components (dispatcher, scheduler, fifo's). 1 I/F (set of functions) used in user tasks to initialize and start

the components. From a Linux point of view these entities populate modules.

İzmir Institute of Technology Embedded Systems Lab

Control flow in a RTAI/Linux system

Virtual Interrupt Controlusingsti()cli()

İzmir Institute of Technology Embedded Systems Lab

RT-Linux Tasks (1)

gcc –c simple.cinsmode simple.ormmod simple.o

İzmir Institute of Technology Embedded Systems Lab

RT-Linux Tasks (2)

İzmir Institute of Technology Embedded Systems Lab

RTAI Project

For further information, installation details and various documents, please refer to:

www.rtai.org

İzmir Institute of Technology Embedded Systems Lab

Real-Time Executives

Simplified RTOS Not a real-time operating system

itself Usually has task scheduling and time

management functions May rely on other OSs, like DOS.

İzmir Institute of Technology Embedded Systems Lab

DACOS (Data Acquisition and Control Operating System)

It’s a real-time executive in fact. Runs on MS-DOS operating system. Most functions require a special

Hardware: DACES Supports:

Data Acquisition. Pipes, variables, processes. Periodic tasks.

İzmir Institute of Technology Embedded Systems Lab

DACOS Components custom.h : The definitions of the max numbers for tasks, pipes,

variables etc. dacos.h : All prototypes for functions and data structures used

by the real-time system. calls.h : The definitions for the system calls. defs.asm : Some definitions for the assembly functions. dacos.c : Almost all of the function implementations of the

real-time executive. kernel.asm : The assembly language routines providing task

switching which cannot be done well within C. main.c : Includes main function which does the initialization

of the executive and shell functions for interacting with user.

qcl -c -AL -Zi -Ox -Aw -Gs dacos.cqcl -c -AL -Zi -Ox -Aw -Gs main.cqcl -c -AL -Zi -Ox -Aw -Gs kernel.asmlink /co /stack:16384 dacos.obj kernel.obj main.obj, dac.exe

İzmir Institute of Technology Embedded Systems Lab

DACOS Features

Scheduling: Preemptive Round-Robin. Each task is given a fixed 500µs time slice.

Interprocess communication: Pipes and variables. DAC.EXE runs on DOS. It reads load.dac system

configuration file. The tasks are stored as procs/*.bin files.

Use DACES hardware: 16 channel analog inputs, 16 digital inputs and 16 digital outputs.

The executive DAC.EXE is only 127KB.

İzmir Institute of Technology Embedded Systems Lab

System Configuration File

pipe.name[string].size[unsigned integer].

var.name[string].initial_value[integer]

sample.channel_number[integer0-15] .sampling_period [unsigned integer].pipe_name[string].

pro.name[string].parameter1.parameter2.parameter3…

timer.period[unsigned int] .name. parameter1. parameter2. parameter3…

İzmir Institute of Technology Embedded Systems Lab

Use of Pipes for IPC

İzmir Institute of Technology Embedded Systems Lab

Sample LOAD.DAC

İzmir Institute of Technology Embedded Systems Lab

Sample Task: average.c

İzmir Institute of Technology Embedded Systems Lab