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

Thread Class Reference

A thread. More...

#include <thread.h>

Inheritance diagram for Thread:

Receiver Sender Context Kernel_thread List of all members.

Public Types

typedef void( Utcb_copy_func )(Thread *sender, Thread *receiver)

Public Member Functions

 Thread (Task *task, Global_id id, unsigned short init_prio, unsigned short mcp)
 Constructor.
void sys_ipc ()
 L4 IPC system call.
void sys_fpage_unmap ()
 L4 system call fpage_unmap.
void sys_thread_switch ()
 L4 system-call thread_switch.
void sys_thread_schedule ()
 L4 system call thread_schedule.
void sys_task_new ()
 L4 system call task_new.
void sys_id_nearest ()
 L4 system call id_nearest.
void sys_thread_ex_regs ()
 L4 system call lthread_ex_regs.
bool handle_page_fault (Address pfa, Mword error, Mword pc)
 The global page fault handler switch.
Task_num d_taskno ()
 Task number for debugging purposes.
LThread_num d_threadno ()
 Thread number for debugging purposes.
Mword is_tcb_mapped () const
bool ipc_short_cut ()
 Short cut for L4 IPC system call (short IPC).
void * operator new (size_t, L4_uid id)
 Class-specific allocator.
void operator delete (void *)
 Deallocator.
virtual ~Thread ()
 Destructor.
Tasktask () const
 Task.
Thread_lockthread_lock ()
 Thread lock.
Preemptionpreemption ()
void handle_timer_interrupt ()
void halt ()
Space_index space_index () const
 Thread's space index.
Space_index chief_index () const
 Chief's space index.
bool kill_task (Space_index subtask)
 Kill a subtask of this thread's task.
unsigned nest () const
 Return nesting level.
bool has_privileged_iopl ()
void unset_utcb_ptr ()
bool initialize (Address ip, Address sp, Thread *pager, Receiver *preempter, Address *o_ip=0, Address *o_sp=0, Thread **o_pager=0, Receiver **o_preempter=0, Address *o_flags=0, bool no_cancel=0, bool alien=0)
 (Re-) Ininialize a thread and make it ready.
int handle_slow_trap (Trap_state *ts)
 The global trap handler switch.
bool raise_exception (Trap_state *ts, Address handler)
 Raise a machine exception for the task.
int snd_exception (Trap_state *) const
void handle_fpu_trap ()
virtual void ipc_receiver_ready ()
 Receiver-ready callback.
Ipc_err ipc_continue (Ipc_err ipc_code)
 Wake up sender.
Threadnext_present () const
void sys_ipc_log ()
 IPC logging.
void sys_ipc_trace ()
 IPC tracing.
void sys_fpage_unmap_log ()
 L4 system call fpage_unmap.
int is_mapped ()
int is_valid ()
void print_snd_partner (int task_format=0)
void print_partner (int task_format=0)
void print_uid (int task_format=0)
void print_state_long (unsigned cut_on_len=0)

Static Public Member Functions

static Threadlookup (L4_uid id, Space *s)
 Calculate TCB pointer from thread ID.
static Mword pagein_tcb_request (Address pc)
 Check if the pagefault occured at a special place: At some places in the kernel we want to ensure that a specific address is mapped.
static Threadlookup (Context *c)
 Lookup function: Find Thread instance that owns a given Context.
static Threadlookup (Global_id id)
 Calculate TCB pointer from global thread ID.
static void halt_current ()
static Threadlookup_first_thread (unsigned space)
 Return first thread in an address space.
static void privilege_initialization ()
static void set_int3_handler (int(*handler)(Trap_state *ts))
static int log_page_fault ()
static Task_num get_task (Global_id id)

Static Public Attributes

static bool may_enter_jdb = false

Protected Member Functions

 Thread (Task *task, L4_uid id)
 Cut-down version of Thread constructor; only for kernel threads Do only what's necessary to get a kernel thread started -- skip all fancy stuff, no locking is necessary.
void kill_all ()
void reset_ipc_window ()
 Resets the ipc window adresses.
void setup_ipc_window (unsigned win, Address address)
 Define contents of IPC windows.
bool in_present_list ()
 Is this thread a member of the present list?.
void present_enqueue (Thread *sibling)
 Enqueue in present list.
void present_dequeue ()
 Dequeue from present list.

Protected Attributes

Preemption _preemption
Deadline_timeout _deadline_timeout
Activation _activation
Task_task
Thread_lock _thread_lock
Thread_pager
Thread_ext_preempter
Threadpresent_next
Threadpresent_prev
L4_rcv_desc _target_desc
unsigned _pagein_status_code
Address _vm_window0
Address _vm_window1
jmp_buf * _recover_jmpbuf
L4_timeout _pf_timeout
Address _last_pf_address
unsigned _last_pf_error_code
unsigned _magic
Irq_alloc_irq
Idt_entry_idt
Unsigned16 _idt_limit

