"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. ...
In message 395CA347.AE870283@evolgo.de you wrote:
Hmm, select() seems to be the gcd of all platforms. Probably we should use this instead of nanosleep().
Probably dumb question:- select() is in the sockets libraries, yes? If we use select(), don't we destroy the point of having all the sockets stuff in an external plugin?
Is there no X related call to get-next-event-but-sleep-for-a-while-first ?
tim
Tim Rowledge wrote:
In message 395CA347.AE870283@evolgo.de you wrote:
Hmm, select() seems to be the gcd of all platforms. Probably we should use this instead of nanosleep().
Probably dumb question:- select() is in the sockets libraries, yes?
In some Linux shared lib, but not in the SocketPlugin:
The header /usr/include/sys/select.h will be included indirectly via time.h from sq.h.
And compiling just the SocketPlugin shows no static linkage of libs:
gcc -g -fpic -O2 -I../../src -I.. -I. -I../src -DHAVE_CONFIG_H -DUNIX -c ../../src/SocketPlugin/SocketPlugin.c gcc -g -fpic -O2 -I../../src -I.. -Wall -I. -I../src -DHAVE_CONFIG_H -DUNIX -c ../../src/SocketPlugin/sqUnixNetwork.c gcc -fpic -shared -o ../SocketPlugin.so SocketPlugin.o sqUnixNetwork.o
So I think select() is in a *.so lib of the Linux system.
If we use select(), don't we destroy the point of having all the sockets stuff in an external plugin?
Yes, but what is the problem here? We just use select() as platform compatible sleep mechanism; from the man page of select(): ... 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. ...
I wanted to use nanosleep() - what principally seems to be better -, but as we have seen it isn't available at all platforms...
Is there no X related call to get-next-event-but-sleep-for-a-while-first ?
What about using a Squeak *without* X? I don't like to be dependent on X here.
Greetings,
Stephan
tim
-- Tim Rowledge, tim@sumeru.stanford.edu, http://sumeru.stanford.edu/tim Klingon Code Warrior:- 5) "Specs are for the weak and timid!"
squeak-dev@lists.squeakfoundation.org