Xref: utzoo comp.lang.c:13902 comp.unix.questions:10132 Path: utzoo!attcan!uunet!ingr!crossgl From: crossgl@ingr.UUCP (Gordon Cross) Newsgroups: comp.lang.c,comp.unix.questions Subject: Re: Delay for a fraction of a second in C Message-ID: <2869@ingr.UUCP> Date: 8 Nov 88 19:23:31 GMT References: <2804@ingr.UUCP> <26678@ucbvax.BERKELEY.EDU> Organization: Intergraph Corp. Huntsville, Al Lines: 37 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