Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ZR233 committed Jan 20, 2025
1 parent b113eca commit 566fc40
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion crates/sparreal-kernel/src/task/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloc::string::{String, ToString};
use tcb::{TaskControlBlock, set_current};
use tcb::{Pid, TaskControlBlock, set_current};

mod schedule;
mod tcb;
Expand Down Expand Up @@ -49,3 +49,5 @@ pub fn init() {
.unwrap();
set_current(&task);
}

pub fn wake_up_in_irq(_pid: Pid) {}
9 changes: 7 additions & 2 deletions crates/sparreal-kernel/src/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::{
},
globals::{cpu_global, cpu_global_meybeuninit, cpu_global_mut, global_val},
irq::{IrqHandleResult, IrqParam},
task,
};

use driver_interface::{interrupt_controller::IrqId, timer::*};
Expand Down Expand Up @@ -90,4 +89,10 @@ pub fn spin_delay(duration: Duration) {
}
}

pub fn sleep(duration: Duration) {}
pub fn sleep(duration: Duration) {
let pid = crate::task::current().info().pid;
after(duration, move || {
crate::task::wake_up_in_irq(pid);
});
crate::task::suspend();
}

0 comments on commit 566fc40

Please sign in to comment.