diff options
| author | Amlal <amlal.elmahrouss@icloud.com> | 2025-02-18 12:09:41 +0100 |
|---|---|---|
| committer | Amlal <amlal.elmahrouss@icloud.com> | 2025-02-18 12:09:41 +0100 |
| commit | 6a9ae8360b9c7757b756be6cc41c77982344b0c6 (patch) | |
| tree | ceaaa4f86f3e097f955d562c325d60222ff4751a /dev/Kernel | |
| parent | f471cf287fdef515ced7357aca2f3f47f284998f (diff) | |
ADD: A better thread scheduler.
Diffstat (limited to 'dev/Kernel')
| -rw-r--r-- | dev/Kernel/HALKit/AMD64/Storage/AHCI.cc | 4 | ||||
| -rw-r--r-- | dev/Kernel/src/HardwareThreadScheduler.cc | 26 |
2 files changed, 16 insertions, 14 deletions
diff --git a/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc b/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc index 9ebfbb0a..283a873d 100644 --- a/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc +++ b/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc @@ -257,9 +257,9 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff volatile FisRegH2D* h2d_fis = (volatile FisRegH2D*)((Kernel::UInt64)&command_table->Cfis); - h2d_fis->FisType = kFISTypeRegH2D; + h2d_fis->FisType = kFISTypeRegH2D; h2d_fis->CmdOrCtrl = CommandOrCTRL; - h2d_fis->Command = Write ? kAHCICmdWriteDmaEx : kAHCICmdReadDmaEx; + h2d_fis->Command = Write ? kAHCICmdWriteDmaEx : kAHCICmdReadDmaEx; if (Identify) h2d_fis->Command = kAHCICmdIdentify; diff --git a/dev/Kernel/src/HardwareThreadScheduler.cc b/dev/Kernel/src/HardwareThreadScheduler.cc index 9b379485..e491e9c9 100644 --- a/dev/Kernel/src/HardwareThreadScheduler.cc +++ b/dev/Kernel/src/HardwareThreadScheduler.cc @@ -61,13 +61,15 @@ namespace Kernel /***********************************************************************************/ Bool HardwareThread::IsBusy() noexcept { - STATIC Int64 busy_timer = 0U; - STATIC Int64 timeout_max = 0x1000000; // an arbitrary value used to tell if the timeout hasn't been reached yet. + STATIC Int64 busy_timer = 0U; + constexpr Int64 kTimeoutMax = 0x1000000; // an arbitrary value used to tell if the timeout hasn't been reached yet. - if (fBusy && busy_timer > timeout_max) + if (fBusy && (busy_timer > kTimeoutMax)) { busy_timer = 0U; fBusy = No; + + return No; } ++busy_timer; @@ -81,13 +83,13 @@ namespace Kernel HAL::StackFramePtr HardwareThread::StackFrame() noexcept { - MUST_PASS(fStack); - return fStack; + MUST_PASS(this->fStack); + return this->fStack; } Void HardwareThread::Busy(const Bool busy) noexcept { - fBusy = busy; + this->fBusy = busy; } HardwareThread::operator bool() @@ -101,7 +103,7 @@ namespace Kernel Void HardwareThread::Wake(const bool wakeup) noexcept { - fWakeup = wakeup; + this->fWakeup = wakeup; } /***********************************************************************************/ @@ -118,8 +120,8 @@ namespace Kernel this->fStack = frame; this->fSourcePID = pid; - fStack->BP = reinterpret_cast<UIntPtr>(image_ptr); - fStack->SP = reinterpret_cast<UIntPtr>(stack_ptr); + this->fStack->BP = reinterpret_cast<UIntPtr>(image_ptr); + this->fStack->SP = reinterpret_cast<UIntPtr>(stack_ptr); Bool ret = mp_register_process(fStack, this->fSourcePID); @@ -134,7 +136,7 @@ namespace Kernel /***********************************************************************************/ bool HardwareThread::IsWakeup() noexcept { - return fWakeup; + return this->fWakeup; } /***********************************************************************************/ @@ -183,8 +185,8 @@ namespace Kernel } else if (idx >= kMaxAPInsideSched) { - static HardwareThread* fakeThread = nullptr; - return {fakeThread}; + static HardwareThread* kFakeThread = nullptr; + return {kFakeThread}; } return &fThreadList[idx]; |
