Make executor static with a force_unlock
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2023-01-03 20:29:25 +01:00
parent 88fd29ea1a
commit 6e64101d09
4 changed files with 13 additions and 6 deletions

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

@ -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<Executor> = AsyncMutex::new(Executor::new());
}
pub struct Executor {
tasks: BTreeMap<TaskId, Task>,

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

@ -1,3 +0,0 @@
struct Spawner {
}