Static Protected Attributes

static const unsigned magic = 0xf001c001
static Trap_state::Handler
nested_trap_handler 
FIASCO_FASTCALL

Private Member Functions

 Thread (const Thread &)
 Default copy constructor is undefined.
void * operator new (size_t)
 Default new operator undefined.
bool handle_sigma0_page_fault (Address pfa)
bool handle_smas_page_fault (Address pfa, Mword error, Ipc_err &ipc_code)
void kill_small_space ()
 Additional things to do before killing, when using small spaces.
Mword small_space ()
 Return small address space the task is in.
void set_small_space (Mword nr)
 Move the task this thread belongs to to the given small address space.
void rcv_startup_msg ()
 Receive startup message.
bool associate_irq (Irq_alloc *irq)
void disassociate_irq (Irq_alloc *irq)
bool handle_smas_gp_fault ()
Mword ipc_send_regs (Thread *receiver, Sys_ipc_frame const *sender_regs)
 IPC rendezvous.
void page_fault_msg (Sys_ipc_frame &r, Address fault_address, Mword fault_ip, Mword err)
 Set up a page fault message.
void commit_ipc_success (Sys_ipc_frame *regs, Ipc_err err)
 Write IPC error code into stack frame and/or UTCB in case of successful IPC.
void commit_ipc_failure (Sys_ipc_frame *regs, Ipc_err err)
 Write IPC error code into stack frame and/or UTCB in case of failed IPC.
Ipc_err get_ipc_err (Sys_ipc_frame *regs)
 Get the current IPC error code out of stack frame and/or UTCB.
void set_source_local_id (Thread *receiver, Sys_ipc_frame *dest_regs)
 Set the source UTCB pointer in the IPC reg's, if this was an intra task IPC.
Address remote_fault_addr (Address pfa)
 Compute remote pagefault address from the local pagefault address in the local Long-IPC window.
Mword update_ipc_window (Address pfa, Mword error_code, Address remote_pfa)
 Try to upgrade the local IPC window with a mapping from the partner's address space.
bool kill ()
 Kill this thread.
void copy_utcb_to (Thread *)
void enqueue_thread0_other_task ()
int is_privileged_for_debug (Trap_state *)
bool get_ioport (Address, Trap_state *, unsigned *, unsigned *)
void enqueue_thread_other_task ()
void setup_lipc_utcb ()
void setup_exception_ipc ()
void setup_utcb_kernel_addr ()
 Dummy function to hold code in thread-ia32-ux-v2x0 generic.
void arch_init ()
 The ia32 specific part of the thread constructor.
int check_trap13_kernel (Trap_state *ts, bool from_user)
void check_f00f_bug (Trap_state *ts)
bool handle_io_page_fault (Trap_state *ts, Address eip, bool from_user)
bool handle_sysenter_trap (Trap_state *ts, Address eip, bool from_user)
bool trap_is_privileged (Trap_state *)
void do_wrmsr_in_kernel (Trap_state *ts)
void do_rdmsr_in_kernel (Trap_state *ts)
int handle_not_nested_trap (Trap_state *ts)
bool handle_lldt (Trap_state *)
void get_timesharing_param (L4_sched_param *param, L4_uid *preempter, L4_uid *ipc_partner)
Mword set_schedule_param (L4_sched_param param, unsigned short const id)
void set_preempter (L4_uid const preempter)
Mword set_realtime_param (L4_sched_param param)
Mword remove_realtime_param ()
Mword begin_periodic (Unsigned64 clock, Mword const type)
Mword end_periodic ()
void reset_nest (L4_uid id)
void inc_nest (L4_uid id)
void update_nest (L4_uid id)
int handle_inter_task_ex_regs (Sys_ex_regs_frame *, L4_uid *, Thread **, Task **, Thread **)
Unsigned64 snd_timeout (L4_timeout t, Sys_ipc_frame const *regs)
 Compute thread's send timeout.
Unsigned64 rcv_timeout (L4_timeout t, Sys_ipc_frame const *regs)
 Compute thread's receive timeout.
Ipc_err do_send (Thread *partner, L4_timeout t, Sys_ipc_frame *regs)
 Send an IPC message.
void prepare_receive (Sender *partner, Sys_ipc_frame *regs)
 Prepare an IPC-receive operation.
Ipc_err do_receive (Sender *sender, L4_timeout t, Sys_ipc_frame *regs)
 Receive an IPC message.
Ipc_err handle_page_fault_pager (Address pfa, Mword error_code)
 Page fault handler.
void unlock_receiver (Receiver *receiver, const Sys_ipc_frame *)
 Unlock the Receiver locked with ipc_try_lock().
