#include <thread_lock.h>
Public Member Functions | |
void | set_switch_hint (Switch_hint const hint) |
Set switch hint. | |
bool const | test_and_set () |
Lock a context. | |
void | lock () |
Lock a thread. | |
void | clear () |
Free the lock. | |
Context *const | lock_owner () const |
Lock owner. | |
bool const | test () |
Is lock set?. | |
Private Member Functions | |
void | lock_utcb () |
Dummy function to hold code in thread_lock generic. | |
void | unlock_utcb () |
Dummy function to hold code in thread_lock generic. | |
Context *const | context () const |
Context this thread lock belongs to. | |
Private Attributes | |
Switch_lock | _switch_lock |
Switch_hint | _switch_hint |
This lock uses the basic priority-inheritance mechanism (Switch_lock) and extends it in two ways: First, it has a hinting mechanism that allows a locker to specify whether the clear() operation should switch to the thread that was locked. Second, it maintains the current locker for Context; this locker automatically gets CPU time allocated to the locked thread (Context's ``donatee''); Context::switch_exec() uses that hint. To make clear, which stuff in the TCB the lock not protects: -the thread state -queues -the raw kernelstack The rest is protected with this lock, this includes the kernelstackpointer (kernel_sp).
|
Free the lock. First return the CPU to helper or next lock owner, whoever has the higher priority, given that thread's priority is higher that ours. Finally, switch to locked thread if that thread has a higher priority, and/or the switch hint says we should. |
|
Context this thread lock belongs to.
|
|
Lock a thread. If the lock is occupied, enqueue in list of helpers and lend CPU to current lock owner until we are the lock owner. |
|
Lock owner.
|
|
Dummy function to hold code in thread_lock generic.
|
|
Set switch hint.
|
|
Is lock set?.
|
|
Lock a context.
|
|
Dummy function to hold code in thread_lock generic.
|
|
|
|
|