I2C SPI USB CAN eSPI Cable Testing View All Videos Quick Start Guides Software Downloads App Notes White Papers User Manuals Knowledge Base Sales Support About Us
Products Blog Sales Support Contact Search
An Introduction to Real-Time Operating Systems (RTOS) in Embedded Systems
Staff Writer

One of the earliest decision points in embedded systems design is whether the system will require real-time computing capabilities. Real-time computing describes the ability to react to inputs and deliver the prescribed output within a constrained time frame. Devices that use real-time computing are deployed in applications where their correct functioning can make the difference between life and death.

As an example, consider the airbag in a conventional family sedan. When the vehicle stops abruptly in the case of a collision, the airbag must be deployed in a split second to be effective for passengers. This means that the embedded microcontroller which controls the airbags must detect that a collision is happening and electronically trigger the release of vehicle airbags - all in just a fraction of a second. This capability is made possible by the technology of real-time computing.

In this introduction to real-time embedded systems, we'll give a high-level overview of what these unique embedded systems are, how they're designed and classified, and why their functionality is so critical in real world applications. We'll also offer some real-time embedded systems examples.

What is a Real-Time Embedded System?

A real-time embedded system combines the technologies of embedded systems and real-time computing. To achieve the most complete and accurate description, we begin with a deeper look at the defining features of these technologies.

Embedded Systems

Embedded systems are hardware-and-software computer systems that perform a dedicated function with a larger system or device. An embedded system typically consists of a microcontroller, also called a computer-on-a-chip. Microcontrollers are equipped with a CPU, memory (RAM and ROM), I/O ports, a communication bus, timers/counters, and DAC/ADC converters. 

Embedded systems have three defining characteristics that embedded systems engineers should be aware of:

  1. Embedded systems are application-specific. While a general-purpose computer could run any compatible application of the user's choosing, an embedded device is programmed and optimized to run one specific application that satisfies its real world function.
  2. Embedded systems do not always have a user interface. A general-purpose computer incorporates a user interface where a user can input instructions or otherwise interact with the system.  An embedded system is often hidden inside a device such that the user does not interact directly with the embedded system itself. Embedded systems typically receive input from sensors or a connected data source instead of directly from the user.
  3. Embedded systems are hardware and software. An embedded device consists of a software application that delivers a specific function or service, along with the necessary hardware to run the application in the live environment. The core challenge of embedded systems design is to create a product that solves the problem while meeting strategic and business requirements for product size, power consumption, and unit cost.

Real-Time Operating Systems

Real-time computing describes the capability of a computing system to respond to a given input within a tightly constrained time frame. In the context of embedded systems, engineers implement real-time computing by installing a special type of operating system onto the embedded device. Operating systems can be conceptualized as the bridge between embedded hardware and software.  There are two basic types for embedded engineers to choose from:

  1. General Purpose Operating System (GPOS) - A GPOS is the software layer that sits between the hardware and the application in an embedded system. GPOS consists of the kernel, memory management, networking, and other services that are provided to the application. A GPOS is used in cases where tasks are not time-sensitive and computing power is valued more highly than rapid response times.
  2. Real-Time Operating System (RTOS) -  An RTOS is used for embedded systems applications that are time-sensitive or time-critical. A time-critical task is defined as one where the task must be performed within specified time constraints to avoid negatively impacting users. In a time-critical system, the value of completing a task is linked to its timeliness and tasks that are completed past the deadline may have a negative value. RTOS includes a task scheduler component whose goal is to ensure that critical tasks meet their deadline, even when it means sacrificing other areas of performance.

Real-time embedded systems are those that incorporate a real-time operating system, ensuring that the device can respond to sensory inputs within the time constraints specified by the embedded software. Real-time embedded systems are further classified based on the type of real-time response they provide.

Real-Time Embedded Systems Air bag deployment depends on the rapid response time of a real-time embedded system with Hard RTOS; Image by Marcel Langthim from Pixabay

3 Classifications for Real-Time Embedded Systems

Real-time embedded systems combine the functionality of a real-time operating system with a microcontroller (hardware) and unique application (software) to solve a business problem. There are three types of RTOS that differ in function based on the time constraints associated with their application.

