When I do $(time sleep 1), I got:
real 0m1.001s
user 0m0.000s
sys 0m0.000s
I’m not sure why sys time was 0, so nanosleep is called from userspace ?
Also, does the real time equals to context switch time + real sleep time (1s) ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Looking at the man page for time, we can see that,
real : Length of time the program took to terminate, calculated as :
user : The sum of the tms_utime and tms_cutime values in a struct tms as returned by times(2)
sys : The sum of the tms_stime and tms_cstime values in a struct tms as returned by times(2)
So the result you are getting effectively means that your program lasted for 1 second and in that 1 second it used 0 seconds as user time and 0 seconds as system time. Which is exactly what we should expect from the program.
When a program is sleeping it just means the kernel will not schedule it for processing, it won’t even run no-ops, it just wont run so no system time is consumed.