mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-25 10:23:23 +00:00
Reduce some redundant usage of current!
and current_thread!
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
98a2e623e2
commit
8f3b1f8ddf
@ -61,14 +61,15 @@ pub fn schedule() {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn preempt() {
|
||||
// TODO: This interface of this method is error prone.
|
||||
// The method takes an argument for the current task to optimize its efficiency,
|
||||
// but the argument provided by the caller may not be the current task, really.
|
||||
// Thus, this method should be removed or reworked in the future.
|
||||
pub fn preempt(task: &Arc<Task>) {
|
||||
// TODO: Refactor `preempt` and `schedule`
|
||||
// after the Atomic mode and `might_break` is enabled.
|
||||
let Some(curr_task) = current_task() else {
|
||||
return;
|
||||
};
|
||||
let mut scheduler = GLOBAL_SCHEDULER.lock_irq_disabled();
|
||||
if !scheduler.should_preempt(&curr_task) {
|
||||
if !scheduler.should_preempt(task) {
|
||||
return;
|
||||
}
|
||||
let Some(next_task) = scheduler.dequeue() else {
|
||||
|
Reference in New Issue
Block a user