|
|
|
@ -11,7 +11,7 @@ const BS: u8 = 0x08u8;
|
|
|
|
|
|
|
|
|
|
use alloc::string::String;
|
|
|
|
|
use user_lib::{ print, println, waitpid};
|
|
|
|
|
use user_lib::syscall::{sys_exec, sys_yield, sys_fork};
|
|
|
|
|
use user_lib::syscall::{sys_exec, sys_yield, sys_fork, sys_get_time};
|
|
|
|
|
use user_lib::user_console::getchar;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -32,6 +32,8 @@ pub fn main() -> i32 {
|
|
|
|
|
println!("");
|
|
|
|
|
if !line.is_empty() {
|
|
|
|
|
line.push('\0');
|
|
|
|
|
let mut st = sys_get_time();
|
|
|
|
|
|
|
|
|
|
let pid = sys_fork();
|
|
|
|
|
if pid == 0 {
|
|
|
|
|
// child process
|
|
|
|
@ -46,7 +48,7 @@ pub fn main() -> i32 {
|
|
|
|
|
let mut exit_code: i32 = 0;
|
|
|
|
|
let exit_pid = waitpid(pid as usize, &mut exit_code);
|
|
|
|
|
assert_eq!(pid, exit_pid);
|
|
|
|
|
println!("Shell: Process {} exited with code {}", pid, exit_code);
|
|
|
|
|
println!("Shell: Process {} exited with code {}, use time: {}ms", pid, exit_code, sys_get_time()-st);
|
|
|
|
|
}
|
|
|
|
|
line.clear();
|
|
|
|
|
}
|
|
|
|
|