diff options
Diffstat (limited to 'src')
| -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); } |