Ipc_err handle_ipc_page_fault (Address pfa, Mword error_code)
 Handle a page fault that occurred in one of the ``IPC-window'' virtual-address-space regions.
Ipc_err ipc_snd_fpage (Thread *receiver, L4_fpage from_fpage, L4_fpage to_fpage, Address offset, bool grant, bool finish, bool dont_switch)
 Send a flexpage.
void wake_receiver (Thread *receiver)
Ipc_err ipc_finish (Thread *receiver, Ipc_err new_state, bool dont_switch)
 Finish an IPC.
Ipc_err ipc_pagein_request (Receiver *receiver, Address address, Mword error_code)
 Send a page-in request to a receiver.
bool invalid_ipc_buffer (void const *a)
Ipc_err do_send_long (Thread *partner, Sys_ipc_frame *i_regs)
 Carry out long IPC.
void page_fault_log (Address pfa, unsigned error_code, unsigned eip)
 Page-fault logging.

Static Private Member Functions

static void user_invoke ()
 Return to user.
static Mword const exception_cs ()
 Return code segment used for exception reflection to user mode.
static void handle_double_fault (void) asm("thread_handle_double_fault")
static void user_invoke_generic ()
static void print_page_fault_error (Mword e)
static int handle_int3 (Trap_state *ts)
 Default handle for int3 extensions if JDB is disabled.
static int call_nested_trap_handler (Trap_state *ts)
 Call the nested trap handler (either Jdb::enter_kdebugger() or the gdb stub.
static Unsigned64 round_quantum (Unsigned64 quantum)
 Round quantum up to the nearest supported value.

Static Private Attributes

static int(* int3_handler )(Trap_state *) = handle_int3

Friends

class Jdb
class Jdb_bt
class Jdb_tcb
class Jdb_thread_list
class Jdb_list_threads
class Jdb_list_timeouts
class Jdb_tbuf_show

Detailed Description

A thread.

This class is the driver class for most kernel functionality.


Member Typedef Documentation

typedef void( Thread::Utcb_copy_func)(Thread *sender, Thread *receiver)
 


Constructor & Destructor Documentation

Thread::Thread Task task,
Global_id  id,
unsigned short  init_prio,
unsigned short  mcp
 

Constructor.

Parameters:
task the task the thread should reside in.
id user-visible thread ID of the sender.
init_prio initial priority.
mcp maximum controlled priority.
Postcondition:
state() != Thread_invalid.

Thread::Thread const Thread  )  [private]
 

Default copy constructor is undefined.

Thread::Thread Task task,
L4_uid  id
[protected]
 

Cut-down version of Thread constructor; only for kernel threads Do only what's necessary to get a kernel thread started -- skip all fancy stuff, no locking is necessary.

Parameters:
space the address space
id user-visible thread ID of the sender

Thread::~Thread  )  [virtual]
 

Destructor.

Reestablish the Context constructor's precondition.

Precondition:
current() == thread_lock()->lock_owner() && state() == Thread_dead

lock_cnt() == 0

Postcondition:
(_kernel_sp == 0) && (* (stack end) == 0) && !exists()


Member Function Documentation

void Thread::arch_init  )  [inline, private]
 

The ia32 specific part of the thread constructor.

bool Thread::associate_irq Irq_alloc irq  )  [private]
 

Mword Thread::begin_periodic Unsigned64  clock,
Mword const   type
[private]
 

int Thread::call_nested_trap_handler Trap_state ts  )  [static, private]
 

Call the nested trap handler (either Jdb::enter_kdebugger() or the gdb stub.

Setup our own stack frame

void Thread::check_f00f_bug Trap_state ts  )  [inline, private]
 

int Thread::check_trap13_kernel Trap_state ts,
bool  from_user
[inline, private]
 

Space_index Thread::chief_index  )  const [inline]
 

Chief's space index.

Returns:
thread's chief's space index.

void Thread::commit_ipc_failure Sys_ipc_frame regs,
Ipc_err  err
[inline, private]
 

Write IPC error code into stack frame and/or UTCB in case of failed IPC.

Parameters:
regs the stack frame
err the error code
See also:
commit_ipc_success

void Thread::commit_ipc_success Sys_ipc_frame regs,
Ipc_err  err
[inline, private]
 

Write IPC error code into stack frame and/or UTCB in case of successful IPC.

Parameters:
regs the stack frame
err the error code
See also:
commit_ipc_failure

void Thread::copy_utcb_to Thread  )  [inline, private]
 

Task_num Thread::d_taskno  )  [inline]
 

Task number for debugging purposes.

May be changed to show sth. more useful for the debugger. Do not rely on this method in kernel code.

See also:
: d_threadno()

LThread_num Thread::d_threadno  )  [inline]
 

Thread number for debugging purposes.

