Can anyone tell me why when I compile and run the bottom code, the execution time of it takes aournd 10s instead of 1s.
I used the “time” command to run the code.
I thought usleep(125000) means sleeping for 0.0125 seconds?
Also when I use time command, what is the real-time vs user-time vs system-time mean ?
Thanks
int main(int argc, char *argv[]) {
int i=0;
while(i<=80)
{
i++;
usleep(125000);
}
return EXIT_SUCCESS;
}
actually, the above code is fine with usleep(12500) which is sleeping 0.0125 sec. But how about the bottom code. Shouldn’t it be executing in 1s? Because it giving me 2s once I do “time” command to execute.
int main(int argc, char *argv[]) {
int i=0;
while(i<=500)
{
i++;
usleep(2000);
}
return EXIT_SUCCESS;
}