[Vm-dev] [commit] r2253 - Integrate Henrik Johansen's fix for the nanosleep call in the heartbeat.

Eliot Miranda eliot.miranda at gmail.com
Fri Aug 13 22:05:41 UTC 2010


Hi Henrik,

On Fri, Aug 13, 2010 at 2:56 PM, Henrik Sperre Johansen <
henrik.s.johansen at veloxit.no> wrote:

>
>  On 13.08.2010 23:14, commits at squeakvm.org wrote:
>
>
> Author: eliot
> Date: 2010-08-13 14:14:21 -0700 (Fri, 13 Aug 2010)
> New Revision: 2253
>
> Modified:
>    branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c
> Log:
> Integrate Henrik Johansen's fix for the nanosleep call in the heartbeat.
>
>
> Modified: branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c
> ===================================================================
> --- branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c	2010-08-11 18:03:02 UTC (rev 2252)
> +++ branches/Cog/platforms/unix/vm/sqUnixHeartbeat.c	2010-08-13 21:14:21 UTC (rev 2253)
> @@ -607,6 +607,8 @@
>  		struct timespec naptime = beatperiod;
>
>  		while (nanosleep(&naptime, &naptime) == -1
> +			/* oversleeps can return tv_sec = -1 tv_nsec approx 999999999 */
> +			&& naptime.tv_sec >= 0 /* avoid undoc'ed oversleep behaviour */
>  			&& (naptime.tv_sec > 0 || naptime.tv_nsec > MINSLEEPNS)) /*repeat*/
>  			if (errno != EINTR) {
>  				perror("nanosleep");
>
>  To be finicky, it's not actually undocumented though, if I interpreted the
> man pages correctly :)
> http://www.opengroup.org/onlinepubs/009695399/functions/nanosleep.html
>
> http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man2/nanosleep.2.html
>
> "If the rmtp argument is non-NULL, the*timespec* structure referenced by
> it is updated to contain the amount of time remaining in the interval (the
> requested time minus the time actually slept). "
>
> Since it also specifies that the valid range for tv_nsec is 0 - 999999999,
> a negative value for tv_sec is the only valid option when it has overslept
> before being interrupted.
>

You're right.  When I speed-read "If rmtp is non-NULL, the timespec structure
it references is updated to contain the unslept amount (the request time
minus the time actually slept)." I ignored "the request time minus the time
actually slept" and assumed it would not return a negative amount.  I'll
change the code.

thanks again,
Eliot


> Cheers,
> Henry
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20100813/b0a21ecc/attachment-0001.htm


More information about the Vm-dev mailing list