From 27fd1ba438eecbe184a5deda6d9f468509ec4f42 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 21 Aug 2025 09:23:13 +0200 Subject: feat: refactor and fixed python scripts. Signed-off-by: Amlal El Mahrouss --- dev/kernel/KernelKit/UserProcessScheduler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dev/kernel/KernelKit/UserProcessScheduler.h') diff --git a/dev/kernel/KernelKit/UserProcessScheduler.h b/dev/kernel/KernelKit/UserProcessScheduler.h index 3dae178a..9fa15f17 100644 --- a/dev/kernel/KernelKit/UserProcessScheduler.h +++ b/dev/kernel/KernelKit/UserProcessScheduler.h @@ -48,7 +48,7 @@ class USER_PROCESS final { AffinityKind Affinity{AffinityKind::kStandard}; ProcessStatusKind Status{ProcessStatusKind::kKilled}; UInt8 StackReserve[kSchedMaxStackSz]; - PROCESS_IMAGE Image{}; + ProcessImage Image{}; SizeT StackSize{kSchedMaxStackSz}; IDylibObject* DylibDelegate{nullptr}; SizeT MemoryCursor{0UL}; @@ -192,7 +192,7 @@ class UserProcessScheduler final : public ISchedulable { NE_MOVE_DELETE(UserProcessScheduler) public: - operator bool(); + operator bool(); bool operator!(); public: -- cgit v1.2.3 From b6ce3d25357b4e01daf212a955a6093133bc2fe4 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 21 Aug 2025 15:19:01 +0200 Subject: feat: Reworked `hefsi_hash_64` to follow the codebase's conventions. Signed-off-by: Amlal El Mahrouss --- dev/kernel/CFKit/Property.h | 6 +++--- dev/kernel/KernelKit/KernelTaskScheduler.h | 2 +- dev/kernel/KernelKit/UserProcessScheduler.h | 2 +- dev/kernel/NeKit/Json.h | 4 ++-- dev/kernel/NeKit/KString.inl | 18 +++++++++--------- dev/kernel/src/FS/HeFS+FileSystemParser.cc | 8 ++++---- 6 files changed, 20 insertions(+), 20 deletions(-) (limited to 'dev/kernel/KernelKit/UserProcessScheduler.h') diff --git a/dev/kernel/CFKit/Property.h b/dev/kernel/CFKit/Property.h index e872896d..7fc9bf07 100644 --- a/dev/kernel/CFKit/Property.h +++ b/dev/kernel/CFKit/Property.h @@ -32,9 +32,9 @@ class Property { Property& operator=(const Property&) = default; Property(const Property&) = default; - BOOL StringEquals(BasicKString<>& name); - PropertyId& GetValue(); - BasicKString<>& GetKey(); + BOOL StringEquals(BasicKString<>& name); + PropertyId& GetValue(); + BasicKString<>& GetKey(); private: KString fName{kMaxPropLen}; diff --git a/dev/kernel/KernelKit/KernelTaskScheduler.h b/dev/kernel/KernelKit/KernelTaskScheduler.h index 78aea53c..527da9f0 100644 --- a/dev/kernel/KernelKit/KernelTaskScheduler.h +++ b/dev/kernel/KernelKit/KernelTaskScheduler.h @@ -28,7 +28,7 @@ class KERNEL_TASK final { HAL::StackFramePtr StackFrame{nullptr}; UInt8* StackReserve{nullptr}; SizeT StackSize{kSchedMaxStackSz}; - ProcessImage Image{}; + ProcessImage Image{}; /// @brief a KID is a Kernel Identification Descriptor, it is used to find a task running within /// the kernel. KID Kid{0}; diff --git a/dev/kernel/KernelKit/UserProcessScheduler.h b/dev/kernel/KernelKit/UserProcessScheduler.h index 9fa15f17..69a631be 100644 --- a/dev/kernel/KernelKit/UserProcessScheduler.h +++ b/dev/kernel/KernelKit/UserProcessScheduler.h @@ -48,7 +48,7 @@ class USER_PROCESS final { AffinityKind Affinity{AffinityKind::kStandard}; ProcessStatusKind Status{ProcessStatusKind::kKilled}; UInt8 StackReserve[kSchedMaxStackSz]; - ProcessImage Image{}; + ProcessImage Image{}; SizeT StackSize{kSchedMaxStackSz}; IDylibObject* DylibDelegate{nullptr}; SizeT MemoryCursor{0UL}; diff --git a/dev/kernel/NeKit/Json.h b/dev/kernel/NeKit/Json.h index ebd4acf9..24357dd7 100644 --- a/dev/kernel/NeKit/Json.h +++ b/dev/kernel/NeKit/Json.h @@ -25,7 +25,7 @@ namespace Kernel { class Json final { public: explicit Json() { - auto len = kJSONMaxLen; + auto len = kJSONMaxLen; BasicKString<> key = KString(len); key += kJSONNullObj; @@ -42,7 +42,7 @@ class Json final { Bool& IsUndefined() { return fUndefined; } private: - Bool fUndefined; // is this instance undefined? + Bool fUndefined; // is this instance undefined? BasicKString<> fKey; BasicKString<> fValue; diff --git a/dev/kernel/NeKit/KString.inl b/dev/kernel/NeKit/KString.inl index a0dd3623..1faefb08 100644 --- a/dev/kernel/NeKit/KString.inl +++ b/dev/kernel/NeKit/KString.inl @@ -19,22 +19,22 @@ inline void rt_string_append(Char* lhs, const Char* rhs, Int32 cur) { } } -template<> +template <> inline Char* BasicKString<>::Data() { return this->fData; } -template<> +template <> inline const Char* BasicKString<>::CData() const { return const_cast(this->fData); } -template<> +template <> inline SizeT BasicKString<>::Length() const { return this->fDataSz; } -template<> +template <> inline bool BasicKString<>::operator==(const BasicKString<>& rhs) const { if (rhs.Length() != this->Length()) return false; @@ -45,7 +45,7 @@ inline bool BasicKString<>::operator==(const BasicKString<>& rhs) const { return true; } -template<> +template <> inline bool BasicKString<>::operator==(const Char* rhs) const { if (rt_string_len(rhs) != this->Length()) return false; @@ -56,7 +56,7 @@ inline bool BasicKString<>::operator==(const Char* rhs) const { return true; } -template<> +template <> inline bool BasicKString<>::operator!=(const BasicKString<>& rhs) const { if (rhs.Length() != this->Length()) return false; @@ -67,7 +67,7 @@ inline bool BasicKString<>::operator!=(const BasicKString<>& rhs) const { return true; } -template<> +template <> inline bool BasicKString<>::operator!=(const Char* rhs) const { if (rt_string_len(rhs) != this->Length()) return false; @@ -78,7 +78,7 @@ inline bool BasicKString<>::operator!=(const Char* rhs) const { return true; } -template<> +template <> inline BasicKString<>& BasicKString<>::operator+=(const BasicKString<>& rhs) { if (rt_string_len(rhs.fData) > this->Length()) return *this; @@ -88,7 +88,7 @@ inline BasicKString<>& BasicKString<>::operator+=(const BasicKString<>& rhs) { return *this; } -template<> +template <> inline BasicKString<>& BasicKString<>::operator+=(const Char* rhs) { rt_string_append(this->fData, const_cast(rhs), this->fCur); this->fCur += rt_string_len(const_cast(rhs)); diff --git a/dev/kernel/src/FS/HeFS+FileSystemParser.cc b/dev/kernel/src/FS/HeFS+FileSystemParser.cc index 344369d5..f1531b4c 100644 --- a/dev/kernel/src/FS/HeFS+FileSystemParser.cc +++ b/dev/kernel/src/FS/HeFS+FileSystemParser.cc @@ -91,14 +91,14 @@ namespace Detail { STATIC UInt64 hefsi_hash_64(const Utf8Char* path) { if (!path || *path == 0) return 0; - const UInt64 FNV_OFFSET_BASIS = 0xcbf29ce484222325ULL; - const UInt64 FNV_PRIME = 0x100000001b3ULL; + const UInt64 kFnvBaseOffset = 0xcbf29ce484222325ULL; + const UInt64 kFnvPrimeNumber = 0x100000001b3ULL; - UInt64 hash = FNV_OFFSET_BASIS; + UInt64 hash = kFnvBaseOffset; while (*path) { hash ^= (Utf8Char) (*path++); - hash *= FNV_PRIME; + hash *= kFnvPrimeNumber; } return hefsi_to_big_endian_64(hash); -- cgit v1.2.3 From 141786008aa639c313d83a6a06db700ed69ed064 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 23 Aug 2025 09:13:37 +0200 Subject: feat: scheduler: ProcessImage should be friend with KernelScheduler, not helper. feat! scheduler: Introduce ProcessID as only PID type. Signed-off-by: Amlal El Mahrouss --- dev/kernel/KernelKit/CoreProcessScheduler.h | 13 ++++++------- dev/kernel/KernelKit/KernelTaskScheduler.h | 6 +++--- dev/kernel/KernelKit/UserProcessScheduler.h | 6 +++--- dev/kernel/NetworkKit/IPC.h | 2 +- dev/kernel/src/UserProcessScheduler.cc | 12 ++++++------ 5 files changed, 19 insertions(+), 20 deletions(-) (limited to 'dev/kernel/KernelKit/UserProcessScheduler.h') diff --git a/dev/kernel/KernelKit/CoreProcessScheduler.h b/dev/kernel/KernelKit/CoreProcessScheduler.h index ee848ffc..fa124a02 100644 --- a/dev/kernel/KernelKit/CoreProcessScheduler.h +++ b/dev/kernel/KernelKit/CoreProcessScheduler.h @@ -117,11 +117,6 @@ enum class ProcessSubsystem : Int32 { kProcessSubsystemCount = 4, }; -/***********************************************************************************/ -//! @brief Local Process identifier. -/***********************************************************************************/ -typedef Int64 ProcessID; - /***********************************************************************************/ //! @brief Local Process status enum. /***********************************************************************************/ @@ -181,7 +176,11 @@ inline bool operator>=(AffinityKind lhs, AffinityKind rhs) { using PTime = UInt64; using ProcessTime = PTime; -using PID = Int64; + +/***********************************************************************************/ +//! @brief Local Process identifier. +/***********************************************************************************/ +using ProcessID = Int64; /***********************************************************************************/ /// @note For User manager, tells where we run the code. @@ -209,7 +208,7 @@ struct ProcessImage final { friend KERNEL_TASK; friend class UserProcessScheduler; - friend class KernelTaskHelper; + friend class KernelTaskScheduler; ImagePtr fCode{}; ImagePtr fBlob{}; diff --git a/dev/kernel/KernelKit/KernelTaskScheduler.h b/dev/kernel/KernelKit/KernelTaskScheduler.h index 527da9f0..527eec5e 100644 --- a/dev/kernel/KernelKit/KernelTaskScheduler.h +++ b/dev/kernel/KernelKit/KernelTaskScheduler.h @@ -17,7 +17,7 @@ namespace Kernel { class KernelTaskHelper; -typedef PID KID; +typedef ProcessID KID; /// @brief Equivalent of USER_PROCESS, but for kernel tasks. /// @author Amlal @@ -38,9 +38,9 @@ class KERNEL_TASK final { /// @author Amlal class KernelTaskHelper final { public: - STATIC Bool Switch(HAL::StackFramePtr frame_ptr, PID new_kid); + STATIC Bool Switch(HAL::StackFramePtr frame_ptr, ProcessID new_kid); STATIC Bool CanBeScheduled(const KERNEL_TASK& process); - STATIC ErrorOr TheCurrentKID(); + STATIC ErrorOr TheCurrentKID(); STATIC SizeT StartScheduling(); }; } // namespace Kernel \ No newline at end of file diff --git a/dev/kernel/KernelKit/UserProcessScheduler.h b/dev/kernel/KernelKit/UserProcessScheduler.h index 69a631be..a7ef13a9 100644 --- a/dev/kernel/KernelKit/UserProcessScheduler.h +++ b/dev/kernel/KernelKit/UserProcessScheduler.h @@ -79,7 +79,7 @@ class USER_PROCESS final { ProcessTime RTime{0}; //! @brief Process run time. ProcessTime UTime{0}; //! #brief Process used time. - PID ProcessId{kSchedInvalidPID}; + ProcessID ProcessId{kSchedInvalidPID}; Int32 Kind{kExecutableKind}; public: @@ -226,9 +226,9 @@ class UserProcessScheduler final : public ISchedulable { class UserProcessHelper final { public: - STATIC Bool Switch(HAL::StackFramePtr frame_ptr, PID new_pid); + STATIC Bool Switch(HAL::StackFramePtr frame_ptr, ProcessID new_pid); STATIC Bool CanBeScheduled(const USER_PROCESS& process); - STATIC ErrorOr TheCurrentPID(); + STATIC ErrorOr TheCurrentPID(); STATIC SizeT StartScheduling(); }; } // namespace Kernel diff --git a/dev/kernel/NetworkKit/IPC.h b/dev/kernel/NetworkKit/IPC.h index d14356c0..223a112b 100644 --- a/dev/kernel/NetworkKit/IPC.h +++ b/dev/kernel/NetworkKit/IPC.h @@ -20,7 +20,7 @@ /// IA separator. #define kIPCRemoteSeparator ":" -/// Interchange address, consists of PID:TEAM. +/// Interchange address, consists of ProcessID:TEAM. #define kIPCRemoteInvalid "00:00" #define kIPCHeaderMagic (0x4950434) diff --git a/dev/kernel/src/UserProcessScheduler.cc b/dev/kernel/src/UserProcessScheduler.cc index b73c9a3f..19e509ed 100644 --- a/dev/kernel/src/UserProcessScheduler.cc +++ b/dev/kernel/src/UserProcessScheduler.cc @@ -437,7 +437,7 @@ ProcessID UserProcessScheduler::Spawn(const Char* name, VoidPtr code, VoidPtr im /// @todo File Tree allocation and dispose methods (amlal) } - (Void)(kout << "PID: " << number(process.ProcessId) << kendl); + (Void)(kout << "ProcessID: " << number(process.ProcessId) << kendl); (Void)(kout << "Name: " << process.Name << kendl); return pid; @@ -573,11 +573,11 @@ Ref& UserProcessScheduler::TheCurrentProcess() { /// @brief Current proccess id getter. /// @return USER_PROCESS ID integer. -ErrorOr UserProcessHelper::TheCurrentPID() { - if (!UserProcessScheduler::The().TheCurrentProcess()) return ErrorOr{-kErrorProcessFault}; +ErrorOr UserProcessHelper::TheCurrentPID() { + if (!UserProcessScheduler::The().TheCurrentProcess()) return ErrorOr{-kErrorProcessFault}; kout << "UserProcessHelper::TheCurrentPID: Leaking ProcessId...\r"; - return ErrorOr{UserProcessScheduler::The().TheCurrentProcess().Leak().ProcessId}; + return ErrorOr{UserProcessScheduler::The().TheCurrentProcess().Leak().ProcessId}; } /// @brief Check if process can be schedulded. @@ -613,11 +613,11 @@ SizeT UserProcessHelper::StartScheduling() { /** * \brief Does a context switch in a CPU. * \param the_stack the stackframe of the running app. - * \param new_pid the process's PID. + * \param new_pid the process's ProcessID. */ /***********************************************************************************/ -Bool UserProcessHelper::Switch(HAL::StackFramePtr frame_ptr, PID new_pid) { +Bool UserProcessHelper::Switch(HAL::StackFramePtr frame_ptr, ProcessID new_pid) { (Void)(kout << "IP: " << hex_number(frame_ptr->IP) << kendl); for (SizeT index = 0UL; index < HardwareThreadScheduler::The().Capacity(); ++index) { -- cgit v1.2.3