Module os::task

source · [−]
Expand description

Implementation of process management mechanism

Here is the entry for process scheduling required by other modules (such as syscall or clock interrupt). By suspending or exiting the current process, you can modify the process state, manage the process queue through TASK_MANAGER, and switch the control flow through PROCESSOR.

Be careful when you see __switch. Control flow around this function might not be what you expect.

Re-exports

pub use context::TaskContext;
pub use id::kstack_alloc;
pub use id::pid_alloc;
pub use id::KernelStack;
pub use id::PidHandle;
pub use id::IDLE_PID;
pub use manager::add_task;
pub use manager::pid2process;
pub use manager::remove_from_pid2process;
pub use manager::remove_task;
pub use manager::wakeup_task;
pub use processor::current_kstack_top;
pub use processor::current_process;
pub use processor::current_task;
pub use processor::current_trap_cx;
pub use processor::current_trap_cx_user_va;
pub use processor::current_user_token;
pub use processor::run_tasks;
pub use processor::schedule;
pub use processor::take_current_task;
pub use signal::SignalFlags;
pub use task::TaskControlBlock;
pub use task::TaskStatus;

Modules

context 🔒

Implementation of TaskContext

id 🔒
manager 🔒

Implementation of TaskManager

process 🔒
processor 🔒

Implementation of Processor and Intersection of control flow

signal 🔒
switch 🔒
task 🔒

Types related to task management & Functions for completely changing TCB

Structs

Creation of initial process

Functions

Add init process to the manager

Make current task blocked and switch to the next task

This function must be followed by a schedule

Check if the current task has any signal to handle

Add signal to the current task

Exit the current ‘Running’ task and run the next task in task list.

the inactive(blocked) tasks are removed when the PCB is deallocated.(called by exit_current_and_run_next)

Make current task suspended and switch to the next task