diff options
author | Danny Holman <dholman@gymli.org> | 2024-03-28 23:19:08 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-03-28 23:19:08 -0500 |
commit | 41cff28f5447b5f669db62ce2a73be98bc5bce37 (patch) | |
tree | 962d7f5ee66b061a2d9d0973cf3bbb551b9bbab6 | |
parent | db684b8653d93f4a374d8d692bb0afb31db67987 (diff) |
kernel: sched: add a flag that is set on init
Add a flag that is set to 1 when the scheduler_init function is called.
This allows the PIT interrupt to preempt the current thread and schedule
the next one according to the scheduler's internal agorithm.
Signed-off-by: Danny Holman <dholman@gymli.org>
-rw-r--r-- | kernel/sched.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 8aab675..d893813 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -11,6 +11,8 @@ static struct list_head *wait_queue; static struct task_block *cur = NULL; static long int next_id = 1; +static int scheduler_enabled = 0; + static void _enqueue(struct list_head *queue, struct task_block *task) { struct list_head *temp = queue; while (temp->next != NULL) @@ -35,9 +37,13 @@ void sched_init(void) { cur = boot_task; switch_thread(boot_task->threads, boot_task->threads); + scheduler_enabled = 1; } void schedule_next(void) { + if (scheduler_enabled == 0) + return; + struct task_block *task = _dequeue(ready_queue); if (task == NULL) return; |