6.0 Introduction To Real-Time Operating Systems (Rtos)
6.0 Introduction To Real-Time Operating Systems (Rtos)
6.0 Introduction To Real-Time Operating Systems (Rtos)
6.0 Introduction
A more complex software architecture is needed to handle multiple tasks,
coordination, communication, and interrupt handling – an RTOS architecture
Distinction:
Desktop OS – OS is in control at all times and runs applications, OS runs in
different address space
RTOS – OS and embedded software are integrated, ES starts and activates the
OS – both run in the same address space (RTOS is less protected)
RTOS includes only service routines needed by the ES application
RTOS vendors: VsWorks (we got it!), VTRX, Nucleus, LynxOS, C/OS
Most conform to POSIX (IEEE standard for OS interfaces)
Desirable RTOS properties: use less memory, application programming interface,
debugging tools, support for variety of microprocessors, already-debugged
network drivers
6.0 INTRODUCTION TO RTOS
6.1 Tasks – 1
Issue – Scheduler/Task signal exchange for block-unblock of tasks via function calls
Issue – All tasks are blocked and scheduler idles forever (not desirable!)
Issue – Two or more tasks with same priority levels in Ready state (time-slice, FIFO)
Each tasks has its won context - not shared, private registers, stack, etc.
In addition, several tasks share common data (via global data declaration; use of
‘extern’ in one task to point to another task that declares the shared data
Shared data caused the ‘shared-data problem’ without solutions discussed in Chp4 or
use of ‘Reentrancy’ characterization of functions
(See Fig 6.5, Fig 6.6, Fig 6.7, and Fig 6.8)
6.0 INTRODUCTION TO RTOS
6.2 Tasks – 2
See Fig 6.9 – Where are data stored in C? Shared, non-shared, or stacked?
See Fig 6.10 – Is it reentrant? What about variable fError? Is printf reentrant?
If shared variables are not protected, could they be accessed using single assembly
instructions (guaranteeing non-atomicity)?
6.0 INTRODUCTION TO RTOS
Simple semaphores – Binary semaphores are often adequate for shared data problems
in RTOS
The nuclear reactor system: The issue of initializing the semaphore variable in a
dedicated task (not in a ‘competing’ task) before initializing the OS – timing of tasks
and priority overrides, which can undermine the effect of the semaphores
Fig 6.15 – a reentrant function, protecting a shared data, cErrors, in critical section
Variants:
Binary semaphores – single resource, one-at-a time, alternating in use (also for
resources)
Counting semaphores – multiple instances of resources, increase/decrease of
integer semaphore variable
Mutex – protects data shared while dealing with priority inversion problem