From 600403a8666da95c8a9e99497b93825cce63c750 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 21 May 2024 11:40:32 -0400 Subject: kernel: Initial sched rewrite - Introduce dynamic scheduling policy - Introduce MLFQ scheduling - Clean up a lot of code Signed-off-by: Ian Moffett --- sys/include/sys/proc.h | 2 ++ sys/include/sys/sched.h | 4 ++-- sys/include/sys/schedvar.h | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) (limited to 'sys/include') diff --git a/sys/include/sys/proc.h b/sys/include/sys/proc.h index ec7d25e..e3416f9 100644 --- a/sys/include/sys/proc.h +++ b/sys/include/sys/proc.h @@ -79,7 +79,9 @@ struct proc { struct vm_range addr_range[PROC_MAX_ADDR_RANGE]; struct spinlock lock; uint8_t is_user; + uint8_t rested; uint32_t signal; + uint32_t priority; struct filedesc *fds[PROC_MAX_FDS]; struct spinlock mapspace_lock; struct vm_mapspace mapspace; diff --git a/sys/include/sys/sched.h b/sys/include/sys/sched.h index 8245120..06cf860 100644 --- a/sys/include/sys/sched.h +++ b/sys/include/sys/sched.h @@ -45,9 +45,9 @@ void sched_context_switch(struct trapframe *tf); void sched_rest(void); __noreturn -uint64_t sys_exit(struct syscall_args *args); +void sched_enter(void); __noreturn -void sched_init_processor(struct cpu_info *ci); +uint64_t sys_exit(struct syscall_args *args); #endif /* !_SYS_SCHED_H_ */ diff --git a/sys/include/sys/schedvar.h b/sys/include/sys/schedvar.h index 431a93e..2a0a1fc 100644 --- a/sys/include/sys/schedvar.h +++ b/sys/include/sys/schedvar.h @@ -30,7 +30,32 @@ #ifndef _SYS_SCHEDVAR_H_ #define _SYS_SCHEDVAR_H_ +#include +#include +#include + #define DEFAULT_TIMESLICE_USEC 3000 #define SHORT_TIMESLICE_USEC 10 +#define SCHED_POLICY_MLFQ 0x0000U /* Multilevel feedback queue */ +#define SCHED_POLICY_RR 0x0001U /* Round robin */ + +typedef uint8_t schedpolicy_t; + +/* Might be set by kconf(1) */ +#if defined(__SCHED_NQUEUE) +#define SCHED_NQUEUE __SCHED_NQUEUE +#else +#define SCHED_NQUEUE 4 +#endif + +/* Ensure SCHED_NQUEUE is an acceptable value */ +__STATIC_ASSERT(SCHED_NQUEUE <= 8, "SCHED_NQUEUE exceeds max"); +__STATIC_ASSERT(SCHED_NQUEUE > 0, "SCHED_NQUEUE cannot be zero"); + +struct sched_queue { + TAILQ_HEAD(, proc) q; + size_t nthread; +}; + #endif /* !_SYS_SCHEDVAR_H_ */ -- cgit v1.2.3