mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +00:00
If no context switch occurs, add 1 to the timesScheduled() for current.
This seems like more accurate accounting.
This commit is contained in:
parent
571dc8234f
commit
ba56f4afde
1 changed files with 10 additions and 9 deletions
|
@ -451,13 +451,6 @@ bool scheduleNewTask()
|
||||||
return contextSwitch(Task::kernelTask());
|
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.
|
// Check and unblock tasks whose wait conditions have been met.
|
||||||
for (auto* task = s_tasks->head(); task; task = task->next()) {
|
for (auto* task = s_tasks->head(); task; task = task->next()) {
|
||||||
if (task->state() == Task::BlockedSleep) {
|
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();
|
auto* prevHead = s_tasks->head();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// Move head to tail.
|
// 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);
|
//kprintf("c_s to %s (same:%u)\n", t->name().characters(), current == t);
|
||||||
t->setTicksLeft(5);
|
t->setTicksLeft(5);
|
||||||
|
t->didSchedule();
|
||||||
|
|
||||||
if (current == t)
|
if (current == t)
|
||||||
return false;
|
return false;
|
||||||
|
@ -562,8 +565,6 @@ static bool contextSwitch(Task* t)
|
||||||
tssDescriptor.type = 11; // Busy TSS
|
tssDescriptor.type = 11; // Busy TSS
|
||||||
|
|
||||||
flushGDT();
|
flushGDT();
|
||||||
|
|
||||||
t->didSchedule();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue