A CPU tick

cpu usageunix

Question:

  • How is a CPU tick calculated and what does it represent?
  • Does a single tick equate to 10 miliseconds thus if some thread reported not called for (5 * 10 ticks = 500 ticks) does this mean the CPU was perhaps too busy to schedule the aforementioned thread to work?

Best Answer

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.

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.