mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-20 10:06:31 +00:00
使用Rust重构CFS调度器 (#131)
* 新建调度器的文件 * 把softirq vector移动到c文件中(原来在.h) * 将进程切换方式改为“中断返回时切换” * new:使用rust重构CFS * 删除已经在smp中废弃的HPET中断转发函数 * 代码格式化 * 删除多余的dunce依赖
This commit is contained in:
28
kernel/src/arch/x86_64/mm/mod.rs
Normal file
28
kernel/src/arch/x86_64/mm/mod.rs
Normal file
@ -0,0 +1,28 @@
|
||||
pub mod barrier;
|
||||
use crate::include::bindings::bindings::process_control_block;
|
||||
|
||||
use core::arch::asm;
|
||||
use core::ptr::read_volatile;
|
||||
|
||||
use self::barrier::mfence;
|
||||
|
||||
/// @brief 切换进程的页表
|
||||
///
|
||||
/// @param 下一个进程的pcb。将会把它的页表切换进来。
|
||||
///
|
||||
/// @return 下一个进程的pcb(把它return的目的主要是为了归还所有权)
|
||||
#[inline(always)]
|
||||
#[allow(dead_code)]
|
||||
pub fn switch_mm(
|
||||
next_pcb: &'static mut process_control_block,
|
||||
) -> &'static mut process_control_block {
|
||||
mfence();
|
||||
// kdebug!("to get pml4t");
|
||||
let pml4t = unsafe { read_volatile(&next_pcb.mm.as_ref().unwrap().pgd) };
|
||||
|
||||
unsafe {
|
||||
asm!("mov cr3, {}", in(reg) pml4t);
|
||||
}
|
||||
mfence();
|
||||
return next_pcb;
|
||||
}
|
Reference in New Issue
Block a user