Какая из двух функций лучше
#include <time.h> int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp);
ИЛИ
#include <time.h> int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
Преимущества clock_nanosleep над nanosleep:
clock_nanosleep
nanosleep
ntpd
В моей системе man 2 clock_nanosleep объясняет различия между двумя функциями следующим образом:
man 2 clock_nanosleep
Like nanosleep(2), clock_nanosleep() allows the caller to sleep for an interval specified with nanosecond precision. It differs in allowing the caller to select the clock against which the sleep interval is to be measured, and in allowing the sleep interval to be specified as either an absolute or a relative value. The clock_id argument [...] can have one of the following values: CLOCK_REALTIME A settable system-wide real-time clock. CLOCK_MONOTONIC A non-settable, monotonically increasing clock that measures time since some unspecified point in the past that does not change after system startup. CLOCK_PROCESS_CPUTIME_ID A settable per-process clock that measures CPU time consumed by all threads in the process.