diff --git a/kernel/Makefile b/kernel/Makefile index ea52c55..cc60d88 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -34,6 +34,7 @@ bootimage := target/$(target)/bootimage.bin user_dir := ../user export ARCH = $(arch) +export SMP = $(smp) #export SFSIMG = $(user_dir)/build/user-$(arch).img ifeq ($(arch), x86_64) export SFSIMG = $(user_dir)/img/ucore-i386.img diff --git a/kernel/src/process/mod.rs b/kernel/src/process/mod.rs index 64bf00a..790e4ce 100644 --- a/kernel/src/process/mod.rs +++ b/kernel/src/process/mod.rs @@ -21,10 +21,13 @@ pub fn init() { } } + // Add idle threads extern fn idle(_arg: usize) -> ! { loop { cpu::halt(); } } - for i in 0..4 { + use core::str::FromStr; + let cores = usize::from_str(env!("SMP")).unwrap(); + for i in 0..cores { manager.add(Process::new_kernel(idle, i), 0); } crate::shell::run_user_shell(); diff --git a/kernel/src/shell.rs b/kernel/src/shell.rs index cef7ca6..236bb42 100644 --- a/kernel/src/shell.rs +++ b/kernel/src/shell.rs @@ -7,6 +7,8 @@ use crate::process::*; pub fn run_user_shell() { if let Ok(inode) = ROOT_INODE.lookup("sh") { + println!("Going to user mode shell."); + println!("Use 'ls' to list available programs."); let data = inode.read_as_vec().unwrap(); processor().manager().add(Process::new_user(data.as_slice(), "sh".split(' ')), 0); } else {