From 08e69a55cfda4722277d16ddb632669edde3580b Mon Sep 17 00:00:00 2001 From: Amlal Date: Wed, 23 Oct 2024 10:08:05 +0200 Subject: IMP: Process scheduler timer interrupt have been implemented, fixes regarding interrupt API and use __TOOLCHAINKIT__ instead of __NDK__ Signed-off-by: Amlal --- dev/zka/src/ACPIFactoryInterface.cc | 13 +++++++------ dev/zka/src/UserProcessScheduler.cc | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) (limited to 'dev/zka/src') diff --git a/dev/zka/src/ACPIFactoryInterface.cc b/dev/zka/src/ACPIFactoryInterface.cc index c7d2914f..230b6ed6 100644 --- a/dev/zka/src/ACPIFactoryInterface.cc +++ b/dev/zka/src/ACPIFactoryInterface.cc @@ -29,11 +29,11 @@ namespace Kernel RSDT* xsdt = reinterpret_cast(rsp_ptr->RsdtAddress); - Int64 num = (xsdt->Length - sizeof(SDT)) / sizeof(UInt32); + Int64 num = (xsdt->Length - sizeof(SDT)) / sizeof(Int64); /*** - crucial to avoid - overflows. - */ + crucial to avoid underflows. + */ if (num < 1) { /// stop here, we should have entries... @@ -64,7 +64,8 @@ namespace Kernel if (signature_index == (cAcpiSignatureLength - 1)) { - kcout << "ACPI: Found the SDT" << endl; + kcout << "ACPI: SDT Signature: " << sdt->Signature << endl; + kcout << "ACPI: SDT OEM ID: " << sdt->OemId << endl; return ErrorOr(reinterpret_cast(xsdt->AddressArr[index])); } } @@ -74,10 +75,10 @@ namespace Kernel } /*** - @brief check SDT header + @brief Checksum on SDT header. @param checksum the header to checksum @param len the length of it. -*/ + */ bool ACPIFactoryInterface::Checksum(const Char* checksum, SSizeT len) { if (len == 0) diff --git a/dev/zka/src/UserProcessScheduler.cc b/dev/zka/src/UserProcessScheduler.cc index bbe644dc..0081367a 100644 --- a/dev/zka/src/UserProcessScheduler.cc +++ b/dev/zka/src/UserProcessScheduler.cc @@ -423,6 +423,12 @@ namespace Kernel SizeT process_index = 0; //! we store this guy to tell the scheduler how many //! things we have scheduled. + if (mTeam.mProcessAmount < 1) + { + kcout << "UserProcessScheduler::Run(): This team doesn't have any process!\r"; + return 0; + } + for (; process_index < mTeam.AsArray().Capacity(); ++process_index) { auto& process = mTeam.AsArray()[process_index]; @@ -430,9 +436,6 @@ namespace Kernel //! check if process needs to be scheduled. if (UserProcessHelper::CanBeScheduled(process)) { - // Set current process header. - this->CurrentProcess() = process; - process.PTime = static_cast(process.Affinity); UserProcessScheduler::The().CurrentProcess().Leak().Status = ProcessStatusKind::kFrozen; @@ -440,6 +443,9 @@ namespace Kernel kcout << "Switch to '" << process.Name << "'.\r"; + // Set current process header. + this->CurrentProcess() = process; + // tell helper to find a core to schedule on. if (!UserProcessHelper::Switch(process.Image, &process.StackReserve[process.StackSize - 1], process.StackFrame, process.ProcessId)) @@ -494,6 +500,10 @@ namespace Kernel process.Status == ProcessStatusKind::kDead) return No; + if (process.Status == ProcessStatusKind::kStarting && + process.Image) + return Yes; + if (!process.Image && process.Kind == UserProcess::kExectuableKind) return No; -- cgit v1.2.3