What's the difference between tms_utime and tm

2019-08-29 03:52发布

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.

标签: c++ cpu
1条回答
混吃等死
2楼-- · 2019-08-29 04:24

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. The tms_stime element is the amount of time spent in the kernel executing code on your behalf. (The tms_cutime and tms_cstime are the sums of the tms_utime and tms_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.

查看更多
登录 后发表回答