From f5bdae2d0cfabf50210ba030febfac2fba8aa333 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 7 Sep 2022 18:21:30 -0600 Subject: [PATCH] Reduce schreduler time slices to reduce latency --- src/arch/aarch64/interrupt/irq.rs | 3 ++- src/arch/x86/interrupt/ipi.rs | 3 ++- src/arch/x86/interrupt/irq.rs | 3 ++- src/arch/x86_64/interrupt/ipi.rs | 3 ++- src/arch/x86_64/interrupt/irq.rs | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/arch/aarch64/interrupt/irq.rs b/src/arch/aarch64/interrupt/irq.rs index 21e5c4a..7501836 100644 --- a/src/arch/aarch64/interrupt/irq.rs +++ b/src/arch/aarch64/interrupt/irq.rs @@ -59,7 +59,8 @@ pub unsafe fn irq_handler_gentimer(irq: u32) { timeout::trigger(); - if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 10 { + // Switch after 3 ticks (about 6.75 ms) + if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 2 { let _ = context::switch(); } trigger(irq); diff --git a/src/arch/x86/interrupt/ipi.rs b/src/arch/x86/interrupt/ipi.rs index 52aad2a..fd70507 100644 --- a/src/arch/x86/interrupt/ipi.rs +++ b/src/arch/x86/interrupt/ipi.rs @@ -24,7 +24,8 @@ interrupt!(switch, || { interrupt!(pit, || { LOCAL_APIC.eoi(); - if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 10 { + // Switch after 3 ticks (about 6.75 ms) + if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 2 { let _ = context::switch(); } }); diff --git a/src/arch/x86/interrupt/irq.rs b/src/arch/x86/interrupt/irq.rs index c36844a..497053f 100644 --- a/src/arch/x86/interrupt/irq.rs +++ b/src/arch/x86/interrupt/irq.rs @@ -189,7 +189,8 @@ interrupt_stack!(pit_stack, |_stack| { // Any better way of doing this? timeout::trigger(); - if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 10 { + // Switch after 3 ticks (about 6.75 ms) + if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 2 { let _ = context::switch(); } }); diff --git a/src/arch/x86_64/interrupt/ipi.rs b/src/arch/x86_64/interrupt/ipi.rs index 52aad2a..fd70507 100644 --- a/src/arch/x86_64/interrupt/ipi.rs +++ b/src/arch/x86_64/interrupt/ipi.rs @@ -24,7 +24,8 @@ interrupt!(switch, || { interrupt!(pit, || { LOCAL_APIC.eoi(); - if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 10 { + // Switch after 3 ticks (about 6.75 ms) + if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 2 { let _ = context::switch(); } }); diff --git a/src/arch/x86_64/interrupt/irq.rs b/src/arch/x86_64/interrupt/irq.rs index c36844a..497053f 100644 --- a/src/arch/x86_64/interrupt/irq.rs +++ b/src/arch/x86_64/interrupt/irq.rs @@ -189,7 +189,8 @@ interrupt_stack!(pit_stack, |_stack| { // Any better way of doing this? timeout::trigger(); - if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 10 { + // Switch after 3 ticks (about 6.75 ms) + if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 2 { let _ = context::switch(); } });