|
PatchworkOS
28a9544
A non-POSIX operating system.
|
System time. More...
Data Structures | |
| struct | sys_time_source_t |
| Timer system source. More... | |
Macros | |
| #define | SYS_TIME_MAX_SOURCES 8 |
| Maximum amount of system timer sources. | |
Functions | |
| uint64_t | sys_time_register_source (const sys_time_source_t *source) |
| Register a system timer source. | |
| void | sys_time_unregister_source (const sys_time_source_t *source) |
| Unregister a system timer source. | |
| clock_t | sys_time_uptime (void) |
| Time since boot. | |
| time_t | sys_time_unix_epoch (void) |
| The unix epoch. | |
| void | sys_time_wait (clock_t nanoseconds) |
| Wait for a specified number of nanoseconds. | |
System time.
The sys time subsystem is responsible for providing a consistent system wide time keeping.
System wide time is provided via "system time sources", which are provided in modules. Each source registers itself with a estimate of its precision, the timer subsystem then chooses the source with the highest precision as the system time source.
| #define SYS_TIME_MAX_SOURCES 8 |
Maximum amount of system timer sources.
Definition at line 28 of file sys_time.h.
| uint64_t sys_time_register_source | ( | const sys_time_source_t * | source | ) |
Register a system timer source.
| source | The timer source to register. |
0. On failure, ERR and errno is set. Definition at line 35 of file sys_time.c.
References bestSource, EINVAL, ENOSPC, ERR, errno, LOG_INFO, sys_time_source_t::name, NULL, sys_time_source_t::precision, sys_time_source_t::read, rwlock_write_acquire(), rwlock_write_release(), source, sourceCount, sources, sourcesLock, and SYS_TIME_MAX_SOURCES.
Referenced by hpet_init().
| time_t sys_time_unix_epoch | ( | void | ) |
The unix epoch.
Definition at line 117 of file sys_time.c.
References bootEpoch, bootEpochInitialized, CLOCKS_PER_SEC, sys_time_uptime(), and timer_boot_epoch_init().
Referenced by inode_new(), inode_notify_access(), inode_notify_change(), inode_notify_modify(), and SYSCALL_DEFINE().
| void sys_time_unregister_source | ( | const sys_time_source_t * | source | ) |
Unregister a system timer source.
| source | The timer source to unregister. |
Definition at line 67 of file sys_time.c.
References bestSource, LOG_INFO, memmove(), sys_time_source_t::name, NULL, panic(), rwlock_write_acquire(), rwlock_write_release(), source, sourceCount, sources, and sourcesLock.
Referenced by hpet_deinit().
| clock_t sys_time_uptime | ( | void | ) |
Time since boot.
Definition at line 106 of file sys_time.c.
References bestSource, NULL, sys_time_source_t::read, RWLOCK_READ_SCOPE, and sourcesLock.
Referenced by aml_def_timer_read(), hpet_timer_handler(), kbd_push(), key_share(), key_timer_handler(), log_print_header(), mouse_push(), mutex_acquire_timeout(), perf_cpu_read(), perf_interrupt_begin(), perf_interrupt_end(), perf_process_ctx_init(), perf_syscall_begin(), perf_syscall_end(), process_kill(), ps2_wait_until_clear(), ps2_wait_until_set(), rand_gen_fallback(), sched_compute_time_slice(), sched_invoke(), sched_push(), sched_push_new_thread(), space_tlb_shootdown(), sys_time_unix_epoch(), sys_time_wait(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), vfs_poll(), wait_block_setup(), and wait_timer_handler().
| void sys_time_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.
| nanoseconds | The number of nanoseconds to wait |
Definition at line 127 of file sys_time.c.
References NULL, panic(), start(), and sys_time_uptime().
Referenced by apic_timer_ticks_per_ns(), ps2_device_init(), ps2_drain(), trampoline_send_startup_ipi(), and trampoline_wait_ready().