Re: sleep doesn't work

From: Walter C. Pelissero <wcp_at_luppolo.lpds.sublink.org>
Date: Mon, 2 Nov 1998 15:31:53 +0100 (CET)

I hope I'm not offending anyone forwarding a private mail to the
mailing list.

>>>>> "Matthew" == Matthew R Wette <mwette_at_grover.jpl.nasa.gov> writes:

Matthew> Try using select() (or poll()) instead of sleep.

Too easy. That would be doing the same as (after 1000). In fact it
works.

BTW the sleep(3) manual page on FreeBSD says:

     This function is implemented using setitimer(2); it requires eight sys-
     tem calls each time it is invoked. A similar but less compatible func-
     tion can be obtained with a single select(2); such a function would not
     restart after signals, but would not interfere with other uses of
     setitimer(2).

and again:

     In practice the FreeBSD implementation will not be interrupted: it will
     always return the original argument or zero. Code that depends on sleep
     being interrupted (using it as a timed pause, for example) needs to be
     recoded to use select(2) or some other delay mechanism. Code that calls
     sleep() repeatedly until it returns zero may busy-wait until a timer is
     available.

Mmh, this might be the culprit. But the mechanism behind this failure
still escape my comprehension.

It would be interesting to try my former code in a non-FreeBSD system.
Received on Mon Nov 02 1998 - 15:50:13 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST