From 24900545d4718e28ab396562c9bb2c1bfffb428a Mon Sep 17 00:00:00 2001 From: sBubshait Date: Thu, 17 Oct 2024 06:54:10 +0100 Subject: [PATCH] Update sema_down to insert into waiters list in priority sorted order --- src/threads/synch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/threads/synch.c b/src/threads/synch.c index 7776cb0..39575ca 100644 --- a/src/threads/synch.c +++ b/src/threads/synch.c @@ -68,7 +68,8 @@ sema_down (struct semaphore *sema) old_level = intr_disable (); 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 (); } sema->value--;