Features Documentation Examples Repository Blog Contact

Process Management

What are Processes?

A process is like a separate logic task running in its own protected workspace. Think of it like each app on your smartphone - they run independently and can’t interfere with each other. Naturally, embedded devices don’t use flexibility of smartphones and run same tasks all the time. The advantage of process concept here is that they are separated from each other.

CMRX brings this concept to microcontrollers for the first time. Instead of having all your code mixed together in one big program, you can split it into separate processes that are isolated from each other.

How Processes Work in CMRX

Each Process Gets Its Own Space

Every process has:

  • Its own data memory: Can’t access other processes’ data. Data cannot be executed.
  • Its own stack: For function calls and local variables. There is one stack for every thread in process. Threads don’t see each other’s stack.
  • Its own services: Each process can define its own services that are available via RPC mechanism.

Note that unlike Linux or other POSIX-compliant systems in CMRX a process can exist without having any running thread. This scenario is usable in cases where process provides RPC services and/or is a driver whose design does not require existence of driver workqueue.

Multi-Threading Within Processes

What are Threads?

Threads are like multiple workers within the same process. They share the process’s memory but can do different tasks at the same time. Each thread can have different priority configured. There is no main thread in process and if last thread of process ends the process is not destroyed.

POSIX-Like Threading

CMRX supports standard threading functions that work like desktop computers:

  • thread_create() - start a new thread
  • thread_join() - wait for a thread to finish
  • mutex_lock() - coordinate between threads
  • kill() - send a signal to another thread

It also supports another synchronization mechanism such as notify/wait.

64kB of protected memory ought to be enough for everyone.