PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
clock.c File Reference
#include <kernel/sched/clock.h>
#include <kernel/cpu/cpu.h>
#include <kernel/cpu/interrupt.h>
#include <kernel/cpu/syscall.h>
#include <kernel/log/log.h>
#include <kernel/log/panic.h>
#include <kernel/module/symbol.h>
#include <kernel/sched/thread.h>
#include <kernel/sched/timer.h>
#include <kernel/sync/rwlock.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/math.h>
Include dependency graph for clock.c:

Go to the source code of this file.

Functions

static void clock_update_best_sources (void)
 
uint64_t clock_source_register (const clock_source_t *source)
 Register a system timer source.
 
void clock_source_unregister (const clock_source_t *source)
 Unregister a system timer source.
 
clock_t clock_uptime (void)
 Retrieve the time in nanoseconds since boot.
 
time_t clock_epoch (void)
 Retrieve the seconds since the unix epoch.
 
void clock_wait (clock_t nanoseconds)
 Wait for a specified number of nanoseconds.
 
 SYSCALL_DEFINE (SYS_UPTIME, clock_t)
 
 SYSCALL_DEFINE (SYS_UNIX_EPOCH, time_t, time_t *timePtr)
 

Variables

static const clock_source_tsources [CLOCK_MAX_SOURCES] = {0}
 
static uint32_t sourceCount = 0
 
static const clock_source_tbestNsSource = NULL
 
static const clock_source_tbestEpochSource = NULL
 
static rwlock_t sourcesLock = RWLOCK_CREATE()
 

Function Documentation

◆ clock_update_best_sources()

static void clock_update_best_sources ( void  )
static

Definition at line 28 of file clock.c.

Here is the caller graph for this function:

◆ SYSCALL_DEFINE() [1/2]

SYSCALL_DEFINE ( SYS_UPTIME  ,
clock_t   
)

Definition at line 149 of file clock.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [2/2]

SYSCALL_DEFINE ( SYS_UNIX_EPOCH  ,
time_t  ,
time_t timePtr 
)

Definition at line 154 of file clock.c.

Here is the call graph for this function:

Variable Documentation

◆ sources

const clock_source_t* sources[CLOCK_MAX_SOURCES] = {0}
static

Definition at line 18 of file clock.c.

◆ sourceCount

uint32_t sourceCount = 0
static

Definition at line 19 of file clock.c.

◆ bestNsSource

const clock_source_t* bestNsSource = NULL
static

Definition at line 20 of file clock.c.

◆ bestEpochSource

const clock_source_t* bestEpochSource = NULL
static

Definition at line 21 of file clock.c.

◆ sourcesLock

rwlock_t sourcesLock = RWLOCK_CREATE()
static

Definition at line 22 of file clock.c.