From fda79173c092e7eb7537557ae1cd19447dd1462b Mon Sep 17 00:00:00 2001 From: sBubshait Date: Wed, 16 Oct 2024 08:00:50 +0100 Subject: [PATCH] Update thread_unblock to maintain priority order in ready_list --- src/threads/thread.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/threads/thread.c b/src/threads/thread.c index 4ddee22..0a66d65 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -263,7 +263,10 @@ thread_unblock (struct thread *t) old_level = intr_disable (); ASSERT (t->status == THREAD_BLOCKED); - list_push_back (&ready_list, &t->elem); + + /* Insert the thread back into the ready list in priority order. */ + list_insert_ordered(&ready_list, &t->elem, priority_more, NULL); + t->status = THREAD_READY; intr_set_level (old_level); }