Amazon Video

Introduction to RTOS Part 12 – Multicore Systems | Digi-Key Electronics

Running tasks in an RTOS on a multicore system can seem daunting at first. Many processors have unique architectures that you must keep in mind when writing programs that use more than one core. We examine the FreeRTOS port for the ESP32 (known as ESP-IDF) and how to synchronize tasks on both cores.

The solution to the challenge can be found here:

Code for this video series (including demonstrations, challenges, and solutions) can be found here:

Programming a multicore system can be separated into two paradigms: asymmetric multiprocessing (AMP) and symmetric multiprocessing (SMP). AMP requires a primary core running an operating system to schedule tasks in other (secondary) cores. In SMP, the OS runs on all cores, and the scheduler is free to pull tasks from a shared list.

ESP-IDF is the port of FreeRTOS for the ESP32, and it supports SMP. The ESP32 is a dual-core system (although, single-core variants exist). We look at how the ESP32 architecture is configured and how each core can access memory, resources, and interrupts.

In ESP-IDF, we have the option of pinning tasks to a core (so that only that core may run a particular task) or setting a task to “no affinity” (so that the task can run in either core). Using “no affinity” is easier to implement and optimizes CPU utilization and load balancing without much effort. However, it becomes difficult to determine when certain tasks will run, which makes predicting deadlines tougher. As a result, many embedded developers prefer to pin tasks to cores, as it allows for a higher level of determinism.

We show how to run tasks on either core in the ESP32 as well as set them to “no affinity.” Kernel objects (e.g. queues, mutexes, and semaphores) work across cores without any modification, as the ESP32’s cores share memory.

Product Links:

Related Videos:
Introduction to RTOS Part 1 – What is a Real-Time Operating System (RTOS)? –​

Introduction to RTOS Part 2 – Getting Started with FreeRTOS –​

Introduction to RTOS Part 3 – Task Scheduling –​

Introduction to RTOS Part 4 – Memory Management –​

Introduction to RTOS Part 5 – Queue –​

Introduction to RTOS Part 6 – Mutex –​

Introduction to RTOS Part 7 –​

Introduction to RTOS Part 8 –

Introduction to RTOS Part 9 –

Introduction to RTOS Part 10 –

Introduction to RTOS Part 11 –

Introduction to RTOS Part 12 –

Related Project Links:

Related Articles:

Learn more: –

Digi-Key’s Blog – TheCircuit

Connect with Digi-Key on Facebook

And follow us on Twitter

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.