mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-09 05:16:47 +00:00
Add schedule after WorkItem enqueue
This commit is contained in:
parent
4afac4d5ac
commit
89ce1f4df9
@ -141,6 +141,9 @@ impl WorkQueue {
|
|||||||
.lock_irq_disabled()
|
.lock_irq_disabled()
|
||||||
.pending_work_items
|
.pending_work_items
|
||||||
.push(work_item);
|
.push(work_item);
|
||||||
|
if let Some(worker_pool) = self.worker_pool.upgrade() {
|
||||||
|
worker_pool.schedule()
|
||||||
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +97,10 @@ impl Worker {
|
|||||||
self.exit();
|
self.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) fn bound_thread(&self) -> &Arc<Thread> {
|
||||||
|
&self.bound_thread
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn is_idle(&self) -> bool {
|
pub(super) fn is_idle(&self) -> bool {
|
||||||
self.inner.lock_irq_disabled().worker_status == WorkerStatus::Idle
|
self.inner.lock_irq_disabled().worker_status == WorkerStatus::Idle
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,16 @@
|
|||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use core::sync::atomic::{AtomicBool, Ordering};
|
use core::{
|
||||||
|
sync::atomic::{AtomicBool, Ordering},
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
use aster_frame::{cpu::CpuSet, sync::WaitQueue, task::Priority};
|
use aster_frame::{
|
||||||
|
cpu::CpuSet,
|
||||||
|
sync::WaitQueue,
|
||||||
|
task::{add_task, Priority},
|
||||||
|
};
|
||||||
|
|
||||||
use super::{simple_scheduler::SimpleScheduler, worker::Worker, WorkItem, WorkPriority, WorkQueue};
|
use super::{simple_scheduler::SimpleScheduler, worker::Worker, WorkItem, WorkPriority, WorkQueue};
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -74,7 +81,7 @@ impl LocalWorkerPool {
|
|||||||
fn add_worker(&self) {
|
fn add_worker(&self) {
|
||||||
let worker = Worker::new(self.parent.clone(), self.cpu_id);
|
let worker = Worker::new(self.parent.clone(), self.cpu_id);
|
||||||
self.workers.lock_irq_disabled().push_back(worker.clone());
|
self.workers.lock_irq_disabled().push_back(worker.clone());
|
||||||
worker.run();
|
add_task(worker.bound_thread().task().clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_worker(&self) {
|
fn remove_worker(&self) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user