Clock subsystem.
More...
Clock subsystem.
The clock subsystem is responsible for providing a consistent system wide time keeping.
System wide time is provided via "clock sources", which are provided in modules. Each source registers itself with a estimate of its precision, the clock subsystem then chooses the two sources, one for uptime and one for unix epoch, with the best precision.
◆ CLOCK_MAX_SOURCES
| #define CLOCK_MAX_SOURCES 8 |
Maximum amount of system timer sources.
Definition at line 26 of file clock.h.
◆ clock_source_register()
Register a system timer source.
- Parameters
-
| source | The timer source to register. |
- Returns
- On success,
0. On failure, ERR and errno is set to:
EINVAL: Invalid parameters.
ENOSPC: No more timer sources can be registered.
Definition at line 47 of file clock.c.
◆ clock_source_unregister()
Unregister a system timer source.
- Parameters
-
| source | The timer source to unregister, or NULL for no-op. |
Definition at line 72 of file clock.c.
◆ clock_uptime()
Retrieve the time in nanoseconds since boot.
- Returns
- The time in nanoseconds since boot.
Definition at line 99 of file clock.c.
◆ clock_epoch()
Retrieve the seconds since the unix epoch.
- Returns
- The amount of seconds since the unix epoch.
Definition at line 119 of file clock.c.
◆ clock_wait()
| void clock_wait |
( |
clock_t |
nanoseconds | ) |
|
Wait for a specified number of nanoseconds.
This function uses a busy-wait loop, making it highly CPU inefficient, but its useful during early initialization or when you are unable to block the current thread.
- Parameters
-
| nanoseconds | The number of nanoseconds to wait. |
Definition at line 130 of file clock.c.