4

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

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.

Community
  • 1
  • 1
Pragatheeswaran
  • 120
  • 1
  • 9

1 Answers1

6

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

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

case _SC_CLK_TCK: return SYSTEM_CLK_TCK;

The default value for SYSTEM_CLK_TCK is defined as 100

Joel Fernandes
  • 4,776
  • 2
  • 26
  • 48