Beruflich Dokumente
Kultur Dokumente
with RTAI
Outline
I.
Specification of a RTOS
Interrupt management,
Time base,
Additionnal Services
Memory Management
Development Architecture
l
Cross Development
Development computer
Source writing
Cross compilation
Linking :
-code
-RT kernel and librairies
-loader
Simulation
Download
Debug
Target computer
Embedded system
I/O
Controlled system
Sometimes keyboard/Screen
Development Architecture II
Simulation
Debug
Execution
LINUX
l
Manage I/O
Disk
Network
Multitask
-
Load balancing
Resource management
Mozilla
Bash
Emacs
API
Kernel
space
COM
MODULE
DRIVER
KERNEL
Not Allowed
FILESYSTEM
Hardware
CPU
RAM
DISK
NETWORK
10
Functions
-
-
-
-
-
-
-
-
-
-
Linux Modules
l
l
l
Modules
l
Process
wake up date cant be guaranted
-Round robin scheduler : load balancing
- Calls to kernel functions can not be preempted
-
Memory
- Swap
Interrupt
- Regularly disabled by the kernel
15
KURT implementation
Linux
l
l
l
l
KURT
RT-Linux, RTAI
or RTAI
https://www.rtai.org/
l
l
RTLinux
RTAI (variante de RTLinux)
eCos
...
And commercial distributions
-
-
-
-
-
FSMLAbs (RTLinux)
MontaVista HardHat
Lineo Embedix Realtime
TimeSys Linux/RT
LynuxWorks BLueCat Linux (Lynx Real Time Systems)
18
RTAI
l
l
l
Multi schedulers
Communications
Open source
Split in sevral modules
Manage flotting point unit (FPU)
19
20
21
Patch Linux
Compile the patched kernel
Install and run the new kernel
22
23
no more needed
24
Compile a module :
Load a module
> insmod exemple1.ko (exemple1.o with kernel 2.4)
List modules
# lsmod
Module
exemple1
sb
Pages
1
6
Used by:
0
1
25
26
Cleaning
l
Remove module
-
27
28
Makefile
l
l
l
www.gnu.org/software/make/manual
29
RTAI modules
+ application modules
-
-
l
I/O handling
Tasks
_ Script
30
X Windows
User Process
RT
Fifo
Linux kernel
RT
Fifo
RT Task
RT Task
RTAI
Screen
Disk
Network
other peripheral
31
RTAI
-
Task scheduling
l
Preemptive
33
Task create
#include <rtai_sched.h>
MODULE_LICENSE("GPL");
static RT_TASK tache;
#define STACK_SIZE 2000
iret = rt_task_init(&tache, // task pointer
routine, // name of function to be execute
1,
// int passed to routine
STACK_SIZE,
// execution stack size
1,
// int priority, 0=highest priority
0,
// int 0 => fpu not used
//
1 => fpu is used
0
// signal (see rt_task_signal_handler)
);
Periodic task
In init_module
iret = rt_task_make_periodic(&tache,
start_date, nano2count(PERIODE));
_
In the task
loop containing task + function rt_task_wait_period
();
35
Suspend
rt_task_suspend( rt_whoami() );
Re-execute
rt_task_resume( &tache);
_ Also
Ending
rt_task_delete( &tache);
36
Time
l
rt_set_oneshot_mode()
l
rt_set_periodic_mode()
l
Default mode
Fixed period
Time (2)
l
Conversions
RTIME tn, tc;
tc = nano2count(tn);
tn = count2nano (tc);
38
RTAI scheduling
l
Priority
-
Dynamic priority
rt_task_set_resume_end_times(wakeup_date, duedate_date);
rt_task_set_resume_end_times(-period,-deadline);
39
Multiprocessor scheduling
l
2 solutions
-
40
VI. SYNCHRONISATION,
COMMUNICATION
41
Transmit an event
-
With/without value
Ordering
-
before / after
Data exchange
-
With synchronisation
Without synchronisation
l
Creation
SEM mon_sem;
rt_typed_sem_init(&mon_sem, // semaphore pointer
1, // initial value
BIN_SEM
// type
);
Take a semaphore
If the semaphore is prsent : on prend le smaphore et on continu
Si le smaphore est absent : on est bloqu jusqu ce que le smaphore
soit restitu
ierr = rt_sem_wait(&mon_sem);
Restituer le smaphore
ierr = rt_sem_signal(&mon_sem);
43
Smaphores (2)
l
Autres types
rt_typed_sem_init(&mon_sem,1,BIN_SEM);
A compte : CNT_SEM
l Ressource : RES_SEM
l
-
l
Destruction
-
ierr = rt_sem_delete(&mon_sem);
Variantes asynchrones
-
blocage au maximum
jusqu date
- rt_sem_wait_timed(&sem,dure) : blocage au maximum
pendant dure
- rt_sem_wait_until(&sem,date):
44
RTAI : Fifos
X Windows
Process utilisateur
RT
Fifo
Noyau Linux
RT
Fifo
Tche
RT
Tche
RT
RTAI
Ecran
Disques
Rseau
Priphriques
45
ct process utilisateur
-
/dev/rtf0, /dev/rtf1 v
46
2 modes d utilisation
l
comme priphrique
API spcifique RT
RTAI : RTFifos
l
ct tche RT (2)
l
API spcifique RT
l
l
Messages
l
Caractristiques
-
SYN/SYN
ierr = rt_receive
(&tache_orig,&entier); //SYN
Variantes
-
If : send ASYN, pas denvoi si recepteur non prt, pas de blocage de lemetteur
Caractristiques
-
-
-
-
-
Variantes send
-
-
-
initialisation spcifique
-
-
ierr = rt_mbx_init(&Bal,taille)
ierr = rt_mbx_delete(&Bal);
50
Segmentation,
Mmoire pagine
pas new/delete ou malloc/free
-
kmalloc / kfree
solutions RT :
s allouer la mmoire de manire statique
- allocation dans une table de blocs limite
-
RTAI : Interruptions
l
l
l
l
52
masquage
encodeur
priorit
priorit
Acq
rt_global_cli() rt_global_sti()
rt_disable_irq(), rt_enable_irq()
IA
set
reset
Bus donnes
53
Installation
#define IT_CLAVIER 1
rt_request_global_irq(IT_CLAVIER,
mon_gestionnaire);
rt_free_global_irq(IT_CLAVIER);
void mon_gestionnaire(void) {
rt_pend_linux_irq(IT_CLAVIER);
Utilisation
traitement urgent
- rveiller tche endormie
-
54
fichiers /dev/nom
l
taille du mot : b, w, l
pause : _p : outl_p
55
Schmas classiques
l
BD : lecteur rdacteur
Client Serveur
l
l
tableau noir
56
AN
N
U
L/
rendre_m
onnaie();
FR
AN
C
EN
CO
R
E
IN
IT
R
ETO
U
R
SER
VI
AN
N
U
L/
rendre_m
onnaie();
PR
EPAR
ATIO
N
SER
VIR
/
deplacer_tasse();
FR
AN
C
ACTIF
PU
SH
/
preparer_cafe();
57
Process Linux
RTAI
Rt_fifo
Acqui
Appel
Genere_transition
Signal transition
Calcul Automate
Rendre monnaie
Dplacer tasse
Prparer caf
Afficher message
58
VII.RTAI : CONCLUSION
59
volution permanente
possibilits en phase de mise au point non
dtailles ici
-
Xenoma
-
POSIX, VxWorks,VRTX,pSOS+,ITRON,RTAI
60
volution permanente
possibilits en phase de mise au point non
dtailles ici
-
debug
Xenomai
61
RTAI-LAB
Spcification schmas-blocs
SCILAB/SCICOS
MATLAB/SIMULINK
Gnration code
+
Librairie RTAI-LAB
RTAI
Excution
http://www.rtai.org
http://www.scicos.org/
http://www.mathworks.com/products/simulink/
62
63
Some RTOS
RTOS
URL
(http://www.dspconsulting.com/rtos.html)
Processor
Licensing
Tornado, VxWorks
h"p://www.wrs.com
h"p://www.mvista.com
No
VRTX
h"p://www.mentor.com
OS-9 V3.0
h"p://www.microware.com
? + target
h"p://www.qnx.com
pSOS
h"p://www.isi.com
RTX
h"p://www.vci.com
x86, P5, P6
QNX
h"p://www.lynx.com
. + many other
64
(source : http://www.embedded.com/)
65
66
67
68
Choice of an RTOS
l
Hardware architecture,
What measuring ? => benchmarks
Premption duration, Task switching, semaphore, memory allocation,
services
Tools
69