It is not about 1+1=2 (functional deterministic), it is about ensuring this calculation in a predefined time deterministic. Due to that a generic realtime does not exist. It is always in context of a specific timing question. Multiple notions of realtime used to describe how good the demands are meet:
Due to https://design.ros2.org/articles/realtime_background.html#memory-management :
- Hard real-time software systems have a set of strict deadlines, and missing a deadline is considered a system failure
- Soft real-time systems try to reach deadlines but do not fail if a deadline is missed. However, they may degrade their quality of service in such an event to improve responsiveness.
- Firm real-time systems treat information delivered/computations made after a deadline as invalid. Like soft real-time systems, they do not fail after a missed deadline, and they may degrade QoS if a deadline is missed.
Functional and time deterministic have one common aspect: correctness. If e.g. the execution miss a time slot it might lead to an error condition.
Linux PREEMPT reaches realtime via
- preemption support for critical sections (from Spinlock to RTMutex)
- preemption support for interrupts – keyword is latency when hardware wake up a kernel task (Interrupt Latency, Scheduling Latency)
- blocking of e.g. slow Intel MMX and SSE processor operations
- blocking of swap operations, because loading data from disk is a slow and unpredictable operation.
Also check https://lwn.net/Articles/146861/
Due to https://design.ros2.org/articles/realtime_background.html#memory-management a program better supports realtime via:
- Dynamic memory allocation can cause poor real-time performance. Calls to malloc/new and free/delete will probably result in pagefaults.
- Additionally, the heap allocates and frees memory blocks in such a way that leads to memory fragmentation, which creates poor performance for reads and writes, since the OS may have to scan for an indeterminate amount of time for a free memory block.