AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
time.h File Reference
#include <core/types.h>

Go to the source code of this file.

Functions

int gettime (struct timespec *ts)
 Reads the wall clock (CLOCK_REALTIME).
int gettimeofday (struct timeval *tv, struct timezone *tz)
 Reads the wall clock, in microseconds, for gettimeofday().
void time_resync (void)
 Sets the wall clock from the real time clock again, if they are 2 seconds or more apart.

Function Documentation

◆ gettime()

int gettime ( struct timespec * ts)

Reads the wall clock (CLOCK_REALTIME).

The first call reads the real time clock.

Parameters
tsset to the time, since the epoch
Returns
0, or a negative errno if the real time clock can't be read

Definition at line 29 of file time.c.

References arch_rtime_ns(), arch_time_get(), clock_base_ns, clock_base_sec, clock_set, gettime(), timespec::tv_nsec, and timespec::tv_sec.

Referenced by cpio_root_node(), devfs_init(), devpts_init(), ext2_inode_discard(), ext2_vlink(), ext2_vmknod(), ext2_vrename(), ext2_vunlink(), gettime(), gettimeofday(), procfs_init(), procfs_vget(), pseudofs_vmknod(), sys_clock_gettime(), time_resync(), tmpfs_mount(), vfs_chmod(), vfs_chown(), and vfs_utimens().

◆ gettimeofday()

int gettimeofday ( struct timeval * tv,
struct timezone * tz )

Reads the wall clock, in microseconds, for gettimeofday().

Parameters
tvif not NULL, set to the time, since the epoch
tzif not NULL, set to UTC (the kernel has no time zones)
Returns
0, or a negative errno if the real time clock can't be read

Definition at line 78 of file time.c.

References gettime(), gettimeofday(), timespec::tv_nsec, timespec::tv_sec, timeval::tv_sec, timeval::tv_usec, timezone::tz_dsttime, and timezone::tz_minuteswest.

Referenced by gettimeofday(), and sys_gettimeofday().

◆ time_resync()

void time_resync ( void )

Sets the wall clock from the real time clock again, if they are 2 seconds or more apart.

The tick calls it now and then: the monotonic clock, which the wall clock follows, may count a little fast or slow.

Definition at line 54 of file time.c.

References arch_rtime_ns(), arch_time_get(), clock_base_ns, clock_base_sec, clock_set, gettime(), printk(), time_resync(), and timespec::tv_sec.

Referenced by sched_tick(), time_resync(), and x86_sched_handler().