Systems

Think Radio on Grown-up Systems

More sophisticated embedded systems may use some or all of the following design elements, bringing them closer to the sophisticated multitasking systems found in phones and laptops.

Memory Management and Memory Leaks

Memory leaks are the bane of embedded devices. One solution is not to do heap memory allocation at all, and to use nothing but statically allocated memory, plus the stack. It very much depends on the product’s purpose, data requirements, and particularly if real-time behaviour is a necessity.

Physical and Virtual Memory

Physical memory is exactly what it sounds like, real physical memory occupying real physical locations in the memory map. In many cases that’s all that is required. If your product runs a single “application”, then with good design, even though every part of the code has access to every possible memory location, it does so in a disciplined way.

Virtual memory provides an abstraction from real physical addresses. If a process (more on processes later) attempts to access a location that it has no business doing, it can be prevented from doing so.

This is the basis of all protected memory systems that work to ensure any misbehaving section of code cannot bring the whole system down.

Threads and Processes

Threads can exist with or without virtual memory. A common arrangement is to have a ‘user’ thread and a ‘worker’ thread. The user thread runs with a higher priority, and ensures the user interface is responsive. The worker thread might do background processing tasks that can conveniently be halted and restarted. With a scheduler, it becomes possible to allocate a certain proportion of available processor time to each thread. However this arrangement isn’t essential to running background tasks, and a simpler solution might be a low-priority event in a single-threaded environment.

A process is a more sophisticated solution employing virtual memory, multiple threads and a scheduler. Here each running process has the ‘illusion’ of being the only one, with no awareness of, or ability to interact with other processes (except by inter-process communication), each with a real physical memory allocation (through the virtual memory system) and one or more threads of execution. The scheduler gives the process a time-slice in which to run.

Threads are the ‘unit’ of execution.
Processes are the ‘unit’ of memory protection.

Servers

A convenient way to organise complex computing tasks is for some of the processes to be ‘servers’ that exist to provide services to applications. Examples might be a file server, comms server, print server etc.

Linux

Finally, having covered all these component parts, we can consider Linux. Linux may not use all of them (although a full desktop system does). But cut-down and simplified Linux versions, suitable for embedded systems are now commonplace.

Raspberry Pi

Finally, finally, why consider custom hardware at all?

Raspberry Pi (RPi), and similar devices, offering a great deal of performance at a very reasonable price are also now a commonplace solution. If sufficient power is available, an almost off-the-shelf solution may be built, or RPi used to provide things like Wifi and USB support, via built-in drivers.