From 87b3f159efae05f5b19d0a070a69464cdac944fa Mon Sep 17 00:00:00 2001 From: zhangxinyu <840317537@qq.com> Date: Wed, 24 May 2023 10:12:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=80=E4=B8=AATa?= =?UTF-8?q?skContext=E7=94=A8=E6=9D=A5=E4=BF=9D=E5=AD=98=E5=86=85=E6=A0=B8?= =?UTF-8?q?=E4=B8=AD=E4=BB=BB=E5=8A=A1=E5=88=87=E6=8D=A2cpu=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ch3/os/src/main.rs | 5 +++-- ch3/os/src/task/context.rs | 12 ++++++++++++ ch3/os/src/task/mod.rs | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 ch3/os/src/task/context.rs create mode 100644 ch3/os/src/task/mod.rs 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