Skip to content

Commit

Permalink
refactor: use kernel_guard hold by RQ in wait_queue.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
hky1999 committed Sep 23, 2024
1 parent 7ad8947 commit 2dd3646
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions modules/axtask/src/wait_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl WaitQueue {
where
F: Fn() -> bool,
{
let _kernel_guard = NoPreemptIrqSave::new();
let mut rq = current_run_queue::<NoPreemptIrqSave>();
loop {
let mut wq = self.queue.lock();
if condition() {
Expand All @@ -132,7 +132,7 @@ impl WaitQueue {
curr.set_in_wait_queue(true);
drop(wq);

current_run_queue::<NoOp>().blocked_resched();
rq.blocked_resched();
}
self.cancel_events(crate::current());
}
Expand All @@ -141,7 +141,7 @@ impl WaitQueue {
/// notify it, or the given duration has elapsed.
#[cfg(feature = "irq")]
pub fn wait_timeout(&self, dur: core::time::Duration) -> bool {
let _kernel_guard = NoPreemptIrqSave::new();
let mut rq = current_run_queue::<NoPreemptIrqSave>();
let curr = crate::current();
let deadline = axhal::time::wall_time() + dur;
debug!(
Expand All @@ -152,7 +152,7 @@ impl WaitQueue {
crate::timers::set_alarm_wakeup(deadline, curr.clone());

self.push_to_wait_queue();
current_run_queue::<NoOp>().blocked_resched();
rq.blocked_resched();

let timeout = curr.in_wait_queue(); // still in the wait queue, must have timed out
self.cancel_events(curr);
Expand All @@ -169,7 +169,7 @@ impl WaitQueue {
where
F: Fn() -> bool,
{
let _kernel_guard = NoPreemptIrqSave::new();
let mut rq = current_run_queue::<NoPreemptIrqSave>();
let curr = crate::current();
let deadline = axhal::time::wall_time() + dur;
debug!(
Expand Down Expand Up @@ -200,7 +200,7 @@ impl WaitQueue {
curr.set_in_wait_queue(true);
drop(wq);

current_run_queue::<NoOp>().blocked_resched()
rq.blocked_resched()
}
self.cancel_events(curr);
timeout
Expand Down

0 comments on commit 2dd3646

Please sign in to comment.