title: In what cases CLOCK_MONOTONIC might not be available
body: <p>In Java <a href="https://docs.oracle.com/javase/10/docs/api/java/lang/System.html#nanoTime()" rel="noreferrer"><code>System.nanoTime()</code></a>'s monotonic <a href="http://hg.openjdk.java.net/jdk10/jdk10/hotspot/file/5ab7a67bc155/src/os/linux/vm/os_linux.cpp#l1262" rel="noreferrer">implementation on Linux</a> relies on the fact that <a href="https://linux.die.net/man/3/clock_gettime" rel="noreferrer"><code>CLOCK_MONOTONIC</code></a> is available on the OS. If it's not available, it falls back to <a href="http://man7.org/linux/man-pages/man2/gettimeofday.2.html" rel="noreferrer"><code>gettimeofday</code></a> which can result in getting a negative time interval when the interval is measured using <code>nanoTime</code>. For instance, the following test might fail.</p>
  
  <pre><code>long t1 = System.nanoTime();
  long t2 = System.nanoTime();
  assert t2 &gt;= t1
  </code></pre>
  
  <p>In what cases <code>CLOCK_MONOTONIC</code> might not be available on a server? Is it reasonable to assume that <code>CLOCK_MONOTONIC</code> clock is available on all modern Linux servers?</p>