Clock#
- group Clock
Functions
-
error_t clock_init(u64 tick_quantum)#
Initialize the periodic clock subsystem.
Initialize internal state and program the first timer deadline using the provided tick quantum.
- Parameters:
tick_quantum – Number of hardware timer ticks per software tick.
- Returns:
error_t E_OK on success, otherwise an error code.
-
u64 clock_now(void)#
Return the current time in hardware timer ticks.
This returns a monotonic timestamp suitable for computing deadlines.
- Returns:
Current time in hardware ticks.
-
u64 clock_ticks_now(void)#
Return the number of software ticks since boot.
Software ticks are incremented by the timer IRQ handler and advance at a rate of one per
tick_quantumhardware ticks.- Returns:
Number of elapsed software ticks.
-
error_t clock_set_next_switch_in(u64 ticks_from_now)#
Request the scheduler be woken in a number of software ticks.
Programs the next switch tick to be
ticks_from_nowsoftware ticks in the future. This does not block; useclock_next_switch_tickorclock_ticks_to_next_switchto query the scheduled value.- Parameters:
ticks_from_now – Number of software ticks from now to schedule.
- Returns:
error_t E_OK on success, otherwise an error code.
-
error_t clock_next_switch_tick(u64 *out_tick)#
Obtain the currently scheduled next-switch absolute tick.
Writes the absolute software tick value at which the scheduler has requested a switch into
out_tick.- Parameters:
out_tick – Pointer to u64 to receive the absolute tick value.
- Returns:
error_t E_OK on success, EINVAL if
out_tickis NULL, or other error codes on failure.
-
error_t clock_ticks_to_next_switch(u64 *out_ticks)#
Obtain the number of software ticks until the next switch.
Writes into
out_ticksthe number of ticks remaining until the scheduled next-switch tick. If a next-switch is not scheduled, behavior is implementation-defined.- Parameters:
out_ticks – Pointer to u64 to receive remaining ticks.
- Returns:
error_t E_OK on success, EINVAL if
out_ticksis NULL, or other error codes on failure.
-
error_t clock_init(u64 tick_quantum)#