Fix PIT Interrupt Not Context Switching [irq]

PIT interrupt should context switch or else all of redox crashes.
This will fix programs like the Snake game crashing all of Redox.
A global AtomicUSize counter was added, and a line to switch contexts
on every 10 PIT interrupts in irq.rs.
This commit is contained in:
Andrew Plaza
2017-04-24 22:07:02 -04:00
parent dd98bfec5c
commit 7127e14b5d

View File

@@ -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();
});