add hint for user shell. detect cores through 'SMP' env.

master
WangRunji 6 years ago
parent fbf59396b2
commit d20d22b85b

@ -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

@ -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();

@ -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 {

Loading…
Cancel
Save