FreeRTOS: POSIX
Return to main page ↑
FreeRTOS_POSIX_clock.c File Reference

Implementation of clock functions in time.h. More...

#include <stddef.h>
#include <string.h>
#include "FreeRTOS_POSIX.h"
#include "FreeRTOS_POSIX/errno.h"
#include "FreeRTOS_POSIX/time.h"
#include "FreeRTOS_POSIX/utils.h"

Functions

int snprintf (char *s, size_t n, const char *format,...)
 
clock_t clock (void)
 Report CPU time used. More...
 
int clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
 Access a process CPU-time clock. More...
 
int clock_getres (clockid_t clock_id, struct timespec *res)
 Returns the resolution of a clock. More...
 
int clock_gettime (clockid_t clock_id, struct timespec *tp)
 Returns the current value for the specified clock, clock_id. More...
 
int clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
 High resolution sleep with specifiable clock. More...
 
int clock_settime (clockid_t clock_id, const struct timespec *tp)
 Sets the time for the specified clock. More...
 
int nanosleep (const struct timespec *rqtp, struct timespec *rmtp)
 High resolution sleep. More...
 

Detailed Description

Implementation of clock functions in time.h.

Function Documentation

◆ clock()

clock_t clock ( void  )

Report CPU time used.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock.html

Returns
The number of FreeRTOS ticks since the scheduler was started minus the ticks spent in the idle task.
Note
This function does NOT report the number of ticks spent by the calling thread.

◆ clock_getcpuclockid()

int clock_getcpuclockid ( pid_t  pid,
clockid_t clock_id 
)

Access a process CPU-time clock.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getcpuclockid.html

Return values
EPERM
Note
This function is currently unsupported.

◆ clock_getres()

int clock_getres ( clockid_t  clock_id,
struct timespec res 
)

Returns the resolution of a clock.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html

Note
clock_id is ignored
This function stores the resolution of the FreeRTOS tick count in the object res points to.
Return values
0- Upon successful execution

◆ clock_gettime()

int clock_gettime ( clockid_t  clock_id,
struct timespec tp 
)

Returns the current value for the specified clock, clock_id.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html

Note
clock_id is ignored
this function does not check for overflows of time_t.
Return values
0- Upon successful completion.

◆ clock_nanosleep()

int clock_nanosleep ( clockid_t  clock_id,
int  flags,
const struct timespec rqtp,
struct timespec rmtp 
)

High resolution sleep with specifiable clock.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_nanosleep.html

Note
clock_id is ignored, as this function uses the FreeRTOS tick count as its clock.
flags is ignored, if INCLUDE_vTaskDelayUntil is 0. i.e. the FreeRTOS function vTaskDelayUntil isn't available.
rmtp is also ignored, as signals are not implemented.
Return values
0- Upon successful completion.
EINVAL- The rqtp argument specified a nanosecond value less than zero or greater than or equal to 1000 million.

◆ clock_settime()

int clock_settime ( clockid_t  clock_id,
const struct timespec tp 
)

Sets the time for the specified clock.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_settime.html

Return values
-1with errno set to EPERM.
Note
This function is currently unsupported, as FreeRTOS does not provide a function to modify the tick count.

◆ nanosleep()

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

High resolution sleep.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html

Note
rmtp is ignored, as signals are not implemented.
Return values
0- Upon successful completion.
-1- The rqtp argument is invalid OR the rqtp argument specified a nanosecond value less than zero or greater than or equal to 1000 million.