diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-03-16 16:42:09 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-03-16 16:42:09 +0100 |
| commit | 57921ca1d52dd3c3c988bf198b903c2da42f391a (patch) | |
| tree | b092732bc6c677536aed58366b149b17d1c46537 /dev/Kernel/src/Semaphore.cc | |
| parent | 52779b9cc5b98ec201cc3a908a009469b4429647 (diff) | |
ADD: BinaryMutex class, and reworking Semaphore class.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/src/Semaphore.cc')
| -rw-r--r-- | dev/Kernel/src/Semaphore.cc | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/dev/Kernel/src/Semaphore.cc b/dev/Kernel/src/Semaphore.cc deleted file mode 100644 index 20dd89e6..00000000 --- a/dev/Kernel/src/Semaphore.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. - -------------------------------------------- */ - -#include <KernelKit/UserProcessScheduler.h> -#include <KernelKit/Semaphore.h> - -namespace NeOS -{ - /***********************************************************************************/ - /// @brief Unlocks the semaphore. - /***********************************************************************************/ - Bool Semaphore::Unlock() noexcept - { - if (fLockingProcess) - { - fLockingProcess = UserProcess(); - fLockingProcess.Status = ProcessStatusKind::kFrozen; - return Yes; - } - - return No; - } - - /***********************************************************************************/ - /// @brief Locks process in the semaphore. - /***********************************************************************************/ - Bool Semaphore::Lock(UserProcess& process) - { - if (!process || fLockingProcess) - return No; - - fLockingProcess = process; - - return Yes; - } - - /***********************************************************************************/ - /// @brief Checks if process is locked. - /***********************************************************************************/ - Bool Semaphore::IsLocked() const - { - return fLockingProcess.Status == ProcessStatusKind::kRunning; - } - - /***********************************************************************************/ - /// @brief Try lock or wait. - /***********************************************************************************/ - Bool Semaphore::LockOrWait(UserProcess& process, TimerInterface* timer) - { - if (timer == nullptr) - return No; - - this->Lock(process); - - timer->Wait(); - - return this->Lock(process); - } - - /***********************************************************************************/ - /// @brief Wait for process to be free. - /***********************************************************************************/ - Void Semaphore::WaitForProcess() noexcept - { - while (fLockingProcess) - ; - } -} // namespace NeOS |
