diff --git a/Tasking/Scheduler.cpp b/Tasking/Scheduler.cpp index a8d4adc..9358f97 100644 --- a/Tasking/Scheduler.cpp +++ b/Tasking/Scheduler.cpp @@ -445,6 +445,7 @@ namespace Tasking return; } CPU::x64::writecr3({.raw = (uint64_t)KernelPageTable}); /* Restore kernel page table for safety reasons. */ + uint64_t SchedTmpTicks = CPU::Counter(); CPUData *CurrentCPU = GetCurrentCPU(); schedbg("Scheduler called on CPU %d.", CurrentCPU->ID); schedbg("%d: %ld%%", CurrentCPU->ID, GetUsage(CurrentCPU->ID)); @@ -635,6 +636,7 @@ namespace Tasking /* RealEnd->[Function Exit] */ RealEnd: + this->SchedulerTicks.Store(CPU::Counter() - SchedTmpTicks); __sync_synchronize(); /* TODO: Is this really needed? */ } diff --git a/Tasking/Task.cpp b/Tasking/Task.cpp index 88b224b..586f110 100644 --- a/Tasking/Task.cpp +++ b/Tasking/Task.cpp @@ -221,7 +221,7 @@ namespace Tasking void Task::WaitForProcess(PCB *pcb) { - if (!pcb) + if (InvalidPCB(pcb)) return; if (pcb->Status == TaskStatus::UnknownStatus) return; @@ -232,7 +232,7 @@ namespace Tasking void Task::WaitForThread(TCB *tcb) { - if (!tcb) + if (InvalidTCB(tcb)) return; if (tcb->Status == TaskStatus::UnknownStatus) return; @@ -243,7 +243,7 @@ namespace Tasking void Task::WaitForProcessStatus(PCB *pcb, TaskStatus status) { - if (!pcb) + if (InvalidPCB(pcb)) return; if (pcb->Status == TaskStatus::UnknownStatus) return; @@ -254,7 +254,7 @@ namespace Tasking void Task::WaitForThreadStatus(TCB *tcb, TaskStatus status) { - if (!tcb) + if (InvalidTCB(tcb)) return; if (tcb->Status == TaskStatus::UnknownStatus) return; @@ -835,6 +835,7 @@ namespace Tasking Task::~Task() { + debug("Destructor called"); SmartCriticalSection(TaskingLock); trace("Stopping tasking"); foreach (PCB *Process in ListProcess) diff --git a/include/task.hpp b/include/task.hpp index 045f1d0..6796d91 100644 --- a/include/task.hpp +++ b/include/task.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -228,6 +229,7 @@ namespace Tasking Vector ListProcess; PCB *IdleProcess = nullptr; TCB *IdleThread = nullptr; + Atomic SchedulerTicks = 0; bool InvalidPCB(PCB *pcb); bool InvalidTCB(TCB *tcb); @@ -260,6 +262,7 @@ namespace Tasking bool StopScheduler = false; public: + uint64_t GetSchedulerTicks() { return SchedulerTicks.Load(); } Vector GetProcessList() { return ListProcess; } Security *GetSecurityManager() { return &SecurityManager; } void Panic() { StopScheduler = true; }