You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
582 B
Rust
20 lines
582 B
Rust
2 years ago
|
use crate::task::context::{TaskContext};
|
||
|
|
||
|
// TCB的字段, 用来保存任务的状态
|
||
|
#[derive(Copy, Clone, PartialEq)]
|
||
|
pub enum TaskStatus {
|
||
|
UnInit, // 未初始化
|
||
|
Ready, // 准备运行
|
||
|
Running, // 正在运行
|
||
|
Exited, // 已退出
|
||
|
}
|
||
|
|
||
|
|
||
|
// 一个任务的主体, 用来保存或者控制一个任务所有需要的东西
|
||
|
#[derive(Copy, Clone)]
|
||
|
pub struct TaskControlBlock {
|
||
|
pub user_time: usize, // 用户态程序用的时间
|
||
|
pub kernel_time: usize, // 内核态程序所用的时间
|
||
|
pub task_status: TaskStatus,
|
||
|
pub task_cx: TaskContext,
|
||
|
}
|