diff options
author | Danny Holman <dholman@gymli.org> | 2024-03-28 22:00:16 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-03-28 22:00:16 -0500 |
commit | db684b8653d93f4a374d8d692bb0afb31db67987 (patch) | |
tree | 83dc7939470b4c9302538fbf220c7a02fc249a51 /include/kernel | |
parent | 3b66779d9a8325c77c6cfbf1565885f98da5378f (diff) |
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 <dholman@gymli.org>
Diffstat (limited to 'include/kernel')
-rw-r--r-- | include/kernel/sched.h | 27 |
1 files changed, 27 insertions, 0 deletions
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 <kernel/asm.h> +#include <kernel/data/list.h> + +#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 |