See also:
: d_taskno()

void Thread::disassociate_irq Irq_alloc irq  )  [private]
 

void Thread::do_rdmsr_in_kernel Trap_state ts  )  [inline, private]
 

Ipc_err Thread::do_receive Sender sender,
L4_timeout  t,
Sys_ipc_frame regs
[private]
 

Receive an IPC message.

Block until we can receive a message or the timeout hits. Before calling this function, the thread needs to call prepare_receive(). The sender and regs arguments must correspond to those supplied to prepare_receive().

Parameters:
sender IPC partner we want to receive a message from. 0 if we accept IPC from any partner (``open wait'').
t a timeout specifier
regs receiver's IPC registers

Ipc_err Thread::do_send Thread partner,
L4_timeout  t,
Sys_ipc_frame regs
[private]
 

Send an IPC message.

Block until we can send the message or the timeout hits.

Parameters:
partner the receiver of our message
t a timeout specifier
regs sender's IPC registers
Returns:
sender's IPC error code

Ipc_err Thread::do_send_long Thread partner,
Sys_ipc_frame i_regs
[private]
 

Carry out long IPC.

This method assumes that IPC handshake has finished successfully (ipc_send_regs()). Its arguments must correspond to those supplied to ipc_send_regs(). The method copies data from the sender's address space into the receiver's using IPC address-space windows. During copying, page faults in both the sender's and the receiver's buffer can occur, leading to page-fault--IPC handling. When using small address spaces great care must be taken when copying out of the users address space, as kernel and user may use different segments.

Parameters:
partner the receiver of our message
regs sender's IPC registers
Returns:
sender's IPC error code

void Thread::do_wrmsr_in_kernel Trap_state ts  )  [inline, private]
 

Mword Thread::end_periodic  )  [private]
 

void Thread::enqueue_thread0_other_task  )  [inline, private]
 

void Thread::enqueue_thread_other_task  )  [inline, private]
 

Mword const Thread::exception_cs  )  [inline, static, private]
 

Return code segment used for exception reflection to user mode.

bool Thread::get_ioport Address  ,
Trap_state ,
unsigned *  ,
unsigned * 
[inline, private]
 

Ipc_err Thread::get_ipc_err Sys_ipc_frame regs  )  [inline, private]
 

Get the current IPC error code out of stack frame and/or UTCB.

Parameters:
*regs the stack frame where to read out the error code
Returns:
the error code found

Task_num Thread::get_task Global_id  id  )  [inline, static]
 

void Thread::get_timesharing_param L4_sched_param param,
L4_uid preempter,
L4_uid ipc_partner
[inline, private]
 

void Thread::halt  ) 
 

void Thread::halt_current  )  [static]
 

void Thread::handle_double_fault void   )  [static, private]
 

void Thread::handle_fpu_trap  )  [inline]
 

int Thread::handle_int3 Trap_state ts  )  [static, private]
 

Default handle for int3 extensions if JDB is disabled.

If the JDB is available, Jdb::handle_int3_threadctx is called instead.

Returns:
0 not handled, wait for user response 1 successfully handled

ALWAYS_INLINE int Thread::handle_inter_task_ex_regs Sys_ex_regs_frame ,
L4_uid ,
Thread **  ,
Task **  ,
Thread ** 
[inline, private]
 

bool Thread::handle_io_page_fault Trap_state ts,
Address  eip,
bool  from_user
[inline, private]
 

Ipc_err Thread::handle_ipc_page_fault Address  pfa,
Mword  error_code
[private]
 

Handle a page fault that occurred in one of the ``IPC-window'' virtual-address-space regions.

Parameters:
pfa virtual address of page fault
error_code page fault error code
Returns:
IPC error code if an error occurred during page-fault handling, 0 if page fault was handled successfully
Precondition:
current_thread() == this

bool Thread::handle_lldt Trap_state  )  [inline, private]
 

int Thread::handle_not_nested_trap Trap_state ts  )  [inline, private]
 

bool Thread::handle_page_fault Address  pfa,
Mword  error_code,
Mword  pc
[inline]
 

The global page fault handler switch.

Handles page-fault monitoring, classification of page faults based on virtual-memory area they occured in, page-directory updates for kernel faults, IPC-window updates, and invocation of paging function for user-space page faults (handle_page_fault_pager).

Parameters:
pfa page-fault virtual address
error_code CPU error code
Returns:
true if page fault could be resolved, false otherwise
Exceptions:
longjmp longjumps to recovery location if page-fault handling fails (i.e., return value would be false), but recovery location has been installed

Ipc_err Thread::handle_page_fault_pager Address  pfa,
Mword  error_code
[private]
 

Page fault handler.

This handler suspends any ongoing IPC, then sets up page-fault IPC. Finally, the ongoing IPC's state (if any) is restored.

