问题
What's the difference between tms_utime
and tms_stime
exactly? I'm referring to the struct tms
used by the POSIX times()
function. Is the data caching time included in the utime
? Can the data caching time be measured separately?
PS: I am using Linux-Ubuntu. For example, I am solving a large sparse linear equation system using my C++ program.
回答1:
Given that you are discussing the tms_utime
and tms_stime
members of struct tms
(which contains 4 elements of type clock_t
) used by times(), the difference is as outlined in my first and last comments:
The
tms_utime
element is the amount of time spent executing your code, or the code in the C library. Thetms_stime
element is the amount of time spent in the kernel executing code on your behalf. (Thetms_cutime
andtms_cstime
are the sums of thetms_utime
andtms_stime
respectively for all the child processes that have exited — see the rationale commentary.)
There is no breakdown of the time into 'time spent waiting for the cache' vs 'time spent not waiting for the cache'. I think the cache time would be included in the tms_stime
value because when the data isn't in the cache, you will need the system to fetch it for you.
来源:https://stackoverflow.com/questions/23095100/whats-the-difference-between-tms-utime-and-tms-stime-with-the-times-function