⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Module timer

Module timer 

Source
Expand description

High-resolution timer management for VeridianOS.

This module provides a software timer wheel that sits above the architecture-specific hardware timer layer (crate::arch::timer). It supports both one-shot and periodic timers with millisecond granularity, using a hierarchical timer wheel with 256 slots for efficient O(1) insertion and expiration.

§Usage

// Initialize the timer subsystem (called once during boot)
timer::init()?;

// Create a one-shot timer that fires after 100ms
let id = timer::create_timer(TimerMode::OneShot, 100, my_callback)?;

// Cancel a timer
timer::cancel_timer(id)?;

// Called from the timer interrupt handler
timer::timer_tick(elapsed_ms);

// Query monotonic uptime
let uptime = timer::get_uptime_ms();