Parameters:
pfa page-fault virtual address
error_code page-fault error code.

bool Thread::handle_sigma0_page_fault Address  pfa  )  [inline, private]
 

int Thread::handle_slow_trap Trap_state ts  ) 
 

The global trap handler switch.

This function handles CPU-exception reflection, emulation of CPU instructions (LIDT, WRMSR, RDMSR), int3 debug messages, kernel-debugger invocation, and thread crashes (if a trap cannot be handled).

Parameters:
state trap state
Returns:
0 if trap has been consumed by handler; -1 if trap could not be handled.

bool Thread::handle_smas_gp_fault  )  [inline, private]
 

bool Thread::handle_smas_page_fault Address  pfa,
Mword  error,
Ipc_err ipc_code
[inline, private]
 

bool Thread::handle_sysenter_trap Trap_state ts,
Address  eip,
bool  from_user
[inline, private]
 

void Thread::handle_timer_interrupt  )  [inline]
 

bool Thread::has_privileged_iopl  )  [inline]
 

bool Thread::in_present_list  )  [inline, protected]
 

Is this thread a member of the present list?.

Returns:
true if thread is in present list

void Thread::inc_nest L4_uid  id  )  [inline, private]
 

bool Thread::initialize Address  ip,
Address  sp,
Thread pager,
Receiver preempter,
Address *  o_ip = 0,
Address *  o_sp = 0,
Thread **  o_pager = 0,
Receiver **  o_preempter = 0,
Address *  o_flags = 0,
bool  no_cancel = 0,
bool  alien = 0
 

(Re-) Ininialize a thread and make it ready.

XXX Contrary to the L4-V2 spec we only cancel IPC if eip != 0xffffffff!

Parameters:
eip new user instruction pointer. Set only if != 0xffffffff.
esp new user stack pointer. Set only if != 0xffffffff.
o_eip return current instruction pointer if pointer != 0
o_esp return current stack pointer if pointer != 0
o_pager return current pager if pointer != 0
o_preempter return current internal preempter if pointer != 0
o_eflags return current eflags register if pointer != 0
Returns:
false if !exists(); true otherwise

bool Thread::invalid_ipc_buffer void const *  a  )  [inline, private]
 

Ipc_err Thread::ipc_continue Ipc_err  ipc_code  ) 
 

Wake up sender.

A receiver wants to wake up a sender after a page-in request.

Parameters:
ipc_code IPC status code that should be signalled to sender. This status code flags error conditions that occurred during a page-in in the receiver.
Returns:
0 if successful, Reaborted if sender was not in IPC anymore.

Ipc_err Thread::ipc_finish Thread receiver,
Ipc_err  new_state,
bool  dont_switch
[private]
 

Finish an IPC.

Parameters:
receiver the receiver of our message
new_state sender's IPC error conditions accumulated so far
Returns:
IPC error code that should be returned to sender

Ipc_err Thread::ipc_pagein_request Receiver receiver,
Address  address,
Mword  error_code
[private]
 

Send a page-in request to a receiver.

Requests that the receiver pages in some pages needed by the sender to copy data into the receiver's address space.

Parameters:
receiver the receiver of our message
address page fault's virtual address in receiver's address space
error_code page fault's error code
Returns:
0 if request could be sent. IPC error code if receiver was in incorrect state.

void Thread::ipc_receiver_ready  )  [virtual]
 

Receiver-ready callback.

Receivers make sure to call this function on waiting senders when they get ready to receive a message from that sender. Senders need to overwrite this interface.

Class Thread's implementation wakes up the sender if it is still in sender-wait state.

Implements Sender.

Mword Thread::ipc_send_regs Thread receiver,
Sys_ipc_frame const *  sender_regs
[inline, private]
 

IPC rendezvous.

This method sets up an IPC. It also finishes the IPC if it was a short IPC.

Parameters:
receiver IPC receiver
sender_regs sender's IPC registers
Returns:
IPC error code that should be returned to the sender. If the IPC could not be set up because of a transient error (e.g., IPC partner not ready to receive), returns 0x80000000.

ALWAYS_INLINE bool Thread::ipc_short_cut  )  [inline]
 

Short cut for L4 IPC system call (short IPC).

For the special case of short IPC we try to avoid the full blown overhead of the interruptible ipc scheme. It's only applicable if the following requirements are all met:

  • short IPC send by the sender
  • short IPC receive by the sender (optional, no receive also possible) except open wait in threads that can receive msgs from IRQs
  • no receive timeout in case of receive part
  • dst is ready to receive
  • dst is a valid, non-nil thread

Returns:
true if shortcut was successful, false if shortcut is not applicable and standard implementation IPC handling should be used instead.

