x
Loading
 Loading
Hello, Guest | Login | Register

The Passage of Time

The kernel keeps track of the flow of time. It provides services to sleep wait for long periods and busy wait for short periods, can schedule events to run at a future time, and can do periodic work with microsecond precision. Here’s a look at kernel time.

Many features of the Linux kernel are critically dependent on the passage of time. The Linux kernel makes use of different timers provided by hardware to provide time-dependent services such as busy wait and sleep wait. The kernel also facilitates scheduling for functions that desire to run after some specified time has elapsed.
In this month’s “Gearheads” column, let’s explore the the semantics of kernel variables like jiffies, HZ, loops_per_jiffy, and xtime, learn how to measure execution times using the Pentium Time Stamp Counter (TSC), and use the Real-Time Clock (RTC) to perform periodic work from an application with microsecond precision.

Of HZ and Jiffies

System timers interrupt the processor, or pop, at programmable frequencies. This frequency, or the number of timer ticks per second, is contained in the kernel variable HZ. Choosing a value for HZ is a trade-off: a large HZ value results in finer timer granularity and better resolution. However, high values of HZ also result in larger overhead, since more cycles are spent executing the timer interrupt handler.
The value of HZ is architecture-dependent. On x86 systems,the 2.4 kernels set HZ to 100, but with 2.6, this value was changed to 1000. On ARM-based platforms, 2.6 kernels use a HZ value of 100.
The jiffies variable holds the number of times the system timer popped since the system booted. The kernel increments jiffies HZ

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Helpful Tools for Software Developers
  2. The Github Hall of Fame
  3. Book'em, Github.
  4. This Week on Github: Stupid Ruby Tricks
  5. A Veritable Scatter Shot!
Follow Linux Magazine
Rackspace