Skip to content

Commit

Permalink
lab6 over
Browse files Browse the repository at this point in the history
  • Loading branch information
freheit889 committed Aug 15, 2020
1 parent dc82f5c commit 29908ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion os/src/interrupt/handler.rs
Expand Up @@ -4,6 +4,7 @@ use riscv::register::stvec;
use riscv::register::scause::Scause;
use riscv::register::scause::{Exception, Trap, Interrupt};
use crate::process::PROCESSOR;
use crate::kernel::syscall_handler;

global_asm!(include_str!("./interrupt.asm"));

Expand Down Expand Up @@ -39,7 +40,9 @@ pub fn handle_interrupt(context: &mut Context, scause: Scause, stval: usize)->*m
// 时钟中断
Trap::Interrupt(Interrupt::SupervisorTimer) => supervisor_timer(context),
//Trap::Interrupt(Interrupt::SupervisorSoft) => supervisor_timer(context),
// 其他情况,终止当前线程
// 其他情况,终止当前线
Trap::Exception(Exception::UserEnvCall) => syscall_handler(context),

_ => fault("unimplemented interrupt type", scause, stval),
}
}
Expand Down
10 changes: 6 additions & 4 deletions os/src/main.rs
Expand Up @@ -41,7 +41,7 @@ pub extern "C" fn rust_main(hartid: usize, sp: usize) -> ! {
}
println!("kernel_end = {:#x}", kernel_end as usize);
println!("_kernel_end = {:#x}", (kernel_end as usize) / 4096);

/*
{
let mut processor=PROCESSOR.lock();
let kernel_process=Process::new_kernel().unwrap();
Expand All @@ -53,9 +53,11 @@ pub extern "C" fn rust_main(hartid: usize, sp: usize) -> ! {
);
processor.add_thread(thread);
}
}

//PROCESSOR.lock().add_thread(create_user_process("hello_world"));
}*/
unsafe{
llvm_asm!("fence.i" :::: "volatile");
};
PROCESSOR.lock().add_thread(create_user_process("hello_world"));


extern "C" {
Expand Down

0 comments on commit 29908ed

Please sign in to comment.