robert-w-gries / rxinu

Rust implementation of Xinu educational operating system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ideas about preemption.

toor opened this issue · comments

commented

I thought I'd just open this issue to share my ideas about preemptive multitasking. Currently, we have a very basic preemptive scheduler, using something akin to the Round Robin scheduling algorithm. A simple way to implement priority scheduling would be to add several different process queues. In pseudocode:

pub struct Scheduler {
    // ...
    process_queues: [RwLock<ProcessList>; n],
}

N.B I have renamed CoopScheduler to Scheduler, since our global kernel scheduler has not been a cooperative scheduler since PIT support was added, realistically speaking.

n here can just be however many process queues we want to have. Ideally, when a process is created, it has a set priority and the scheduler automagically pushes the new process to the correct queue. A helper method checks whether each queue is empty in turn when a rescheduling call is made. If any of the higher process queues are not empty, then the first available process there gets marked as the next process to run. Of course, this process would also have to be marked as ready for the scheduler to be allowed to run it. This in theory should not be too difficult to implement. If such a scheduling algorithm were to be implemented, we would be using Priority-based Round Robin scheduling of a kind.

Hi Will, thanks for the contribution!

I am planning on using xinu's implementation of Priority Scheduling first since this project focuses on re-implementing the xinu operating system.

This system will use one process queue and aging to ensure all processes are able to run.

I'll eventually add more scheduler implementations. A secondary goal of this project is to make the kernel extensible and useful for research. I think an interesting exercise with the kernel could be benchmarking various scheduling programs.

commented

Interesting, good to know. Thanks.