diff --git a/context/switch.rs b/context/switch.rs index 49902d274b898636230e4f771e75894272d9fd98..2e16727025cd22af22c65be5b57bfd9123c04971 100644 --- a/context/switch.rs +++ b/context/switch.rs @@ -54,6 +54,8 @@ pub unsafe fn switch() { return; } + //println!("Switch {} to {}", (&*from_ptr).id, (&*to_ptr).id); + (&mut *from_ptr).running = false; (&mut *to_ptr).running = true; if let Some(ref stack) = (*to_ptr).kstack { diff --git a/scheme/initfs.rs b/scheme/initfs.rs index aa5e7ff574eba488756a40cee0c127b70e038d32..0a33ce781708718990b558da8a749e7014f0dfd8 100644 --- a/scheme/initfs.rs +++ b/scheme/initfs.rs @@ -22,7 +22,7 @@ impl InitFsScheme { files.insert(b"bin/ion", include_bytes!("../../build/userspace/ion")); files.insert(b"bin/pcid", include_bytes!("../../build/userspace/pcid")); files.insert(b"bin/ps2d", include_bytes!("../../build/userspace/ps2d")); - files.insert(b"etc/init.rc", b"echo testing\n#initfs:bin/pcid\ninitfs:bin/ps2d\n#initfs:bin/ion"); + files.insert(b"etc/init.rc", b"#initfs:bin/pcid\ninitfs:bin/ps2d\n#initfs:bin/ion"); InitFsScheme { next_id: 0, diff --git a/scheme/irq.rs b/scheme/irq.rs index 8eee59db268946110cca0ae82637b98e87c00e59..fb68e11792df8cb7a11aea9afbf029982c2de1c0 100644 --- a/scheme/irq.rs +++ b/scheme/irq.rs @@ -1,6 +1,6 @@ use core::{mem, str}; -use arch::interrupt::irq::{COUNTS, acknowledge}; +use arch::interrupt::irq::{ACKS, COUNTS, acknowledge}; use context; use syscall::{Error, Result}; use super::Scheme; @@ -27,20 +27,15 @@ impl Scheme for IrqScheme { fn read(&mut self, file: usize, buffer: &mut [u8]) -> Result<usize> { // Ensures that the length of the buffer is larger than the size of a usize if buffer.len() >= mem::size_of::<usize>() { - let prev = { COUNTS.lock()[file] }; - loop { - { - let current = COUNTS.lock()[file]; - if prev != current { - // Safe if the length of the buffer is larger than the size of a usize - assert!(buffer.len() >= mem::size_of::<usize>()); - unsafe { *(buffer.as_mut_ptr() as *mut usize) = current; } - return Ok(mem::size_of::<usize>()); - } - } - - // Safe if all locks have been dropped - unsafe { context::switch(); } + let ack = ACKS.lock()[file]; + let current = COUNTS.lock()[file]; + if ack != current { + // Safe if the length of the buffer is larger than the size of a usize + assert!(buffer.len() >= mem::size_of::<usize>()); + unsafe { *(buffer.as_mut_ptr() as *mut usize) = current; } + return Ok(mem::size_of::<usize>()); + } else { + return Ok(0); } } else { Err(Error::InvalidValue) @@ -50,9 +45,10 @@ impl Scheme for IrqScheme { fn write(&mut self, file: usize, buffer: &[u8]) -> Result<usize> { if buffer.len() >= mem::size_of::<usize>() { assert!(buffer.len() >= mem::size_of::<usize>()); - let prev = unsafe { *(buffer.as_ptr() as *const usize) }; + let ack = unsafe { *(buffer.as_ptr() as *const usize) }; let current = COUNTS.lock()[file]; - if prev == current { + if ack == current { + ACKS.lock()[file] = ack; unsafe { acknowledge(file); } return Ok(mem::size_of::<usize>()); } else {