NeKernel dev
Loading...
Searching...
No Matches
BinaryMutex.h
Go to the documentation of this file.
1/* ========================================
2
3 Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
4
5======================================== */
6
7#pragma once
8
10#include <KernelKit/Timer.h>
11#include <NeKit/Config.h>
12
13namespace Kernel {
14class USER_PROCESS;
15
17class BinaryMutex final {
18 public:
19 using LockedPtr = USER_PROCESS*;
20
21 explicit BinaryMutex() = default;
22 ~BinaryMutex() = default;
23
24 public:
25 bool IsLocked() const;
26 bool Unlock();
27
28 public:
29 BOOL WaitForProcess(const UInt32& sec);
30
31 public:
32 bool Lock(LockedPtr process);
33 bool LockAndWait(LockedPtr process, TimerInterface* timer);
34
35 public:
37
38 private:
40};
41} // namespace Kernel
#define NE_COPY_DEFAULT(KLASS)
Definition Detail.h:17
#define BOOL
bool Lock(LockedPtr process)
Locks process in the binary mutex.
Definition BinaryMutex.cc:29
~BinaryMutex()=default
bool IsLocked() const
Checks if process is locked.
Definition BinaryMutex.cc:41
bool Unlock()
Unlocks the binary mutex.
Definition BinaryMutex.cc:15
bool LockAndWait(LockedPtr process, TimerInterface *timer)
Try lock or wait.
Definition BinaryMutex.cc:49
BOOL WaitForProcess(const UInt32 &sec)
Wait for process sec until we check if it's free.
Definition BinaryMutex.cc:64
LockedPtr fLockingProcess
Definition BinaryMutex.h:39
USER_PROCESS * LockedPtr
Definition BinaryMutex.h:19
Definition Timer.h:18
UPS inline definitions.
Definition Device.h:12
__UINT32_TYPE__ UInt32
Definition Config.h:44