How to obtain the current number of jiffies since reboot in Linux?

Technically jiffy in computer parlance is the duration of 1 tick of the system timer interrupt. It's not absolute though. For Linux 2.6.13+ on Intel x86 jiffy is 4ms, but can range from 1ms to 10ms depending upon architecture and kernel version.

From the Kernel Timer Systems page:

Historically, the kernel used 100 as the value for HZ, yielding a jiffy interval of 10 ms. With 2.4, the HZ value for i386 was changed to 1000, yeilding a jiffy interval of 1 ms. Recently (2.6.13) the kernel changed HZ for i386 to 250. (1000 was deemed too high).

It lists /proc/timer_list and /proc/timer_stats.

You can activate the timer_stats at boot time, then cat this file to print stats.


No, you only need the first line. The first line aggregates everything else in the other cpu lines.

Example output:

[john@awesome]$cat /proc/stat
cpu  35024984 1771325 94153391 1810948613 2648063 352387 557232
cpu0 13955475 927654 59431476 895791946 1910028 318618 438048
cpu1 21069509 843671 34721915 915156667 738035 33769 119184
intr 1403502159 1138402452 597 0 3 3 0 5 0 1 0 0 0 12315 0 92119425 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 57676632 0 0 0 0 0 0 0 115290726 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ctxt 21043582666
btime 1252332786
processes 25663823
procs_running 1
procs_blocked 0

What each column means (left to right):

  • user: normal processes executing in user mode
  • nice: niced processes executing in user mode
  • system: processes executing in kernel mode
  • idle: idle time
  • iowait: waiting for I/O to complete
  • irq: servicing interrupts
  • softirq: servicing softirqs

as you can see, the first column after cpu (user mode processes) is equal to the 2 numbers beneath it added together.

Tags:

Linux

Kernel