Real-time and embedded systems operate in constrained environments in which memory and processing power are limited. They must provide their services within strict time deadlines to their users and to the surrounding world to which they interface. It is these memory, speed and timing constraints that dictate the use of real-time operating systems in embedded software.
In the discussion that follows, we will focus on the kernel—that part of an operating system that provides the most basic services to application software running on a processor. Kernel services typically include:
- Scheduling for application software tasks
- Communication and synchronization between tasks
- Dynamic allocation of RAM
- Timer services
Basic kernel services
The kernel of a real-time operating system (RTOS) provides an abstraction layer that hides from application software the hardware details of the processor (or set of processors) upon which the application software will run. In doing so, it supplies five main categories of basic services to application software (Figure 1).
Figure 1. Basis services provided by a real-time operating system kernel
The most basic category of kernel services is task management. This set of services allows application software developers to design their software as a number of separate "chunks" of software—each handling a distinct topic, a distinct goal, and perhaps its own real-time deadline. Each separate chunk of software is called a task. Services in this category include the ability to launch tasks and assign priorities to them. The main RTOS service in this category is the scheduling of tasks as the embedded system is in operation. The task scheduler controls the execution of application software tasks, and can make them run in a very timely and responsive fashion. (Later we will see the details of how this is done.)
The second category of kernel services is intertask communication and synchronization. These services make it possible for tasks to pass information from one to another, without danger of that information ever being damaged. They also make it possible for tasks to coordinate, so that they can productively cooperate with one another. Without the help of these RTOS services, tasks might well communicate corrupted information or otherwise interfere with each other. Since many embedded systems have stringent timing requirements, most RTOS kernels also provide some basic timer services, such as task delays and time-outs.
Many (but not all) RTOS kernels provide dynamic memory allocation services. This category of services allows tasks to "borrow" chunks of RAM memory for temporary use in application software. Often these chunks of memory are then passed from task to task, as a means of quickly communicating large amounts of data between tasks. Some very small RTOS kernels intended for tightly memory-limited environments do not offer dynamic memory allocation services.
Many (but not all) RTOS kernels also provide a device I/O supervisor category of services. These services, if available, provide a uniform framework for organizing and accessing the many hardware device drivers that are typical of an embedded system.
In addition to kernel services, many RTOSs offer a number of optional add-on operating system components for high-level services such as file system organization, network communication, network management, database management, and user-interface graphics. Although many of these add-on components are much larger and much more complex than the RTOS kernel, they rely on the presence of the RTOS kernel and take advantage of its basic services. To keep memory consumption to a minimum, each of these add-on components is included in an embedded system only if its services are needed.
In this article, we will focus on the basic RTOS kernel services for task management, intertask communication and synchronization, and dynamic memory allocation.