What's the difference between tms_utime and tms_stime with the times() function?

ⅰ亾dé卋堺 提交于 2019-12-25 06:05:25

问题


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. 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.



来源:https://stackoverflow.com/questions/23095100/whats-the-difference-between-tms-utime-and-tms-stime-with-the-times-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!