Start timeout in kernel executor

This commit is contained in:
luojia65 2021-03-11 10:47:59 +08:00
parent 7a254e6670
commit 199e3df019
4 changed files with 5 additions and 2 deletions

View File

@ -30,6 +30,8 @@ where
// poll our future and give it a waker
let mut context = Context::from_waker(&*waker);
// println!("Poll begin");
crate::trap::set_next_timeout(); // 开始计时,如果运行超时,切换上下文
let ret = task.future.lock().as_mut().poll(&mut context);
// println!("Ret = {:?}", ret);
if let Poll::Pending = ret {

View File

@ -72,7 +72,7 @@ pub extern "C" fn supervisor_timer(trap_frame: &mut TrapFrame) -> *mut TrapFrame
// 保存当前任务的上下文
if let Some(handle) = current_task() {
KernelHartInfo::save_task_context(handle, trap_frame);
panic!("Current task: {:x?}", handle);
println!("Current task: {:x?}", handle);
}
trap_frame

View File

@ -2,6 +2,7 @@ mod handler;
mod timer;
pub use handler::TrapFrame;
pub use timer::set_next_timeout;
/// 初始化中断相关的子模块
///

View File

@ -11,7 +11,7 @@ pub fn init() {
static INTERVAL: usize = 100000;
fn set_next_timeout() {
pub fn set_next_timeout() {
set_timer(time::read() + INTERVAL);
}