Docsity

Real Time Operating System Lecture 1, Summaries of Embedded Systems

Toggle sidebar
bg1
RTOS 1 | Real-Time Operating Systems | Lecture notes Page 1
RTOS 1 – Real-Time Operating Systems
Embedded Systems · Lecture notes for exam revision · concept-first
0. The whole lecture in 30 seconds
• Embedded systems are getting complex, but products must reach the market fast, so designers reuse
components (IP = intellectual property, hardware or software).
• Reusing a normal OS (Windows/Linux style) is wasteful for an embedded device: too big, too many
unused functions, and no single OS fits every application. So we reconfigure the OS and keep only the
parts we need.
• An embedded OS / RTOS is structured differently: applications can talk directly to the kernel and
device drivers, protection is optional, privileged instructions are not needed, and interrupts can be wired
directly to handlers.
• Above all, an RTOS must be predictable: it must meet deadlines, give high-resolution timing, and
keep interrupt handling and disk access predictable.
• “Real time” means absolute (wall-clock) time, not just counting clock ticks.
1. Why do we even need to talk about an RTOS?
Not every embedded system is real-time, but very often there are real-time requirements. A
general-purpose OS approach usually cannot be applied directly.
The design squeeze (two competing pressures)
•Complexity is rising: multiple processors, hardware-software mixes, ASICs, all in one system. Designing
this takes more time.
•Time-to-market is shrinking: if you are late, you lose the business.
These pull in opposite directions. The standard escape is reuse of components.
Reuse and IP
•IP (Intellectual Property) = a ready-made, reusable block. Usually we think of hardware cores (a
processor core), but IP can also be software, for example an operating system.
• So the natural question is: can we simply reuse an existing OS?
Why we cannot just drop in a normal OS
• An embedded system is limited in payload, area, size and memory. It cannot be “too heavy”.
• A normal OS has lots of functions. An embedded application needs only a few.
•Rule to remember: unused functions cannot be tolerated. We cannot waste memory on code we never
run.
•No single OS fits all. Embedded systems appear in countless applications, so one OS cannot meet
every need.
Intuition: Packing for a trip. A normal OS is a giant suitcase with everything. An embedded system is a
small backpack. You pack only what this trip needs.
2. Reconfiguring an existing OS ("pack only what we need")
Goal: generate a lean, customised version of an OS for one specific application, without making it bulky or
inefficient. Think component-based design: pick the relevant components and plug them together.
pf3
pf4
pf5

Partial preview of the text

Download Real Time Operating System Lecture 1 and more Summaries Embedded Systems in PDF only on Docsity!

RTOS 1 – Real-Time Operating Systems

Embedded Systems · Lecture notes for exam revision · concept-first

0. The whole lecture in 30 seconds

  • Embedded systems are getting complex, but products must reach the market fast, so designers reuse components (IP = intellectual property, hardware or software).
  • Reusing a normal OS (Windows/Linux style) is wasteful for an embedded device: too big, too many unused functions, and no single OS fits every application. So we reconfigure the OS and keep only the parts we need.
  • An embedded OS / RTOS is structured differently: applications can talk directly to the kernel and device drivers , protection is optional, privileged instructions are not needed, and interrupts can be wired directly to handlers.
  • Above all, an RTOS must be predictable : it must meet deadlines , give high-resolution timing , and keep interrupt handling and disk access predictable.
  • “Real time” means absolute (wall-clock) time , not just counting clock ticks.

1. Why do we even need to talk about an RTOS?

Not every embedded system is real-time, but very often there are real-time requirements. A general-purpose OS approach usually cannot be applied directly.

The design squeeze (two competing pressures)

  • Complexity is rising : multiple processors, hardware-software mixes, ASICs, all in one system. Designing this takes more time.
  • Time-to-market is shrinking : if you are late, you lose the business.

These pull in opposite directions. The standard escape is reuse of components.

Reuse and IP

  • IP (Intellectual Property) = a ready-made, reusable block. Usually we think of hardware cores (a processor core), but IP can also be software , for example an operating system.
  • So the natural question is: can we simply reuse an existing OS?

Why we cannot just drop in a normal OS

  • An embedded system is limited in payload, area, size and memory. It cannot be “too heavy”.
  • A normal OS has lots of functions. An embedded application needs only a few.
  • Rule to remember: unused functions cannot be tolerated. We cannot waste memory on code we never run.
  • No single OS fits all. Embedded systems appear in countless applications, so one OS cannot meet every need.

Intuition: Packing for a trip. A normal OS is a giant suitcase with everything. An embedded system is a small backpack. You pack only what this trip needs.

2. Reconfiguring an existing OS ("pack only what we need")

Goal: generate a lean, customised version of an OS for one specific application, without making it bulky or inefficient. Think component-based design : pick the relevant components and plug them together.

Technique Idea Verdict Object-oriented approach

OS parts as classes. Start from a general class and make subclasses for specific needs. Example: a general Scheduler class, then a specialised scheduler subclass with one fixed policy and time quantum.

Popular and clean

Conditional compilation

Preprocessor statements like #if / #ifdef: only some code is compiled depending on the configuration.

