参数和返回值 “Context”
Context *handler(Event ev, Context *ctx) {
...
}
movl $1, %rax
先前状态机就被永久 “破坏” 了状态机在执行……
AbstractMachine API
Context *on_interrupt(Event ev, Context *ctx) {
if (!current) {
current = &tasks[0]; // First trap for this CPU
} else {
current->context = ctx; // Keep the stack-saved context
}
// Schedule
do {
current = current->next;
} while (!on_this_cpu(current));
return current->context;
}