Ipc_err Thread::ipc_snd_fpage Thread receiver,
L4_fpage  from_fpage,
L4_fpage  to_fpage,
Address  offset,
bool  grant,
bool  finish,
bool  dont_switch
[private]
 

Send a flexpage.

Assumes we are in the middle of long IPC.

Parameters:
receiver the receiver of our message
from_fpage sender's flexpage
to_fpage receiver's flexpage
offset sender-specified offset into receiver's flexpage
grant if set the page will be granted, otherwise mapped
finish if true, finish IPC operation after sending flexpage; if false, leave IPC partners in IPC-in-progress state
Returns:
IPC error code if an error occurred. 0 if successful

int Thread::is_mapped  )  [inline]
 

int Thread::is_privileged_for_debug Trap_state  )  [inline, private]
 

Mword Thread::is_tcb_mapped  )  const [inline]
 

int Thread::is_valid  ) 
 

bool Thread::kill  )  [private]
 

Kill this thread.

If this thread has local number 0, kill its address space (task) as well. This function does not handle recursion.

Returns:
false if thread does not exists or has already been killed. Otherwise, true.

void Thread::kill_all  )  [inline, protected]
 

void Thread::kill_small_space  )  [inline, private]
 

Additional things to do before killing, when using small spaces.

bool Thread::kill_task Space_index  subtask  ) 
 

Kill a subtask of this thread's task.

This must be executed on thread 0 of the chief of the task to be killed.

Parameters:
subtask a task number
Returns:
false if this thread does not exists or has been killed already. Otherwise, true.
Precondition:
id().id.lthread == 0 && Space_index_util::chief(subtask) == space_index()

int Thread::log_page_fault  )  [inline, static]
 

Thread * Thread::lookup Global_id  id  )  [inline, static]
 

Calculate TCB pointer from global thread ID.

Parameters:
id the thread ID.
Returns:
TCB pointer if the ID was valid, 0 otherwise.

Thread * Thread::lookup Context c  )  [inline, static]
 

Lookup function: Find Thread instance that owns a given Context.

Parameters:
c a context
Returns:
the thread that owns the context

Thread * Thread::lookup L4_uid  id,
Space s
[inline, static]
 

Calculate TCB pointer from thread ID.

Parameters:
id thread ID.
s space, needed if ID is local.
Returns:
thread pointer if the ID was valid, 0 otherwise.

Thread * Thread::lookup_first_thread unsigned  space  )  [inline, static]
 

Return first thread in an address space.

unsigned Thread::nest  )  const [inline]
 

Return nesting level.

Returns:
nesting level of thread's clan

Thread * Thread::next_present  )  const [inline]
 

void Thread::operator delete void *   )  [inline]
 

Deallocator.

This function currently does nothing: We do not free up space allocated to thread-control blocks.

void * Thread::operator new size_t  ,
L4_uid  id
[inline]
 

Class-specific allocator.

This allocator ensures that threads are allocated at a fixed virtual address computed from their thread ID.

Parameters:
id thread ID
Returns:
address of new thread control block

Reimplemented in Kernel_thread.

void* Thread::operator new size_t   )  [private]
 

Default new operator undefined.

void Thread::page_fault_log Address  pfa,
unsigned  error_code,
unsigned  eip
[private]
 

Page-fault logging.

void Thread::page_fault_msg Sys_ipc_frame r,
Address  fault_address,
Mword  fault_ip,
Mword  err
[inline, private]
 

Set up a page fault message.

Parameters:
r the stack frame
fault_address the address where the PF occured
fault_ip EIP value on page fault
err error code

Mword Thread::pagein_tcb_request Address  eip  )  [inline, static]
 

Check if the pagefault occured at a special place: At some places in the kernel we want to ensure that a specific address is mapped.

The regular case is "mapped", the exception or slow case is "not mapped". The fastest way to check this is to touch into the memory. If there is no mapping for the address we get a pagefault. Now the pagefault exception handler can recognize that situation by scanning the code. The trick is that the assembler instruction "andl $0xffffffff, %ss:(%ecx)" _clears_ the carry flag normally (see Intel reference manual). The pager wants to inform the code that there was a pagefault and therefore _sets_ the carry flag. So the code has only to check if the carry flag is set. If yes, there was a pagefault at this instruction.

Parameters:
ip pagefault address

Preemption * Thread::preemption  )  [inline]
 

void Thread::prepare_receive Sender partner,
Sys_ipc_frame regs
[inline, private]
 

Prepare an IPC-receive operation.

This method must be called before do_receive() and, when carrying out a combined snd-and-receive operation, also before do_send().

Parameters:
partner IPC partner we want to receive a message from. 0 if we accept IPC from any partner (``open wait'').
regs receiver's IPC registers

void Thread::present_dequeue  )  [inline, protected]
 

Dequeue from present list.

