Have you ever thought about what stands behind embedded devices’ capability to react to external conditions instantly? Why do the lights in a smart home turn on within a second, reacting to movement, or why does resuscitation equipment turn on within milliseconds, reacting to respiratory failure, cardiac arrest, or other changes of patients’ health conditions?
The magic behind the reactive response of such devices is real-time computing. This article provides a deep look into real-time embedded systems, including their classification, design patterns and application examples.
Defining a Real-Time Embedded System
To understand what a real-time embedded system is, let’s first define the umbrella term: embedded system.
A general embedded system represents a device that has hardware elements and software specially designed for this hardware. Such devices aim to perform one or several dedicated functions. They can work either in isolation or as part of larger systems. The best examples are home appliances (washing machines), medical devices (blood pressure monitors), monitoring and control sensors in vehicles, information kiosks, and many more.
The standard hardware components comprise:
- a CPU
- RAM or ROM memory
- I/O ports
- signal converters
- computer buses
- various peripherals
- systems-on-chip (SOC)
- systems-on-module (SOM).
Note: all embedded systems have different hardware configurations depending on their purpose. For example, one device may have a display and a keyboard, while another will do without them.
Software components may include:
- an operating system (OS)
- application software
- management software.
Note: embedded solutions may be programmable (capable of updating and changing) or non-programmable. Complex solutions need an operating system, while primitive devices work without it.
Embedded systems can utilize two types of OS:
- GPOS (a general-purpose operating system) is used in personal computers and other systems that perform common tasks. A GPOS requires high-performance processing power and handles operations without observing time limits (i.e., the response time is not critical).
- RTOS (a real-time operating system) is used in sensors and devices that must complete operations within strict time constraints (i.e., the response time is critical). An RTOS needs less processing power, and its priority is to comply with time limits.
A real-time embedded system is a particular version of an embedded system that works on the basis of real-time computing represented by a dedicated type of operating system — RTOS.
Its working principles are as follows:
- Quick response to external factors: an embedded system must work within fixed time constraints.
- Predictability: an embedded system must be deterministic or predictable, meaning that no deviations are allowed.
- The deadline is above all: meeting the deadline is more important than other performance characteristics.
- Operational failures may lead to catastrophe: if a task does not meet time limits, it negatively affects users and may even lead to fatal results.
Categories of Real-Time Embedded Systems
Real-time embedded systems fall into three categories — soft, firm and hard — depending on the acceptability of violation of time constraints. Their classification is illustrated in the infographics.
- Hard — timing constraints must not be violated. For such built-in systems, it’s crucial that the deadline is met in all cases. No errors are acceptable as they will lead to harmful effects and the device will totally lose its operation value. An air defense system that needs to detect and intercept an attacking missile within milliseconds has this type of embedded system. Its failure jeopardizes human lives. Other examples are airplane sensors or self-driving car control systems.
- Firm — exceeding the deadline is occasionally permitted, though it is undesirable. Operating failures of firm real-time systems don’t result in harmful effects. But devices lose their performance value because of such failures. Manufacturing robots refer to this category.
- Soft — exceeding the deadline is acceptable. Response failures of soft real-time systems diminish user experience, but they don’t reduce the performance value at once. If such a system fails to meet a deadline, it will either recover or gradually diminish its operation. For example, TV router boxes and gaming consoles refer to soft real-time embedded systems. Time lags in their operation may happen, but they have either insignificant or no consequences.
So, we assume whether a system can exceed deadlines or not and what the consequences will be.
Design patterns are general coding concepts or templates that describe how to solve typical problems that may occur during the development of specific products. Their common usage in software engineering is reasonable: you get reliable development paradigms and streamline the workflow.
An embedded product development life cycle goes from an idea to concept, ending up with real-life implementation. To build a working product, software engineers leverage a range of embedded system design patterns.
- Architecture design patterns describe what modules you can use to create various architectural options.
- Object design patterns provide solutions that will help you manage various entities and resources in a system.
- Protocol design patterns help you implement protocol layers and make them seamlessly interact with each other.
Challenges of Developing Real-Time Embedded Systems
Embedded development is among the most challenging software engineering areas because it faces numerous design constraints that arise due to business requirements.
These refer to hardware components, the required characteristics of the device itself and external environmental factors. Embedded engineers usually have to create a product that should satisfy the following conditions:
- Definite device size
- Spatial constraints for device installation
- Limited memory and power consumption
- Certain environmental conditions for device operation (temperature, humidity, pressure)
The very essence of real-time systems is that they must respond to events within predefined time limits. The most severe challenge for developers is to create a system capable of meeting the deadline under any conditions. They must do accurate calculations and build the appropriate task scheduling system to succeed.
For real-time systems, it’s crucial to organize data processing strictly following timing constraints. Real-time operating systems comprise scheduling algorithms that are responsible for managing these constraints. Thus, quick responses to events directly depend on which scheduling algorithm you choose for your real-time embedded solution.
There are preventive and non-preventive algorithms, and software engineers can choose from several popular types.
- Priority scheduling. This algorithm prioritizes all tasks and puts forward the task with the highest priority to be performed first by the processor. A preventive version of the algorithm stops a running task if there is another one with a higher priority in the queue. A non-preventive version doesn’t stop running tasks, but a higher priority task will be the next in the line. This approach doesn’t suit tasks with equal priority.
- Round-robin scheduling. This is a preventive scheduling algorithm that doesn’t prioritize tasks. Instead, it allocates an equal time interval (e.g., 500 ms) for each task, and the CPU processes them one by one. One task may go several rounds to be completed. This approach is relatively easy and straightforward.
- First come, first served (FCFS). This is a non-preventive algorithm that puts tasks into the running state depending on the time they arrive. The process is straightforward: the task that comes first is the first to utilize the computing power. This algorithm ensures a high response time.
- Shortest job first (SJF). The non-preventive version of this algorithm allocates tasks depending on their execution time: the task with the shortest execution time is run next. The preventive variant can interrupt running tasks if a task with a shorter remaining execution period arrives.
Practical Applications of Real-Time Embedded Systems
The ubiquitous penetration of real-time embedded solutions into all industries and spheres of life can be explained by the enormous benefits they provide.
Let’s look at the most popular and beneficial applications of real-time embedded systems across industries.
Medical use cases of embedded systems are widespread globally. Real-time devices have taken root in healthcare for they are beneficial to both doctors and patients: they help control health conditions, improve diagnosis and treatment, and facilitate telemedicine.
Biomedical sensors are incorporated into wearables and implantable devices, diagnostic tools and equipment (MRI and CT scanners, ultrasound scans), laboratory analytical applications and much more.
Transport telematics based on embedded solutions has become extremely important for the transportation industry. Modern vehicles (cars, trucks, ships, trains, planes) are equipped with numerous sensors, GPS trackers and control systems that ensure safe driving and help prevent accidents.
In addition, they ensure online monitoring so that drivers, dispatchers and managers are continuously aware of all processes. This results in better decision-making, improved business efficiency and significant time and money savings.
Spacecraft are literally stuffed with real-time embedded devices because they can’t operate without ongoing monitoring and management.
Real-time embedded development is also the driving force behind industrial automation. In modern plants and factories, robotics, AI systems and IoT devices perform many processes, but they require continuous online supervision by human employees.
Monitoring sensors control assembly-line operation, and particularly machinery working conditions such as temperature, humidity, pressure, vibration and other variables, predicting possible failures. This practice is called predictive maintenance.
Smart homes and cities
The concepts of smart home and smart city are gaining popularity due to the development of Internet of Things technology and real-time embedded systems.
Smart lighting, heating and air conditioning that you can control via mobile applications, smart parking, communication systems, digital signage with multimedia content, surveillance systems all utilize real-time embedded systems to function.
The Importance of Developing Real-Time Embedded Systems
Many spheres today depend on digital technologies. What is more, instant automatic responses to external conditions are required from devices to handle many operations successfully and, in many circumstances, they can be vital.
Now you see that real-time embedded solutions are all around for a good reason: they simplify numerous processes and increase the quality of life.
Highly qualified embedded developers at SaM Solutions have many practical projects under their belt, and they will be glad to help you bring your ideas to life. Don’t hesitate to contact us.