This is the last piece for the policy-free kernel: allow userspace programs to decide how tasks are scheduled. The following design is based on MINIX3.
Implement a multi-priority round-robin scheduling:
The task with the highest priority runs forever until it spends its quantum.
If there're multiple tasks with the same priority, the kernel runs each task in a preemptive context switching with the hard-coded time slice in a round-robin fashion.
If a task spends the allocated quantum, the kernel refills it with reset. If reset is -1, it sends an exception message to its pager task.
If CPU affinity is set for a task, only specified CPUs are allowed to run the task.
Add sched system call.
error_t sys_sched(task_t task, int priority, int quantum, int reset, unsigned affinity);
sys_spawn: Add TASK_SCHED flag not to start the new task until sys_sched is invoked.
If it's not given, the task will be started with the lowest priority and the default quantum.
This is the last piece for the policy-free kernel: allow userspace programs to decide how tasks are scheduled. The following design is based on MINIX3.
reset
. Ifreset
is -1, it sends an exception message to its pager task.sched
system call.error_t sys_sched(task_t task, int priority, int quantum, int reset, unsigned affinity);
sys_spawn
: AddTASK_SCHED
flag not to start the new task untilsys_sched
is invoked.