What is a CPU tick?

A tick is an arbitrary unit for measuring internal system time. There is usually an OS-internal counter for ticks; the current time and date used by various functions of the OS are derived from that counter.

How many milliseconds a tick represents depends on the OS, and may even vary between installations. Use the OS's mechanisms to convert ticks into seconds.

  • On MS Windows, there are 10,000 ticks in a millisecond (see http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx ).
  • On Linux, the number of clock ticks per second can be obtained using sysconf(_SC_CLK_TCK);. See e.g. http://linux.die.net/man/2/times

As to why a thread reports it's not being called: That will depend on whether the thread is blocking somewhere (waiting, I/O etc.). If it is not blocking, then yes, the OS's scheduler will decide when it gets to run, which may be a long time if the system is busy.

Edit:

Note that, perhaps unfortunately, some authors also use tick as a synonym for processor clock cycle (e.g. this text). I believe this usage is less widespread, but still, best to find out first what people are talking about.


Edit: Taken from PC Hardware in a Nutshell:

"The processor clock coordinates all CPU and memory operations by periodically generating a time reference signal called a clock cycle or tick. Clock frequency is specified in gigahertz (GHz), which specifies billions of ticks per second. Clock speed determines how fast instructions execute. Some instructions require one tick, others multiple ticks, and some processors execute multiple instructions during one tick."


The time between ticks is determined by your clock speed, and it takes one to many ticks depending on the OP being performed. For example, a 286 class CPU needs 20 ticks to multiply two numbers.

If you need high performance timers, then I don't think you can rely on ticks being constant across all systems.

The CPU scheduler could have delayed the thread, especially if there was another thread with a higher priority. So yes, the CPU could've been too busy.

Tags:

Unix

Cpu Usage