Real-time systems are a class of embedded systems where the time of reaction is critical. The consequences of not reacting in time vary between different applications. Based on severity, real-time systems are classified as follows:
- Hard real time: Missing a deadline is not acceptable and considered a system failure. These are usually mission-critical systems in airplanes, cars, and power plants.
- Firm real time: Missing a deadline is acceptable in rare cases. The usefulness of the result is zero after the deadline. Think about a live streaming service. A video frame delivered too late can only be discarded. This is tolerable provided it happens infrequently.
- Soft real time: Missing a deadline is acceptable. The usefulness of results degrades after the deadline, causing degradation of the overall quality, and should be avoided. Such an example is capturing and synchronizing data from multiple sensors.
Real-time systems are not necessarily required to be super fast. What they need is predictable reaction time. If a system can normally respond to an event within 10 milliseconds, but it often takes much longer, it is not a real-time system. If a system responds within 1 second guaranteed, this constitutes hard real time.
Determinism and predictability are the main traits of real-time systems. In this chapter, we will explore potential sources of unpredictable behavior and ways to mitigate them.
This chapter covers the following topics:
- Using real-time schedulers in Linux
- Using statically allocated memory
- Avoiding exceptions for error handling
- Exploring real-time operating systems
The recipes in this chapter will help you better understand the specifics of real-time systems and learn some best practices of software development for this kind of embedded system.