function::task_current - Linux
Overview
function::task_current
is a Rust function that returns the current task context. It’s used to retrieve information about the currently running task, such as its ID, state, and priority.
Syntax
pub fn task_current() -> TaskContext;
Options/Flags
None.
Examples
use kernel_hal::task_current;
let task_context = task_current();
println!("Current task ID: {}", task_context.id());
Common Issues
None.
Integration
function::task_current
can be combined with other Rust functions and crates to manipulate or introspect tasks in the system. For example, it can be used with the kernel_hal::process
crate to get information about the process that owns the current task.
Related Commands
task::yield
– Yields the current task’s time slice to another task.task::sleep
– Suspends the current task for a specified duration.task::kill
– Terminates the current task.