Remove this thread from present list.

void Thread::present_enqueue Thread sibling  )  [inline, protected]
 

Enqueue in present list.

Parameters:
sibling present-list member after which we should be enqueued
Precondition:
sibling->in_present_list() == true

void Thread::print_page_fault_error Mword  e  )  [static, private]
 

void Thread::print_partner int  task_format = 0  ) 
 

void Thread::print_snd_partner int  task_format = 0  ) 
 

void Thread::print_state_long unsigned  cut_on_len = 0  ) 
 

void Thread::print_uid int  task_format = 0  ) 
 

void Thread::privilege_initialization  )  [static]
 

bool Thread::raise_exception Trap_state ts,
Address  handler
[inline]
 

Raise a machine exception for the task.

This function modifies a thread's user stack pointer and user instruction pointer to emulate a machine exception.

Parameters:
ts trap state that is being posted
handler pointer to user-level handler function the thread has installed
Returns:
false if thread is not ready or has been reinititialized using initialize(). Otherwise true.

void Thread::rcv_startup_msg  )  [inline, private]
 

Receive startup message.

Wait for startup IPC from pager and set ip and sp.

Unsigned64 Thread::rcv_timeout L4_timeout  t,
Sys_ipc_frame const *  regs
[inline, private]
 

Compute thread's receive timeout.

Parameters:
t timeout descriptor
regs ipc registers
Returns:
0 if timeout expired, absolute timeout value otherwise

Address Thread::remote_fault_addr Address  pfa  )  [inline, private]
 

Compute remote pagefault address from the local pagefault address in the local Long-IPC window.

Parameters:
pfa Local pagefault address in IPC window
Returns:
Remote pagefault address in partner's address space

Mword Thread::remove_realtime_param  )  [inline, private]
 

void Thread::reset_ipc_window  )  [inline, protected]
 

Resets the ipc window adresses.

Should be called at the end of every long IPC to prevent unnecessary pagefaults. If we dont do this, the test if (EXPECT_TRUE (_vm_window0 == address)) in setup_ipc_window(unsigned win, Address address) is mostly successful. If the test is positive, we dont copy the PDE slots. Because pingpong uses the same ipc buffers again and again, then this so called "optimization" results in pagefaults for EVERY long ipc. Reason: pingpong sets for the first time the _vm_window*, do the long ipc and switch to the receiver. Then receiver switches back to the sender using another ipc. Remember: every thread switch flushes the ipc window pde slots. But, because we have same ipc buffer addresses as before, the test is always positive, and so we dont update the now empty pde slots. The result is, for EVERY long ipc, after the first long ipc, we get an pagefault.

void Thread::reset_nest L4_uid  id  )  [inline, private]
 

Unsigned64 Thread::round_quantum Unsigned64  quantum  )  [inline, static, private]
 

Round quantum up to the nearest supported value.

void Thread::set_int3_handler int(*)(Trap_state *ts)  handler  )  [inline, static]
 

void Thread::set_preempter L4_uid const   preempter  )  [inline, private]
 

Mword Thread::set_realtime_param L4_sched_param  param  )  [inline, private]
 

Mword Thread::set_schedule_param L4_sched_param  param,
unsigned short const   id
[inline, private]
 

void Thread::set_small_space Mword  nr  )  [inline, private]
 

Move the task this thread belongs to to the given small address space.

void Thread::set_source_local_id Thread receiver,
Sys_ipc_frame dest_regs
[inline, private]
 

Set the source UTCB pointer in the IPC reg's, if this was an intra task IPC.

Necessary for efficient LIPC. It's a dummy on non LIPC kernels.

Parameters:
receiver the receiver
Returns:
dest_regs the receivers IPC registers

void Thread::setup_exception_ipc  )  [inline, private]
 

void Thread::setup_ipc_window unsigned  win,
Address  address
[inline, protected]
 

Define contents of IPC windows.

The address range set for these ranges is mapped upon the next page fault in handle_page_fault().

Parameters:
win number of IPC window -- either 0 or 1.
address 4-MByte-aligned virtual address of range to be mapped into given window

void Thread::setup_lipc_utcb  )  [inline, private]
 

void Thread::setup_utcb_kernel_addr  )  [inline, private]
 

Dummy function to hold code in thread-ia32-ux-v2x0 generic.

Mword Thread::small_space  )  [inline, private]
 

Return small address space the task is in.

int Thread::snd_exception Trap_state  )  const [inline]
 

Unsigned64 Thread::snd_timeout L4_timeout  t,
Sys_ipc_frame const *  regs
[inline, private]
 

Compute thread's send timeout.

Parameters:
t timeout descriptor
regs ipc registers
Returns:
0 if timeout expired, absolute timeout value otherwise

Space_index Thread::space_index  )  const [inline]
 

