diff --git a/src/interrupt/irq.rs b/src/interrupt/irq.rs index 0d8fbcb34c348a1509523d591bfd342d61a193c3..2a27f81a0cf776fe7f2e91555b08af9f818f46c8 100644 --- a/src/interrupt/irq.rs +++ b/src/interrupt/irq.rs @@ -1,7 +1,12 @@ use context::timeout; use device::pic; use device::serial::{COM1, COM2}; +use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; + use time; +use context; + +static PIT_TICKS: AtomicUsize = ATOMIC_USIZE_INIT; unsafe fn trigger(irq: u8) { extern { @@ -46,6 +51,10 @@ interrupt!(pit, { pic::MASTER.ack(); + if PIT_TICKS.fetch_add(1, Ordering::SeqCst) % 10 == 0 { + context::switch(); + } + // Any better way of doing this? timeout::trigger(); });