TinyGo 4 — Cooperative soft-RT tasks

Updated

July 30, 2026

TinyGo elective 4 — Cooperative multi-task table

Elective · ~3h
Goal: Run ≥3 periodic tasks cooperatively; demonstrate starvation when one task hogs the CPU; write RT conclusions.

Theory

Model Meaning
Cooperative Task runs until yield; bad task starves others
Preemptive RTOS Timer IRQ switches tasks
This lab if now >= task.Next { run; next += period }

TinyGo here is not FreeRTOS. Learn limits honestly.

Lab

  1. Task table: blink 500 ms, heartbeat UART 1 s, sensor 100 ms.
  2. Idle Sleep(1ms) in outer loop.
  3. Inject bad task with long Sleep; observe heartbeat jitter.
  4. NOTES.md: when cooperative is enough vs interrupts/RTOS.

Full code: monorepo Go project 44.

Checkpoint

  • ≥3 periods running
  • Bad-task experiment documented
  • NOTES.md with conclusions

Next elective

TinyGo 5 — I2C monitor (96-tinygo-05-…).