L4Re - L4 Runtime Environment
L4::Thread Class Reference

C++ L4 kernel thread interface. More...

+ Inheritance diagram for L4::Thread:
+ Collaboration diagram for L4::Thread:

Data Structures

class  Attr
 Thread attributes used for control_commit(). More...
 
class  Modify_senders
 Wrapper class for modifying senders. More...
 

Public Member Functions

l4_msgtag_t ex_regs (l4_addr_t ip, l4_addr_t sp, l4_umword_t flags, l4_utcb_t *utcb=l4_utcb()) throw ()
 Exchange basic thread registers. More...
 
l4_msgtag_t ex_regs (l4_addr_t *ip, l4_addr_t *sp, l4_umword_t *flags, l4_utcb_t *utcb=l4_utcb()) throw ()
 Exchange basic thread registers and return previous values. More...
 
l4_msgtag_t control (Attr const &attr) throw ()
 Commit the given thread-attributes object. More...
 
l4_msgtag_t switch_to (l4_utcb_t *utcb=l4_utcb()) throw ()
 Switch execution to this thread. More...
 
l4_msgtag_t stats_time (l4_kernel_clock_t *us, l4_utcb_t *utcb=l4_utcb()) throw ()
 Get consumed time of thread in us. More...
 
l4_msgtag_t vcpu_resume_start (l4_utcb_t *utcb=l4_utcb()) throw ()
 vCPU resume, start. More...
 
l4_msgtag_t vcpu_resume_commit (l4_msgtag_t tag, l4_utcb_t *utcb=l4_utcb()) throw ()
 vCPU resume, commit. More...
 
l4_msgtag_t vcpu_control (l4_addr_t vcpu_state, l4_utcb_t *utcb=l4_utcb()) throw ()
 Enable or disable the vCPU feature for the thread. More...
 
l4_msgtag_t vcpu_control_ext (l4_addr_t ext_vcpu_state, l4_utcb_t *utcb=l4_utcb()) throw ()
 Enable or disable the extended vCPU feature for the thread. More...
 
l4_msgtag_t register_del_irq (Cap< Irq > irq, l4_utcb_t *u=l4_utcb()) throw ()
 Register an IRQ that will trigger upon deletion events. More...
 
l4_msgtag_t modify_senders (Modify_senders const &todo) throw ()
 Apply sender modifiction rules. More...
 
- Public Member Functions inherited from L4::Kobject
l4_msgtag_t dec_refcnt (l4_mword_t diff, l4_utcb_t *utcb=l4_utcb())
 Decrement the in kernel reference counter for the object. More...
 

Additional Inherited Members

- Protected Types inherited from L4::Kobject_t< Thread, Kobject, L4_PROTO_THREAD, Type_info::Demand_t< 1 > >
typedef Thread Class
 The target interface type (inheriting from Kobject_t)
 
typedef Typeid::Iface< PROTO, Thread__Iface
 The interface description for the derived class.
 
typedef Typeid::Merge_list< Typeid::Iface_list< __Iface >, typename Kobject ::__Iface_list > __Iface_list
 The list of all RPC interfaces provided directly or through inheritance.
 
- Protected Member Functions inherited from L4::Kobject_t< Thread, Kobject, L4_PROTO_THREAD, Type_info::Demand_t< 1 > >
L4::Cap< Classc () const
 Get the capability to ourselves.
 
- Protected Member Functions inherited from L4::Kobject
l4_cap_idx_t cap () const throw ()
 Return capability selector. More...
 
- Static Protected Member Functions inherited from L4::Kobject_t< Thread, Kobject, L4_PROTO_THREAD, Type_info::Demand_t< 1 > >
static void __check_protocols__ ()
 Helper to check for protocol conflicts.
 

Detailed Description

C++ L4 kernel thread interface.

The Thread class defines a thread of execution in the L4 context. Usually user-level and kernel threads are mapped 1:1 to each other. Thread kernel objects are created using a factory, see the L4::Factory API (L4::Factory::create()).

Amongst other things an L4::Thread encapsulates:

  • CPU state
    • General-purpose registers
    • Program counter
    • Stack pointer
  • FPU state
  • Scheduling parameters, see the L4::Scheduler API
  • Execution state
    • Blocked, Runnable, Running

Thread objects provide an API for

Include File
#include <l4/sys/thread>

For the C interface see the Thread API.

Definition at line 58 of file thread.

Member Function Documentation

◆ control()

l4_msgtag_t L4::Thread::control ( Attr const &  attr)
throw (
)
inline

Commit the given thread-attributes object.

Parameters
attrthe attribute object to commit to the thread.

Definition at line 215 of file thread.

◆ ex_regs() [1/2]

l4_msgtag_t L4::Thread::ex_regs ( l4_addr_t  ip,
l4_addr_t  sp,
l4_umword_t  flags,
l4_utcb_t utcb = l4_utcb() 
)
throw (
)
inline

Exchange basic thread registers.

Parameters
ipNew instruction pointer, use ~0UL to leave the instruction pointer unchanged.
spNew stack pointer, use ~0UL to leave the stack pointer unchanged.
flagsEx-regs flags, see L4_thread_ex_regs_flags.
utcbUTCB to use for this operation.
Returns
System call return tag

