如何使用getrusage()报告花费的时间冬眠? [英] How does getrusage() report time spent hibernating?

查看:150
本文介绍了如何使用getrusage()报告花费的时间冬眠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用的getrusage 来告诉我,我在我的应用程序的事件循环花多少时间。

I am currently using getrusage to tell me how much time I spend in my application's event loop.

我不知道这将冬眠的影响。正在休眠时间报道呢?或者,也许因为系统时间?这是指定的地方将按Posix还是这取决于系统?

I wonder how this will be affected by hibernating. Is hibernation time reported at all? Or perhaps as system time? Is this specified somewhere in Posix or is this system dependent?

修改问计的Windows同样的问题<一href=\"http://stackoverflow.com/questions/31246869/how-does-getthreadtimes-report-time-spent-hibernating\">here.

Edit Asking the same question for Windows here.

推荐答案

我不认为POSIX提到冬眠的任何地方,所以它在技术上是依赖于平台。

I don't think POSIX mentions hibernation anywhere, so it is technically platform dependent.

我只能说为Linux,但其他UNIX变种 - 也许甚至是Windows - 也许同样的行为,因为这是最有意义的。

I can only speak for Linux, but other UNIX variants - and perhaps even Windows - probably behave similarly, since this is what makes most sense.

在Linux中,与冬眠引擎盖下会发生什么确切的细节文档/电源/ swsusp.txt内核源代码中所述。总之,用户进程发送,使它们切换到 TASK_UNINTERRUPTIBLE 状态的假信号。在 TASK_UNINTERRUPTIBLE 状态的过程中被取出运行队列,并把睡觉,直到它在等待条件成真,所以花的时间在 TASK_UNINTERRUPTIBLE 既不算作用户的时间,也没有为系统时间。如果你要衡量运行时间时间(1),你顶多看到,它有助于挂钟时间。

In Linux, the exact details of what happens under the hood with hibernation are described in Documentation/power/swsusp.txt under the kernel source. In short, user processes are sent a fake signal that causes them to switch to TASK_UNINTERRUPTIBLE state. A process in the TASK_UNINTERRUPTIBLE state is taken out of the run queue and put to sleep until the condition it is waiting for comes true, so time spent in TASK_UNINTERRUPTIBLE is neither counted as user time nor as system time. If you were to measure runtimes with time(1), you would at most see that it contributes to wall clock time.

使用的getrusage(2),你不会看到任何报告的CPU时代的区别,因为这个过程是不能运行的。

With getrusage(2), you won't see a difference in any of the reported CPU times because the process wasn't runnable.

因此​​,要回答你的问题:休眠时间是不是在所有报道

So, to answer your question: hibernation time is not reported at all.

这篇关于如何使用getrusage()报告花费的时间冬眠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