Works, but code becomes highly unreadable Compile-time evaluation

Advanced compiler-level decisions, similar to conditional compilation.

Similar to above

Linker-time optimization

Many modules exist, but at link time you link only the ones the application needs and leave out the rest.

Very important and obvious Static data structures Prefer arrays over linked lists (dynamic structures) wherever possible.

Better, more predictable performance

Reconfiguring an OS trades size for testing effort

Full OS includes unused parts

Pick components by application need

Link only those leave out the rest

Custom lean OS no wasted memory

Test and verify every derived version

each new configuration is tested again

Diagram 1. Start from a full OS, pick only the components you need, link only those, and you get a lean custom OS. The catch is the loop at the bottom: every new configuration is a new OS that must be tested again.

Real examples

  • VxWorks : a popular embedded OS with a GUI configuration panel. You tick the components you want, tie them together, and get your own custom version.
  • eCos : an open-source real-time OS from Red Hat , with roughly 100 to 200 configuration points.

The downside of reconfiguration: testing

  • A single dedicated OS is tested once.
  • A reconfigurable OS produces a new version every time you configure it , and each derived version must be tested and verified again.
  • With 100-200 configuration points (eCos), the number of possible versions explodes, so verifying every one is very difficult.

Exam line: Reconfiguration gives flexibility and small size, but the price is a heavy testing and verification burden.

4. Protection and privileged instructions

Feature General-purpose OS Embedded OS / RTOS Path to devices Always via the OS Can go directly to driver or kernel Protection (base/limit registers, device protection, critical sections)

Essential Optional , since the system is mostly single-purpose Privileged instructions (only runnable in kernel mode, otherwise a system call is raised)

Needed to enforce protection Not required

Interrupt handling Through the kernel Device can connect directly to the interrupt line

Why drop them? Protection and privileged instructions exist to stop one process from interfering with another or with a device. If there is only one purpose and the system is already tested, that overhead is not needed.

Modern twist: because of security concerns (defence and other critical sectors), protection is now being added again at both OS and hardware level. This is a recent trend; traditionally embedded OSs treated protection as not critical.

5. Interrupts: the source of unpredictability - Interrupts are asynchronous : they can arrive at any time. That makes them a point of unpredictability. - In real-time systems we want two things: meet the time constraints and be predictable. So interrupts must be handled very carefully.

How it differs

  • General OS: an interrupt always goes through the kernel / OS.
  • Embedded OS: since the system is already tested and protection is not always needed, a device can connect directly to the processor's interrupt line , and the matching handler runs without going through the OS. This gives efficient control over a variety of devices.

Embedded systems let a device interrupt its handler directly

General OS

Embedded OS

Device Interrupt line Kernel / OS Handler

Device Interrupt line Handler

no OS in the path

Catch: one interrupt pin is wired to one handler. With no OS in the path, you cannot choose between routines by condition.

Diagram 3. The general OS adds a hop through the kernel. The embedded system skips it, which is faster and simpler, but loses the OS's ability to choose among handlers.

The catch (a favourite exam point)

With a direct connection, one interrupt pin maps to one piece of software. You cannot choose between several routines depending on conditions , because the device is wired straight to the pin. The OS is no longer there to make that decision.

6. Real-time capability

Definition: A real-time operating system is an operating system that supports the construction of real-time systems , so that real-time behaviour can be delivered.

Requirements of a real-time system (from this lecture)

A. Predictability. Timing behaviour must be predictable.

  • Do not disable interrupts for long. If interrupts are disabled for a long stretch, you may miss them and you no longer know when they will be served, so predictability is lost.
  • Use contiguous file allocation on disk. Normally files are scattered, so access time varies a lot (the next sector could be anywhere). Contiguous files give predictable head movement, which gives predictable access time.

B. Manage timing and scheduling, with deadlines.

  • On a PC you never give a compile job a deadline. In an RTOS, deadlines are central , and the OS must schedule so that timing and deadlines are honoured. Otherwise it is not real-time behaviour at all.

C. High-resolution timing. A timer that says “it will happen within an hour” is useless. The timer resolution must be fine enough for the application.

7. Why is it called "REAL" time? - Relative time (ticks): “Event A after 5 ticks, event B after 3 ticks.” This only tells you the gap between events. You have no idea of absolute time, and 5 ticks could even be an hour. It is also discrete , since computers work in discrete steps no matter how fine the resolution. - Absolute / real time (clock time): the actual physical time, in principle a real number. This is what real-time systems care about.

Real-time systems care about clock time, not just tick counts

Relative time (ticks)

Absolute time (clock time)

Event A Event B

only the gap between events is known

Deadline at a fixed clock time

anchored to a real clock: TAI or UTC

Diagram 4. Ticks tell you the spacing between events. A real-time deadline must be pinned to an actual clock time.

Memory trick for RTOS requirements: P-D-T P redictability (interrupts, contiguous files) • D eadlines (scheduling that honours them) • T iming resolution (fine-grained timers)

9. What comes next

The next lecture covers more requirements of real-time systems , and after that real-time scheduling problems.