diff options
author | Ian Moffett <ian@osmora.org> | 2024-05-21 11:40:32 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-05-21 12:40:10 -0400 |
commit | 600403a8666da95c8a9e99497b93825cce63c750 (patch) | |
tree | 8786da4813fd0ea47ef778120812bf19effb3f0f /sys/include | |
parent | ccfba09b7a23632b6a8c1d8731fcdbf778e148b1 (diff) |
kernel: Initial sched rewrite
- Introduce dynamic scheduling policy
- Introduce MLFQ scheduling
- Clean up a lot of code
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/include')
-rw-r--r-- | sys/include/sys/proc.h | 2 | ||||
-rw-r--r-- | sys/include/sys/sched.h | 4 | ||||
-rw-r--r-- | sys/include/sys/schedvar.h | 25 |
3 files changed, 29 insertions, 2 deletions
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 <sys/cdefs.h> +#include <sys/proc.h> +#include <sys/queue.h> + #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_ */ |