Sie sind auf Seite 1von 11

RTAI

RTAI
Asst. Prof. Dr. Tolga Ayav
Department of Computer Engineering
zmir Institute of Technology
Embedded ystems !ab

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
"A#D$A#E
ystem libraries
Drivers
LINUX %ernel
"ard&are interrupts
I/O
'ser(s tas%
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)
#eal)time plugin
ystem libraries
Linux kernel
Drivers
I/O
I/O
"ard&are interrupts
oft&are interrupts
#eal Time tas%
'ser(s tas%
Real-time Scheduler
"A#D$A#E
zmir Institute of Technology Embedded Systems Lab

RTAI Block Description

The software architecture of !T"I is made of


# I$% to &inu' H( )ana*ement +H"&, basically a data
structure-
. basic components +dispatcher, scheduler, fifo's,-
# I$% +set of functions, used in user tasks to initiali/e and start
the components-

%rom a &inu' point of view these entities populate modules-


zmir Institute of Technology Embedded Systems Lab

Control flow in a RTAI/Linux system
*irtual Interrupt Control
using
sti+,
cli+,
zmir Institute of Technology Embedded Systems Lab

RTAI Installation
0lease see the repository
http$$#12-3-#.2-.4$rtai
!ead the file rtai5installation-pdf

Writin !ernel "o#ule
6include 7linu'$kernel-h8
6include 7linu'$module-h8
6include 7linu'$init-h8
6include 7asm$io-h8
6include 7rtai-h8
6include 7rtai5sched-h8
6include 7rtai5fifos-h8
)9:;&<5&I=<>S<+?@0&?,A
static int 55preempt5init+void,
B
printk+?Cernel module startedDn?,A
return EA
F
static void 55preempt5e'it+void,
B
printk+?Cernel module e'itedDnDn?,A
F
module5init+55preempt5init,A
module5e'it+55preempt5e'it,A

$assin parameters to
mo#ule
int var G HEA
module5param+var,int,HE,A
void write5lpt +unsi*ned char byte,
B
outb+byte, &0T,A
F
static int 55preempt5init+void,
B
printk+?Cernel module startedDn?,A
printk+?Dn Iariable Ialue JdDnDn?, var,A
write5lpt++unsi*ned char, var K E'ff,A
return EA
F
static void 55preempt5e'it+void,
B
write5lpt++unsi*ned char, E,A
printk+?Cernel module e'itedDnDn?,A
F
module5init+55preempt5init,A
module5e'it+55preempt5e'it,

Typical RTAI Task
static !T5T"SC thread#A
static void task# +lon* thread,
B
outb+byte, &0T,A
F
static int 55preempt5init+void,
B
!TI)< startA
rtf5create+%I%9, #EEE,A
rt5task5init5cpuid+Kthread#, task#, E, LEEE, E, E, E, E,A
period G start5rt5timer+nanoHcount+TI=C5TI)<,,A
rt5task5make5periodic+Kthread#, start, period,A
return EA
F
static void 55preempt5e'it+void,
B
stop5rt5timer+,A
rt5task5delete+Kthread#,A
rtf5destroy+%I%9,A
printk+?Cernel module e'itedDnDn?,A
F

%xperiment
(rite an !T"I task that produces a 0() si*nal from &0T
port of the computer- The name of the module will be
MpwmN- 0eriod T +ns, and duty cycle +percenta*e, will be
passed to the the module as parameters such that
insmod pwm.o T!"## $!%#
9bserve the 0() si*nal usin* an osciloscope-

$W" sinal

Das könnte Ihnen auch gefallen