TaskManager

Struct TaskManager 

Source
pub struct TaskManager {
    tid_allocator: TidAllocator,
    tasks: BTreeMap<u32, Arc<SpinLock<Task>>>,
}
Expand description

任务管理器,负责管理所有任务的生命周期和调度 包括任务的创建、销毁和查找等功能 内部维护一个任务映射表,使用任务 ID 作为键 并提供分配唯一任务 ID 的功能 注意:该结构体的实例应当被包装在适当的同步原语中以确保线程安全

Fields§

§tid_allocator: TidAllocator§tasks: BTreeMap<u32, Arc<SpinLock<Task>>>

Trait Implementations§

Source§

impl TaskManagerTrait for TaskManager

Source§

fn new() -> Self

创建一个新的任务管理器实例 返回值: TaskManager 结构体 该实例初始化了任务 ID 分配器和任务映射表
Source§

fn allocate_tid(&mut self) -> u32

分配一个唯一的任务 ID 返回值: 分配的任务 ID
Source§

fn add_task(&mut self, task: Arc<SpinLock<Task>>)

将一个任务添加到任务管理器中 参数: Read more
Source§

fn exit_task(&mut self, task: Arc<SpinLock<Task>>, code: i32)

将一个任务标记为退出 参数: Read more
Source§

fn release_task(&mut self, task: Arc<SpinLock<Task>>)

释放一个已退出的任务 参数: Read more
Source§

fn get_task(&self, tid: u32) -> Option<Arc<SpinLock<Task>>>

根据任务 ID 获取对应的任务 参数: Read more
Source§

fn get_task_cond( &self, cond: impl Fn(&Arc<SpinLock<Task>>) -> bool, ) -> Vec<Arc<SpinLock<Task>>>

根据条件获取符合条件的任务列表 参数: Read more
Source§

fn get_process_threads( &self, process: Arc<SpinLock<Task>>, ) -> Vec<Arc<SpinLock<Task>>>

获取进程(线程组)内所有线程 参数: Read more
Source§

fn get_process_children( &self, process: Arc<SpinLock<Task>>, ) -> Vec<Arc<SpinLock<Task>>>

获取进程的所有子进程 参数: Read more
Source§

fn send_signal(&self, task: Arc<SpinLock<Task>>, signal: usize) -> bool

发送信号给指定任务 参数: Read more
Source§

fn get_all_tasks(&self) -> Vec<Arc<SpinLock<Task>>>

获取所有任务 返回值: 所有任务的列表

Auto Trait Implementations§

§

impl !Freeze for TaskManager

§

impl !RefUnwindSafe for TaskManager

§

impl Send for TaskManager

§

impl Sync for TaskManager

§

impl Unpin for TaskManager

§

impl !UnwindSafe for TaskManager

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.