clock_gettime系统调用的clk_id之间有什么区别

时间:2019-05-19 20:44:18

标签: c linux time system-calls

我试图打发时间:

int clock_gettime(clockid_t clk_id, struct timespec *tp)

我对应该放置的clk_id感到困惑。有:

CLOCK_REALTIME
CLOCK_REALTIME_COARSE
CLOCK_MONOTONIC
CLOCK_MONOTONIC_COARSE
CLOCK_MONOTONIC_RAW
CLOCK_BOOTTIME
CLOCK_PROCESS_CPUTIME_ID
CLOCK_THREAD_CPUTIME_ID

它们之间有什么区别?

1 个答案:

答案 0 :(得分:1)

以下是其中一些内容的摘要,请使用man clock_gettime

查看此人的页面
 CLOCK_REALTIME   identifies the realtime clock for the system.  

 CLOCK_MONOTONIC  identifies a clock that increases at a steady rate
                  (monotonically). 

 CLOCK_BOOTTIME   identical to CLOCK_MONOTONIC, except it also includes 
                  any time that the system is suspended.

 CLOCK_PROCESS_CPUTIME_ID
                  identifies a per process clock based on tick values.

 CLOCK_THREAD_CPUTIME_ID
                  identifies a per thread clock based on tick values.