Loading...
Searching...
No Matches
L4::Thread::Attr Class Reference

Thread attributes used for control(). More...

`#include <thread>`

Collaboration diagram for L4::Thread::Attr:

## Public Member Functions

| Attr (l4_utcb_t *utcb=l4_utcb()) noexcept
| Create a thread-attribute object with the given UTCB.
void | pager (Cap< void > const &pager) noexcept
| Set the pager capability selector.
Cap< void > | pager () noexcept
| Get the capability selector used for page-fault messages.
void | exc_handler (Cap< void > const &exc_handler) noexcept
| Set the exception-handler capability selector.
Cap< void > | exc_handler () noexcept
| Get the capability selector used for exception messages.
void | bind (l4_utcb_t *thread_utcb, Cap< Task > const &task) noexcept
| Bind the thread to a task.
void | alien (int on) noexcept
| Enable alien mode.

## Friends

class | L4::Thread

## Detailed Description

Thread attributes used for control().

This class is responsible for initializing various attributes of a thread in a UTCB for the control() method.

Note
  Instantiation of this class starts the preparation of the UTCB. Do not invoke any non-Attr functions between the instantiation and the call to L4::Thread::control().

See also
  Thread control for some more details.

Definition at line 137 of file thread.

## Constructor & Destructor Documentation

## Attr()

L4::Thread::Attr::Attr | ( | l4_utcb_t * | utcb = l4_utcb() | ) |

inlineexplicitnoexcept

Create a thread-attribute object with the given UTCB.

Parameters

  utcb | The UTCB to use for the later L4::Thread::control() function. Usually this is the UTCB of the calling thread. See l4_utcb().

Definition at line 151 of file thread.

## Member Function Documentation

## alien()

void L4::Thread::Attr::alien | ( | int | on | ) |

inlinenoexcept

Enable alien mode.

Parameters

  on | Boolean value defining the state of the feature.

For a thread in alien mode the kernel produces just an exception IPC for each IPC and exception caused by the alien thread instead of handling these events regularly. (Page faults of alien threads and interrupts occurring while the alien thread is running are always handled regularly.) While the alien thread is blocking, the exception handler can inspect and modify the state of the alien thread and potentially also the system call arguments. If the exception handler replies with L4_PROTO_ALLOW_SYSCALL as message tag, the kernel handles the next IPC or exception of the alien thread in a regular way. If the exception handler leaves certain thread state unchanged (in particular the instruction pointer), this will be the IPC or exception that caused the call of the exception handler. For a regularly processed IPC or exception of the alien thread the kernel also performs an exception IPC on kernel exit.

This feature can be used to attach a debugger to a thread and trace all object invocations and their results. It could also be used to handle other systems that use the same syscall instruction as L4Re.

Definition at line 224 of file thread.

## bind()

void L4::Thread::Attr::bind | ( | l4_utcb_t * | thread_utcb,
|  | Cap< Task > const & | task )

inlinenoexcept

Bind the thread to a task.

Parameters

  thread_utcb | The thread’s UTCB address within the task it shall be bound to. The address must be aligned (architecture dependent; at least word aligned) and it must point to at least L4_UTCB_OFFSET bytes of kernel-user memory.
  task | The task the thread shall be bound to.

Precondition
  The thread must not be bound to a task yet.
  The capability task must have the permission L4_CAP_FPAGE_S, otherwise the later call to L4::Thread::control() with this Attr object will fail with L4_EPERM.

A thread may execute code in the context of a task if and only if the thread is bound to the task. To actually start execution, L4::Thread::ex_regs() needs to be used. Execution in the context of the task means that the code has access to all the task’s resources (and only those). The executed code itself must be one of those resources. A thread can be bound at most once to a task.

Note
  The UTCBs of different threads in the same task should not overlap in order to prevent data corruption.

Definition at line 218 of file thread.

## exc_handler() [1/2]

Cap< void > L4::Thread::Attr::exc_handler | ( |  | ) |

inlinenoexcept

Get the capability selector used for exception messages.

Returns
  The capability selector used to send exception messages. The selector is valid in the task the thread is bound to.

Definition at line 189 of file thread.

## exc_handler() [2/2]

void L4::Thread::Attr::exc_handler | ( | Cap< void > const & | exc_handler | ) |

inlinenoexcept

Set the exception-handler capability selector.

Parameters

  exc_handler | The capability selector that shall be used for exception messages. This capability selector must be valid within the task the thread is bound to.

Definition at line 180 of file thread.

References exc_handler().

Referenced by exc_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

## pager() [1/2]

Cap< void > L4::Thread::Attr::pager | ( |  | ) |

inlinenoexcept

Get the capability selector used for page-fault messages.

Returns
  The capability selector used to send page-fault messages. The selector is valid in the task the thread is bound to.

Definition at line 170 of file thread.

## pager() [2/2]

void L4::Thread::Attr::pager | ( | Cap< void > const & | pager | ) |

inlinenoexcept

Set the pager capability selector.

Parameters

  pager | The capability selector that shall be used for page-fault messages. This capability selector must be valid within the task the thread is bound to.

Definition at line 161 of file thread.

References pager().

Referenced by pager().

Here is the call graph for this function:
Here is the caller graph for this function:

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

- l4/sys/thread