![]() |
Max OS 0.3
|
Enables a resource to be used by only one instance at a time through a combination of spinning and queuing. When waiting enqueued, thread will sleep. More...
#include <spinlock.h>
Public Member Functions | |
| void | lock () |
| Lock the spinlock once it is available, sleeping until other processes are done with it. | |
| void | unlock () |
| Unlock the spinlock. | |
| bool | is_locked () const |
| Check if the spinlock is locked. | |
| void | acquire () |
| Acquire the spinlock, spin until the lock is available and sleeping the thread until marked as available. | |
| void | release () |
| Mark as unlocked, wake the next enqueued thread. | |
Enables a resource to be used by only one instance at a time through a combination of spinning and queuing. When waiting enqueued, thread will sleep.
Definition at line 49 of file spinlock.h.
| void BlockingLock::acquire | ( | ) |
Acquire the spinlock, spin until the lock is available and sleeping the thread until marked as available.
Definition at line 101 of file spinlock.cpp.
References MaxOS::common::BLOCKING_FAST_TRY_LIMIT, MaxOS::processes::GlobalScheduler::core_scheduler(), MaxOS::processes::GlobalScheduler::current_thread(), MaxOS::hardwarecommunication::InterruptManager::ForceInterruptReturn(), and MaxOS::common::Vector< Type >::push_back().
Referenced by lock().
| bool BlockingLock::is_locked | ( | ) | const |
Check if the spinlock is locked.
Definition at line 92 of file spinlock.cpp.
| void BlockingLock::lock | ( | ) |
Lock the spinlock once it is available, sleeping until other processes are done with it.
Definition at line 73 of file spinlock.cpp.
References acquire().
| void BlockingLock::release | ( | ) |
Mark as unlocked, wake the next enqueued thread.
Definition at line 129 of file spinlock.cpp.
References MaxOS::common::Vector< Type >::empty(), MaxOS::processes::GlobalScheduler::get_thread(), and MaxOS::common::Vector< Type >::pop_front().
Referenced by unlock().
| void BlockingLock::unlock | ( | ) |
Unlock the spinlock.
Definition at line 81 of file spinlock.cpp.
References release().