![]() |
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 <block.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.
| void BlockingLock::acquire | ( | ) |
Acquire the spinlock, spin until the lock is available and sleeping the thread until marked as available.
Move the yielding logic into process/thread code so that it can be reused
circular dependancy resolution
Definition at line 49 of file block.cpp.
References MaxOS::processes::BLOCKING_FAST_TRY_LIMIT, and MaxOS::processes::GlobalScheduler::current_thread().
Referenced by lock().
| bool BlockingLock::is_locked | ( | ) | const |
| void BlockingLock::lock | ( | ) |
Lock the spinlock once it is available, sleeping until other processes are done with it.
Definition at line 23 of file block.cpp.
References acquire().
Referenced by MaxOS::processes::SharedMessageEndpoint::send().
| void BlockingLock::release | ( | ) |
Mark as unlocked, wake the next enqueued thread.
Definition at line 68 of file block.cpp.
References MaxOS::processes::GlobalScheduler::get_thread(), and MaxOS::processes::Thread::thread_state.
Referenced by unlock().
| void BlockingLock::unlock | ( | ) |
Unlock the spinlock.
Definition at line 30 of file block.cpp.
References release().
Referenced by MaxOS::processes::SharedMessageEndpoint::send().