2018-06-03 19:05:43 +04:00
|
|
|
use spin::Once;
|
2018-07-16 20:23:02 +04:00
|
|
|
use sync::{SpinNoIrqLock, Mutex, MutexGuard, SpinNoIrq};
|
2018-07-16 21:56:28 +04:00
|
|
|
pub use self::context::Context;
|
|
|
|
pub use ucore_process::processor::*;
|
|
|
|
pub use ucore_process::scheduler::*;
|
2018-04-27 19:10:39 +04:00
|
|
|
|
2018-07-16 20:23:02 +04:00
|
|
|
mod context;
|
2018-07-16 21:56:28 +04:00
|
|
|
|
|
|
|
type Processor = Processor_<Context, StrideScheduler>;
|
2018-04-27 19:10:39 +04:00
|
|
|
|
2018-07-12 08:13:39 +04:00
|
|
|
pub fn init() {
|
2018-07-16 20:23:02 +04:00
|
|
|
PROCESSOR.call_once(||
|
2018-07-16 21:56:28 +04:00
|
|
|
SpinNoIrqLock::new(Processor::new(
|
|
|
|
unsafe { Context::new_init() },
|
|
|
|
// NOTE: max_time_slice <= 5 to ensure 'priority' test pass
|
|
|
|
StrideScheduler::new(5),
|
|
|
|
))
|
2018-07-16 20:23:02 +04:00
|
|
|
);
|
2018-04-27 19:10:39 +04:00
|
|
|
}
|
|
|
|
|
2018-05-31 18:22:19 +04:00
|
|
|
pub static PROCESSOR: Once<SpinNoIrqLock<Processor>> = Once::new();
|
2018-04-27 19:10:39 +04:00
|
|
|
|
2018-07-16 20:23:02 +04:00
|
|
|
pub fn processor() -> MutexGuard<'static, Processor, SpinNoIrq> {
|
|
|
|
PROCESSOR.try().unwrap().lock()
|
2018-04-27 19:10:39 +04:00
|
|
|
}
|