Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As a previous answer said, the rate at which <code>jiffies</code> increments is fixed.</p> <p>The standard way of specifying time for a function that accepts <code>jiffies</code> is using the constant <code>HZ</code>.</p> <p>That's the abbreviation for Hertz, or the number of ticks per second. On a system with a timer tick set to 1ms, HZ=1000. Some distributions or architectures may use another number (100 used to be common).</p> <p>The standard way of specifying a <code>jiffies</code> count for a function is using <code>HZ</code>, like this:</p> <pre><code>schedule_timeout(HZ / 10); /* Timeout after 1/10 second */ </code></pre> <p>In most simple cases, this works fine.</p> <pre><code>2*HZ /* 2 seconds in jiffies */ HZ /* 1 second in jiffies */ foo * HZ /* foo seconds in jiffies */ HZ/10 /* 100 milliseconds in jiffies */ HZ/100 /* 10 milliseconds in jiffies */ bar*HZ/1000 /* bar milliseconds in jiffies */ </code></pre> <p>Those last two have a bit of a problem, however, as on a system with a 10 ms timer tick, <code>HZ/100</code> is 1, and the precision starts to suffer. You may get a delay anywhere between 0.0001 and 1.999 timer ticks (0-2 ms, essentially). If you tried to use <code>HZ/200</code> on a 10ms tick system, the integer division gives you 0 jiffies!</p> <p>So the rule of thumb is, be very careful using HZ for tiny values (those approaching 1 jiffie).</p> <p>To convert the other way, you would use:</p> <pre><code>jiffies / HZ /* jiffies to seconds */ jiffies * 1000 / HZ /* jiffies to milliseconds */ </code></pre> <p>You shouldn't expect anything better than millisecond precision.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload