diff --git a/ch3/os/src/main.rs b/ch3/os/src/main.rs index bb76f3f..d7018a4 100644 --- a/ch3/os/src/main.rs +++ b/ch3/os/src/main.rs @@ -14,6 +14,7 @@ pub mod trap; pub mod syscall; pub mod loader; pub mod config; +pub mod task; // 汇编脚本引入, 调整内核的内存布局之后, 会跳入到 rust_main中执行 global_asm!(include_str!("entry.asm")); @@ -40,8 +41,8 @@ pub fn rust_main(){ loader::load_app(); trap::init(); - batch::init(); - batch::run_next_app(); + // batch::init(); + // batch::run_next_app(); loop { } diff --git a/ch3/os/src/task/context.rs b/ch3/os/src/task/context.rs new file mode 100644 index 0000000..cb52c48 --- /dev/null +++ b/ch3/os/src/task/context.rs @@ -0,0 +1,12 @@ + + + + + +pub struct TaskContext{ + ra: usize, // 保存了进行切换之后需要 跳转继续执行的地址 + sp: usize, // 当前任务的内核栈的栈顶 + s: [usize; 12] // 当前任务内核状态 +} + + diff --git a/ch3/os/src/task/mod.rs b/ch3/os/src/task/mod.rs new file mode 100644 index 0000000..019f068 --- /dev/null +++ b/ch3/os/src/task/mod.rs @@ -0,0 +1 @@ +mod context; \ No newline at end of file