guy@auspex.UUCP (Guy Harris) (11/05/88)
>Pour yourself a cup of strong coffee, then try the following:
And watch it fail to compile on many systems.
Unfortunately, neither "select" nor "setitimer" exist on all UNIX
systems. (They also tend not to exist on non-UNIX systems, which is why
this discussion is getting sent back to comp.unix.questions, where it
belongs.)
However, you can use "poll" instead of "select" on System V Release 3,
so at least there you can block for an amount of time < 1 second
(although there still isn't a way to get a signal delivered after an
interval of < 1 second in vanilla S5R3).
henry@utzoo.uucp (Henry Spencer) (11/06/88)
In article <399@auspex.UUCP> guy@auspex.UUCP (Guy Harris) writes: >(although there still isn't a way to get a signal delivered after an >interval of < 1 second in vanilla S5R3). Considering how dangerous and troublesome signals are as a method of interprocess communication, this may be a good thing. -- The Earth is our mother. | Henry Spencer at U of Toronto Zoology Our nine months are up. |uunet!attcan!utzoo!henry henry@zoo.toronto.edu
knudsen@ihlpl.ATT.COM (Knudsen) (11/08/88)
In the OS9 operating system, you can sleep for a granularity of 1/10 sec, or on the Color Computers, 1/60 sec. The C library sleep() only allows 1 sec resolution, but a general system call lets me get the 16.7 ms resolution on my Coco. I use it to play MIDI music, so I know it works; I've *heard* it work. Moral: Don't confuse what the C Std Library (or any other lib) gives you with what the underlying OS is really capable of. Portability? Bring friends. Big strong friends.... -- Mike Knudsen Bell Labs(AT&T) att!ihlpl!knudsen "Lawyers are like nuclear bombs and PClones. Nobody likes them, but the other guy's got one, so I better get one too."
crossgl@ingr.UUCP (Gordon Cross) (11/09/88)
In article <26678@ucbvax.BERKELEY.EDU>, jas@ernie.Berkeley.EDU (Jim Shankland) writes: > > Never trust statements about the UNIX kernel from people who can't even > spell the word. Every so often this sort of thing pops up: people abusing other people about spelling errors. This often (once started) gets out of hand as everyone begins "flaming" other's spelling and/or punctuation errors swamping the net with meaningless dribble. So please if you wish to correct someone on a spelling error, how about e-mail... Now down to business... In a previous article I wrote the following in response to a question regarding how to sleep for a period of time less than one second in C: > > You are not going to be able to do this without coding up some kind of > "delay loop" yourself. Of course that solution is definitely NOT portable in > any way since the loop would have to be fine tuned to your machines execution > speed. Remember that in the UNIX kernel, scheduled wakeups occur at fixed > one second intervals. Thus, unless you are using a non standard kernel, > sleeps of only whole numbers of seconds are possible! I have of course been catching some heat (from the flames :-)) regarding this response. And I must say it is well deserved! In my attempt to keep the answer as short as possible, I oversimplified the problem. I also neglected to mention that I would not actually RECOMMEND a "delay loop" since other approaches (ie. NOT requiring sleeps of less than one second) are almost always available. Several responses to this question mentioned other methods whereby this could be accomplished. Each of these solutions rely on mechanisms (such as BSD's sockets) not available on all UNIX implementations. I was just attempting to come up with a method that would be workable (if you absolutly just HAD to have sub-second waits) on any implementation. Sorry about the confusion! Gordon Cross Intergraph Corp. Huntsville, AL