Skip to content

Commit 4e8013a

Browse files
fix(scheduler): awaiting tasks
* Correctly set a sleep duration of 0 for tasks that do not have a deadline. * Look in the `deadline_awaiting` queue if the task trying to wake up has a non-zero duration. Signed-off-by: Anhad Singh <[email protected]>
1 parent fe38d28 commit 4e8013a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/aero_kernel/src/userland/scheduler/round_robin.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ impl TaskQueue {
9090
debug_assert!(!task.link.is_linked()); // Make sure the task is not already linked
9191

9292
task.update_state(TaskState::AwaitingIo);
93+
task.set_sleep_duration(0);
94+
9395
self.awaiting.push_back(task);
9496
}
9597
}
@@ -213,7 +215,11 @@ impl SchedulerInterface for RoundRobin {
213215
let queue = self.queue.get_mut();
214216

215217
if task.state() == TaskState::AwaitingIo {
216-
let mut cursor = unsafe { queue.awaiting.cursor_mut_from_ptr(task.as_ref()) };
218+
let mut cursor = if task.load_sleep_duration() > 0 {
219+
unsafe { queue.deadline_awaiting.cursor_mut_from_ptr(task.as_ref()) }
220+
} else {
221+
unsafe { queue.awaiting.cursor_mut_from_ptr(task.as_ref()) }
222+
};
217223

218224
if let Some(task) = cursor.remove() {
219225
queue.push_runnable(task);

src/aero_kernel/src/utils/sync.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pub struct BMutexGuard<'a, T: ?Sized + 'a> {
178178
mutex: &'a BMutex<T>,
179179
}
180180

181-
impl<'a, T: ?Sized> core::ops::Deref for BMutexGuard<'a, T> {
181+
impl<T: ?Sized> core::ops::Deref for BMutexGuard<'_, T> {
182182
type Target = T;
183183

184184
#[inline]
@@ -187,14 +187,14 @@ impl<'a, T: ?Sized> core::ops::Deref for BMutexGuard<'a, T> {
187187
}
188188
}
189189

190-
impl<'a, T: ?Sized> core::ops::DerefMut for BMutexGuard<'a, T> {
190+
impl<T: ?Sized> core::ops::DerefMut for BMutexGuard<'_, T> {
191191
#[inline]
192192
fn deref_mut(&mut self) -> &mut T {
193193
self.guard.deref_mut()
194194
}
195195
}
196196

197-
impl<'a, T: ?Sized> Drop for BMutexGuard<'a, T> {
197+
impl<T: ?Sized> Drop for BMutexGuard<'_, T> {
198198
fn drop(&mut self) {
199199
self.mutex.wq.notify();
200200
}
@@ -261,7 +261,7 @@ pub struct MutexGuard<'a, T: ?Sized + 'a> {
261261
irq_lock: bool,
262262
}
263263

264-
impl<'a, T: ?Sized> core::ops::Deref for MutexGuard<'a, T> {
264+
impl<T: ?Sized> core::ops::Deref for MutexGuard<'_, T> {
265265
type Target = T;
266266

267267
#[inline]
@@ -270,14 +270,14 @@ impl<'a, T: ?Sized> core::ops::Deref for MutexGuard<'a, T> {
270270
}
271271
}
272272

273-
impl<'a, T: ?Sized> core::ops::DerefMut for MutexGuard<'a, T> {
273+
impl<T: ?Sized> core::ops::DerefMut for MutexGuard<'_, T> {
274274
#[inline]
275275
fn deref_mut(&mut self) -> &mut T {
276276
&mut self.guard
277277
}
278278
}
279279

280-
impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> {
280+
impl<T: ?Sized> Drop for MutexGuard<'_, T> {
281281
#[inline]
282282
fn drop(&mut self) {
283283
unsafe {

0 commit comments

Comments
 (0)