From ba56f4afde609e74aa8398653b399725f88c8448 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 25 Oct 2018 12:45:29 +0200 Subject: [PATCH] If no context switch occurs, add 1 to the timesScheduled() for current. This seems like more accurate accounting. --- Kernel/Task.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Kernel/Task.cpp b/Kernel/Task.cpp index c8f5303133..4f8a22b089 100644 --- a/Kernel/Task.cpp +++ b/Kernel/Task.cpp @@ -451,13 +451,6 @@ bool scheduleNewTask() return contextSwitch(Task::kernelTask()); } -#if 0 - kprintf("Scheduler choices:\n"); - for (auto* task = s_tasks->head(); task; task = task->next()) { - kprintf("%p %u %s\n", task, task->pid(), task->name().characters()); - } -#endif - // Check and unblock tasks whose wait conditions have been met. for (auto* task = s_tasks->head(); task; task = task->next()) { if (task->state() == Task::BlockedSleep) { @@ -475,6 +468,15 @@ bool scheduleNewTask() } } +#if 0 + kprintf("Scheduler choices:\n"); + for (auto* task = s_tasks->head(); task; task = task->next()) { + if (task->state() == Task::BlockedWait || task->state() == Task::BlockedSleep) + continue; + kprintf("%w %s(%u)\n", task->state(), task->name().characters(), task->pid()); + } +#endif + auto* prevHead = s_tasks->head(); for (;;) { // Move head to tail. @@ -509,6 +511,7 @@ static bool contextSwitch(Task* t) { //kprintf("c_s to %s (same:%u)\n", t->name().characters(), current == t); t->setTicksLeft(5); + t->didSchedule(); if (current == t) return false; @@ -562,8 +565,6 @@ static bool contextSwitch(Task* t) tssDescriptor.type = 11; // Busy TSS flushGDT(); - - t->didSchedule(); return true; }