"David T. Lewis" wrote:
>
> On Thu, Jun 29, 2000 at 10:15:28PM +0200, Bert Freudenberg wrote:
> > On Thu, 29 Jun 2000, Tim Rowledge wrote:
> >
> > > > nanosleep(&sleepTime, &reminderTime);
> > > Excellent - do you know if it actually portable to most unices, or is it
> > > likely to be a hit and miss affair?
> >
> > It's a POSIX standard function. I checked (the manpages) on Irix and
> > SunOS. For Suns, it seems you have to link with libposix4 though ...
> >
> > -- Bert
> >
> It will be somewhat hit and miss.
> For example, BDSI does not seem to have it.
>
> bash-2.02$ uname
> BSD/OS
> bash-2.02$ man nanosleep
> man: no entry for nanosleep in the manual.
Raivis Bucis wrote:
>
> : On Fri, 30 Jun 2000, David T. Lewis wrote:
> :
> : Maybe in BSD there is some other short sleep than usleep?
>
> Yes. Look at select or poll (without any descriptor).
>
> Raivis
Hmm, select() seems to be the gcd of all platforms. Probably we should
use this instead of nanosleep().
But what is the better variant: To force to initialize the Socket
module, which leads to indirectly calling select(), or to call it
directly in ioRelinquishProcessorForMicroseconds(int microSeconds)?
I prefer the latter, because the Socket module could be nonexistent.
But we have to handle the case where microSeconds are 0, because
select() could block then (this is errorneous in my previous
nanosecond() proposal, too).
Other opinions?
Greetings,
Stephan
>From the man page:
SELECT(2) Linux Programmer's Manual SELECT(2)
NAME
select, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - synchronous
I/O multiplexing
SYNOPSIS
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
int select(int n, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
FD_CLR(int fd, fd_set *set);
FD_ISSET(int fd, fd_set *set);
FD_SET(int fd, fd_set *set);
FD_ZERO(fd_set *set);
DESCRIPTION
select waits for a number of file descriptors to change
status.
...
NOTES
Some code calls select with all three sets empty, n zero,
and a non-null timeout as a fairly portable way to sleep
with subsecond precision.
...
--
Stephan Rudlof (sr(a)evolgo.de)
"Genius doesn't work on an assembly line basis.
You can't simply say, 'Today I will be brilliant.'"
-- Kirk, "The Ultimate Computer", stardate 4731.3