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: ProcessIdProcess ID
tid: ThreadIdThread ID
parent_pid: ProcessIdParent process ID
name: StringTask name
state: ProcessStateTask state
priority: PriorityScheduling priority
sched_class: SchedClassScheduling class
sched_policy: SchedPolicyScheduling policy
cpu_affinity: CpuSetCPU affinity
current_cpu: Option<u8>Current CPU (if running)
time_slice: u32Time slice remaining (in ticks)
vruntime: u64Virtual runtime (for CFS)
stats: TaskStatsTask statistics
context: TaskContextArchitecture-specific context
kernel_stack: usizeKernel stack pointer
user_stack: usizeUser stack pointer
page_table: usizePage 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: u32Number of times this task has been migrated
tls_base: u64TLS 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: boolWhether this task has user-space address mappings. Used for lazy TLB optimization: kernel threads skip CR3 reload.
Implementations§
Source§impl Task
impl Task
Sourcepub fn new(
pid: ProcessId,
tid: ThreadId,
name: String,
entry_point: usize,
stack_base: usize,
page_table: usize,
) -> Self
pub fn new( pid: ProcessId, tid: ThreadId, name: String, entry_point: usize, stack_base: usize, page_table: usize, ) -> Self
Create new task
Sourcepub fn can_run_on(&self, cpu: u8) -> bool
pub fn can_run_on(&self, cpu: u8) -> bool
Check if task can run on given CPU
Sourcepub fn update_runtime(&self, ticks: u64)
pub fn update_runtime(&self, ticks: u64)
Update runtime statistics
Sourcepub fn mark_scheduled(&self, _cpu: u8, voluntary: bool)
pub fn mark_scheduled(&self, _cpu: u8, voluntary: bool)
Mark as scheduled
Sourcepub fn effective_priority(&self) -> u8
pub fn effective_priority(&self) -> u8
Calculate dynamic priority, accounting for priority inheritance boost.