![]() |
AKOS
v1.0.0
Documentation
|
The scheduler decides which thread runs next. In AKOS, it is the part of the kernel that keeps the ready threads organized and picks the next thread to run.
That gives AKOS a simple but practical scheduling model for embedded systems: urgent work runs first, and equal-priority work shares the CPU fairly.
AKOS keeps a ready list for each priority level, and the priority bitmap tracks which of those levels currently have ready work.
The priority subsystem uses one bit per priority level:
Lower numeric values mean higher priority, so the scheduler always looks for the smallest ready priority value first.
The related APIs are:
When a thread becomes ready, the kernel inserts it into the list for its priority. If that list was empty before, the matching bit in the priority table is set. If the list becomes empty again, the bit is cleared.
The bitmap makes it fast to find the highest ready priority without scanning every ready list one by one.
The AKOS scheduler combines three ideas into one flow: priority based scheduling, round robin scheduling, and tick and time slicing.
The full flow looks like this:
That is why the scheduler works well for AKOS:
AKOS uses priority-based preemptive scheduling. A thread with a higher priority can take the CPU from a lower-priority thread when it becomes ready.
This can happen when:
When that happens, AKOS can trigger a context switch so the higher-priority thread runs as soon as possible.
A thread enters the ready state when it is able to run again. Common cases are:
When that happens, AKOS inserts the thread into the appropriate ready list and updates the priority bitmap if needed.
Threads can leave the ready state when they:
Blocked threads stay out of the ready lists until the kernel decides they are eligible to run again.
The scheduler chapter connects directly to a few other parts of the kernel:
The short version is: AKOS always runs the highest-priority ready thread, and threads at the same priority take turns in the ready list.