1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-26 09:53:28 +04:00

try to fix interrupt & deadlock on RV32

This commit is contained in:
WangRunji 2018-11-26 16:58:45 +08:00
parent 46f0e85230
commit 2db453556d
3 changed files with 6 additions and 3 deletions

View File

@ -10,8 +10,8 @@ pub unsafe fn disable_and_store() -> usize {
#[cfg(target_arch = "riscv32")] #[cfg(target_arch = "riscv32")]
pub unsafe fn disable_and_store() -> usize { pub unsafe fn disable_and_store() -> usize {
let sstatus: usize; let sstatus: usize;
asm!("csrrci $0, 0x100, 1" : "=r"(sstatus)); asm!("csrrci $0, 0x100, 2" : "=r"(sstatus));
sstatus & 1 sstatus & 2
} }
#[inline(always)] #[inline(always)]

View File

@ -92,7 +92,10 @@ impl Processor {
} }
pub fn tick(&self) { pub fn tick(&self) {
let flags = unsafe { interrupt::disable_and_store() };
let need_reschedule = self.manager().tick(self.pid()); let need_reschedule = self.manager().tick(self.pid());
unsafe { interrupt::restore(flags); }
if need_reschedule { if need_reschedule {
self.yield_now(); self.yield_now();
} }

View File

@ -1,6 +1,6 @@
use core::fmt; use core::fmt;
use log::{self, Level, LevelFilter, Log, Metadata, Record}; use log::{self, Level, LevelFilter, Log, Metadata, Record};
use spin::Mutex; use crate::sync::SpinNoIrqLock as Mutex;
use lazy_static::lazy_static; use lazy_static::lazy_static;
lazy_static! { lazy_static! {