Source: https://mokxi.com/learn/path/concurrency-fundamentals
Updated: 2026-11-20

All paths

# Concurrency: tasks, races and async

Concurrency on one core in MicroPython on a Pico: superloops, interrupt races measured for real, critical sections, coroutines, asyncio, queues, and a responsive multi-sensor box.

Raspberry Pi Pico Free 7 lessons 5 h 4 chapters 2,173 XP Coding · Advanced +250 XP

0 of 7 done

Start the course free Doing two things Lesson plan for teachers

What you will build

## 2 projects, built step by step

7 lessons in 4 chapters, about 5 hours on a simulated Raspberry Pi Pico. Free, in your browser, every step checked by the simulator.

Chapter 1 project

### Interrupt races

A hard interrupt counts a 1 kHz wheel sensor. Put a little work in the wrong place and ticks vanish: a real race, measured.
Open it in the simulator

Chapter 3 project

### Queues

A ring buffer an interrupt can fill without allocating, what happens when the consumer is too slow, and a queue class with backpressure for tasks.
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

## Two things at once

From a blocking loop to a superloop, then interrupts and the race they bring.

Open 227 XP

### Doing two things

Why one sleep() ruins a two-job program, and the superloop that fixes it: timestamps, ticks_diff and a debounced button.

0 of 5 steps

Start What is in it

Project Locked 454 XP

### Interrupt races

A hard interrupt counts a 1 kHz wheel sensor. Put a little work in the wrong place and ticks vanish: a real race, measured.

0 of 5 steps

4 questions, graded as you go.

Chapter 2

## Sharing safely

Critical sections, the no-memory rule of hard interrupts, and micropython.schedule.

Locked 250 XP

### Critical sections

Close the race for good with disable_irq, measure how long interrupts stay off, then meet the rule hard interrupts live by: no new memory.

0 of 5 steps

4 questions, graded as you go.

Chapter 3

## Cooperative tasks

Generators as coroutines, a scheduler by hand, asyncio, and queues with backpressure.

Locked 227 XP

### Coroutines

Generators are functions that pause. Build a round-robin scheduler, then one that sleeps: the engine inside every async library.

0 of 5 steps

Locked 250 XP

### asyncio in MicroPython

Tasks with async and await, the blocking mistake that freezes them all (measured), and a hard IRQ waking a task through ThreadSafeFlag.

0 of 5 steps

Project Locked 500 XP

### Queues

A ring buffer an interrupt can fill without allocating, what happens when the consumer is too slow, and a queue class with backpressure for tasks.

0 of 5 steps

5 questions, graded as you go.

Chapter 4

## Boss

A multi-sensor box that never stops answering, with its lag measured.

Locked 265 XP

### Boss: a responsive multi-sensor box

Everything at once: an IRQ-counted wheel with a critical section, a smoothed knob in slices, a flag-driven button, a heartbeat, an alarm and a lag watchdog.

0 of 6 steps

3 questions, graded as you go.

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

### Two things at once

- Doing two things Why one sleep() ruins a two-job program, and the superloop that fixes it: timestamps, ticks_diff and a debounced button.
- Interrupt races A hard interrupt counts a 1 kHz wheel sensor. Put a little work in the wrong place and ticks vanish: a real race, measured.

Chapter 2

### Sharing safely

- Critical sections Close the race for good with disable_irq, measure how long interrupts stay off, then meet the rule hard interrupts live by: no new memory.

Chapter 3

### Cooperative tasks

- Coroutines Generators are functions that pause. Build a round-robin scheduler, then one that sleeps: the engine inside every async library.
- asyncio in MicroPython Tasks with async and await, the blocking mistake that freezes them all (measured), and a hard IRQ waking a task through ThreadSafeFlag.
- Queues A ring buffer an interrupt can fill without allocating, what happens when the consumer is too slow, and a queue class with backpressure for tasks.

Chapter 4

### Boss

- Boss: a responsive multi-sensor box Everything at once: an IRQ-counted wheel with a critical section, a smoothed knob in slices, a flag-driven button, a heartbeat, an alarm and a lag watchdog.

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 Concurrency: tasks, races and async

Is Concurrency: tasks, races and async free?

Yes. All 7 lessons of Concurrency: tasks, races and async are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Raspberry Pi Pico?

No. Every lesson runs on a simulated Raspberry Pi Pico 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 Concurrency: tasks, races and async take?

About 5 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: Interrupt races and Queues.

Where do I start?

With "Doing two things", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.
