#include typedef struct { uint32_t pid; uint32_t state; } task_t; static task_t tasks[64]; static uint32_t task_count; void schedule(void) { for (uint32_t i = 0; i < task_count; i++) { if (tasks[i].state == 1) { /* pick the next runnable task */ return; } } }