Remove from sleeping_threads immediately, instead of when thread is scheduled
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user