#[repr(transparent)]pub struct Task(/* private fields */);Expand description
Wraps the kernel’s struct task_struct.
Invariants
All instances are valid tasks created by the C portion of the kernel.
Instances of this type are always ref-counted, that is, a call to get_task_struct ensures
that the allocation remains valid at least until the matching call to put_task_struct.
Examples
The following is an example of getting the PID of the current thread with zero additional cost when compared to the C version:
let pid = current!().pid();Getting the PID of the current process, also zero additional cost:
let pid = current!().group_leader().pid();Getting the current task and storing it in some struct. The reference count is automatically
incremented when creating State and decremented when it is dropped:
use kernel::{task::Task, types::ARef};
struct State {
creator: ARef<Task>,
index: u32,
}
impl State {
fn new() -> Self {
Self {
creator: current!().into(),
index: 0,
}
}
}Implementations§
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more