This method allows to manipulate a thread. The basic functionality is to set the instruction pointer and the stack pointer of a thread. Additionally, this method allows also to cancel ongoing IPC operations and to force the thread to raise an artificial exception (see flags).

The thread is started using L4::Scheduler::run_thread(). However, if at the time L4::Scheduler::run_thread() is called, the instruction pointer of the thread is invalid, a later call to ex_regs() with a valid instruction pointer might start the thread.

Definition at line 85 of file thread.

◆ ex_regs() [2/2]

l4_msgtag_t L4::Thread::ex_regs ( l4_addr_t ip,
l4_addr_t sp,
l4_umword_t flags,
l4_utcb_t utcb = l4_utcb() 
)
throw (
)
inline

Exchange basic thread registers and return previous values.

Parameters
[in,out]ipNew instruction pointer, use ~0UL to leave the instruction pointer unchanged, return previous instruction pointer.
[in,out]spNew stack pointer, use ~0UL to leave the stack pointer unchanged, returns previous stack pointer.
[in,out]flagsEx-regs flags, see L4_thread_ex_regs_flags, return previous CPU flags of the thread.
utcbUTCB to use for this operation.
Returns
System call return tag. [out] parameters are only valid if the function returns successfully. Use l4_error() to check.

This method allows to manipulate and start a thread. The basic functionality is to set the instruction pointer and the stack pointer of a thread. Additionally, this method allows also to cancel ongoing IPC operations and to force the thread to raise an artificial exception (see flags).

Definition at line 111 of file thread.

◆ modify_senders()

l4_msgtag_t L4::Thread::modify_senders ( Modify_senders const &  todo)
throw (
)
inline

Apply sender modifiction rules.

Parameters
todoPrepared sender modification rules.
Returns
System call return tag.

Definition at line 373 of file thread.

◆ register_del_irq()

l4_msgtag_t L4::Thread::register_del_irq ( Cap< Irq irq,
l4_utcb_t u = l4_utcb() 
)
throw (
)
inline

Register an IRQ that will trigger upon deletion events.

Parameters
irqCapability selector for the IRQ object to be triggered.
uUTCB to be used for this operation, usually the UTCB of the calling thread.
Returns
System call return tag containing the return code.

An example of a deletion event is the removal of an IPC gate that is bound to this thread.

See also
l4_thread_register_del_irq

Definition at line 313 of file thread.

◆ stats_time()

l4_msgtag_t L4::Thread::stats_time ( l4_kernel_clock_t us,
l4_utcb_t utcb = l4_utcb() 
)
throw (
)
inline

Get consumed time of thread in us.

Parameters
[out]usConsumed time in ┬Ás.
utcbUTCB of the current thread.
Returns
Syscall return tag.

Definition at line 236 of file thread.

◆ switch_to()

l4_msgtag_t L4::Thread::switch_to ( l4_utcb_t utcb = l4_utcb())
throw (
)
inline

Switch execution to this thread.

Parameters
utcbthe UTCB of the current thread.
Note
The current time slice is inherited to this thread.

Definition at line 225 of file thread.

◆ vcpu_control()

l4_msgtag_t L4::Thread::vcpu_control ( l4_addr_t  vcpu_state,
l4_utcb_t utcb = l4_utcb() 
)
throw (
)
inline

Enable or disable the vCPU feature for the thread.

Parameters
vcpu_stateThe virtual address where the kernel shall store the vCPU state in case of vCPU exits. The address must be a valid kernel-user-memory address (see L4::Task::add_ku_mem()).
utcbUTCB to use for this operation.
Returns
Syscall return tag.

This function enables the vCPU feature of this thread if vcpu_state is set to a valid kernel-user-memory address, or disables the vCPU feature if vcpu_state is 0. (Disable: optional, currently unsupported.)

Definition at line 272 of file thread.

◆ vcpu_control_ext()

l4_msgtag_t L4::Thread::vcpu_control_ext ( l4_addr_t  ext_vcpu_state,
l4_utcb_t utcb = l4_utcb() 
)
throw (
)
inline

Enable or disable the extended vCPU feature for the thread.

Parameters
ext_vcpu_stateThe virtual address where the kernel shall store the vCPU state in case of vCPU exits. The address must be a valid kernel-user-memory address (see L4::Task::add_ku_mem()).
utcbUTCB to use for this operation.
Returns
Syscall return tag.

The extended vCPU feature allows the use of hardware-virtualization features such as Intel's VT or AMD's SVM.

This function enables the extended vCPU feature of this thread if ext_vcpu_state is set to a valid kernel-user-memory address, or disables the vCPU feature if ext_vcpu_state is 0.

Note
The extended vCPU mode includes the normal vCPU mode.

Definition at line 296 of file thread.

◆ vcpu_resume_commit()

l4_msgtag_t L4::Thread::vcpu_resume_commit ( l4_msgtag_t  tag,
l4_utcb_t utcb = l4_utcb() 
)
throw (
)
inline

vCPU resume, commit.

See also
l4_thread_vcpu_resume_commit

Definition at line 253 of file thread.

◆ vcpu_resume_start()

l4_msgtag_t L4::Thread::vcpu_resume_start ( l4_utcb_t utcb = l4_utcb())
throw (
)
inline

vCPU resume, start.

See also
l4_thread_vcpu_resume_start

Definition at line 245 of file thread.


The documentation for this class was generated from the following file: