All paths

Scheduling and RTOS

From a scheduler written by hand to FreeRTOS on the Uno: tasks and priorities, time slicing on the logic analyzer, queues, mutexes and priority inversion, starvation and the watchdog, and a four-task device.

Arduino Uno R3Free7 lessons6 h4 chapters2,970 XPEmbedded engineering · Expert+400 XP

0 of 7 done

What you will build

2 projects, built step by step

7 lessons in 4 chapters, about 6 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.

Chapter 2 project

Time slicing and preemption

Two tasks that never yield still share the processor a tick at a time, seen on the logic analyzer; a higher priority task cuts in on time; and one priority change starves a task completely.

Open it in the simulator
Chapter 3 project

Starvation and the watchdog

A busy worker starves a heartbeat task, a watchdog task at the top catches it in the act, and splitting the work into chunks lets every task check in on time.

Open it in the simulator
The map

Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

Scheduling by hand

Many jobs in one loop, and where that stops working.

  1. Open350 XP

    A scheduler by hand

    Three jobs at three rates in one loop with millis() and no delay(): a table of jobs, a loop that runs whichever is due, and the one rule that makes it work.

    0 of 6 steps

Chapter 2

Tasks and the scheduler

Tasks, priorities, and a tick that takes the processor back.

  1. Locked350 XP

    Tasks and priorities

    The same lamps as FreeRTOS tasks: each one a loop of its own with a stack and a priority, vTaskDelay() counted in 16 ms ticks, and a report that outranks them.

    0 of 6 steps

  2. ProjectLocked700 XP

    Time slicing and preemption

    Two tasks that never yield still share the processor a tick at a time, seen on the logic analyzer; a higher priority task cuts in on time; and one priority change starves a task completely.

    0 of 6 steps

Chapter 3

Tasks that work together

Queues, mutexes, priority inversion and starvation.

  1. Locked270 XP

    Queues

    A sensor task hands readings to a logger task through a FreeRTOS queue: no shared variable, a receiver that sleeps until data arrives, and what happens when the queue fills up.

    0 of 5 steps

  2. Locked320 XP

    Mutexes and priority inversion

    Three tasks and one shared bus: a mutex guards it, priority inversion makes the most important task wait for the least, and priority inheritance fixes it. Then break the fix and watch it happen.

    0 of 6 steps

  3. ProjectLocked600 XP

    Starvation and the watchdog

    A busy worker starves a heartbeat task, a watchdog task at the top catches it in the act, and splitting the work into chunks lets every task check in on time.

    0 of 5 steps

Chapter 4

Boss project

A temperature alarm built from four tasks.

  1. Locked380 XP

    Boss: a multi-task device

    A temperature alarm built from four tasks: a sensor overwrites a one-slot queue, a display owns the LCD, a button notifies the alarm, and a mutex keeps every serial line whole.

    0 of 6 steps

Syllabus

Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

Scheduling by hand

  1. A scheduler by handThree jobs at three rates in one loop with millis() and no delay(): a table of jobs, a loop that runs whichever is due, and the one rule that makes it work.
Chapter 2

Tasks and the scheduler

  1. Tasks and prioritiesThe same lamps as FreeRTOS tasks: each one a loop of its own with a stack and a priority, vTaskDelay() counted in 16 ms ticks, and a report that outranks them.
  2. Time slicing and preemptionTwo tasks that never yield still share the processor a tick at a time, seen on the logic analyzer; a higher priority task cuts in on time; and one priority change starves a task completely.
Chapter 3

Tasks that work together

  1. QueuesA sensor task hands readings to a logger task through a FreeRTOS queue: no shared variable, a receiver that sleeps until data arrives, and what happens when the queue fills up.
  2. Mutexes and priority inversionThree tasks and one shared bus: a mutex guards it, priority inversion makes the most important task wait for the least, and priority inheritance fixes it. Then break the fix and watch it happen.
  3. Starvation and the watchdogA busy worker starves a heartbeat task, a watchdog task at the top catches it in the act, and splitting the work into chunks lets every task check in on time.
Chapter 4

Boss project

  1. Boss: a multi-task deviceA temperature alarm built from four tasks: a sensor overwrites a one-slot queue, a display owns the LCD, a button notifies the alarm, and a mutex keeps every serial line whole.
Keep going

The next course on your track

Scheduling and RTOS is part of the embedded track, a ladder of courses from zero to expert.

Next course

Low power products

Make a battery last years: where an Uno’s current goes, sleep modes and wake sources, a power budget on a bare chip, measuring with a meter and an INA219, battery life checked against a draining cell, and a coin cell node.

Open the next course
Track

Embedded track

Arduino, ESP32, Raspberry Pi Pico and STM32: pins, timing, buses, motors, WiFi, registers and debugging, every lesson checked on a simulated board.

See every course on the track
Kits

Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.

See every kit
Questions

About Scheduling and RTOS

Is Scheduling and RTOS free?

Yes. All 7 lessons of Scheduling and RTOS are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Arduino Uno R3?

No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Scheduling and RTOS take?

About 6 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Time slicing and preemption and Starvation and the watchdog.

Where do I start?

With "A scheduler by hand", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.