Thread's space index.

Returns:
thread's space index.

void Thread::sys_fpage_unmap  )  [inline]
 

L4 system call fpage_unmap.

ALWAYS_INLINE void Thread::sys_fpage_unmap_log  )  [inline]
 

L4 system call fpage_unmap.

ALWAYS_INLINE void Thread::sys_id_nearest  )  [inline]
 

L4 system call id_nearest.

ALWAYS_INLINE void Thread::sys_ipc  )  [inline]
 

L4 IPC system call.

This is the `normal'' version of the IPC system call. It usually only gets called if ipc_short_cut() has failed.

Parameters:
regs system-call arguments.
Returns:
value to be returned in eax register.

ALWAYS_INLINE void Thread::sys_ipc_log  )  [inline]
 

IPC logging.

called from interrupt gate.

ALWAYS_INLINE void Thread::sys_ipc_trace  )  [inline]
 

IPC tracing.

ALWAYS_INLINE void Thread::sys_task_new  )  [inline]
 

L4 system call task_new.

ALWAYS_INLINE void Thread::sys_thread_ex_regs  )  [inline]
 

L4 system call lthread_ex_regs.

ALWAYS_INLINE void Thread::sys_thread_schedule  )  [inline]
 

L4 system call thread_schedule.

void Thread::sys_thread_switch  )  [inline]
 

L4 system-call thread_switch.

Task * Thread::task  )  const [inline]
 

Task.

Returns:
pointer to thread's task.

Thread_lock * Thread::thread_lock  )  [inline]
 

Thread lock.

Overwrite Context's version of thread_lock() with a semantically equivalent, but more efficient version.

Returns:
lock used to synchronize accesses to the thread.

bool Thread::trap_is_privileged Trap_state  )  [inline, private]
 

void Thread::unlock_receiver Receiver receiver,
const Sys_ipc_frame
[inline, private]
 

Unlock the Receiver locked with ipc_try_lock().

If the sender goes to wait for a registered message enable LIPC.

Parameters:
receiver receiver to unlock
sender_regs dummy

void Thread::unset_utcb_ptr  )  [inline]
 

Mword Thread::update_ipc_window Address  pfa,
Mword  error_code,
Address  remote_pfa
[private]
 

Try to upgrade the local IPC window with a mapping from the partner's address space.

Parameters:
pfa Local pagefault address in IPC window
remote_pfa Remote pagefault address in partner's address space
Returns:
true if the partner had the page mapped and we could copy false if the partner needs to map the page himself first

void Thread::update_nest L4_uid  id  )  [inline, private]
 

void Thread::user_invoke  )  [static, private]
 

Return to user.

This function is the default routine run if a newly initialized context is being switch_exec()'ed.

void Thread::user_invoke_generic  )  [inline, static, private]
 

void Thread::wake_receiver Thread receiver  )  [inline, private]
 


Friends And Related Function Documentation

friend class Jdb [friend]
 

Reimplemented from Sender.

friend class Jdb_bt [friend]
 

friend class Jdb_list_threads [friend]
 

friend class Jdb_list_timeouts [friend]
 

friend class Jdb_tbuf_show [friend]
 

friend class Jdb_tcb [friend]
 

Reimplemented from Context.

friend class Jdb_thread_list [friend]
 

Reimplemented from Sender.


Member Data Documentation

Activation Thread::_activation [protected]
 

Deadline_timeout Thread::_deadline_timeout [protected]
 

Thread * Thread::_ext_preempter [protected]
 

Idt_entry* Thread::_idt [protected]
 

Unsigned16 Thread::_idt_limit [protected]
 

Irq_alloc* Thread::_irq [protected]
 

Address Thread::_last_pf_address [protected]
 

unsigned Thread::_last_pf_error_code [protected]
 

unsigned Thread::_magic [protected]
 

unsigned Thread::_pagein_status_code [protected]
 

Thread* Thread::_pager [protected]
 

L4_timeout Thread::_pf_timeout [protected]
 

Preemption Thread::_preemption [protected]
 

jmp_buf* Thread::_recover_jmpbuf [protected]
 

L4_rcv_desc Thread::_target_desc [protected]
 

Task* Thread::_task [protected]
 

Thread_lock Thread::_thread_lock [protected]
 

Reimplemented from Context.

Address Thread::_vm_window0 [protected]
 

Address Thread::_vm_window1 [protected]
 

Trap_state::Handler nested_trap_handler Thread::FIASCO_FASTCALL [static, protected]
 

int(* Thread::int3_handler = handle_int3 [static, private]
 

const unsigned Thread::magic = 0xf001c001 [static, protected]
 

bool Thread::may_enter_jdb = false [static]
 

Thread* Thread::present_next [protected]
 

Thread * Thread::present_prev [protected]
 


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