From 41cff28f5447b5f669db62ce2a73be98bc5bce37 Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Thu, 28 Mar 2024 23:19:08 -0500 Subject: 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 --- kernel/sched.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'kernel') 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; -- cgit v1.2.3