mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 16:16:16 +04:00
Only yield for timer interrupt
This commit is contained in:
parent
34e53e22b4
commit
e601787ca2
@ -194,7 +194,7 @@ pub fn handle_reserved_inst(tf: &mut UserContext) -> bool {
|
|||||||
let tls = tf.tls;
|
let tls = tf.tls;
|
||||||
|
|
||||||
set_trapframe_register(rt, tls, tf);
|
set_trapframe_register(rt, tls, tf);
|
||||||
debug!("Read TLS by rdhwr {:x} to register {:?}", tls, rt);
|
trace!("Read TLS by rdhwr {:x} to register {:?}", tls, rt);
|
||||||
tf.epc = tf.epc + 4;
|
tf.epc = tf.epc + 4;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -510,6 +510,7 @@ pub fn spawn(thread: Arc<Thread>) {
|
|||||||
trace!("back from user: {:#x?} trap_num {:#x}", cx, trap_num);
|
trace!("back from user: {:#x?} trap_num {:#x}", cx, trap_num);
|
||||||
|
|
||||||
let mut exit = false;
|
let mut exit = false;
|
||||||
|
let mut do_yield = false;
|
||||||
match trap_num {
|
match trap_num {
|
||||||
// must be first
|
// must be first
|
||||||
_ if is_page_fault(trap_num) => {
|
_ if is_page_fault(trap_num) => {
|
||||||
@ -527,6 +528,7 @@ pub fn spawn(thread: Arc<Thread>) {
|
|||||||
crate::arch::interrupt::ack(trap_num);
|
crate::arch::interrupt::ack(trap_num);
|
||||||
trace!("handle irq {:#x}", trap_num);
|
trace!("handle irq {:#x}", trap_num);
|
||||||
if is_timer_intr(trap_num) {
|
if is_timer_intr(trap_num) {
|
||||||
|
do_yield = true;
|
||||||
crate::arch::interrupt::timer();
|
crate::arch::interrupt::timer();
|
||||||
}
|
}
|
||||||
IRQ_MANAGER.read().try_handle_interrupt(Some(trap_num));
|
IRQ_MANAGER.read().try_handle_interrupt(Some(trap_num));
|
||||||
@ -556,7 +558,7 @@ pub fn spawn(thread: Arc<Thread>) {
|
|||||||
if exit {
|
if exit {
|
||||||
info!("thread {} stopped", thread.tid);
|
info!("thread {} stopped", thread.tid);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else if do_yield {
|
||||||
yield_now().await;
|
yield_now().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user