From ad677bd1ed2c6d1a052d426117a4d20a0b59ac52 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 31 Dec 2024 16:50:34 +0100 Subject: FIX: CUSA and improved algorithm. Signed-off-by: Amlal El Mahrouss --- dev/Kernel/KernelKit/Defines.h | 2 +- dev/Kernel/KernelKit/IPEFDLLObject.h | 4 ++-- dev/Kernel/KernelKit/Semaphore.h | 10 ++++----- dev/Kernel/KernelKit/UserProcessScheduler.h | 30 +++++++++++++-------------- dev/Kernel/KernelKit/UserProcessScheduler.inl | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) (limited to 'dev/Kernel/KernelKit') diff --git a/dev/Kernel/KernelKit/Defines.h b/dev/Kernel/KernelKit/Defines.h index 26618c93..abebdfdb 100644 --- a/dev/Kernel/KernelKit/Defines.h +++ b/dev/Kernel/KernelKit/Defines.h @@ -12,4 +12,4 @@ #define KERNELKIT_VERSION_BCD 0x01020 class UserProcessScheduler; -class UserProcess; +class UserThread; diff --git a/dev/Kernel/KernelKit/IPEFDLLObject.h b/dev/Kernel/KernelKit/IPEFDLLObject.h index 579587ee..1781c589 100644 --- a/dev/Kernel/KernelKit/IPEFDLLObject.h +++ b/dev/Kernel/KernelKit/IPEFDLLObject.h @@ -99,8 +99,8 @@ namespace Kernel typedef IPEFDLLObject* IDLL; - EXTERN_C IDLL rtl_init_dylib(UserProcess* header); - EXTERN_C Void rtl_fini_dylib(UserProcess* header, IDLL lib, Bool* successful); + EXTERN_C IDLL rtl_init_dylib(UserThread& header); + EXTERN_C Void rtl_fini_dylib(UserThread& header, IDLL lib, Bool* successful); } // namespace Kernel #endif /* ifndef __KERNELKIT_SHARED_OBJECT_H__ */ diff --git a/dev/Kernel/KernelKit/Semaphore.h b/dev/Kernel/KernelKit/Semaphore.h index 9ae3f617..41e02645 100644 --- a/dev/Kernel/KernelKit/Semaphore.h +++ b/dev/Kernel/KernelKit/Semaphore.h @@ -12,9 +12,9 @@ namespace Kernel { - class UserProcess; + class UserThread; - typedef UserProcess* UserProcessPtr; + typedef UserThread& UserProcessRef; /// @brief Access control class, which locks a task until one is done. class Semaphore final @@ -31,13 +31,13 @@ namespace Kernel void WaitForProcess() noexcept; public: - bool Lock(UserProcess* process); - bool LockOrWait(UserProcess* process, TimerInterface* timer); + bool Lock(UserThread& process); + bool LockOrWait(UserThread& process, TimerInterface* timer); public: ZKA_COPY_DEFAULT(Semaphore); private: - UserProcessPtr fLockingProcess{nullptr}; + UserProcessRef fLockingProcess; }; } // namespace Kernel diff --git a/dev/Kernel/KernelKit/UserProcessScheduler.h b/dev/Kernel/KernelKit/UserProcessScheduler.h index 744ad45a..452a55a3 100644 --- a/dev/Kernel/KernelKit/UserProcessScheduler.h +++ b/dev/Kernel/KernelKit/UserProcessScheduler.h @@ -31,7 +31,7 @@ namespace Kernel //! @note Forward class declarations. class IDLLObject; - class UserProcess; + class UserThread; class UserProcessTeam; class UserProcessScheduler; class UserProcessHelper; @@ -142,16 +142,16 @@ namespace Kernel } }; - /// @name UserProcess + /// @name UserThread /// @brief User process class, holds information about the running process/thread. - class UserProcess final + class UserThread final { public: - explicit UserProcess(); - ~UserProcess(); + explicit UserThread(); + ~UserThread(); public: - ZKA_COPY_DEFAULT(UserProcess); + ZKA_COPY_DEFAULT(UserThread); public: Char Name[kProcessNameLen] = {"Process"}; @@ -261,18 +261,18 @@ namespace Kernel ZKA_COPY_DEFAULT(UserProcessTeam); - Array& AsArray(); - Ref& AsRef(); + Array& AsArray(); + Ref& AsRef(); ProcessID& Id() noexcept; public: - Array mProcessList; - Ref mCurrentProcess; + Array mProcessList; + Ref mCurrentProcess; ProcessID mTeamId{0}; ProcessID mProcessCount{0}; }; - using UserProcessPtr = UserProcess*; + using UserProcessRef = UserThread&; /// @brief Process scheduler class. /// The main class which you call to schedule user processes. @@ -293,7 +293,7 @@ namespace Kernel UserProcessTeam& CurrentTeam(); public: - ProcessID Spawn(UserProcess* process); + ProcessID Spawn(const Char* name, VoidPtr code, VoidPtr image); const Bool Remove(ProcessID process_id); const Bool IsUser() override; @@ -301,7 +301,7 @@ namespace Kernel const Bool HasMP() override; public: - Ref& GetCurrentProcess(); + Ref& GetCurrentProcess(); const SizeT Run() noexcept; public: @@ -312,14 +312,14 @@ namespace Kernel }; /* - * \brief UserProcess helper class, which contains needed utilities for the scheduler. + * \brief UserThread helper class, which contains needed utilities for the scheduler. */ class UserProcessHelper final { public: STATIC Bool Switch(VoidPtr image_ptr, UInt8* stack_ptr, HAL::StackFramePtr frame_ptr, const PID& new_pid); - STATIC Bool CanBeScheduled(const UserProcess* process); + STATIC Bool CanBeScheduled(const UserThread& process); STATIC ErrorOr TheCurrentPID(); STATIC SizeT StartScheduling(); }; diff --git a/dev/Kernel/KernelKit/UserProcessScheduler.inl b/dev/Kernel/KernelKit/UserProcessScheduler.inl index 70f9f0a8..83ced960 100644 --- a/dev/Kernel/KernelKit/UserProcessScheduler.inl +++ b/dev/Kernel/KernelKit/UserProcessScheduler.inl @@ -14,7 +14,7 @@ namespace Kernel /***********************************************************************************/ template - Boolean UserProcess::Delete(ErrorOr ptr, const SizeT& sz) + Boolean UserThread::Delete(ErrorOr ptr, const SizeT& sz) { if (!ptr || sz == 0) -- cgit v1.2.3