From 20be75748cbb06dc5b775f7626e62e08768bba8e Mon Sep 17 00:00:00 2001 From: EDiasAlberto Date: Wed, 23 Oct 2024 19:57:17 +0100 Subject: [PATCH] replace thread_mlfqs checks in priority calculations with assertions --- src/threads/thread.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/threads/thread.c b/src/threads/thread.c index 1a7ab68..cb60d1b 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -474,12 +474,8 @@ thread_recalculate_priority (void) { struct thread *t = thread_current (); - if (thread_mlfqs) - { - t->priority = calculate_bsd_priority (t->recent_cpu, t->nice); - return; - } - + ASSERT(!thread_mlfqs) + enum intr_level old_level = intr_disable (); t->priority = t->base_priority; @@ -732,6 +728,9 @@ thread_schedule_tail (struct thread *prev) static int calculate_bsd_priority (fp32_t recent_cpu, int nice) { + + ASSERT(thread_mlfqs); + int priority = PRI_MAX - (fp_round (recent_cpu) / 4) - (nice * 2); if (priority < PRI_MIN) return PRI_MIN;