• microcontrollers

  • multiprocessing

  • multithreading

What is Ferntech?

Use case

System  ->  Controller(UMC)  ->  Subsystem  ->  Device

Infrastructure

Infrastructure

Infrastructure

Infrastructure

Infrastructure

Communication

MQTT

  • Message Queuing Telemetry Transport
  • MQTT topics
  • widely used for IOT
  • ~90 times faster than HTTP
  • supports ssl encryption

The controller

Controller's primary tasks

  1. Connect to the Web app
  2. Detect devices
  3. Monitor devices
  4. Configure devices
  5. Collect "historical data"
  6. Detect problems and notify the user

Controller's secondary tasks

  1. Handle unstable internet connections
  2. Handle slow internet connections
  3. Handle unstable power supply
  4. Handle weird devices' behaviours
  5. Provide emergent debug access to the programmer
  6. Take care of the resources - RAM/CPU/card memory...
  7. ....

In general..

...We need a long running process and can take care of all the tasks asynchronously.

How to make a long running process ?

Asynchrony != Parallelism

Process vs Thread

(vs GIL)

Demo time

Demo 1 - HTTP

Threads

Processes

vs

Demo 1 - HTTP

Threads

Processes

vs

Demo 2 - CPU

Threads

Processes

vs

Demo 2 - CPU

Threads

Processes

vs

Demo 3 - memory sharing

Threads

Processes

vs

Rule of thumbs:

  • Network/IO - multithreading 
  • CPU - multiprocessing
  • more processes != performance boost
  • Keep hierarchy simple!
  • Some times you can just "async-await"

Demo 4

Requirements:

Driver example

Back to the controller

  • Development
  • Bugfix
  • Testing 
  • Deployment

Q&A :)

Practical multiprocessing and multithreading for microcontrollers

By Hack Bulgaria

Practical multiprocessing and multithreading for microcontrollers

  • 1,041