From 610f91d87152cbe48d3054fcf437d8239da6ef35 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sat, 21 Dec 2024 21:59:13 +0100 Subject: IMP: :boom: Breaking changes some checks are needed to be done. Signed-off-by: Amlal --- dev/Kernel/KernelKit/Semaphore.h | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 dev/Kernel/KernelKit/Semaphore.h (limited to 'dev/Kernel/KernelKit/Semaphore.h') diff --git a/dev/Kernel/KernelKit/Semaphore.h b/dev/Kernel/KernelKit/Semaphore.h new file mode 100644 index 00000000..a5727d5e --- /dev/null +++ b/dev/Kernel/KernelKit/Semaphore.h @@ -0,0 +1,43 @@ +/* ------------------------------------------- + + Copyright (C) 2024, TQ B.V, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include +#include +#include + +namespace Kernel +{ + class UserProcess; + + typedef UserProcess* UserProcessPtr; + + /// @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(UserProcess* process); + bool LockOrWait(UserProcess* process, TimerInterface* timer); + + public: + ZKA_COPY_DEFAULT(Semaphore); + + private: + UserProcessPtr fLockingProcess{nullptr}; + }; +} // namespace Kernel -- cgit v1.2.3