From 869571108d4b0547223148751338c215543dddf6 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Fri, 25 Oct 2024 14:10:59 +0100 Subject: [PATCH] Remove from sleeping_threads immediately, instead of when thread is scheduled --- src/devices/timer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/devices/timer.c b/src/devices/timer.c index 4bb602e..e7fdc53 100644 --- a/src/devices/timer.c +++ b/src/devices/timer.c @@ -119,9 +119,6 @@ timer_sleep (int64_t ticks) NULL); intr_set_level (old_level); sema_down (&st.semaphore); - old_level = intr_disable (); - list_remove (&st.elem); - intr_set_level (old_level); } /* Sleeps for approximately MS milliseconds. Interrupts must be @@ -204,7 +201,10 @@ timer_interrupt (struct intr_frame *args UNUSED) { struct asleep_thread *st = list_entry (e, struct asleep_thread, elem); if (ticks >= st->end_at) - sema_up (&st->semaphore); + { + list_remove (&st->elem); + sema_up (&st->semaphore); + } else break; }