pub struct CurrentTask(/* private fields */);
Expand description
Represents the Task
in the current
global.
This type exists to provide more efficient operations that are only valid on the current task. For example, to retrieve the pid-namespace of a task, you must use rcu protection unless it is the current task.
§Invariants
Each value of this type must only be accessed from the task context it was created within.
Of course, every thread is in a different task context, but for the purposes of this invariant, these operations also permanently leave the task context:
- Returning to userspace from system call context.
- Calling
release_task()
. - Calling
begin_new_exec()
in a binary format loader.
Other operations temporarily create a new sub-context:
- Calling
kthread_use_mm()
creates a new context, andkthread_unuse_mm()
returns to the old context.
This means that a CurrentTask
obtained before a kthread_use_mm()
call may be used again
once kthread_unuse_mm()
is called, but it must not be used between these two calls.
Conversely, a CurrentTask
obtained between a kthread_use_mm()
/kthread_unuse_mm()
pair
must not be used after kthread_unuse_mm()
.
Implementations§
Source§impl CurrentTask
impl CurrentTask
Sourcepub fn mm(&self) -> Option<&MmWithUser>
pub fn mm(&self) -> Option<&MmWithUser>
Access the address space of the current task.
This function does not touch the refcount of the mm.
Sourcepub fn active_pid_ns(&self) -> Option<&PidNamespace>
pub fn active_pid_ns(&self) -> Option<&PidNamespace>
Access the pid namespace of the current task.
This function does not touch the refcount of the namespace or use RCU protection.
To access the pid namespace of another task, see Task::get_pid_ns
.
Methods from Deref<Target = Task>§
Sourcepub fn group_leader(&self) -> &Task
pub fn group_leader(&self) -> &Task
Returns the group leader of the given task.
Sourcepub fn signal_pending(&self) -> bool
pub fn signal_pending(&self) -> bool
Determines whether the given task has pending signals.
Sourcepub fn get_pid_ns(&self) -> Option<ARef<PidNamespace>>
pub fn get_pid_ns(&self) -> Option<ARef<PidNamespace>>
Returns task’s pid namespace with elevated reference count
Sourcepub fn tgid_nr_ns(&self, pidns: Option<&PidNamespace>) -> Pid
pub fn tgid_nr_ns(&self, pidns: Option<&PidNamespace>) -> Pid
Returns the given task’s pid in the provided pid namespace.