Lines Matching full:task

30 /// Returns the currently running task.
36 unsafe { &*$crate::task::Task::current() }
40 /// Returns the currently running task's pid namespace.
46 unsafe { &*$crate::task::Task::current_pid_ns() }
74 /// Getting the current task and storing it in some struct. The reference count is automatically
78 /// use kernel::{task::Task, types::ARef};
81 /// creator: ARef<Task>,
95 pub struct Task(pub(crate) Opaque<bindings::task_struct>); struct
97 // SAFETY: By design, the only way to access a `Task` is via the `current` function or via an
98 // `ARef<Task>` obtained through the `AlwaysRefCounted` impl. This means that the only situation in
99 // which a `Task` can be accessed mutably is when the refcount drops to zero and the destructor
101 unsafe impl Send for Task {} implementation
103 // SAFETY: It's OK to access `Task` through shared references from other threads because we're
106 unsafe impl Sync for Task {} implementation
117 impl Task { impl
118 /// Returns a raw pointer to the current task.
127 /// Returns a task reference for the currently executing task/thread.
129 /// The recommended way to get the current task/thread is to use the
134 /// Callers must ensure that the returned object doesn't outlive the current task/thread.
135 pub unsafe fn current() -> impl Deref<Target = Task> { in current()
137 task: &'a Task, in current() field
142 type Target = Task; in current()
145 self.task in current()
149 let current = Task::current_raw(); in current()
151 // SAFETY: If the current thread is still running, the current task is valid. Given in current()
154 task: unsafe { &*current.cast() }, in current()
159 /// Returns a PidNamespace reference for the currently executing task's/thread's pid namespace.
163 /// current task's/thread's pid namespace is to use the [`current_pid_ns`] macro because it is
168 /// Callers must ensure that the returned object doesn't outlive the current task/thread.
171 task: &'a PidNamespace, in current_pid_ns() field
179 self.task in current_pid_ns()
183 // The lifetime of `PidNamespace` is bound to `Task` and `struct pid`. in current_pid_ns()
185 // The `PidNamespace` of a `Task` doesn't ever change once the `Task` is alive. A in current_pid_ns()
187 // on the calling `Task`'s pid namespace. It will only effect the pid namespace of children in current_pid_ns()
188 // created by the calling `Task`. This invariant guarantees that after having acquired a in current_pid_ns()
189 // reference to a `Task`'s pid namespace it will remain unchanged. in current_pid_ns()
191 // When a task has exited and been reaped `release_task()` will be called. This will set in current_pid_ns()
192 // the `PidNamespace` of the task to `NULL`. So retrieving the `PidNamespace` of a task in current_pid_ns()
195 // the `Task` will prevent `release_task()` being called. in current_pid_ns()
197 // In order to retrieve the `PidNamespace` of a `Task` the `task_active_pid_ns()` function in current_pid_ns()
200 // (1) retrieving the `PidNamespace` of the `current` task in current_pid_ns()
201 // (2) retrieving the `PidNamespace` of a non-`current` task in current_pid_ns()
211 // task means `NULL` can be returned as the non-`current` task could have already passed in current_pid_ns()
231 // `task->thread_pid`. The `struct pid` stored in that field is used to retrieve the in current_pid_ns()
232 // `PidNamespace` of the caller. When `release_task()` is called `task->thread_pid` will be in current_pid_ns()
235 // from `task->thread_pid` to finish. in current_pid_ns()
237 // SAFETY: The current task's pid namespace is valid as long as the current task is running. in current_pid_ns()
238 let pidns = unsafe { bindings::task_active_pid_ns(Task::current_raw()) }; in current_pid_ns()
240 // SAFETY: If the current thread is still running, the current task and its associated in current_pid_ns()
243 // `Task`). The caller needs to ensure that the PidNamespaceRef doesn't outlive the in current_pid_ns()
244 // current task/thread. in current_pid_ns()
245 task: unsafe { PidNamespace::from_ptr(pidns) }, in current_pid_ns()
250 /// Returns a raw pointer to the task.
256 /// Returns the group leader of the given task.
257 pub fn group_leader(&self) -> &Task { in group_leader() argument
258 // SAFETY: The group leader of a task never changes after initialization, so reading this in group_leader()
262 // SAFETY: The lifetime of the returned task reference is tied to the lifetime of `self`, in group_leader()
263 // and given that a task has a reference to its group leader, we know it must be valid for in group_leader()
264 // the lifetime of the returned task reference. in group_leader()
268 /// Returns the PID of the given task.
270 // SAFETY: The pid of a task never changes after initialization, so reading this field is in pid()
275 /// Returns the UID of the given task.
277 // SAFETY: It's always safe to call `task_uid` on a valid task. in uid()
281 /// Returns the effective UID of the given task.
283 // SAFETY: It's always safe to call `task_euid` on a valid task. in euid()
287 /// Determines whether the given task has pending signals.
289 // SAFETY: It's always safe to call `signal_pending` on a valid task. in signal_pending()
293 /// Returns task's pid namespace with elevated reference count
307 /// Returns the given task's pid in the provided pid namespace.
321 /// Wakes up the task.
323 // SAFETY: It's always safe to call `wake_up_process` on a valid task, even if the task in wake_up()
329 // SAFETY: The type invariants guarantee that `Task` is always refcounted.
330 unsafe impl crate::types::AlwaysRefCounted for Task { implementation
364 /// Uses the namespace of the current task.