什么是Android CPU使用环境中的“时钟刻度”?

时间:2022-03-05 20:34:21

I am currently working on a project in Android. I want to get the total cpu usage of each and every process. So i am using the contents of "/proc/pid/stat". I referred this answer to get the stats. Now i got all the utime, stime etc., The problem is with the value of "Hertz". The answer says that it is the number of clock ticks per second. I don't get the exact meaning of clock tick even after browsing a lot. What is a clock tick and is it the frequency of the processor? And the answer says that we can get the clock ticks using

我目前正在开发一个Android项目。我想获得每个进程的总CPU使用率。所以我使用“/ proc / pid / stat”的内容。我提到这个答案来获取统计数据。现在我得到了所有的utime,stime等,问题在于“Hertz”的价值。答案是它是每秒钟的滴答数。即使经过大量浏览,我也无法获得时钟刻度的确切含义。什么是时钟滴答,它是处理器的频率?答案说我们可以使用时钟滴答

sysconf(_SC_CLK_TCK)

的sysconf(_SC_CLK_TCK)

I don't know how to use this linux command in Android to get the clock ticks. I have googled it and i couldn't find it. Pls help me with this. And it would be more helpful if there is an example for this clock tick.

我不知道如何在Android中使用这个linux命令来获取时钟滴答。我用谷歌搜索它,我找不到它。请帮我解决这个问题。如果有一个这个时钟滴答的例子会更有帮助。

1 个解决方案

#1


5  

100 is the default value set on Linux. And it appears to be unchanged in Android as shown in the sysconf.c source file - goo.gl/C5yubg

100是Linux上设置的默认值。它在Android中似乎没有变化,如sysconf.c源文件所示 - goo.gl/C5yubg

If you see line 167, this is what sysconf(_SC_CLK_TCK) will retrun:

如果你看到第167行,这就是sysconf(_SC_CLK_TCK)将重新启动的内容:

case _SC_CLK_TCK: return SYSTEM_CLK_TCK;

case _SC_CLK_TCK:return SYSTEM_CLK_TCK;

The default value for SYSTEM_CLK_TCK is defined as 100

SYSTEM_CLK_TCK的默认值定义为100

#1


5  

100 is the default value set on Linux. And it appears to be unchanged in Android as shown in the sysconf.c source file - goo.gl/C5yubg

100是Linux上设置的默认值。它在Android中似乎没有变化,如sysconf.c源文件所示 - goo.gl/C5yubg

If you see line 167, this is what sysconf(_SC_CLK_TCK) will retrun:

如果你看到第167行,这就是sysconf(_SC_CLK_TCK)将重新启动的内容:

case _SC_CLK_TCK: return SYSTEM_CLK_TCK;

case _SC_CLK_TCK:return SYSTEM_CLK_TCK;

The default value for SYSTEM_CLK_TCK is defined as 100

SYSTEM_CLK_TCK的默认值定义为100