Remove from sleeping_threads immediately, instead of when thread is scheduled

This commit is contained in:
2024-10-25 14:10:59 +01:00
parent af31968e67
commit 869571108d

View File

@@ -119,9 +119,6 @@ timer_sleep (int64_t ticks)
NULL); NULL);
intr_set_level (old_level); intr_set_level (old_level);
sema_down (&st.semaphore); 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 /* 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); struct asleep_thread *st = list_entry (e, struct asleep_thread, elem);
if (ticks >= st->end_at) if (ticks >= st->end_at)
sema_up (&st->semaphore); {
list_remove (&st->elem);
sema_up (&st->semaphore);
}
else else
break; break;
} }