2023-02-01 22:27:22ladle
OS_runloop_once
osjob_t , 代表 job ,及儲存內容
排程函式 os_runloop_once()
void os_runloop_once() {
osjob_t* j = NULL;
hal_processPendingIRQs(); // 處理待處理的 IRQ
hal_disableIRQs(); // 禁止 IRQ
// check for runnable jobs
if(OS.runnablejobs) {
j = OS.runnablejobs;
OS.runnablejobs = j->next;
} else if(OS.scheduledjobs && hal_checkTimer(OS.scheduledjobs->deadline)) { // check for expired timed jobs
j = OS.scheduledjobs;
OS.scheduledjobs = j->next;
} else { // nothing pending
hal_sleep(); // wake by irq (timer already restarted)
}
hal_enableIRQs();
if(j) { // run job callback
j->func(j);
}
}