Realtime means a task must start running and finish
by a certain deadline, usually in response to an
asynchronous event like a button being pushed.
This is not necessarily "fast", but "timely".
"Soft" realtime: late is bad. Example: fax machine.
Missed deadline could be perceived by the user as
"This stupid machine is too slow", or "I don't know
why, but sometimes you must push that button twice"
"Hard" realtime: late is wrong. Example: fly-by-wire
system. Missed deadline here could crash the plane.
Realtime OS (RTOS) is sometimes just a library of code
that can be used in an embedded system. More often, it
contains features that let a programming problem be
decomposed into tasks:
- Support for installable interrupt handlers, like the
getvect() and setvect() functions
- Code runs with interrupts enabled as much as possible,
so interrupts aren't missed or serviced too late
- Interrupt bottom-halves (deferred interrupt processing)
- Features for inter-process communication (IPC) and
synchronization, such as message queues and semaphores
- Software timers and timeouts
- Preemptive multitasking
- Many (typically 256) task priority levels
- Priority inheritance. If a low-priority task holds a
resource needed by a high-priority task, the priority
of the low-priority task gets boosted temporarily,
letting it run until it frees the resource needed by
the high priority task.
- Variable time slice
Simple open-source RTOS: uC/OS:
http://www.ucos-ii.com/ports_v1.htm
Complex open-source RTOS: RTEMS:
http://www.rtems.com
Complex closed-source RTOS: QNX:
http://www.qnx.com