posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
POSIX_TIMERS

POSIX Timers option group. More...

Macros

#define CLOCK_REALTIME   ((clockid_t)SYS_CLOCK_REALTIME)
 Clock measuring real (wall-clock) time.
 
#define CLOCKS_PER_SEC   1000000
 Number of clock ticks per second as seen by clock().
 
#define TIMER_ABSTIME   SYS_TIMER_ABSTIME
 Flag for clock_nanosleep() and timer_settime(): interpret time as absolute.
 

Functions

int clock_getres (clockid_t clock_id, struct timespec *ts)
 Get the resolution of a clock.
 
int clock_gettime (clockid_t clock_id, struct timespec *ts)
 Get the current time of a clock.
 
int clock_settime (clockid_t clock_id, const struct timespec *ts)
 Set the time of a clock.
 
int nanosleep (const struct timespec *rqtp, struct timespec *rmtp)
 Sleep for a specified number of nanoseconds (high-resolution sleep).
 
int timer_create (clockid_t clockId, struct sigevent *ZRESTRICT evp, timer_t *ZRESTRICT timerid)
 Create a per-process timer.
 
int timer_delete (timer_t timerid)
 Delete a per-process timer.
 
int timer_getoverrun (timer_t timerid)
 Get the number of timer overruns since the last timer expiration notification.
 
int timer_gettime (timer_t timerid, struct itimerspec *its)
 Get the time remaining until the next timer expiration.
 
int timer_settime (timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue)
 Arm or disarm a per-process timer.
 

Detailed Description

POSIX Timers option group.

Macro Definition Documentation

◆ CLOCK_REALTIME

#define CLOCK_REALTIME   ((clockid_t)SYS_CLOCK_REALTIME)

Clock measuring real (wall-clock) time.

Definition at line 107 of file time.h.

◆ CLOCKS_PER_SEC

#define CLOCKS_PER_SEC   1000000

Number of clock ticks per second as seen by clock().

Definition at line 113 of file time.h.

◆ TIMER_ABSTIME

#define TIMER_ABSTIME   SYS_TIMER_ABSTIME

Flag for clock_nanosleep() and timer_settime(): interpret time as absolute.

Definition at line 142 of file time.h.

Function Documentation

◆ clock_getres()

int clock_getres ( clockid_t  clock_id,
struct timespec ts 
)

Get the resolution of a clock.

Parameters
clock_idClock to query.
tsOutput: resolution (smallest representable interval).
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html

◆ clock_gettime()

int clock_gettime ( clockid_t  clock_id,
struct timespec ts 
)

Get the current time of a clock.

Parameters
clock_idClock to read.
tsOutput: current time.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html

◆ clock_settime()

int clock_settime ( clockid_t  clock_id,
const struct timespec ts 
)

Set the time of a clock.

Parameters
clock_idClock to set.
tsNew time value.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_settime.html

◆ nanosleep()

int nanosleep ( const struct timespec rqtp,
struct timespec rmtp 
)

Sleep for a specified number of nanoseconds (high-resolution sleep).

Parameters
rqtpRequested sleep duration.
rmtpOutput: remaining time if the call was interrupted, or NULL.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html

◆ timer_create()

int timer_create ( clockid_t  clockId,
struct sigevent *ZRESTRICT  evp,
timer_t *ZRESTRICT  timerid 
)

Create a per-process timer.

Parameters
clockIdClock to base the timer on.
evpNotification specification, or NULL for SIGALRM delivery.
timeridOutput: new timer ID.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_create.html

◆ timer_delete()

int timer_delete ( timer_t  timerid)

Delete a per-process timer.

Parameters
timeridTimer to delete.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_delete.html

◆ timer_getoverrun()

int timer_getoverrun ( timer_t  timerid)

Get the number of timer overruns since the last timer expiration notification.

Parameters
timeridTimer to query.
Returns
Overrun count on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_getoverrun.html

◆ timer_gettime()

int timer_gettime ( timer_t  timerid,
struct itimerspec its 
)

Get the time remaining until the next timer expiration.

Parameters
timeridTimer to query.
itsOutput: current timer value and interval.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_gettime.html

◆ timer_settime()

int timer_settime ( timer_t  timerid,
int  flags,
const struct itimerspec value,
struct itimerspec ovalue 
)

Arm or disarm a per-process timer.

Parameters
timeridTimer to set.
flags0 for a relative time, TIMER_ABSTIME for an absolute time.
valueNew expiration time and interval; set it_value to zero to disarm.
ovalueOutput: previous timer value, or NULL.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_settime.html