diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-24 18:06:32 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-24 18:06:32 +0200 |
| commit | 529945c987c5107d84b627a56627df6dd40dd3da (patch) | |
| tree | 33ed7c7e3795e091fa85daf5ef3c37a74618d9d1 /dev/ZKA/Sources | |
| parent | fdc8aaab2ad3c2f2f3f4bb4ffb71bc2d797366aa (diff) | |
[FIX] Kernel: Fix scheduler code and improved it's inner workings.
[FIX] DLLMain now spins scheduler when it's done about showing the setup
window.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA/Sources')
| -rw-r--r-- | dev/ZKA/Sources/DLLMain.cxx | 22 | ||||
| -rw-r--r-- | dev/ZKA/Sources/ProcessScheduler.cxx | 36 | ||||
| -rw-r--r-- | dev/ZKA/Sources/Timer.cxx | 2 |
3 files changed, 37 insertions, 23 deletions
diff --git a/dev/ZKA/Sources/DLLMain.cxx b/dev/ZKA/Sources/DLLMain.cxx index cecf7347..b3bcd48c 100644 --- a/dev/ZKA/Sources/DLLMain.cxx +++ b/dev/ZKA/Sources/DLLMain.cxx @@ -24,6 +24,7 @@ #include <KernelKit/CodeManager.hxx> #include <CFKit/Property.hxx> #include <Modules/CoreCG/WindowRenderer.hxx> +#include <KernelKit/Timer.hxx> EXTERN Kernel::Property cKernelVersion; @@ -180,14 +181,19 @@ namespace Kernel::Detail }; } // namespace Kernel::Detail +namespace Kernel +{ + EXTERN ProcessScheduler* cProcessScheduler; +} // namespace Kernel + /// @brief Application entrypoint. /// @param Void /// @return Void EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void) { - CGInit(); + CGInit(); - CGDrawInRegion(CGColor(0x45, 0x00, 0x06), CG::UIAccessibilty::The().Height(), CG::UIAccessibilty::The().Width(), + CGDrawInRegion(CGColor(0x45, 0x00, 0x06), CG::UIAccessibilty::The().Height(), CG::UIAccessibilty::The().Width(), 0, 0); CGFini(); @@ -209,16 +215,14 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void) root_install_wnd->w_needs_repaint = Yes; - CG::UI_WINDOW_STRUCT* arr[] = {root_zka_wnd, root_install_wnd}; - - CGDrawInRegion(CGColor(0x45, 0x00, 0x06), CG::UIAccessibilty::The().Height(), CG::UIAccessibilty::The().Width(), - 0, 0); - - CGFini(); + CG::CGDrawWindowList(&root_zka_wnd, 1); + CG::CGDrawWindowList(&root_install_wnd, 1); - CG::CGDrawWindowList(arr, 2); + /// @note BThread doesn't parse the symbols so doesn't nullify them, .bss is though. + Kernel::cProcessScheduler = nullptr; while (Yes) { + Kernel::ProcessHelper::StartScheduling(); } } diff --git a/dev/ZKA/Sources/ProcessScheduler.cxx b/dev/ZKA/Sources/ProcessScheduler.cxx index 1d83e519..d33c7e85 100644 --- a/dev/ZKA/Sources/ProcessScheduler.cxx +++ b/dev/ZKA/Sources/ProcessScheduler.cxx @@ -28,7 +28,10 @@ namespace Kernel /// @brief Exit Code global variable. /***********************************************************************************/ - STATIC Int32 cLastExitCode = 0U; + Int32 cLastExitCode = 0U; + + /// @brief The main process object. + ProcessScheduler* cProcessScheduler = nullptr; /// @brief Gets the last exit code. /// @note Not thread-safe. @@ -202,7 +205,7 @@ namespace Kernel } } - ProcessScheduler::The().Leak().Remove(this->ProcessId); + cProcessScheduler->Remove(this->ProcessId); } /// @brief Add process to list. @@ -278,6 +281,16 @@ namespace Kernel return (mTeam.AsArray().Count() - 1); } + /***********************************************************************************/ + + Ref<ProcessScheduler> ProcessScheduler::The() + { + MUST_PASS(cProcessScheduler); + return *cProcessScheduler; + } + + /***********************************************************************************/ + /// @brief Remove process from list. /// @param processSlot process slot inside team. /// @retval true process was removed. @@ -301,6 +314,8 @@ namespace Kernel /// @return SizeT ProcessScheduler::Run() noexcept { + kcout << "newoskrnl: Entering scheduler control..\r"; + SizeT process_index = 0; //! we store this guy to tell the scheduler how many //! things we have scheduled. @@ -337,6 +352,8 @@ namespace Kernel } } + kcout << "newoskrnl: Exiting scheduler control..\r"; + return process_index; } @@ -348,14 +365,6 @@ namespace Kernel } /// @internal - STATIC Ref<ProcessScheduler> cSchedulerRef; - - /// @brief Shared instance of the process scheduler. - /// @return - Ref<ProcessScheduler>& ProcessScheduler::The() - { - return cSchedulerRef; - } /// @brief Gets current running process. /// @return @@ -369,7 +378,7 @@ namespace Kernel PID& ProcessHelper::TheCurrentPID() { kcout << "ProcessHelper::TheCurrentPID: Leaking ProcessId...\r"; - return ProcessScheduler::The().Leak().TheCurrent().Leak().ProcessId; + return cProcessScheduler->TheCurrent().Leak().ProcessId; } /// @brief Check if process can be schedulded. @@ -414,9 +423,10 @@ namespace Kernel SizeT ProcessHelper::StartScheduling() { - auto& process_ref = ProcessScheduler::The().Leak(); - SizeT ret = process_ref.Run(); + if (!cProcessScheduler) + cProcessScheduler = new ProcessScheduler(); + SizeT ret = cProcessScheduler->Run(); return ret; } diff --git a/dev/ZKA/Sources/Timer.cxx b/dev/ZKA/Sources/Timer.cxx index 7a5ebd8d..3e5f6f3d 100644 --- a/dev/ZKA/Sources/Timer.cxx +++ b/dev/ZKA/Sources/Timer.cxx @@ -41,7 +41,7 @@ Int32 SoftwareTimer::Wait() noexcept while (*fDigitalTimer < (*fDigitalTimer + fWaitFor)) { - ++fDigitalTimer; + ++(*fDigitalTimer); } return 0; |