Hard RTOS - A hard RTOS is implemented when it is crucial that no deadlines are missed and all tasks are completed within the prescribed time frame. In a hard RTOS, delays in the system are strictly time-bound to ensure that deadlines are met at a 100% rate and any missed deadline is considered a system failure. Firm RTOS - In a firm RTOS, errors are occasionally permissible but there is an understanding that missed deadlines result in degraded performance of the device. A device using a firm RTOS may occasionally miss a deadline, but the application can recover as long as failures are relatively infrequent.  Soft RTOS - In a soft RTOS, user experience is optimized when tasks are completed on-time but performance is not totally degraded when deadlines are missed. Consider a video game console that runs a game engine: it must schedule tasks and complete them on time for the game to run smoothly, but a little bit of lag or an occasional hiccup in performance does not necessarily ruin the experience for the player. 

Real-Time Embedded Systems Design Patterns

A design pattern describes a repeatable solution to a problem that commonly occurs when designing a specific type of device. The pattern acts as a description of how an engineer can solve a specific problem, a framework taken from a solution to a similar problem. Design patterns help embedded systems engineers avoid reinventing the wheel as they develop their products, limiting their total debug time and reducing overall time-to-market. 

The following design patterns are useful for engineers building real-time embedded systems:

Object Design Patterns

  • Manager Design Pattern - The manager object can be implemented to keep track of multiple entities in embedded systems applications where the system must support several entities of the same or similar type.
  • Resource Manager Pattern - This design pattern can be used to implement a centralized resource manager for multiple resources of the same type.
  • Half Call Design Pattern - This design pattern is used for implementations that require interactions between more than one communication protocol. 

Protocol Design Patterns

  • Protocol Stack Design Pattern - This design pattern can be used to implement a layered protocol and provides for dynamic insertion and removal of protocol layers within the stack.
  • Protocol Layer Design Pattern - This design pattern is used to decouple protocol layers and reduce dependencies between layers of the protocol stack.
  • Protocol Packet Design Pattern - This design pattern offers a simplified buffering architecture for real-time embedded systems, implementing a single buffer that supports addition and extraction of the various protocol layers.

Architecture Design Patterns

  • Processor Architecture Patterns- There are many possible architectures for real-time embedded systems that have been documented as a design pattern. Each architecture design pattern specifies its own processes and modules along with the corresponding roles and responsibilities. Some available options include:

    • Operations & Maintenance Processor Architecture
    • Central Manager Architecture
    • Module Manager Architecture
    • Device Controller Architecture
  • Feature Coordination Pattern - In real-time embedded systems design, each task should include a feature coordinator. Feature coordination ensures that a feature does not fail to complete a result of packet loss or task failure. Feature coordination also helps embedded systems recover after a request time-out.
  • Timer Management Design Patterns - Timer management is a key feature of real-time embedded systems. Timer management design patterns are used frequently to address the requirements of real-time embedded devices. They include patterns for failure detection, message loss and fault recovery sequences, inactivity detection, sequencing operations, and other features that ensure tasks are completed by the specified deadline.

Real-Time Embedded Systems Examples

Let's review a few short examples of real-time embedded systems - one from each of the classifications outlined above.

We've already mentioned vehicle airbags, which you may have identified as an example of a hard real-time embedded system. Remember the criteria for hard real-time: the value of the task is zero or negative when the deadline is missed. In this case, a missed deadline means that the airbag was not deployed in time to protect passengers in the collision.

A cardiac pacemaker could be an example of a soft real-time embedded system. Pace-makers control the heartbeat by sending electronic pulses to the heart when the attached electrical nodes detect cardiac arrhythmia in the patient. The electrical pulses help the patient's heart return to a normal beating pattern. While pace-makers provide a necessary and life-saving function, they can function effectively even while missing the occasional task deadline.

A manufacturing assembly line with robotic components might require a firm real-time embedded system. Imagine a machine that performs a simple task like sealing a toothpaste tube. If a task misses a deadline, the process fails and a single tube of toothpaste might be ruined - but as long as this happens infrequently and does not cause a major disruption, it is not considered a system failure.

Summary

Real-time embedded systems offer the predictability and performance that help embedded systems engineers build products that tackle real-world problems. 

At Total Phase, we build the products that embedded systems developers need to change the world - development kits to help get you started, host adapters to support the product development process, and protocol analyzers to reduce debug time and help get your product to market even faster. 

We're also supporting embedded systems development through our knowledge base where we offer tips and advice on real-time embedded programming and a host of other topics.

Learn More About Our Products