Merge branch 'gleb/fix-bsd-ready-list-order' into 'master'

Re-sort ready_list when priorities update + PRI_UPDATE_FREQ

See merge request lab2425_autumn/pintos_22!17
This commit is contained in:
Saleh Bubshait
2024-10-25 08:32:08 +00:00

View File

@@ -55,6 +55,7 @@ static fp32_t load_avg = { 0 }; /* System load average. */
/* Scheduling. */
#define TIME_SLICE 4 /* # of timer ticks to give each thread. */
#define PRI_UPDATE_FREQ 4 /* # of timer ticks to update priorities. */
static unsigned thread_ticks; /* # of timer ticks since last yield. */
/* If false (default), use round-robin scheduler.
@@ -172,9 +173,12 @@ thread_tick (void)
load_avg = fp_add (old_coeff, new_coeff);
thread_foreach (update_recent_cpu, NULL);
/* Priorities have been updated, need to re-sort. */
list_sort (&ready_list, priority_more, NULL);
}
if (ticks % TIME_SLICE == 0) // recent_cpu was updated, update priority.
/* Recent cpu was updated, update priority. */
if (ticks % PRI_UPDATE_FREQ == 0)
t->priority = calculate_bsd_priority (t->recent_cpu, t->nice);
}