Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Thread_lock Class Reference

Thread lock. More...

#include <thread_lock.h>

List of all members.

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


Detailed Description

Thread lock.

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).


Member Function Documentation

void Thread_lock::clear  ) 
 

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 *const Thread_lock::context  )  const [inline, private]
 

Context this thread lock belongs to.

Returns:
context locked by this thread lock

void Thread_lock::lock  )  [inline]
 

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.

Context *const Thread_lock::lock_owner  )  const [inline]
 

Lock owner.

Returns:
current owner of the lock. 0 if there is no owner.

void Thread_lock::lock_utcb  )  [inline, private]
 

Dummy function to hold code in thread_lock generic.

void Thread_lock::set_switch_hint Switch_hint const   hint  )  [inline]
 

Set switch hint.

Parameters:
hint a hint to the clear() function

bool const Thread_lock::test  )  [inline]
 

Is lock set?.

Returns:
true if lock is set.

bool const Thread_lock::test_and_set  ) 
 

Lock a context.

Returns:
true if we owned the lock already. false otherwise.

void Thread_lock::unlock_utcb  )  [inline, private]
 

Dummy function to hold code in thread_lock generic.


Member Data Documentation

Switch_hint Thread_lock::_switch_hint [private]
 

Switch_lock Thread_lock::_switch_lock [private]
 


The documentation for this class was generated from the following files:
Generated on Mon Sep 26 14:20:17 2005 for Fiasco by  doxygen 1.4.2