]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
feat: increase timer frequency to 100Hz (like Linux)
authorTulio A M Mendes <[email protected]>
Sat, 14 Feb 2026 07:58:29 +0000 (04:58 -0300)
committerTulio A M Mendes <[email protected]>
Sat, 14 Feb 2026 07:58:29 +0000 (04:58 -0300)
commitdf7c93c9146bc3399f01803bdbdbafe3b78b14f0
tree59a2830be69f3913b236737c3f2a33c7985fab66
parent7c445159a6925232ce01761633ca202fd70cd8c0
feat: increase timer frequency to 100Hz (like Linux)

- Central TIMER_HZ=100 and TIMER_MS_PER_TICK=10 constants in timer.h
- Replace all hardcoded 50Hz / 20ms-per-tick assumptions:
  syscall.c (nanosleep, clock_gettime), procfs.c (/proc/uptime),
  net_ping.c (sleep/time calculations), sys_arch.c (sys_now),
  sync.c (ksem_wait_timeout ms-to-ticks conversion)
- Use timer_init(TIMER_HZ) instead of hardcoded 50
- BSP-only timer tick via lapic_get_id() — APs return early to
  eliminate sched_lock/vga_lock contention at higher tick rates
- vga_flush() skips spinlock + cursor update when nothing dirty
- Preempt every 2nd tick (effective 50Hz preemption) to avoid
  excessive CR3 reloads in emulated environments (QEMU TLB flush
  overhead). Sleep/timing resolution remains at full 100Hz via
  process_wake_check on every tick.

Tests: 20/20 smoke (11s), 16/16 battery, cppcheck clean
include/timer.h
src/drivers/timer.c
src/drivers/vga_console.c
src/kernel/main.c
src/kernel/procfs.c
src/kernel/sync.c
src/kernel/syscall.c
src/net/lwip_port/sys_arch.c
src/net/net_ping.c