diff --git a/shared-scheduler/src/algorithm/ring_fifo.rs b/shared-scheduler/src/algorithm/ring_fifo.rs index 9fa612b..eb45327 100644 --- a/shared-scheduler/src/algorithm/ring_fifo.rs +++ b/shared-scheduler/src/algorithm/ring_fifo.rs @@ -90,7 +90,7 @@ impl RingQueue { } unsafe { *self.elem[self.tail].as_mut_ptr() = value }; self.tail = self.tail.wrapping_add(1); - if self.tail > N || self.tail == 0 { + if self.tail >= N || self.tail == 0 { self.tail = self.tail.wrapping_sub(N); } None // success @@ -101,7 +101,7 @@ impl RingQueue { } let value = unsafe { ptr::read(self.elem[self.front].as_ptr()) }; self.front = self.front.wrapping_add(1); // assured non empty - if self.front > N || self.front == 0 { + if self.front >= N || self.front == 0 { self.front = self.front.wrapping_sub(N); } Some(value) diff --git a/tornado-kernel/src/virtio/mod.rs b/tornado-kernel/src/virtio/mod.rs index 86da825..e874463 100644 --- a/tornado-kernel/src/virtio/mod.rs +++ b/tornado-kernel/src/virtio/mod.rs @@ -77,7 +77,7 @@ pub extern "C" fn virtio_virt_to_phys(vaddr: VirtualAddress) -> PhysicalAddress pub async fn async_virtio_blk_test() { let mut read_buf = [0u8; 512]; let mut write_buf = [0u8; 512]; - for i in 0..50 { + for i in 0..512 { write_buf.iter_mut().for_each(|byte| *byte = i as u8); BLOCK_DEVICE.write_block(i as usize, &write_buf).await; BLOCK_DEVICE.read_block(i as usize, &mut read_buf).await;