Patch sched rust (#139)

* update

* 添加rt调度器的rust初步实现

* 完善rt调度逻辑

* 调试rt调度器

* 修改sched的返回值

* cargo fmt 格式化

* 删除无用代码,修补rt bug

* 删除无用的代码,和重复的逻辑

* 软中断bugfix

* 删除一些代码

* 添加kthread_run_rt文档

* 解决sphinix警告_static目录不存在的问题

Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
kong
2023-01-14 22:38:05 +08:00
committed by GitHub
parent ec53d23ed0
commit 06b09f34ed
44 changed files with 426 additions and 173 deletions

View File

@ -2,7 +2,7 @@ use core::arch::x86_64::_popcnt64;
/// @brief ffz - 寻找u64中的第一个0所在的位从第0位开始寻找
/// 请注意如果x中没有0,那么结果将是未定义的。请确保传入的x至少存在1个0
///
///
/// @param x 目标u64
/// @return i32 bit-number(0..63) of the first (least significant) zero bit.
#[inline]

View File

@ -1,6 +1,6 @@
pub mod irqflags;
#[macro_use]
pub mod current;
pub mod ptrace;
pub mod bitops;
pub mod cmpxchg;
pub mod cmpxchg;
pub mod ptrace;

View File

@ -3,10 +3,10 @@ use crate::include::bindings::bindings::pt_regs;
/// @brief 判断给定的栈帧是否来自用户态
/// 判断方法为根据代码段选择子是否具有ring3的访问权限低2bit均为1
pub fn user_mode(regs: *const pt_regs)->bool{
if (unsafe{(*regs).cs} & 0x3) != 0{
pub fn user_mode(regs: *const pt_regs) -> bool {
if (unsafe { (*regs).cs } & 0x3) != 0 {
return true;
}else {
} else {
return false;
}
}
}

View File

@ -3,16 +3,16 @@ use core::arch::asm;
/// @brief 关闭中断
#[inline]
pub fn cli(){
unsafe{
pub fn cli() {
unsafe {
asm!("cli");
}
}
/// @brief 开启中断
#[inline]
pub fn sti(){
unsafe{
pub fn sti() {
unsafe {
asm!("sti");
}
}
}

View File

@ -2,22 +2,22 @@
use core::arch::asm;
#[inline(always)]
pub fn mfence(){
unsafe{
pub fn mfence() {
unsafe {
asm!("mfence");
}
}
#[inline(always)]
pub fn lfence(){
unsafe{
pub fn lfence() {
unsafe {
asm!("lfence");
}
}
#[inline(always)]
pub fn sfence(){
unsafe{
pub fn sfence() {
unsafe {
asm!("sfence");
}
}
}

View File

@ -19,7 +19,7 @@ pub fn switch_mm(
mfence();
// kdebug!("to get pml4t");
let pml4t = unsafe { read_volatile(&next_pcb.mm.as_ref().unwrap().pgd) };
unsafe {
asm!("mov cr3, {}", in(reg) pml4t);
}

View File

@ -1,7 +1,7 @@
#[macro_use]
pub mod asm;
pub mod context;
pub mod cpu;
pub mod interrupt;
pub mod mm;
pub mod context;
pub mod sched;
pub mod sched;