The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
clock.h File Reference
#include "common/stdint.h"

Go to the source code of this file.

Data Structures

struct  ktimespec
 struct timespec (ABI: long seconds and nanoseconds, as the libc's <time.h> has it). More...

Macros

#define CLOCK_REALTIME   0
 the system clocks.
#define CLOCK_MONOTONIC   1
#define CLOCK_PROCESS_CPUTIME_ID   2
#define NSEC_PER_SEC   1000000000u

Functions

void clock_init (void)
 read the wall-clock time from the RTC.
void clock_init_sleep (void)
 set up the queue nanosleep sleeps on.
uint32_t clock_realtime_seconds (void)
 the wall-clock time in seconds since 1970 (0 if the RTC gave none).
void clock_ticks_to_timespec (uint64_t ticks, struct ktimespec *out)
 a timespec from a number of timer ticks.
uint64_t clock_timespec_to_ticks (const struct ktimespec *span)
 the timer ticks that cover at least a time span (rounded up).
void clock_realtime (struct ktimespec *out)
 the wall-clock time as a timespec.

Macro Definition Documentation

◆ CLOCK_REALTIME

#define CLOCK_REALTIME   0

the system clocks.

CLOCK_REALTIME seconds since 1970 (from the RTC at boot, then the timer ticks) CLOCK_MONOTONIC time since boot; never set, never goes back CLOCK_PROCESS_CPUTIME_ID user and system time of the calling process

the resolution is one timer tick (10 ms at 100 Hz).

◆ CLOCK_MONOTONIC

#define CLOCK_MONOTONIC   1

◆ CLOCK_PROCESS_CPUTIME_ID

#define CLOCK_PROCESS_CPUTIME_ID   2

◆ NSEC_PER_SEC

#define NSEC_PER_SEC   1000000000u

Function Documentation

◆ clock_init()

void clock_init ( void )

read the wall-clock time from the RTC.

call once at boot.

◆ clock_init_sleep()

void clock_init_sleep ( void )

set up the queue nanosleep sleeps on.

call once at boot, before the first nanosleep.

◆ clock_realtime_seconds()

uint32_t clock_realtime_seconds ( void )

the wall-clock time in seconds since 1970 (0 if the RTC gave none).

◆ clock_ticks_to_timespec()

void clock_ticks_to_timespec ( uint64_t ticks,
struct ktimespec * out )

a timespec from a number of timer ticks.

◆ clock_timespec_to_ticks()

uint64_t clock_timespec_to_ticks ( const struct ktimespec * span)

the timer ticks that cover at least a time span (rounded up).

◆ clock_realtime()

void clock_realtime ( struct ktimespec * out)

the wall-clock time as a timespec.

the realtime clock as a timespec: the boot time plus the ticks since.

the wall-clock time as a timespec.