简体   繁体   English

如何知道进程的空闲时间

[英]How to know a process's idle time

Probably this question is a duplicate.but i was not able to find. 可能这个问题是重复的。但是我找不到。 How do i check that how much time a process has been in idle state. 我如何检查某个进程处于空闲状态的时间。

my actual problem: 我的实际问题:

I have a process which runs on solaris unix X86 server. 我有一个在solaris UNIX X86服务器上运行的进程。 In our test servers its finishes its job in 4 hours.But in our client servers its taking more than than 10 hours.I checked in the client server and found that the configuration in our client server is different from our test server.for eg: number of virtual processors in testserver are-24 but in client server are only 8. and processor speed also differs. 在我们的测试服务器中,它需要4个小时才能完成工作;但是在我们的客户端服务器中,它要花费10多个小时。我检查了客户端服务器,发现客户端服务器中的配置与我们的测试服务器不同,例如: testserver中的虚拟处理器数量为24,而客户端服务器中的虚拟处理器数量仅为8。处理器速度也有所不同。

I suspect it is because of the configuration that the process is not actually getting the cpu time and i suspect that it is idle for most of the time. 我怀疑是由于配置导致该进程实际上没有获得cpu时间,而且我怀疑该进程在大多数时间内都处于空闲状态。

But i just want to know how much time the process is idle.Is there any specific way to do this?The process is written in c++ so i am also tagging this as c++ 但是我只想知道该进程有多少空闲时间。是否有任何特定的方法来做到这一点?该过程是用C ++编写的,所以我也将其标记为c ++

nmon is available at www.sourceforge.net but there are plenty of tools nmon可从www.sourceforge.net获得,但有很多工具

Your "idle time" may be context switching if your app is a cpu beast. 如果您的应用是cpu野兽,那么您的“空闲时间”可能是上下文切换。 Without instrumenting the code, to get an idea of what is going on, try pbind to lock the process to a single cpu, then run your app 在不检测代码的情况下,要了解发生了什么,请尝试使用pbind将进程锁定到单个cpu,然后运行您的应用

time myapp

Your real time (wall time) and the cpu times for user and kernel will be given. 将给出您的实时(挂墙时间)以及用户和内核的cpu时间。 Since the process is constrained the wall time may be longer, but this will give you total cpu for parent, LWP's, and children. 由于该过程受到限制,挂墙时间可能会更长,但这将为您提供父母,LWP和孩子的总CPU。

Beyond that you can instrument the code and report generally finer grained information by using procfs (procfs.h) to get cpu information. 除此之外,您还可以使用procfs(procfs.h)来获取cpu信息,从而检测代码并报告更细粒度的信息。 You can compile to enable profiling, then see where your bottlenecks are as well if deem the cpu consumption is too high. 您可以进行编译以启用性能分析,然后在认为CPU消耗过高的情况下查看瓶颈所在。

been in idle state 处于空闲状态

I'm not sure what you mean by "idle". 我不确定“闲置”是什么意思。 Do you mean "blocked". 您的意思是“被阻止”。 Comparing the total of user+system CPU to the elapsed time will give you an approximation of that, assuming your computer is not heavily loaded. 将用户+系统的CPU总数与经过的时间进行比较,可以得出近似的结果,前提是您的计算机负载不大。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM