From e601787ca2619209aa1f254940ef716376bc9031 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Thu, 9 Jul 2020 12:50:06 +0800 Subject: [PATCH] Only yield for timer interrupt --- kernel/src/arch/mipsel/interrupt/mod.rs | 2 +- kernel/src/process/thread.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/src/arch/mipsel/interrupt/mod.rs b/kernel/src/arch/mipsel/interrupt/mod.rs index 43b47586..6b845f49 100644 --- a/kernel/src/arch/mipsel/interrupt/mod.rs +++ b/kernel/src/arch/mipsel/interrupt/mod.rs @@ -194,7 +194,7 @@ pub fn handle_reserved_inst(tf: &mut UserContext) -> bool { let tls = tf.tls; 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; return true; } else { diff --git a/kernel/src/process/thread.rs b/kernel/src/process/thread.rs index 82869205..3891aae2 100644 --- a/kernel/src/process/thread.rs +++ b/kernel/src/process/thread.rs @@ -510,6 +510,7 @@ pub fn spawn(thread: Arc) { trace!("back from user: {:#x?} trap_num {:#x}", cx, trap_num); let mut exit = false; + let mut do_yield = false; match trap_num { // must be first _ if is_page_fault(trap_num) => { @@ -527,6 +528,7 @@ pub fn spawn(thread: Arc) { crate::arch::interrupt::ack(trap_num); trace!("handle irq {:#x}", trap_num); if is_timer_intr(trap_num) { + do_yield = true; crate::arch::interrupt::timer(); } IRQ_MANAGER.read().try_handle_interrupt(Some(trap_num)); @@ -556,7 +558,7 @@ pub fn spawn(thread: Arc) { if exit { info!("thread {} stopped", thread.tid); break; - } else { + } else if do_yield { yield_now().await; } }