diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-08-16 19:56:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-16 19:56:21 +0200 |
| commit | 1a32b9307357ac0fc9095e853b2b6d94f9fe62bb (patch) | |
| tree | f41f723659c8926e38182fbe062746d821ab487e /dev/kernel/src/BinaryMutex.cc | |
| parent | eb9df5eea339812513c25a8d3b2eeb03c633e7ac (diff) | |
| parent | b301047903b79560dce69085fc271a653a1eb4b6 (diff) | |
Merge pull request #55 from nekernel-org/dev
v0.0.4
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(); |
