From 5ba02ca940475c7dc266e6eb5785c92f2d011e0a Mon Sep 17 00:00:00 2001 From: Andrew Plaza <andrew.plaza15@gmail.com> Date: Tue, 25 Apr 2017 14:40:23 -0400 Subject: [PATCH] Reset PIT_TICKS to 0 on context::switch, change condition for context::switch [irq] Set the counter to 0 when context is to be switched in the PIT interrupt, and change the condition for context switching from % 10 to >= 10. --- src/interrupt/irq.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/interrupt/irq.rs b/src/interrupt/irq.rs index 2a27f81a..d1fd7ab6 100644 --- a/src/interrupt/irq.rs +++ b/src/interrupt/irq.rs @@ -51,7 +51,9 @@ interrupt!(pit, { pic::MASTER.ack(); - if PIT_TICKS.fetch_add(1, Ordering::SeqCst) % 10 == 0 { + if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 10 { + PIT_TICKS.store(0, Ordering::SeqCst); + assert_eq!(PIT_TICKS.load(Ordering::SeqCst), 0); context::switch(); } -- GitLab