Como usar nanosleep () em C? O que são `tim.tv_sec` e` tim.tv_nsec`?
Qual é o uso detim.tv_sec
etim.tv_nsec
na sequência
Como posso dormir a execução para500000
microssegundos?
#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 \n");
return -1;
}
printf("Nano sleep successfull \n");
return 0;
}