mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 18:26:48 +00:00
parent
471d65cf15
commit
173c4567cf
@ -5,6 +5,7 @@ pub mod fair;
|
|||||||
pub mod idle;
|
pub mod idle;
|
||||||
pub mod pelt;
|
pub mod pelt;
|
||||||
pub mod prio;
|
pub mod prio;
|
||||||
|
pub mod syscall;
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
intrinsics::{likely, unlikely},
|
intrinsics::{likely, unlikely},
|
||||||
|
37
kernel/src/sched/syscall.rs
Normal file
37
kernel/src/sched/syscall.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
use system_error::SystemError;
|
||||||
|
|
||||||
|
use crate::arch::cpu::current_cpu_id;
|
||||||
|
use crate::exception::InterruptArch;
|
||||||
|
use crate::process::ProcessManager;
|
||||||
|
use crate::sched::CurrentIrqArch;
|
||||||
|
use crate::sched::Scheduler;
|
||||||
|
use crate::syscall::Syscall;
|
||||||
|
|
||||||
|
use super::fair::CompletelyFairScheduler;
|
||||||
|
use super::{cpu_rq, schedule, SchedMode};
|
||||||
|
|
||||||
|
impl Syscall {
|
||||||
|
pub fn do_sched_yield() -> Result<usize, SystemError> {
|
||||||
|
// 禁用中断
|
||||||
|
let irq_guard = unsafe { CurrentIrqArch::save_and_disable_irq() };
|
||||||
|
|
||||||
|
let pcb = ProcessManager::current_pcb();
|
||||||
|
let rq = cpu_rq(pcb.sched_info().on_cpu().unwrap_or(current_cpu_id()).data() as usize);
|
||||||
|
let (rq, guard) = rq.self_lock();
|
||||||
|
|
||||||
|
// TODO: schedstat_inc(rq->yld_count);
|
||||||
|
|
||||||
|
CompletelyFairScheduler::yield_task(rq);
|
||||||
|
|
||||||
|
pcb.preempt_disable();
|
||||||
|
|
||||||
|
drop(guard);
|
||||||
|
drop(irq_guard);
|
||||||
|
|
||||||
|
pcb.preempt_enable(); // sched_preempt_enable_no_resched();
|
||||||
|
|
||||||
|
schedule(SchedMode::SM_NONE);
|
||||||
|
|
||||||
|
Ok(0)
|
||||||
|
}
|
||||||
|
}
|
@ -1007,6 +1007,8 @@ impl Syscall {
|
|||||||
Self::fchmodat(dirfd, pathname, mode)
|
Self::fchmodat(dirfd, pathname, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SYS_SCHED_YIELD => Self::do_sched_yield(),
|
||||||
|
|
||||||
SYS_SCHED_GETAFFINITY => {
|
SYS_SCHED_GETAFFINITY => {
|
||||||
let pid = args[0] as i32;
|
let pid = args[0] as i32;
|
||||||
let size = args[1];
|
let size = args[1];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user