Sunday, June 21, 2020

Why Real Time Embedded Linux ?


Why Real Time Embedded Linux ?

You might hear of embedded Linux for real time very often. It sounds the entire embedded world depends on this. The question really contains 3 important concepts, we can break this question into 3 sub-questions based on these 3 concepts.

Why Linux ?

This is a generic question, easy for public to understand. Linux is Open source, less legal issues, popular, easier to get support, APIs and expertise. etc.

Why Embedded (vs Desktop Linux) ?

A bit more technical.

1. Embedded Linux system usually requires great reliability. Desktop Linux may have >100M code installed, with a lot of un-necessary features. Embedded Linux typically have 1M foot print, with only required feature installed.

2. Resource constraint. Embedded Linux has no HDD, and its non-volatile storage is life constraint. This coupled with the reliability and power safe requirement, a large portion of embedded linux system is actually read only.

Why Real Time ?

A common mis-understanding about Real Time is that Real Time means Fast, actually Real Time means deterministic. In other words, to complete a task within a specified time, otherwise will lead to an error condition. For example, a dish washer need to stop water filling in Read Time fashion, but screen display update may not be real time.

We classify a task either deterministic or in-deterministic, so the concept of soft Real Time should be obsolete.

Linux is not intrinsically deterministic, there are processed can run to completion. Hence, we need some other modification to make Embedded Linux real-time, mainly two ways, use a RealTime kernal and make regular Linux as a process. or use Preempt_RT, break down Linux locked processes, and put main ISR routine to a task, only left signaling inside ISR, like FreeRTOS. In practical, we can control the worst case latency to be less than 100 micro-seconds, good enough for Real-Time applications.

ARM in a nutshell.

What is ARM ?

ARM is an Advanced RISC Machine,. 

It is a RISC not CISC processor.  It is basically a LOAD-STORE architecture, where data processing operations are only between registers and does not involve any memory operations. 

It is a 32 bit processor and also has variants of 16 bit and 8 bit architecture, so a word is 32 bits, not 16 bits.

It got auto-increment and auto decremented addressing modes to optimize program loops, which is not very common with RISC processors.

It has a very good speed vs power consumption ratio which makes it suitable for embedded system.

It has 3 stages pipe-line: Fetch, Decode and Execute. 

7 sounds a lucky number for ARM: 

It has 7 operating modes:  Supervisor mode;  User Mode, System Mode, Fast Interrupt Mode, Interrupt Mode, Undefined mode and abort Mode. 

It has 7 interrupts/exceptions, Reset, Undefined, Pre-fetch abort, data abort, software interrupt, FIQ and IRQ, make ARM enter 5 modes, User Mode and System Mode do not need interrupt to enter,

It has 7 addressing modes: immediate mode, index mode, indirect mode, absolute (Direct) mode register mode, displacement mode and Auto-increment/Auto'decrement mode.