]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
feat: full SMP scheduling — AP tick accounting, IPI wakeups, load balancing
authorTulio A M Mendes <[email protected]>
Sat, 14 Mar 2026 13:23:54 +0000 (10:23 -0300)
committerTulio A M Mendes <[email protected]>
Sat, 14 Mar 2026 13:23:54 +0000 (10:23 -0300)
commit1374a6fc9217cf7236b0eed671ae0471db0a00d8
tree7c4971ce78007812b5ccd4a1e7fc9e33a57cd7ab
parent737c3bc4e49affa47a986517808d5273e2f5e02c
feat: full SMP scheduling — AP tick accounting, IPI wakeups, load balancing

Scheduler changes (src/kernel/scheduler.c):
- sched_ap_tick(): per-CPU tick accounting for APs (utime, ITIMER_VIRTUAL,
  ITIMER_PROF) — previously only BSP tracked CPU time
- sched_load_balance(): periodic work stealing — migrates one process from
  busiest to idlest CPU when imbalance >= 2 (avoids ping-pong)
- IPI resched after sleep wakeups: process_wake_check() now sends IPI to
  remote CPUs that received newly-ready processes from the sleep queue
- IPI resched after parent wakeup: process_exit_notify() sends IPI when
  waking a parent blocked in waitpid on a different CPU
- Load counter (sched_pcpu_inc_load) added to wakeup paths that were
  missing it (exit_notify parent wake, sleep queue wake)

Timer changes:
- src/drivers/timer.c: hal_tick_bridge() now calls sched_ap_tick() on APs
  and sched_load_balance() on BSP every 10 ticks (~200ms at 50Hz)
- src/hal/x86/timer.c: APs now go through hal_tick_bridge instead of
  calling bare schedule(), enabling proper AP tick accounting
- Uses percpu_cpu_index() (GS segment read) instead of smp_current_cpu()
  (LAPIC ID linear scan) for faster CPU identification

Tests:
- New SMP parallel fork smoke test: forks 8 children with busy loops,
  verifies all complete with correct exit status (exercises multi-CPU
  scheduling, IPI wakeups, and load balancing)
- 102/102 smoke tests pass, cppcheck clean, 64/64 host tests pass
include/process.h
src/drivers/timer.c
src/hal/x86/timer.c
src/kernel/scheduler.c
tests/smoke_test.exp
user/fulltest.c