diff options
| author | Amlal EL Mahrouss <amlal@softwarelabs.com> | 2024-06-14 09:58:11 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlal@softwarelabs.com> | 2024-06-14 09:58:11 +0200 |
| commit | dd7b72379108c10cd68853d2a8a0332784ebb8cb (patch) | |
| tree | 0b057b7a0aeebb68967c4fc2caf56a39eddbb8fe /Kernel/Sources | |
| parent | 479ee6ad453401f5ae7f46d3d91136753f0839e7 (diff) | |
Kernel: Scheduler: ProcessHeader::New: do not get the pointer before allocating it!
Kernel: HAL: AMD64: Two things.
- Switching to an ARM HAL for our Zeta platform.
- Fix return register when sending acknowledge on APIC, which was using
the 32-bit eax instead of rax.
Kernel: Boot: Update uname for Windows.
Kernel: GDT: move as global (HalKenelMain.cxx)
Signed-off-by: Amlal EL Mahrouss <amlal@softwarelabs.com>
Diffstat (limited to 'Kernel/Sources')
| -rw-r--r-- | Kernel/Sources/KeMain.cxx | 11 | ||||
| -rw-r--r-- | Kernel/Sources/ProcessScheduler.cxx | 45 |
2 files changed, 33 insertions, 23 deletions
diff --git a/Kernel/Sources/KeMain.cxx b/Kernel/Sources/KeMain.cxx index 58c76dc4..23e32c1d 100644 --- a/Kernel/Sources/KeMain.cxx +++ b/Kernel/Sources/KeMain.cxx @@ -203,8 +203,6 @@ namespace NewOS::Detail NewOS::Utils::execute_from_image(stageBoard, NewOS::ProcessHeader::kAppKind); - - /// TODO: now jump to user mode using the HAL. } } // namespace NewOS::Detail @@ -217,4 +215,13 @@ EXTERN_C NewOS::Void KeMain(NewOS::Void) NewOS::Detail::FilesystemWizard wizard; // automatic. NewOS::Detail::SystemLauncher_Main(); + + // fetch system cores. + NewOS::HAL::hal_system_get_cores(kHandoverHeader->f_HardwareTables.f_RsdPtr); + + while (true) + { + // start scheduling. + NewOS::ProcessHelper::StartScheduling(); + } } diff --git a/Kernel/Sources/ProcessScheduler.cxx b/Kernel/Sources/ProcessScheduler.cxx index d9d013c6..dc273cf6 100644 --- a/Kernel/Sources/ProcessScheduler.cxx +++ b/Kernel/Sources/ProcessScheduler.cxx @@ -59,18 +59,20 @@ namespace NewOS VoidPtr ProcessHeader::New(const SizeT& sz) { - if (this->FreeMemory < 1) + if (this->HeapCursor) { - DbgLastError() = kErrorHeapOutOfMemory; - this->Crash(); /// out of memory. + if (this->FreeMemory < 1) + { + DbgLastError() = kErrorHeapOutOfMemory; + + /* we're going out of memory */ + this->Crash(); - return nullptr; - } + return nullptr; + } - if (this->HeapCursor) - { - VoidPtr ptr = this->HeapCursor; this->HeapCursor = (VoidPtr)((UIntPtr)this->HeapCursor + (sizeof(sz))); + VoidPtr ptr = this->HeapCursor; ++this->UsedMemory; --this->FreeMemory; @@ -206,12 +208,14 @@ namespace NewOS ke_new_ke_heap(sizeof(HAL::StackFrame), true, false)); MUST_PASS(process.Leak().StackFrame); + + process.Leak().Status = ProcessStatus::kRunning; - mTeam.AsArray().Add(process); - - process.Leak().ProcessId = mTeam.AsArray().Count() - 1; + process.Leak().ProcessId = (mTeam.AsArray().Count() - 1); process.Leak().HeapCursor = process.Leak().HeapPtr; + mTeam.AsArray().Add(process); + return mTeam.AsArray().Count() - 1; } @@ -232,17 +236,14 @@ namespace NewOS /// @return SizeT ProcessScheduler::Run() noexcept { - SizeT processIndex = 0; //! we store this guy to tell the scheduler how many + SizeT process_index = 0; //! we store this guy to tell the scheduler how many //! things we have scheduled. - for (; processIndex < mTeam.AsArray().Count(); ++processIndex) + for (; process_index < mTeam.AsArray().Count(); ++process_index) { - auto process = mTeam.AsArray()[processIndex]; - - if (!process) - continue; + auto process = mTeam.AsArray()[process_index]; - //! run any process needed to be scheduled. + //! check if process needs to be scheduled. if (ProcessHelper::CanBeScheduled(process.Leak())) { auto unwrapped_process = *process.Leak(); @@ -255,6 +256,8 @@ namespace NewOS // tell helper to find a core to schedule on. ProcessHelper::Switch(mTeam.AsRef().Leak().StackFrame, mTeam.AsRef().Leak().ProcessId); + + kcout << unwrapped_process.Name << ": process switched.\r"; } else { @@ -263,7 +266,7 @@ namespace NewOS } } - return processIndex; + return process_index; } /// @brief Gets the current scheduled team. @@ -328,8 +331,8 @@ namespace NewOS bool ProcessHelper::StartScheduling() { - auto& processRef = ProcessScheduler::The().Leak(); - SizeT ret = processRef.Run(); + auto& process_ref = ProcessScheduler::The().Leak(); + SizeT ret = process_ref.Run(); kcout << "newoskrnl: Iterated over: "; kcout.Number(ret); |
