Compare commits

...

2 Commits

Author SHA1 Message Date
6e64101d09 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>
2023-01-03 20:29:25 +01:00
88fd29ea1a No idea how to do a spawner
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
2023-01-02 22:38:17 +01:00
2 changed files with 13 additions and 2 deletions

@ -21,7 +21,7 @@ use crate::fs::FileSystem;
use core::panic::PanicInfo; use core::panic::PanicInfo;
use drivers::vga::{self, Color, ColorCode}; use drivers::vga::{self, Color, ColorCode};
use multiboot2::BootInformation; use multiboot2::BootInformation;
use task::{executor::Executor, keyboard, Task}; use task::{executor::EXECUTOR, keyboard, Task};
use alloc::sync::Arc; use alloc::sync::Arc;
use core::cell::RefCell; use core::cell::RefCell;
@ -61,11 +61,14 @@ pub extern "C" fn julios_main(multiboot_info_addr: usize) -> ! {
println!("***JuliOS V0.1.0***"); println!("***JuliOS V0.1.0***");
serial_println!("Hello serial"); 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(drivers::atapi::init()));
executor.spawn(Task::new(keyboard::print_keypresses())); executor.spawn(Task::new(keyboard::print_keypresses()));
executor.spawn(Task::new(get_file())); executor.spawn(Task::new(get_file()));
executor.spawn(Task::new(proc::scheduler::scheduler_run())); executor.spawn(Task::new(proc::scheduler::scheduler_run()));
EXECUTOR.force_unlock(); // Ouioui t'inquietes
executor.run(); executor.run();
} }

@ -1,7 +1,15 @@
use crate::utils::AsyncMutex;
use super::{Task, TaskId}; use super::{Task, TaskId};
use alloc::{collections::BTreeMap, sync::Arc, task::Wake}; use alloc::{collections::BTreeMap, sync::Arc, task::Wake};
use core::task::{Context, Poll, Waker}; use core::task::{Context, Poll, Waker};
use crossbeam_queue::ArrayQueue; use crossbeam_queue::ArrayQueue;
use lazy_static::lazy_static;
lazy_static! {
pub static ref EXECUTOR: AsyncMutex<Executor> = AsyncMutex::new(Executor::new());
}
pub struct Executor { pub struct Executor {
tasks: BTreeMap<TaskId, Task>, tasks: BTreeMap<TaskId, Task>,