2018-07-16 20:23:02 +04:00
|
|
|
use process::*;
|
|
|
|
use arch::interrupt::TrapFrame;
|
2018-07-12 20:00:42 +04:00
|
|
|
|
|
|
|
pub fn timer() {
|
2018-07-16 20:23:02 +04:00
|
|
|
let mut processor = processor();
|
2018-07-12 20:00:42 +04:00
|
|
|
processor.tick();
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn before_return() {
|
|
|
|
if let Some(processor) = PROCESSOR.try() {
|
|
|
|
processor.lock().schedule();
|
|
|
|
}
|
2018-07-16 20:23:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn error(tf: &TrapFrame) {
|
|
|
|
if let Some(processor) = PROCESSOR.try() {
|
|
|
|
let mut processor = processor.lock();
|
|
|
|
let pid = processor.current_pid();
|
|
|
|
error!("Process {} error:\n{:#x?}", pid, tf);
|
|
|
|
processor.exit(pid, 0x100); // TODO: Exit code for error
|
|
|
|
} else {
|
|
|
|
panic!("Exception when processor not inited\n{:#x?}", tf);
|
|
|
|
}
|
2018-07-12 20:00:42 +04:00
|
|
|
}
|