clock tick

On most of the linux system (at least the one I have)have CLOCKS_PER_SEC set to 1 million (in bits/time.h header file)

Does this means the CPU executes 1 million assembly instructions in 1 sec ?

So this has nothing to do with if CPU speed is 2 GHz or 3 GHz etc... ??
Who is Participating?
unknown_routineConnect With a Mentor Commented:
This is  the implementation of the clock() function. On Linux, the clock ticks faster(than windows). It ticks 1 million times a second.(in windows you see this parameter is 1000)

This clock tick has nothing to do with the clock rate of your CPU
perlperlAuthor Commented:
so what does that 1 million tick mean? does it mean it is executing 1 milllion instructions in 1 sec?
No points for this please - I'm simply trying to clarify what unknown_routine already said.

The CLOCKS_PER_SEC value indicates the granularity of the value returned by the clock() function :

No more, no less.

This is completely unrelated to the CPU frequency, or even the hardware clock frequency. Your operating system might make use of either or both to decide what value to return from clock(), but the value of CLOCKS_PER_SEC is purely in the software domain (specifically it's defined by POSIX), and completely detached from the hardware domain.
so what does that 1 million tick mean? does it mean it is executing 1 milllion instructions in 1 sec?
to add to before comments:

the return type of clock is defined as clock_t type what is an integer type. depending on the platform and compiler it may be either 32 bit or 64 bit unsigned integer. in case of 32 bit Linux platform and CLOCKS_PER_SEC=1000000, the result is the number of microseconds since last processor start and would wrap the maximum integer every 72 minutes. at 32-bit windows and CLOCKS_PER_SEC=1000, the clock_t means milliseconds and it would overflow to zero every 50 days. note, on windows systems clock function doesn't have an accuracy better than 15 milliseconds while on Linux it is better than 0.5 milliseconds, normally. at both platforms you can switch to high performance timers (if hardware supplies some and drivers were available) which are able to synchronize on 10 MHz or better.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.