What is the use of tim.tv_sec
and tim.tv_nsec
in the following?
我如何睡觉执行<代码>500 000微观秒?
#include <stdio.h>
#include <time.h>
int main()
{
struct timespec tim, tim2;
tim.tv_sec = 1;
tim.tv_nsec = 500;
if(nanosleep(&tim , &tim2) < 0 )
{
printf("Nano sleep system call failed
");
return -1;
}
printf("Nano sleep successfull
");
return 0;
}