Amazon FreeRTOS: POSIX
返回主页↑
time.h 文件引用

时间类型。 更多……

转到此文件的源代码。

数据结构体

struct  timespec
 表示运行时间 更多……
 
struct  itimerspec
 定时器 更多……
 

单位转换常数。
#define MICROSECONDS_PER_SECOND   ( 1000000LL )
 
#define NANOSECONDS_PER_SECOND   ( 1000000000LL )
 
#define NANOSECONDS_PER_TICK   ( NANOSECONDS_PER_SECOND / configTICK_RATE_HZ )
 
时钟标识符。
#define CLOCK_REALTIME   0
 
#define CLOCK_MONOTONIC   1
 
将 clock() 函数返回的值转换为秒的数值。
#define CLOCKS_PER_SEC   ( ( clock_t ) configTICK_RATE_HZ )
 
指示时间的标志是绝对标志。

对于获取定时器对象的函数,它指的是与定时器关联的时钟。

#define TIMER_ABSTIME   0x01
 

函数

clock_t clock (void)
 报告使用的 CPU 时间。 更多……
 
int clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
 访问进程 CPU 时钟。 更多……
 
int clock_getres (clockid_t clock_id, struct timespec *res)
 返回时钟的分辨率。 更多……
 
int clock_gettime (clockid_t clock_id, struct timespec *tp)
 返回指定时钟的当前值,clock_id。 更多……
 
int clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
 具有可指定时钟的高分辨率睡眠。 更多……
 
int clock_settime (clockid_t clock_id, const struct timespec *tp)
 设置指定时钟的时间。 更多……
 
int nanosleep (const struct timespec *rqtp, struct timespec *rmtp)
 高分辨率睡眠。 更多……
 
int timer_create (clockid_t clockid, struct sigevent *evp, timer_t *timerid)
 创建进程自己的定时器。 更多……
 
int timer_delete (timer_t timerid)
 删除每进程定时器。 更多……
 
int timer_getoverrun (timer_t timerid)
 获取定时器超限计数。 更多……
 
int timer_gettime (timer_t timerid, struct itimerspec *value)
 获取定时器到期前的时间量。 更多……
 
int timer_settime (timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue)
 设置定时器下一次到期前的时间。 更多……
 

详细描述

宏定义文档

◆ MICROSECONDS_PER_SECOND

#define MICROSECONDS_PER_SECOND   ( 1000000LL )

每秒的微秒数。

◆ NANOSECONDS_PER_SECOND

#define NANOSECONDS_PER_SECOND   ( 1000000000LL )

每秒的纳秒数。

◆ NANOSECONDS_PER_TICK

#define NANOSECONDS_PER_TICK   ( NANOSECONDS_PER_SECOND / configTICK_RATE_HZ )

每 FreeRTOS 滴答的纳秒数。

◆ CLOCK_REALTIME

#define CLOCK_REALTIME   0

全系统实时测量时钟标识符。

◆ CLOCK_MONOTONIC

#define CLOCK_MONOTONIC   1

全系统单调时钟标识符。

函数文档

◆ clock()

clock_t clock ( void  )

报告使用的 CPU 时间。

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

返回
启动调度程序后的 FreeRTOS 滴答数减去空闲任务所花费滴答数的差。
注意事项
此函数不会报告调用线程花费的滴答数。

◆ clock_getcpuclockid()

int clock_getcpuclockid ( pid_t  pid,
clockid_t clock_id 
)

访问进程 CPU 时钟。

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

返回值
EPERM
注意事项
目前暂不支持此函数。

◆ clock_getres()

int clock_getres ( clockid_t  clock_id,
struct timespec res 
)

返回时钟的分辨率。

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

注意事项
已忽略 clock_id
此函数将 FreeRTOS 滴答数的分辨率存储在 res 指向的对象中。
返回值
0——成功执行后

◆ clock_gettime()

int clock_gettime ( clockid_t  clock_id,
struct timespec tp 
)

返回指定时钟的当前值,clock_id。

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

注意
clock_id 被忽略
此函数不检查 time_t 溢出情形。
返回值
0——成功完成后

◆ clock_nanosleep()

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

具有可指定时钟的高分辨率睡眠。

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

注意
因为此函数使用 FreeRTOS 滴答数作为时钟,因此已忽略 clock_id。
如果 INCLUDE_vTaskDelayUntil 为 0 ,则会忽略标志。即 FreeRTOS 函数 vTaskDelayUntil 不可用。
因为信号未实现,因此也忽略 rmtp。
返回值
0——成功完成后
EINVAL—rqtp参数指定的纳秒值小于零或大于等于 10 亿。

◆ clock_settime()

int clock_settime ( clockid_t  clock_id,
const struct timespec tp 
)

设置指定时钟的时间。

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

返回值
——1errno 设置为 EPERM。
注意
因为 FreeRTOS 不提供修改滴答计数的函数,因此当前不支持此函数。

◆ nanosleep()

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

高分辨率睡眠。

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

注意事项
因为未实现信号,所以已忽略 rmtp。
返回值
0——成功完成后。
——1——rqtp 自变量无效或 rqtp 自变量指定的纳秒值小于 0 或大于或等于 10 亿。

◆ timer_create()

int timer_create ( clockid_t  clockid,
struct sigevent evp,
timer_t timerid 

创建过程特定定时器。

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

注意事项
因为此函数使用 FreeRTOS 滴答数作为时钟,因此已忽略 clock_id。
因为当前不支持信号,所以 evp.sigev_notify 必须设置为 SIGEV_THREAD。
返回值
0——成功完成后,定时器引用的位置将更新。
-1——如果发生错误,也设置 errno。
errno 值可能产生的副作用

ENOTSUP—如果 evp 为 NULL 或 evp->sigen_notify == SIGEV_SIGNAL。
EAGAIN—系统缺乏满足请求所需的足够信号队列资源。

◆ timer_delete ()

int timer_delete ( timer_t  timerid)

删除每进程定时器。

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

返回值
0——成功完成后

◆ timer_getoverrun()

int timer_getoverrun ( timer_t  timerid)

获取定时器超限计数。

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

返回值
0—因为不支持信号,所以始终返回 0。

◆ timer_gettime ()

int timer_gettime ( timer_t  timerid,
struct itimerspec value 
)

获取定时器到期前的时间量。

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

返回值
0——成功完成后

◆ timer_settime ()

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

设置定时器下一次到期前的时间。

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

返回值
0—成功完成后。
-1—发生错误时,也设置 errno。
副作用:可用 errno 值

EINVAL—值结构指定的纳秒值小于零或大于等于 10 亿,并且该结构的 it_value 成员未指定零秒和纳秒。