Embedded Systems 6. Real-Time Operating Systems: Lothar Thiele
Embedded Systems 6. Real-Time Operating Systems: Lothar Thiele
Embedded Systems 6. Real-Time Operating Systems: Lothar Thiele
Swiss Federal
Institute of Technology
6-1
Computer Engineering
and Networks Laboratory
Contents of Course
1. Embedded Systems Introduction
2. Software Introduction
3. Real-Time Models
4. Periodic/Aperiodic Tasks
7. System Components
10. Models
8. Communication
11. Architecture
Synthesis
5. Resource Sharing
6. Real-Time OS
12. Model Based Design
Software and
Programming
Swiss Federal
Institute of Technology
Processing and
Communication
6- 2
Hardware
Computer Engineering
and Networks Laboratory
Embedded OS
Why an OS at all?
Same reasons why we need one for a traditional computer.
Not all services are needed for any device.
Swiss Federal
Institute of Technology
6- 3
Computer Engineering
and Networks Laboratory
Embedded OS
Why is a desktop OS not suited?
Monolithic kernel is too feature reach.
Monolithic kernel is not modular, fault-tolerant, configurable,
modifiable, .
Takes too much space.
Not power optimized.
Not designed for mission-critical applications.
Timing uncertainty too large.
Swiss Federal
Institute of Technology
6- 4
Computer Engineering
and Networks Laboratory
6- 5
Computer Engineering
and Networks Laboratory
http://www.windriver.com/products/development_tools/ide/tornado2/tornado_2_ds.pdf
Windriver
Swiss Federal
Institute of Technology
6- 6
Computer Engineering
and Networks Laboratory
Swiss Federal
Institute of Technology
Standard OS
6- 7
Computer Engineering
and Networks Laboratory
Swiss Federal
Institute of Technology
6- 8
Computer Engineering
and Networks Laboratory
Swiss Federal
Institute of Technology
6- 9
Computer Engineering
and Networks Laboratory
Swiss Federal
Institute of Technology
6- 10
Computer Engineering
and Networks Laboratory
Interrupt
service
Timer
interrupt
Time service &
events
System calls
(trap)
Scheduling
&
dispatcher
Task
execution
Swiss Federal
Institute of Technology
6- 11
Computer Engineering
and Networks Laboratory
Practically important.
Swiss Federal
Institute of Technology
6- 12
Computer Engineering
and Networks Laboratory
6- 13
Computer Engineering
and Networks Laboratory
Context Switching
Swiss Federal
Institute of Technology
6- 14
Computer Engineering
and Networks Laboratory
Process States
Minimal Set of Process States:
terminate
wait
wait
run
end_cycle
dispatch
preemption
activate
Swiss Federal
Institute of Technology
signal
TIMER
ready
6- 15
idle
resume
Computer Engineering
and Networks Laboratory
Process states
Run:
A task enters this state as it starts executing on the processor
Ready:
State of those tasks that are ready to execute but cannot be executed
because the processor is assigned to another task.
Wait:
A task enters this state when it executes a synchronization primitive to
wait for an event, e.g. a wait primitive on a semaphore. In this case,
the task is inserted in a queue associated with the semaphore. The
task at the head is resumed when the semaphore is unlocked by a
signal primitive.
Idle:
A periodic job enters this state when it completes its execution and has
to wait for the beginning of the next period.
Swiss Federal
Institute of Technology
6- 16
Computer Engineering
and Networks Laboratory
Threads
A thread is an execution stream within the context of a thread
state; e.g., a thread is a basic unit of CPU utilization.
The key difference between processes and threads: multiple
threads share parts of their state.
Typically shared: memory.
Typically owned: registers, stack.
6- 17
Computer Engineering
and Networks Laboratory
Swiss Federal
Institute of Technology
6- 18
Computer Engineering
and Networks Laboratory
Process Management
Process synchronization:
In classical operating systems, synchronization and mutual
exclusion is performed via semaphores and monitors.
In real-time OS, special semaphores and a deep integration
into scheduling is necessary (priority inheritance protocols,
.).
Further responsibilities:
Initializations of internal data structures (tables, queues, task
description blocks, semaphores, )
Swiss Federal
Institute of Technology
6- 19
Computer Engineering
and Networks Laboratory
Communication Mechanisms
Problem: the use of shared resources for implementing
message passing schemes may cause priority inversion
and blocking.
Swiss Federal
Institute of Technology
6- 20
Computer Engineering
and Networks Laboratory
Communication mechanisms
Synchronous communication:
Whenever two tasks want to communicate they must be
synchronized for a message transfer to take place (rendezvous)
They have to wait for each other.
Problem in case of dynamic real-time systems: Estimating
the maximum blocking time for a process rendez-vous.
In a static real-time environment, the problem can be solved
off-line by transforming all synchronous interactions into
precedence constraints.
Swiss Federal
Institute of Technology
6- 21
Computer Engineering
and Networks Laboratory
Communication mechanisms
Asynchronous communication:
Tasks do not have to wait for each other
The sender just deposits its message into a channel and
continues its execution; similarly the receiver can directly
access the message if at least a message has been
deposited into the channel.
More suited for real-time systems than synchronous comm.
Mailbox: Shared memory buffer, FIFO-queue, basic
operations are send and receive, usually has fixed capacity.
Problem: Blocking behavior if channel is full or empty;
alternative approach is provided by cyclical asynchronous
buffers.
Sender
Empfnger
mailbox
Swiss Federal
Institute of Technology
6- 22
Computer Engineering
and Networks Laboratory
Swiss Federal
Institute of Technology
6- 23
Computer Engineering
and Networks Laboratory
6- 24
Computer Engineering
and Networks Laboratory
Example RT Linux
Init
Bash
Mozilla
scheduler
Linux-Kernel
driver
RT-Task
RT-Task
interrupts
I/O
RT-Linux
RT-Scheduler
interrupts
interrupts
Hardware
Swiss Federal
Institute of Technology
6- 25
Computer Engineering
and Networks Laboratory
RT-Task
Init
Bash
Mozilla
Linux-Kernel
driver
I/O, interrupts
Hardware
Swiss Federal
Institute of Technology
6- 26
Computer Engineering
and Networks Laboratory
Research issues:
Swiss Federal
Institute of Technology
6- 27
Computer Engineering
and Networks Laboratory