diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-27 11:20:49 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-27 11:20:49 +0100 |
| commit | 8e3bfed0e3a80d79a7b02edf79dc6cd5e5c51a6d (patch) | |
| tree | 260c642a7bd05e001bcb31a3272bcfc14ed20a1c | |
| parent | e159d3895e29f38ec1345d396a593a04b7475b92 (diff) | |
feat: kernel: Fix binary mutex object.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | src/kernel/KernelKit/BinaryMutex.h | 2 | ||||
| -rw-r--r-- | src/kernel/src/BinaryMutex.cc | 9 |
2 files changed, 4 insertions, 7 deletions
diff --git a/src/kernel/KernelKit/BinaryMutex.h b/src/kernel/KernelKit/BinaryMutex.h index f3b59f23..42ae3694 100644 --- a/src/kernel/KernelKit/BinaryMutex.h +++ b/src/kernel/KernelKit/BinaryMutex.h @@ -28,7 +28,7 @@ class BinaryMutex final { BOOL WaitForProcess(const UInt32& sec); public: - bool Lock(LockedPtr process); + bool Lock(const Ref<LockedPtr>& process); bool LockAndWait(LockedPtr process, ITimer* timer); public: diff --git a/src/kernel/src/BinaryMutex.cc b/src/kernel/src/BinaryMutex.cc index 47bbcb3d..fe4171e1 100644 --- a/src/kernel/src/BinaryMutex.cc +++ b/src/kernel/src/BinaryMutex.cc @@ -24,7 +24,7 @@ Bool BinaryMutex::Unlock() { /// @brief Locks process in the binary mutex. /***********************************************************************************/ -Bool BinaryMutex::Lock(UserProcess* process) { +Bool BinaryMutex::Lock(const Ref<BinaryMutex::LockedPtr>& process) { if (!process || this->IsLocked()) return No; this->fLockingProcess = process; @@ -37,20 +37,17 @@ Bool BinaryMutex::Lock(UserProcess* process) { /***********************************************************************************/ Bool BinaryMutex::IsLocked() const { - return this->fLockingProcess->Status == ProcessStatusKind::kRunning; + return this->fLockingProcess && this->fLockingProcess->Status == ProcessStatusKind::kRunning; } /***********************************************************************************/ /// @brief Try lock or wait. /***********************************************************************************/ -Bool BinaryMutex::LockAndWait(UserProcess* process, ITimer* timer) { +Bool BinaryMutex::LockAndWait(BinaryMutex::LockedPtr process, ITimer* timer) { if (timer == nullptr) return No; - this->Lock(process); - timer->Wait(); - return this->Lock(process); } |
