Merge code refactors into main branch #16

Merged
ed1223 merged 8 commits from merged-complete into master 2024-10-24 22:15:25 +00:00
4 changed files with 96 additions and 96 deletions
Showing only changes of commit 7d196ffc57 - Show all commits

View File

@@ -167,7 +167,7 @@ thread_tick (void)
size_t ready = threads_ready (); size_t ready = threads_ready ();
if (t != idle_thread) if (t != idle_thread)
ready++; ready++;
fp32_t old_coeff = fp_div_int (fp_mul_int(load_avg, 59), 60); fp32_t old_coeff = fp_div_int (fp_mul_int (load_avg, 59), 60);
fp32_t new_coeff = fp_div_int (fp_from_int (ready), 60); fp32_t new_coeff = fp_div_int (fp_from_int (ready), 60);
load_avg = fp_add (old_coeff, new_coeff); load_avg = fp_add (old_coeff, new_coeff);
@@ -293,7 +293,7 @@ thread_unblock (struct thread *t)
ASSERT (t->status == THREAD_BLOCKED); ASSERT (t->status == THREAD_BLOCKED);
/* Insert the thread back into the ready list in priority order. */ /* Insert the thread back into the ready list in priority order. */
list_insert_ordered(&ready_list, &t->elem, priority_more, NULL); list_insert_ordered (&ready_list, &t->elem, priority_more, NULL);
t->status = THREAD_READY; t->status = THREAD_READY;
intr_set_level (old_level); intr_set_level (old_level);
@@ -368,7 +368,7 @@ thread_yield (void)
if (cur != idle_thread) if (cur != idle_thread)
{ {
/* Insert the thread back into the ready list in priority order. */ /* Insert the thread back into the ready list in priority order. */
list_insert_ordered(&ready_list, &cur->elem, priority_more, NULL); list_insert_ordered (&ready_list, &cur->elem, priority_more, NULL);
} }
cur->status = THREAD_READY; cur->status = THREAD_READY;
@@ -726,7 +726,7 @@ static int
calculate_bsd_priority (fp32_t recent_cpu, int nice) calculate_bsd_priority (fp32_t recent_cpu, int nice)
{ {
ASSERT(thread_mlfqs); ASSERT (thread_mlfqs);
int priority = PRI_MAX - (fp_round (recent_cpu) / 4) - (nice * 2); int priority = PRI_MAX - (fp_round (recent_cpu) / 4) - (nice * 2);
if (priority < PRI_MIN) if (priority < PRI_MIN)