21 lines
1.5 KiB
HTML
21 lines
1.5 KiB
HTML
<!--# set var="title" value="Is sleep(3) effected by time changes?" -->
|
||
<!--# set var="date" value="2006-02-13" -->
|
||
|
||
<!--# include file="include/top.html" -->
|
||
|
||
<p>It’s an interesting question. I tried it; it isn’t. Here’s my guess at an explanation:</p>
|
||
|
||
<p><a href="http://www.tin.org/bin/man.cgi?section=3&topic=sleep">sleep(3)</a> is implemented internally on most systems as <a href="http://www.tin.org/bin/man.cgi?section=2&topic=alarm">alarm(2)</a> and <a href="http://www.tin.org/bin/man.cgi?section=2&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&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 what’s 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. They’re using <a href="http://www.tin.org/bin/man.cgi?section=2&topic=gettimeofday">gettimeofday(2)</a> or something that derives from it (i.e. <a href="http://www.tin.org/bin/man.cgi?section=2&topic=time">time(2)</a>) instead of properly calling clock_gettime(CLOCK_MONOTONIC).</p>
|
||
|
||
<!--# include file="include/bottom.html" -->
|