Lec RTOS 1x2
Lec RTOS 1x2
(Working Draft)
More Precisely?
The system allows access to sensitive resources with
defined response times.
o Maximum response times are good for hard real-time
o Average response times are ok for soft real-time
How to do an RT Extension?
Compliant kernels
o Takes an existing RTOS and make it execute other UNIX
binaries (see LynxOS).
o Interfaces need to be reprogrammed.
o Behavior needs to be correctly reimplemented.
Problems:
A single failing hard task can kill the whole system.
The RTOS kernel requires its own IO drivers.
How to do an RT Extension?
Core kernel modifications
o Takes the non-RT operating systems and modifies it to
become an RTOS.
Problem: (need to do all this)
o Implement high-resolution timers
o Make the kernel preemptive
o Implement priority inheritance
o Replace FIFOs with priority queues
o Find and change long kernel execution paths
eCos
o Hardware Abstraction Layer (HAL)
o Real-time kernel Counters -- Count event occurrences
Clocks -- Provide system clocks
Interrupt handling Alarms -- Run an alarm function
Mutexes -- Synchronization primitive
Exception handling Condition Variables -- Synchronization primitive
Semaphores -- Synchronization primitive
Choice of schedulers Mail boxes -- Synchronization primitive
Event Flags -- Synchronization primitive
Thread support
Spinlocks -- Low-level Synchronization Primitive
Scheduler Control -- Control the state of the scheduler
Interrupt Handling -- Manage interrupt handlers
Rich set of synchronization primitives
Timers, counters and alarms
Choice of memory allocators
Debug and instrumentation support
Component-based Kernels
eCos
o µITRON 3.0 compatible API
o POSIX compatible API
o ISO C and math libraries
o Serial, ethernet, wallclock and watchdog device drivers
o USB slave support
o TCP/IP networking stacks
o GDB debug support
All components can be added through a
configuration file that includes and excludes parts of
the source code.
RTOS Predictability
All components of the RTOS must be predictable
o System calls, device drivers, kernel internal management
Memory access
o Page faults, lookup time, caches
Disk access
o Bound for head movement while reading/writing data
Net access
o Bound for time for transmission, switching
o Dropped packets??
Scheduling must be deterministic
Spring ‘10 CIS 541 18
Admission Control
Admission control is a function that decides if new
work entering the system should be admitted or
not.
To perform this it requires:
o A model of the state of system resources
o Knowledge about incoming requests
o An algorithm to make the admission decision
o Policies for actions to take upon admission and rejection
Admission Control
The admission algorithm requires preanalyzed tasks
Shared data
Execution time
Precedence information
Importance level
Deadlines
Positive decision assigns time slices to the task
Negative decision has options:
o Run a simpler version of the task
o Run on a different machine
o Reject the task
Task Declaration
RTOSs tailored to microprocessors often require a
static declaration of tasks.
Advantages are:
o Simple check that the system has sufficient resources.
o No admission control necessary.
o No overhead introduced by the admission test.
o No thread spawning problems
Configurability
As mentioned with component-based RTOS, the
system must be configurable.
Include only components needed for the present
system
Components must be removable
o Inter-module dependencies limit configurability
Configuration tailors OS to system
o Different configuration possibilities
Example RoboVM (PICDEM and modular robot).
Tasks Implementation
At most 16 events.
The task state is encoded in the following variables:
o tsk_X_state_ID
Bits 0-3: task identifier
Bit 4: unused
Bit 5-7: task state
o tsk_X_active_prio
Bits 0-3: task priority
Bit 5-7: activation counter
Event Implementation
At most 16 events.
The event status is encoded in these two variables:
o EventMaskType event_X
For each task 16 possible events.
o EventMaskType wait_X
Each task can listen for 16 possible events.
Alarm Implementation
Each tick the alarm counters get incremented by
one.
If the alarm value equals the counter value, then the
alarm will cause an event.