Beruflich Dokumente
Kultur Dokumente
Summary
1. Introduction
2. Real-time operating systems (RTOS)
3. RTOS Market
4. POSIX 1003 Standard
5. RTEMS operating system
(a) POSIX thread model of RTEMS and fixed priority
scheduling
(b) Synchronization tools
(c) Clocks and timers management
6. Summary
7. References.
Introduction
Properties/constraints of embedded real-time
systems :
Summary
1. Introduction
2. Real-time operating systems (RTOS)
3. RTOS Market
4. POSIX 1003 Standard
5. RTEMS operating system
(a) POSIX thread model of RTEMS and fixed priority
scheduling
(b) Synchronization tools
(c) Clocks and timers management
6. Summary
7. References.
7/55
Target machine
GDB
rsh
rGDB
Windows/Linux
Monitor
NFS disk
Summary
1. Introduction
2. Real-time operating systems (RTOS)
3. RTOS Market
4. POSIX 1003 Standard
5. RTEMS operating system
(a) POSIX thread model of RTEMS and fixed priority
scheduling
(b) Synchronization tools
(c) Clocks and timers management
6. Summary
7. References.
25
21.42
19.7
Percents
20
15
12.84
10.19
10
6.64 5.96
4.69
sN
T
O
S9
V
RT
Ly X
nx
iR OS
W MX
in
do III
w
sC
N
uc E
le
us
+
R
RT T
L X
Ch inu
or x
us
O
O S
th
er
s
3.89
om
em
ad
vx
do
e R OS
TO
S
W QN
X
in
pS
or
ks
Summary
1. Introduction
2. Real-time operating systems (RTOS)
3. RTOS Market
4. POSIX 1003 Standard
5. RTEMS operating system
(a) POSIX thread model of RTEMS and fixed priority
scheduling
(b) Synchronization tools
(c) Clocks and timers management
6. Summary
7. References.
Meaning
POSIX 1003.1
POSIX 1003.2
Real-time extensions.
Threads
POSIX 1003.5
...
Each chapter provides a set of services. A service may be mandatory
or optional.
University of Brest Page 14/55
Meaning
_POSIX_PRIORITY_SCHEDULING
_POSIX_REALTIME_SIGNALS
Real-time signals
_POSIX_ASYNCHRONOUS_IO
Asynchronous I/O
_POSIX_TIMERS
WatchDogs
_POSIX_SEMAPHORES
Synchronization tools
...
Summary
1. Introduction
2. Real-time operating systems (RTOS)
3. RTOS Market
4. POSIX 1003 Standard
5. RTEMS operating system
(a) POSIX thread model of RTEMS and fixed priority
scheduling
(b) Synchronization tools
(c) Clocks and timers management
6. Summary
7. References.
16
# d e f i n e CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 40
# d e f i n e CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
# d e f i n e CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
# i n c l u d e < s t d i o . h>
v o i d POSIX_Init ( v o i d argument ) {
p r i n t f ( " H e l l o wo r l d RTEMS\ n " ) ;
exit (0);
r e t u r n NULL ;
}
O2 g g
mcpu=cypress msoftf l o a t
o oo p t i m i z e / h e l l o . exe
oo p t i m i z e / i n i t . o
data
bss
dec
109840
3652
5360
118852
hex f i l e n a m e
1d044 oo p t i m i z e / h e l l o . exe
# f i l e oo p t i m i z e / h e l l o . exe
Summary
1. Introduction
2. Real-time operating systems (RTOS)
3. RTOS Market
4. POSIX 1003 Standard
5. RTEMS operating system
(a) POSIX thread model of RTEMS and fixed priority
scheduling
(b) Synchronization tools
(c) Clocks and timers management
6. Summary
7. References.
Spawn a thread.
Parameters: code, attributes, arg.
Terminate a thread.
Parameters : return code.
Return thread id
Delete a thread.
Parameters : thread id.
Wait for
the completion of a son.
Delete relationship between
a son and its father.
Send a signal to a thread.
Change signal mask
University of Brest Page 25/55
of a thread.
POSIX policies:
1. SCHED_F IF O: when a thread becomes ready, it is inserted in the tail of its
corresponding priority queue. Give the processor to the thread in the head of the
queue. When blocked or terminated, a thread leaves the queue and the next
process/thread in the queue gets the processor.
2. SCHED_RR: SCHED_F IF O with a time quantum. A time quantum is a maximum
duration that a thread can run on the processor before preemption by an other thread
of the same queue. When the quantum is exhausted, the preempted thread is moved
to the tail of the queue.
3. SCHED_OT HER: implementation defined (may implement a time sharing
scheduler).
b
0
Task
Ci
Si
Priority
Policy
FIFO
RR
RR
FIFO
c b c d d d
4 5
a d d d
7
b c b b
10
15
0
1
2
Scheduling parameters :
struct sched_param
{
int sched_priority;
...
};
We can perform scheduling parameter updates :
Read maximum
priority level
sched_get_priority_min
Read minimum
priority level
sched_rr_get_interval
Read quantum
sched_yield
pthread_setschedparam
Assign priority/policy
pthread_getschedparam
Read priority/policy
Meaning
detachstate
schedpolicy
scheduling policy
schedparam
inheritsched
stacksize
stackaddr
Allocate an attribute
Remove an attribute
Set a value to an attribute
Read the value of an attribute
Summary
1. Introduction
2. Real-time operating systems (RTOS)
3. RTOS Market
4. POSIX 1003 Standard
5. RTEMS operating system
(a) POSIX thread model of RTEMS and fixed priority
scheduling
(b) Synchronization tools
(c) Clocks and timers management
6. Summary
7. References.
Synchronization tools
Different types:
1. Mutexes.
2. Counting semaphores.
3. Conditional variables.
Mutex (1)
Semaphores that are optimized for critical section: can not be used elsewhere.
Composed of a queue and a boolean.
Semaphore queue : threads are sorted according to their priority if SCHED_F IF O
or SCHED_RR.
Behavior can be tailored with attributes:
Attribute name
Meaning
protocol
Inheritance protocol
pshared
prioceiling
Mutex (2)
pthread_mutex_init
pthread_mutex_lock
pthread_mutex_trylock
pthread_mutex_unlock
pthread_mutex_destroy
pthread_mutexattr_init
pthread_mutexattr_setAT T
pthread_mutexattr_getAT T
Initialize a mutex
Lock ;
may be blocking
Try to lock ;
unblocking primitive
Unlock
Delete a mutex
Initialize an
attribute
Set an attribute
Read an attribute
Initialize a semaphore
Delete a semaphore
Unlock semaphore.
Lock a semaphore ;
may be blocking
sem_trywait Unblocking locking semaphore
s t r u c t timespec d e l a y ;
i f ( s e m _ i n i t (&sem , 0 , 0 ) ! = 0 )
perror ( " sem_init " ) ;
i f ( p t h r e a d _ c r e a t e (& i d , NULL , th , NULL ) ! = 0 )
perror ( " pthread_create " ) ;
d e l a y . tv _ s e c =4;
d e l a y . tv_nsec =0;
Summary
1. Introduction
2. Real-time operating systems (RTOS)
3. RTOS Market
4. POSIX 1003 Standard
5. RTEMS operating system
(a) POSIX thread model of RTEMS and fixed priority
scheduling
(b) Synchronization tools
(c) Clocks and timers management
6. Summary
7. References.
Summary
1. Introduction
2. Real-time operating systems (RTOS)
3. RTOS Market
4. POSIX 1003 Standard
5. RTEMS operating system
(a) POSIX thread model of RTEMS and fixed priority
scheduling
(b) Synchronization tools
(c) Clocks and timers management
6. Summary
7. References.
Summary
RTOS, or monitor: portability (architecture),
configurability (resource available),cross-compiling,
RTOS adapted to each domain/application.
RTEMS : one process/several threads, several API
including POSIX.
POSIX API for real-time systems : thread and fixed
priority scheduling, semaphore/mutex and inheritance
protocols, timer/clock and periodic thread releases. =
may lead to the development of real-time
applications that can be compliant with real-time
scheduling theory.
Summary
1. Introduction
2. Real-time operating systems (RTOS)
3. RTOS Market
4. POSIX 1003 Standard
5. RTEMS operating system
(a) POSIX thread model of RTEMS and fixed priority
scheduling
(b) Synchronization tools
(c) Timers and signal management
6. Summary
7. References.
References
[GAL 95] B. O. Gallmeister. POSIX 4 : Programming for the Real World . OReilly and
Associates, January 1995.
[TIM 00] M. Timmerman. RTOS Market survey : preliminary result . Dedicated System
Magazine, (1):68, January 2000.
[VAH 96] U. Vahalia. UNIX Internals : the new frontiers. Prentice Hall, 1996.