Skip to content
Snippets Groups Projects
Commit 7127e14b authored by Andrew Plaza's avatar Andrew Plaza
Browse files

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.
parent dd98bfec
No related branches found
No related tags found
1 merge request!12Fix PIT Interrupt Not Context Switching [irq]
use context::timeout; use context::timeout;
use device::pic; use device::pic;
use device::serial::{COM1, COM2}; use device::serial::{COM1, COM2};
use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
use time; use time;
use context;
static PIT_TICKS: AtomicUsize = ATOMIC_USIZE_INIT;
unsafe fn trigger(irq: u8) { unsafe fn trigger(irq: u8) {
extern { extern {
...@@ -46,6 +51,10 @@ interrupt!(pit, { ...@@ -46,6 +51,10 @@ interrupt!(pit, {
pic::MASTER.ack(); pic::MASTER.ack();
if PIT_TICKS.fetch_add(1, Ordering::SeqCst) % 10 == 0 {
context::switch();
}
// Any better way of doing this? // Any better way of doing this?
timeout::trigger(); timeout::trigger();
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment