summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/KernelKit/Semaphore.h
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-12-21 21:59:13 +0100
committerAmlal <amlalelmahrouss@icloud.com>2024-12-21 21:59:45 +0100
commit610f91d87152cbe48d3054fcf437d8239da6ef35 (patch)
treea386f7047ab73d088169ab2371ddc6ffe8020f1c /dev/Kernel/KernelKit/Semaphore.h
parent509fcca5986651c8ba712fb395f8498f2dea4109 (diff)
IMP: :boom: Breaking changes some checks are needed to be done.
Signed-off-by: Amlal <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/KernelKit/Semaphore.h')
-rw-r--r--dev/Kernel/KernelKit/Semaphore.h43
1 files changed, 43 insertions, 0 deletions
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 <NewKit/Defines.h>
+#include <KernelKit/Timer.h>
+#include <CompilerKit/CompilerKit.h>
+
+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