From db684b8653d93f4a374d8d692bb0afb31db67987 Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Thu, 28 Mar 2024 22:00:16 -0500 Subject: kernel: add a basic thread scheduler Add a basic thread scheduler. This should allow the kernel to schedule threads according to the round robin algorithm. Signed-off-by: Danny Holman --- include/kernel/sched.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 include/kernel/sched.h (limited to 'include') diff --git a/include/kernel/sched.h b/include/kernel/sched.h new file mode 100644 index 0000000..fef36b8 --- /dev/null +++ b/include/kernel/sched.h @@ -0,0 +1,27 @@ +#ifndef KERNEL_SCHED_H +#define KERNEL_SCHED_H + +#include +#include + +#define THREAD_READY 0 +#define THREAD_RUNNING 1 +#define THREAD_WAIT 2 + +struct task_block { + unsigned int pid; + unsigned int parent_pid; + int nice; + unsigned int num_threads; + struct thread_block *threads; + struct list_head list; +}; + +void sched_init(void); +void schedule_next(void); + +struct task_block* init_task(int nice, unsigned int ppid); +void schedule_thread(struct thread_block *thread); +void switch_thread(struct thread_block *old, struct thread_block *new); + +#endif -- cgit v1.2.3