If no context switch occurs, add 1 to the timesScheduled() for current.

This seems like more accurate accounting.
This commit is contained in:
Andreas Kling 2018-10-25 12:45:29 +02:00
parent 571dc8234f
commit ba56f4afde

View file

@ -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;
}