From: Matthias Kruk Date: Sat, 1 Feb 2020 06:47:15 +0000 (+0900) Subject: Add generic scheduler interface, to be implemented by all schedulers X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=7be196272ae61068937b79bb24ca6abd4bde7cb6;p=corax Add generic scheduler interface, to be implemented by all schedulers --- diff --git a/kernel/include/sched.h b/kernel/include/sched.h index 7efa399..7e059a8 100644 --- a/kernel/include/sched.h +++ b/kernel/include/sched.h @@ -3,6 +3,25 @@ #include +struct task; + +typedef enum { + SCHED_TASK_READY, + SCHED_TASK_RUNNING, + SCHED_TASK_SLEEPING +} sched_task_state_t; + +struct sched { + int (*tick)(struct sched*); + + int (*sleep)(struct sched*, struct task*); + int (*wakeup)(struct sched*, struct task*, int); + + int (*schedule)(struct sched*, struct task*); + int (*drop)(struct sched*, struct task*); + int (*nice)(struct sched*, struct task*, int); +}; + void sched_tick(void); void sched_wait(pid_t); int sched_raise(pid_t);