Re-sort ready_list when priorities update + PRI_UPDATE_FREQ

- PRI_UPDATE_FREQ is a separate value from TIME_SLICE, they just
  happen to be set the same.
This commit is contained in:
2024-10-25 09:13:19 +01:00
parent c4cefbc2d5
commit 093c6efd30

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);
}