9using namespace MaxOS::processes;
10using namespace MaxOS::hardwarecommunication;
11using namespace MaxOS::system;
13BlockingLock::BlockingLock() =
default;
14BlockingLock::~BlockingLock() =
default;
16bool BlockingLock::must_spin() {
53 if(!__atomic_test_and_set(&m_locked, __ATOMIC_ACQUIRE))
58 thread->thread_state = ThreadState::WAITING;
59 m_queue.push_back(thread->tid);
74 __atomic_clear(&m_locked, __ATOMIC_RELEASE);
Defines BlockingLock class for thread synchronization.
constexpr uint8_t BLOCKING_FAST_TRY_LIMIT
How many attempts to acquire the lock should fail before queueing.
void acquire()
Acquire the spinlock, spin until the lock is available and sleeping the thread until marked as availa...
void lock()
Lock the spinlock once it is available, sleeping until other processes are done with it.
void release()
Mark as unlocked, wake the next enqueued thread.
void unlock()
Unlock the spinlock.
bool is_locked() const
Check if the spinlock is locked.
static Thread * get_thread(uint64_t tid)
Gets a thread on the currently executing core by its TID.
static bool is_active()
Checks if the global scheduler is active.
static Thread * current_thread()
Gets the thread on the currently executing core.
volatile thread_state_t thread_state
The current state of the thread.
Defines a GlobalScheduler and Scheduler for managing processes and threads.