diff --git a/os/src/config.rs b/os/src/config.rs index c4b90f770592f532d54886a17131d454c9fd5f5a..06efeb35921d266b6e1e5cc44bb83f7c96cb0d18 100644 --- a/os/src/config.rs +++ b/os/src/config.rs @@ -1,7 +1,7 @@ pub const USER_STACK_SIZE: usize = 4096 * 2; pub const KERNEL_STACK_SIZE: usize = 4096 * 2; -pub const KERNEL_HEAP_SIZE: usize = 0x30_0000; -pub const MEMORY_END: usize = 0x80800000; +pub const KERNEL_HEAP_SIZE: usize = 0x20_0000; +pub const MEMORY_END: usize = 0x80600000; pub const PAGE_SIZE: usize = 0x1000; pub const PAGE_SIZE_BITS: usize = 0xc; diff --git a/user/src/bin/forktest.rs b/user/src/bin/forktest.rs index dcf8859e96efb4f3e1ce5227cb546fabdbb49204..fea6967c412316a5dd6995306ad420e045f56f74 100644 --- a/user/src/bin/forktest.rs +++ b/user/src/bin/forktest.rs @@ -6,7 +6,7 @@ extern crate user_lib; use user_lib::{fork, wait, exit}; -const MAX_CHILD: usize = 20; +const MAX_CHILD: usize = 40; #[no_mangle] pub fn main() -> i32 { diff --git a/user/src/bin/forktest2.rs b/user/src/bin/forktest2.rs index f47e73f2bdf20fa59dca663da53d6c3a745996ad..493fccd8276b17a1f09350f3946a339aaf9fae74 100644 --- a/user/src/bin/forktest2.rs +++ b/user/src/bin/forktest2.rs @@ -4,9 +4,9 @@ #[macro_use] extern crate user_lib; -use user_lib::{fork, wait, get_time, getpid, exit, yield_,}; +use user_lib::{fork, wait, getpid, exit, sleep, get_time}; -static NUM: usize = 13; +static NUM: usize = 30; #[no_mangle] pub fn main() -> i32 { @@ -15,11 +15,9 @@ pub fn main() -> i32 { if pid == 0 { let current_time = get_time(); let sleep_length = (current_time as i32 as isize) * (current_time as i32 as isize) % 1000 + 1000; - println!("Subprocess {} sleep for {} ms", getpid(), sleep_length); - while get_time() < current_time + sleep_length { - yield_(); - } - println!("Subprocess {} OK!", getpid()); + println!("pid {} sleep for {} ms", getpid(), sleep_length); + sleep(sleep_length as usize); + println!("pid {} OK!", getpid()); exit(0); } } diff --git a/user/src/bin/forktree.rs b/user/src/bin/forktree.rs index 397e5e05dc23dfb4d89141bf2245dc7e5aacd99a..26954b7a6512980b3aee6357d3edfee1ad5ef0f0 100644 --- a/user/src/bin/forktree.rs +++ b/user/src/bin/forktree.rs @@ -6,7 +6,7 @@ extern crate user_lib; use user_lib::{sleep, getpid, fork, exit, yield_}; -const DEPTH: usize = 3; +const DEPTH: usize = 4; fn fork_child(cur: &str, branch: char) { let mut next = [0u8; DEPTH + 1]; diff --git a/user/src/bin/matrix.rs b/user/src/bin/matrix.rs index d5f946b86d4f5b9c73f291eda196a16611d69498..959043374f3b04064f397120ed2cde62f4ae4a54 100644 --- a/user/src/bin/matrix.rs +++ b/user/src/bin/matrix.rs @@ -6,7 +6,7 @@ extern crate user_lib; use user_lib::{fork, wait, yield_, exit, getpid, get_time}; -static NUM: usize = 20; +static NUM: usize = 35; const N: usize = 10; static P: i32 = 10007; type Arr = [[i32; N]; N]; diff --git a/user/src/bin/user_shell.rs b/user/src/bin/user_shell.rs index 6aa8e31f3a8b921a827374f78a210189cff67ea2..973f89010c6e8692a7479f4a27ded9d25d89a8fc 100644 --- a/user/src/bin/user_shell.rs +++ b/user/src/bin/user_shell.rs @@ -32,7 +32,7 @@ pub fn main() -> i32 { // child process if exec(line.as_str()) == -1 { println!("Error when executing!"); - return 0; + return -4; } unreachable!(); } else {