我试图打发时间:
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
它们之间有什么区别?
答案 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.