Make cpu->proc_run_q_count not atomic

This commit is contained in:
2026-02-22 14:03:51 +01:00
parent 85872b856b
commit e69606668d
4 changed files with 16 additions and 7 deletions

View File

@@ -58,13 +58,22 @@ struct cpu* cpu_find_lightest (void) {
struct limine_mp_response* mp = limine_mp_request.response;
int start = atomic_fetch_add (&last_cpu_index, 1) % mp->cpu_count;
struct cpu* best_cpu = &cpus[start];
int best_load = atomic_load (&best_cpu->proc_run_q_count);
spin_lock (&best_cpu->lock);
int best_load = best_cpu->proc_run_q_count;
spin_unlock (&best_cpu->lock);
for (int i = 1; i < (int)mp->cpu_count; i++) {
int idx = (start + i) % mp->cpu_count;
struct cpu* cpu = &cpus[idx];
int l = atomic_load (&cpu->proc_run_q_count);
spin_lock (&cpu->lock);
int l = cpu->proc_run_q_count;
spin_unlock (&cpu->lock);
if (l < best_load) {
best_load = l;
best_cpu = cpu;