diff options
Diffstat (limited to 'dev/kernel/src/BinaryMutex.cc')
| -rw-r--r-- | dev/kernel/src/BinaryMutex.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/dev/kernel/src/BinaryMutex.cc b/dev/kernel/src/BinaryMutex.cc index bbf7a477..9bfb89d9 100644 --- a/dev/kernel/src/BinaryMutex.cc +++ b/dev/kernel/src/BinaryMutex.cc @@ -11,10 +11,10 @@ namespace Kernel { /***********************************************************************************/ /// @brief Unlocks the binary mutex. /***********************************************************************************/ + Bool BinaryMutex::Unlock() noexcept { - if (fLockingProcess.Status == ProcessStatusKind::kRunning) { - fLockingProcess = USER_PROCESS(); - fLockingProcess.Status = ProcessStatusKind::kFrozen; + if (fLockingProcess->Status == ProcessStatusKind::kRunning) { + fLockingProcess = nullptr; return Yes; } @@ -25,7 +25,8 @@ Bool BinaryMutex::Unlock() noexcept { /***********************************************************************************/ /// @brief Locks process in the binary mutex. /***********************************************************************************/ -Bool BinaryMutex::Lock(USER_PROCESS& process) { + +Bool BinaryMutex::Lock(USER_PROCESS* process) { if (!process || this->IsLocked()) return No; this->fLockingProcess = process; @@ -36,14 +37,16 @@ Bool BinaryMutex::Lock(USER_PROCESS& process) { /***********************************************************************************/ /// @brief Checks if process is locked. /***********************************************************************************/ + Bool BinaryMutex::IsLocked() const { - return this->fLockingProcess.Status == ProcessStatusKind::kRunning; + return this->fLockingProcess->Status == ProcessStatusKind::kRunning; } /***********************************************************************************/ /// @brief Try lock or wait. /***********************************************************************************/ -Bool BinaryMutex::LockOrWait(USER_PROCESS& process, TimerInterface* timer) { + +Bool BinaryMutex::LockOrWait(USER_PROCESS* process, TimerInterface* timer) { if (timer == nullptr) return No; this->Lock(process); @@ -57,7 +60,8 @@ Bool BinaryMutex::LockOrWait(USER_PROCESS& process, TimerInterface* timer) { /// @brief Wait for process **sec** until we check if it's free. /// @param sec seconds. /***********************************************************************************/ -BOOL BinaryMutex::WaitForProcess(const Int16& sec) noexcept { + +BOOL BinaryMutex::WaitForProcess(const UInt32& sec) noexcept { HardwareTimer hw_timer(rtl_milliseconds(sec)); hw_timer.Wait(); |
