/// Task information #[allow(dead_code)] pub struct TaskInfo { /// Task status in it's life cycle status: TaskStatus, /// The numbers of syscall called by task syscall_times: [u32; MAX_SYSCALL_NUM], /// Total running time of task time: usize, }
/// YOUR JOB: Finish sys_task_info to pass testcases pub fn sys_task_info(_ti: *mut TaskInfo) -> isize { trace!("kernel: sys_task_info"); 0 }
/// The task control block (TCB) of a task. #[derive(Copy, Clone)] pub struct TaskControlBlock { /// The task status in it's lifecycle pub task_status: TaskStatus, /// The task context pub task_cx: TaskContext, /// syscall time count pub sys_call_times: [u32; MAX_SYSCALL_NUM],// add }
/// os/src/task/mod.rs pub struct TaskManager { /// total number of tasks num_app: usize, /// use inner value to get mutable access inner: UPSafeCell<TaskManagerInner>, }
/// Inner of Task Manager pub struct TaskManagerInner { /// task list tasks: [TaskControlBlock; MAX_APP_NUM], /// id of current `Running` task current_task: usize, }
/// os/src/task/task.rs /// The task control block (TCB) of a task. #[derive(Copy, Clone)] pub struct TaskControlBlock { /// The task status in it's lifecycle pub task_status: TaskStatus, /// The task context pub task_cx: TaskContext, /// syscall time count pub sys_call_times: [u32; MAX_SYSCALL_NUM], }
/// The status of a task #[derive(Copy, Clone, PartialEq)] pub enum TaskStatus { /// uninitialized UnInit, /// ready to run Ready, /// running Running, /// exited Exited, }
time
使用 os/src/timer.rs 中给好的 get_time_ms() 即可
1 2 3 4 5 6
/// get current time in milliseconds #[allow(dead_code)] pub fn get_time_ms() -> usize { time::read() * MSEC_PER_SEC / CLOCK_FREQ }