Professional Documents
Culture Documents
Embedded Systems Overview: - RTOS/EOS Design Concept
Embedded Systems Overview: - RTOS/EOS Design Concept
Process Management
Process Scheduling
Interrupt
IPC: Synchronization
IPC: Data Exchanging
Memory Management
Device Drivers
Power Management
Thread-safe function
The function called in a thread should not keep intermediate data
in variables that are shared between the different threads.
3
dynamic priority
The scheduler becomes more complex because it has to calculate
tasks priority on-line, based on dynamically changing parameters.
Earliest-deadline-first (EDF)
A task with a closer deadline gets a higher scheduling priority.
The scheduler needs not only to know the deadline time of all
tasks it has to schedule, but also their duration.
rate-monotonic scheduling.
A task gets a higher priority if it has to run more frequently.
This is a common approach in case that all tasks are periodic.
So, a task that has to run every n milliseconds gets a higher
priority than a task that runs every m milliseconds when n<m.
5
Challenges in RTOS
Interrupt latency
The time between the arrival of interrupt and the start of corresponding ISR.
Modern processors with multiple levels of caches and instruction pipelines
that need to be reset before ISR can start might result in longer latency.
Interrupt enable/disable
The capability to enable or disable (mask) interrupt individually.
Interrupt priority
to block a new interrupt if an ISR of a higher-priority interrupt is still running.
the ISR of a lower-priority interrupt is preempted by a higher-priority interrupt.
The priority problems in task scheduling also show up in interrupt handling.
6
Interrupt sharing
allow different devices to be linked to the same hardware interrupt.
check a status register on each of the devices that share the interrupt
calling in turn all ISRs that users have registered with this IRQ.
In Linux
Kernel registers one interrupt handler per IRQ.
The handler runs first (interrupt disabled), and then invoke one-by-one all
the application-registered ISRs (interrupt enabled) before user tasks.
Top half and Bottom half (softirq or tasklet)
Priority space
Priority inversion
using priority-based task scheduling and locking primitives should know
the priority inversion danger: a medium-priority job runs while a highpriority task is ready to proceed.
9
10
Priority Inheritance
12
Priority Ceiling
13
Demand paging
Not recently-accessed pages are swapped out to make room for other pages.
swapping is a non-deterministic thing (takes non-deterministic time).
MMU of an RTOS must support page locking, i.e., to lock pages of realtime tasks in the physical RAM, to avoid the paging overhead.
POSIX provides mlock() and mlockall() for this.
15
Memory sharing
One of the most efficient ways for tasks to communicate is through
shared memory. The OS has two major responsibilities for this:
(1) shared memory (de)allocation (2) access synchronization
RAM disks
hard disk access has non-deterministic overhead
part of the available RAM can used to emulate a hard disk; i.e., some
memory is organized and accessed as a file system.
When the RAM disk should preserve data when the power is switched off,
it is usually implemented as a flash disk.
Striped libraries
use stripped down version of libraries to save memory as much as
possible.
16
18