1#include <asm.h>
2#include <irq/idt.h>
3#include <kassert.h>
4#include <sch/sched.h>
5#include <smp/core.h>
6#include <sync/rcu.h>
7#include <thread/dpc.h>
8#include <thread/workqueue.h>
9
10void scheduler_idle_main(void *nop) {
11 (void) nop;
12 struct scheduler *sched = global.schedulers[smp_id_raw()];
13
14 while (true) {
15 disable_interrupts();
16 if (scheduler_mark_self_needs_resched(false) ||
17 sched->total_thread_count > 0 ||
18 sched->completed_rbt.root != NULL) {
19 enable_interrupts();
20 scheduler_yield();
21 continue;
22 }
23
24 do_idle_insn();
25 }
26}
27