* @brief The result type of lock operations.
*/
enum Status
- {
+ {
Not_locked, ///< The lock was formerly not aquired and -- we got it
Locked, ///< The lock was already aquired by ourselves
Invalid ///< The lock does not exist (is invalid)
* @return current owner of the lock. 0 if there is no owner.
*/
PUBLIC
-inline
+inline
Context * NO_INSTRUMENT
Switch_lock::lock_owner() const
{
Switch_lock::Status NO_INSTRUMENT
Switch_lock::try_lock()
{
- Lock_guard<Cpu_lock> guard (&cpu_lock);
+ Lock_guard<Cpu_lock> guard(&cpu_lock);
if (EXPECT_FALSE(!valid()))
return Invalid;
- bool ret = cas (&_lock_owner, (Address)0, Address(current()));
+ bool ret = cas(&_lock_owner, (Address)0, Address(current()));
if (ret)
current()->inc_lock_cnt(); // Do not lose this lock if current is deleted
Switch_lock::Status NO_INSTRUMENT
Switch_lock::lock()
{
- Lock_guard <Cpu_lock> guard (&cpu_lock);
+ Lock_guard <Cpu_lock> guard(&cpu_lock);
return lock_dirty();
}
return Invalid;
// have we already the lock?
- if(Address(_lock_owner) & ~1UL == Address(current()))
+ if (Address(_lock_owner) & ~1UL == Address(current()))
return Locked;
while (test())
// Help lock owner until lock becomes free
// while (test())
- bool tmp = current()->switch_exec_locked (lock_owner(), Context::Helping);
+ bool tmp = current()->switch_exec_locked(lock_owner(), Context::Helping);
(void)tmp;
Proc::irq_chance();
*/
bool need_sched = false;
if (h != c.owner)
- need_sched = c.owner->switch_exec_locked (h, Context::Ignore_Helping);
+ need_sched = c.owner->switch_exec_locked(h, Context::Ignore_Helping);
/*
* Someone apparently tries to delete us. Therefore we aren't
* allowed to continue to run and therefore let the scheduler
- * pick the next thread to execute.
+ * pick the next thread to execute.
*/
if (need_sched || (c.owner->lock_cnt() == 0 && c.owner->donatee()))
- c.owner->schedule ();
+ c.owner->schedule();
}
/** Free the lock.
@pre The lock must be valid (see valid()).
*/
-PUBLIC
+PUBLIC
void NO_INSTRUMENT
Switch_lock::clear()
{
- Lock_guard<Cpu_lock> guard (&cpu_lock);
+ Lock_guard<Cpu_lock> guard(&cpu_lock);
switch_dirty(clear_no_switch_dirty());
}
clear();
}
-/** Free the lock.
+/** Free the lock.
Return the CPU to helper if there is one, since it had to have a
higher priority to be able to help (priority may be its own, it
may run on a donated timeslice or round robin scheduling may have
void NO_INSTRUMENT
Switch_lock::invalidate()
{
- Lock_guard<Cpu_lock> guard (&cpu_lock);
+ Lock_guard<Cpu_lock> guard(&cpu_lock);
_lock_owner |= 1;
}
void NO_INSTRUMENT
Switch_lock::wait_free()
{
- Lock_guard<Cpu_lock> guard (&cpu_lock);
+ Lock_guard<Cpu_lock> guard(&cpu_lock);
assert (!valid());
// have we already the lock?
- if(lock_owner() == current())
+ if (lock_owner() == current())
{
set_lock_owner(0);
current()->dec_lock_cnt();
// Help lock owner until lock becomes free
// while (test())
- check (!current()->switch_exec_locked ((Context*)(Address(_lock_owner & ~1UL)), Context::Helping));
+ check (!current()->switch_exec_locked((Context*)(Address(_lock_owner & ~1UL)), Context::Helping));
Proc::irq_chance();
}