Source: https://mokxi.com/teachers/plans/rtos-and-timing
Updated: 2026-11-11

Lesson plan

# Scheduling and RTOS lesson plan

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.

4 chapters, 7 lessons, about 6 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## Objectives and materials

### By the end, students can

- Many jobs in one loop, and where that stops working.
- Tasks, priorities, and a tick that takes the processor back.
- Queues, mutexes, priority inversion and starvation.
- A temperature alarm built from four tasks.

### Materials for the whole unit

- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- LED x 3
- Logic analyzer, four channels
- Potentiometer
- Pushbutton
- Resistor x 3

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 55 min

## Scheduling by hand

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

Lesson | Time | What students do

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. | 55 min

- Run it: three jobs, one loop
- A job is a function and a clock
- Two rates at once
- Press the button
- Speed up the yellow job
- The rule, and where it breaks

### Materials

- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- LED x 3
- Potentiometer
- Pushbutton
- Resistor x 3

### Check for understanding

Each student finishes "A scheduler by hand" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "The rule, and where it breaks".

Chapter 2. About 1 h 50 min

## Tasks and the scheduler

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

Lesson | Time | What students do

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. | 55 min

- Run it: three tasks
- vTaskDelay is not delay
- Priorities
- Every task has its own stack
- Change a task
- What you gave up

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. | 55 min

- Run it: two badly behaved tasks
- The tick takes it back
- See the slices
- Preemption from above
- Starve one
- The rule for priorities

### Materials

- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- LED x 3
- Logic analyzer, four channels
- Potentiometer
- Pushbutton
- Resistor x 3

### Check for understanding

Each student finishes "Time slicing and preemption" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "The rule for priorities".

Chapter 3. About 2 h 25 min

## Tasks that work together

Queues, mutexes, priority inversion and starvation.

Lesson | Time | What students do

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. | 45 min

- Run it: a sensor and a logger
- Why not a global?
- Turn the knob
- Fill it up
- Choosing what a full queue does

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. | 55 min

- Run it: one bus, three tasks
- What a mutex is
- The trap
- Priority inheritance
- Break it
- Locks without regrets

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. | 45 min

- Run it: a heartbeat and a referee
- The heartbeat
- Press the button
- Share the processor
- The hardware watchdog

### Materials

- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- LED x 3
- Potentiometer
- Pushbutton
- Resistor x 3

### Check for understanding

Each student finishes "Starvation and the watchdog" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "The hardware watchdog".

Chapter 4. About 55 min

## Boss project

A temperature alarm built from four tasks.

Lesson | Time | What students do

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. | 55 min

- Run it: four tasks, one device
- The display has one owner
- Make it hot
- It blinks
- Acknowledge it
- Set your own limit

### Materials

- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- LED x 3
- Potentiometer
- Pushbutton
- Resistor x 3

### Check for understanding

Each student finishes "Boss: a multi-task device" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Set your own limit".

Your class

## Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
