From f3d931aa7cfaf96baef8383b59a8938779541ee7 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Thu, 15 Aug 2024 18:35:34 +0200 Subject: [IMP] Moved source code into dev/ folder. Signed-off-by: Amlal EL Mahrouss --- dev/Kernel/KernelKit/Semaphore.hxx | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 dev/Kernel/KernelKit/Semaphore.hxx (limited to 'dev/Kernel/KernelKit/Semaphore.hxx') diff --git a/dev/Kernel/KernelKit/Semaphore.hxx b/dev/Kernel/KernelKit/Semaphore.hxx new file mode 100644 index 00000000..33dfe651 --- /dev/null +++ b/dev/Kernel/KernelKit/Semaphore.hxx @@ -0,0 +1,43 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#include +#include +#include + +namespace Kernel +{ + class PROCESS_HEADER_BLOCK; + + typedef PROCESS_HEADER_BLOCK* ProcessHeaderRef; + + /// @brief Access control class, which locks a task until one is done. + class Semaphore final + { + public: + explicit Semaphore() = default; + ~Semaphore() = default; + + public: + bool IsLocked() const; + bool Unlock() noexcept; + + public: + void WaitForProcess() noexcept; + + public: + bool Lock(PROCESS_HEADER_BLOCK* process); + bool LockOrWait(PROCESS_HEADER_BLOCK* process, HardwareTimerInterface* timer); + + public: + NEWOS_COPY_DEFAULT(Semaphore); + + private: + ProcessHeaderRef fLockingProcess{nullptr}; + }; +} // namespace Kernel -- cgit v1.2.3