1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

Kernel: Add basic process priority support.

For now, the WindowServer process will run with high priority,
while the Finalizer process will run with low priority.
Everyone else gets to be "normal".

At the moment, priority simply determines the size of your time slices.
This commit is contained in:
Andreas Kling 2019-02-07 12:21:17 +01:00
parent ee2bb98b88
commit 71b9ec1ae0
6 changed files with 46 additions and 7 deletions

View file

@ -8,7 +8,18 @@
//#define LOG_EVERY_CONTEXT_SWITCH
//#define SCHEDULER_DEBUG
static const dword time_slice = 20; // *1ms
static dword time_slice_for(Process::Priority priority)
{
// One time slice unit == 1ms
switch (priority) {
case Process::LowPriority:
return 5;
case Process::NormalPriority:
return 15;
case Process::HighPriority:
return 50;
}
}
Process* current;
Process* g_last_fpu_process;
@ -244,7 +255,7 @@ void Scheduler::switch_now()
bool Scheduler::context_switch(Process& process)
{
process.set_ticks_left(time_slice);
process.set_ticks_left(time_slice_for(process.priority()));
process.did_schedule();
if (current == &process)