



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Embedded Systems · Lecture notes for exam revision · concept-first
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.
These pull in opposite directions. The standard escape is reuse of components.
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.
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
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.
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.
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.
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.
A. Predictability. Timing behaviour must be predictable.
B. Manage timing and scheduling, with deadlines.
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.
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.