Files
firestuff/2006-02-13-is-sleep-effected-by-time-changes.html
2019-04-25 02:45:09 +00:00

21 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!--# set var="title" value="Is sleep(3) effected by time changes?" -->
<!--# set var="date" value="2006-02-13" -->
<!--# include file="include/top.html" -->
<p>Its an interesting question. I tried it; it isnt. Heres my guess at an explanation:</p>
<p><a href="http://www.tin.org/bin/man.cgi?section=3&amp;topic=sleep">sleep(3)</a> is implemented internally on most systems as <a href="http://www.tin.org/bin/man.cgi?section=2&amp;topic=alarm">alarm(2)</a> and <a href="http://www.tin.org/bin/man.cgi?section=2&amp;topic=sigsuspend">sigsuspend(2)</a>. This means that this is an in-kernel question, not a userspace question. However, we know from <a href="http://www.tin.org/bin/man.cgi?section=3&amp;topic=clock_gettime">clock_gettime(3)</a> that the kernel has multiple internal clocks. CLOCK_MONOTONIC is defined as:</p>
<blockquote>
<p>Clock that cannot be set and represents monotonic time since some unspecified starting point.</p>
</blockquote>
<p>This must be whats used for alarm(), which makes sense.</p>
<p>On a related note:</p>
<p>Those annoying programs that behave very oddly when you change the system time are broken. Theyre using <a href="http://www.tin.org/bin/man.cgi?section=2&amp;topic=gettimeofday">gettimeofday(2)</a> or something that derives from it (i.e. <a href="http://www.tin.org/bin/man.cgi?section=2&amp;topic=time">time(2)</a>) instead of properly calling clock_gettime(CLOCK_MONOTONIC).</p>
<!--# include file="include/bottom.html" -->