Update sema_down to insert into waiters list in priority sorted order

This commit is contained in:
sBubshait
2024-10-17 06:54:10 +01:00
parent fb268cdef0
commit 24900545d4

View File

@@ -68,7 +68,8 @@ sema_down (struct semaphore *sema)
old_level = intr_disable (); old_level = intr_disable ();
while (sema->value == 0) while (sema->value == 0)
{ {
list_push_back (&sema->waiters, &thread_current ()->elem); list_insert_ordered(&sema->waiters, &thread_current ()->elem,
priority_more, NULL);
thread_block (); thread_block ();
} }
sema->value--; sema->value--;