diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 7b008937..b1561f96 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -1,5 +1,7 @@ //! Environment call handling routines +use log::log; + use {alloc::boxed::Box, core::cell::LazyCell, hbvm::mem::Address}; use crate::{ @@ -245,6 +247,7 @@ pub fn handler(vm: &mut Vm, pid: &usize) { 6 => { // Wait till interrupt use crate::kmain::EXECUTOR; let interrupt_type = vm.registers[3].cast::(); + info!("Interrupt subscribled: {}", interrupt_type); unsafe{ EXECUTOR.pause(pid.clone()); LazyCell::::get_mut(&mut EXECUTOR).unwrap().interrupt_subscribe(pid.clone(), interrupt_type); diff --git a/kernel/src/task.rs b/kernel/src/task.rs index b815f2c9..9aa67f8a 100644 --- a/kernel/src/task.rs +++ b/kernel/src/task.rs @@ -35,7 +35,7 @@ impl + Send> Process for T {} pub struct Executor { tasks: Slab, task_queue: Arc>, - interrupt_lookup: Box<[Option; u8::MAX as usize]>, + interrupt_lookup: [Option; u8::MAX as usize], } impl Executor { @@ -60,7 +60,7 @@ impl Executor { } } - pub fn unpause(self, id: usize) { + pub fn unpause(&self, id: usize) { if let Some(task) = self.tasks.get(id) { task.set_paused(false); self.task_queue.push(id); @@ -85,7 +85,8 @@ impl Executor { } if batch_len == 0 { - break; + //break; + continue; } for &(mut id) in &task_batch[..batch_len] { @@ -108,8 +109,7 @@ impl Executor { pub fn send_interrupt(&self, interrupt : u8){ let id = self.interrupt_lookup[interrupt as usize]; if let Some(id) = id{ - let task = &self.tasks[id]; - task.set_paused(false); + self.unpause(id); } } } diff --git a/sysdata/libraries/stn/src/sleep.hb b/sysdata/libraries/stn/src/sleep.hb index 470b137d..5aeaf148 100644 --- a/sysdata/libraries/stn/src/sleep.hb +++ b/sysdata/libraries/stn/src/sleep.hb @@ -3,5 +3,5 @@ subscribe_to_interrupt := fn(interrupt_number: u8): bool { } // Pauses execution until the interrupt occures sleep_until_interrupt := fn(interrupt_number: u8): void { - @eca(6, 32); -} + @eca(6, interrupt_number) +} \ No newline at end of file diff --git a/sysdata/programs/timer_test/meta.toml b/sysdata/programs/timer_test/meta.toml new file mode 100644 index 00000000..c05908d0 --- /dev/null +++ b/sysdata/programs/timer_test/meta.toml @@ -0,0 +1,11 @@ +[package] +name = "timer_test" +authors = ["Talha Qamar"] + +[dependants.libraries] + +[dependants.binaries] +hblang.version = "1.0.0" + +[build] +command = "hblang src/main.hb" diff --git a/sysdata/programs/timer_test/src/main.hb b/sysdata/programs/timer_test/src/main.hb new file mode 100644 index 00000000..d359f3c4 --- /dev/null +++ b/sysdata/programs/timer_test/src/main.hb @@ -0,0 +1,10 @@ +sleep := @use("../../../libraries/stn/src/sleep.hb") +log := @use("../../../libraries/stn/src/log.hb") + +main := fn(): int { + loop { + log.info("BEFORE\0") + sleep.sleep_until_interrupt(32) + log.info("AFTER\0") + } +} diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index e5a2a8e5..34ab7905 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -34,6 +34,9 @@ resolution = "1024x768x24" # [boot.limine.ableos.modules.ps2_keyboard_driver] # path = "boot:///ps2_keyboard_driver.hbf" +[boot.limine.ableos.modules.timer_test] +path = "boot:///timer_test.hbf" + # [boot.limine.ableos.modules.sunset_client] # path = "boot:///sunset_client.hbf" #