1. nanosleep 测试
函数的原型如下:
int clock_gettime(clockid_t clk_id, struct timespect *tp);
clockid_t clk_id用于指定计时时钟的类型,对于我们Programmer以下三种比较常用:
CLOCK_REALTIME, a system-wide realtime clock.
CLOCK_PROCESS_CPUTIME_ID, high-resolution timer provided by the CPU for each process.
CLOCK_THREAD_CPUTIME_ID, high-resolution timer provided by the CPU for each of the threads.
int nanosleep(const struct timespec *req, struct timespec *rem);
struct timespec
{
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
这个函数功能是暂停某个进程直到你规定的时间后恢复,参数req就是你要暂停的时间,其中req->tv_sec是以