From a0a0167af0712394d1a300b68d072d7db69a34f8 Mon Sep 17 00:00:00 2001 From: zhangxinyu <840317537@qq.com> Date: Fri, 9 Jun 2023 10:45:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E7=94=A8=E6=88=B7=E6=80=81?= =?UTF-8?q?=E6=AF=8F=E4=B8=AA=E5=BA=94=E7=94=A8=E4=BC=9A=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=85=B6=E6=B6=88=E8=80=97=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ch5/user/src/bin/user_shell.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ch5/user/src/bin/user_shell.rs b/ch5/user/src/bin/user_shell.rs index e771f86..2dd5fec 100644 --- a/ch5/user/src/bin/user_shell.rs +++ b/ch5/user/src/bin/user_shell.rs @@ -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(); }