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.

4
  • Please check this answer superuser.com/questions/101183/what-is-a-cpu-tick Commented Feb 3, 2015 at 6:58
  • Is it true that in a linux system, ticks occur approximately 100 times per second? i.e., 100 clock ticks per second is usual? Commented Feb 3, 2015 at 7:04
  • It depnds on the Hertez set in kernel confiiguration. Commented Feb 3, 2015 at 7:07
  • 1
    This might help you to understand better makelinux.net/books/lkd2/ch10lev1sec2 Commented Feb 3, 2015 at 7:16

1 Answer 1

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 - code.google.com/archive/p/android-source-browsing/source

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.