Skip to content

Commit

Permalink
Bug fix: preempt low priority task when high priority task is spawned.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyma98 committed Aug 13, 2024
1 parent 8d12e5e commit 9c04ef9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/schedule/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ pub(crate) fn make_new_task_ready(id: u8, task: Arc<Task>) -> Result<(), ()> {

EXIST_TASK_NUM.fetch_add(1, Ordering::SeqCst);

if is_scheduler_started() {
super::with_current_task(|cur_task| {
if task.should_preempt(cur_task) {
request_context_switch();
}
});
}

Ok(())
}

Expand Down

0 comments on commit 9c04ef9

Please sign in to comment.