diff --git a/os/src/config.rs b/os/src/config.rs index c4b90f77..06efeb35 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 dcf8859e..fea6967c 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 f47e73f2..493fccd8 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 397e5e05..26954b7a 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 d5f946b8..95904337 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 6aa8e31f..973f8901 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 {