Update thread module to maintain list of ready threads in descending order of priority

This commit is contained in:
Themis Demetriades
2024-10-15 13:51:41 +01:00
parent d4d5a7a937
commit 79061fcb9b

View File

@@ -256,7 +256,7 @@ thread_unblock (struct thread *t)
old_level = intr_disable ();
ASSERT (t->status == THREAD_BLOCKED);
list_push_back (&ready_list, &t->elem);
list_insert_ordered (&ready_list, &t->elem, &thread_priority_greater, NULL);
t->status = THREAD_READY;
intr_set_level (old_level);
}
@@ -327,7 +327,8 @@ thread_yield (void)
old_level = intr_disable ();
if (cur != idle_thread)
list_push_back (&ready_list, &cur->elem);
list_insert_ordered (&ready_list, &cur->elem, thread_priority_greater,
NULL);
cur->status = THREAD_READY;
schedule ();
intr_set_level (old_level);