Embedded Systems

Introduction

It gets real

Let us be honest: Embedded systems are the real $%Β‘&.

Not only has more nuance than software programming, it's fun as it gets. Most of their life most programmers don't get to see their code interacting with the real world. It interacts with Clients. Either other computers or humans. Only at the level of information exchange.

But with embedded systems the deployment of information into a terminal is not the service provided. Embedded systems interact with the real world.

It can be robotics, mechanized industry, providing labor, transport, communication, vision, control, energy... almost anything.

Concurrency

Concurrency is the management of time in the control flow.

It means that the processor has to distribute computing time among different tasks, but with the raise of Multi-Core processors, it became a matter of distributing tasks among processors too. Turning CPU time into a wiggly wobbly... stuff.

Safety and Security

Safety: The software must not harm the world.
Security: The world must not harm the software.
John Barnes - Safe and Secure Software 

A security-critical system is one in which it must not be possible for malicious input to alter the integrity of the system.

A safety-critical system is one that must be correct. It must meet it's specifications.

Freedom

Programming Languages are developed in a context.

The neoliberal tendencies of the 90s brought with it a raise in languages that focused on "freedom to". If you want to shoot your foot you should be damned right to do so!

But as tendencies changed in the 2000's and 10's to "freedom from" we switched to a more socially safe environment. People wanted to be free from second hand smoke, so we banned smoking in public areas. We wanted a planet free from pollution, so we adopted ecological policies. We wanted freedom from terrorism, so we increased security in airports. If you want to shoot me in my foot you must be damned crazy!

In programming languages politic tendencies, so to say, C/C++ is the most libertarian "do whatever you want" leaning. Ada, on the other hand, falls in the most social "freedom from" and "you can do whatever you want to yourself, but in a safe environment".

C := "Trust the programmer (individual)"

Ada := "Trust the system."

Who to Trust?

Well... trusting the programmer has some issues. For starters, our brains are excellent at interpreting intended meaning. Here you have an example of code in both Ada and C/C++. can you tell what's the intended meaning?

Ada

if streetlight = green then
  Car.Check_Distance;
  Car.Go_Forward;
 end if;

C/C++

if (streetlight=green) 
   Car.Check_Distance;
   Car.Go_Forward;

Did you catch the error in the C code? It is setting the variable streetlight to green, not checking if is green.

The point is not that "it is a simple mistake that no good programmer will make". I'm sure this simple statement won't happen to you (right?) the point is that when you read the C code it makes sense of what you intended. It can happen because the brain interprets. And with 3.000 lines of code... well... it will most certainly happen. If not to you, to someone. Bad programmers do exist (and usually consider themselves to be awesome programmers, so they don't double check.

Don't trust me yet? Well, did you notice that the car will go forward no matter the color of the streetlight? Missing parentheses are probably the most common error ever. C/C++ has more bibliography on coding techniques to avoid pitfalls than actual algorithm design. Isn't this a HUGE waste of time?

it is preferable for such pitfalls to be avoided in the first place, through appropriate language design and that is how Ada has approached this issue.