⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Task

Struct Task 

Source
pub struct Task {
Show 27 fields pub pid: ProcessId, pub tid: ThreadId, pub parent_pid: ProcessId, pub name: String, pub state: ProcessState, pub priority: Priority, pub sched_class: SchedClass, pub sched_policy: SchedPolicy, pub cpu_affinity: CpuSet, pub current_cpu: Option<u8>, pub time_slice: u32, pub vruntime: u64, pub stats: TaskStats, pub context: TaskContext, pub kernel_stack: usize, pub user_stack: usize, pub page_table: usize, pub blocked_on: Option<u64>, pub wait_link: Option<usize>, pub ready_link: Option<usize>, pub thread_ref: Option<NonNull<Thread>>, pub last_cpu: Option<u8>, pub migrations: u32, pub tls_base: u64, pub priority_boost: Option<Priority>, pub ipc_regs: [u64; 7], pub has_user_mappings: bool,
}
Expand description

Task Control Block (TCB)

Fields§

§pid: ProcessId

Process ID

§tid: ThreadId

Thread ID

§parent_pid: ProcessId

Parent process ID

§name: String

Task name

§state: ProcessState

Task state

§priority: Priority

Scheduling priority

§sched_class: SchedClass

Scheduling class

§sched_policy: SchedPolicy

Scheduling policy

§cpu_affinity: CpuSet

CPU affinity

§current_cpu: Option<u8>

Current CPU (if running)

§time_slice: u32

Time slice remaining (in ticks)

§vruntime: u64

Virtual runtime (for CFS)

§stats: TaskStats

Task statistics

§context: TaskContext

Architecture-specific context

§kernel_stack: usize

Kernel stack pointer

§user_stack: usize

User stack pointer

§page_table: usize

Page table base address

§blocked_on: Option<u64>

IPC endpoint blocked on (if any)

§wait_link: Option<usize>

Wait queue link (for blocking)

§ready_link: Option<usize>

Ready queue link

§thread_ref: Option<NonNull<Thread>>

Thread reference (for state synchronization)

§last_cpu: Option<u8>

Last CPU this task ran on

§migrations: u32

Number of times this task has been migrated

§tls_base: u64

TLS base snapshot for context switch

§priority_boost: Option<Priority>

Priority boost from priority inheritance protocol. When a high-priority task blocks on a resource held by this task, the holder’s effective priority is boosted to prevent inversion.

§ipc_regs: [u64; 7]

IPC register set for fast-path direct message transfer. Sender copies message data here; receiver reads on wake-up.

§has_user_mappings: bool

Whether this task has user-space address mappings. Used for lazy TLB optimization: kernel threads skip CR3 reload.

Implementations§

Source§

impl Task

Source

pub fn new( pid: ProcessId, tid: ThreadId, name: String, entry_point: usize, stack_base: usize, page_table: usize, ) -> Self

Create new task

Source

pub fn can_run_on(&self, cpu: u8) -> bool

Check if task can run on given CPU

Source

pub fn update_runtime(&self, ticks: u64)

Update runtime statistics

Source

pub fn mark_scheduled(&self, _cpu: u8, voluntary: bool)

Mark as scheduled

Source

pub fn effective_priority(&self) -> u8

Calculate dynamic priority, accounting for priority inheritance boost.

Auto Trait Implementations§

§

impl !Freeze for Task

§

impl !RefUnwindSafe for Task

§

impl !Send for Task

§

impl !Sync for Task

§

impl Unpin for Task

§

impl !UnwindSafe for Task

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.