diff --git a/src/lib.rs b/src/lib.rs index da0d762..7a32461 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ use crate::fs::FileSystem; use core::panic::PanicInfo; use drivers::vga::{self, Color, ColorCode}; use multiboot2::BootInformation; -use task::{executor::Executor, keyboard, Task}; +use task::{executor::EXECUTOR, keyboard, Task}; use alloc::sync::Arc; use core::cell::RefCell; @@ -61,11 +61,14 @@ pub extern "C" fn julios_main(multiboot_info_addr: usize) -> ! { println!("***JuliOS V0.1.0***"); serial_println!("Hello serial"); - let mut executor = Executor::new(); + let mut executor = EXECUTOR.try_lock().unwrap(); executor.spawn(Task::new(drivers::atapi::init())); executor.spawn(Task::new(keyboard::print_keypresses())); executor.spawn(Task::new(get_file())); executor.spawn(Task::new(proc::scheduler::scheduler_run())); + + EXECUTOR.force_unlock(); // Ouioui t'inquietes + executor.run(); } diff --git a/src/task/executor.rs b/src/task/executor.rs index e9a7ff3..c567907 100644 --- a/src/task/executor.rs +++ b/src/task/executor.rs @@ -1,7 +1,15 @@ +use crate::utils::AsyncMutex; + use super::{Task, TaskId}; + use alloc::{collections::BTreeMap, sync::Arc, task::Wake}; use core::task::{Context, Poll, Waker}; use crossbeam_queue::ArrayQueue; +use lazy_static::lazy_static; + +lazy_static! { + pub static ref EXECUTOR: AsyncMutex = AsyncMutex::new(Executor::new()); +} pub struct Executor { tasks: BTreeMap, diff --git a/src/task/mod.rs b/src/task/mod.rs index 6201b8a..078e6b8 100644 --- a/src/task/mod.rs +++ b/src/task/mod.rs @@ -6,7 +6,6 @@ use core::task::{Context, Poll}; pub mod executor; pub mod keyboard; -pub mod spawner; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] struct TaskId(u64); diff --git a/src/task/spawner.rs b/src/task/spawner.rs deleted file mode 100644 index 9e2e0cb..0000000 --- a/src/task/spawner.rs +++ /dev/null @@ -1,3 +0,0 @@ -struct Spawner { - -} \ No newline at end of file