[comp.unix.questions] Re^2: sleep

rolff@mosh.UUCP (Anders Rolff) (12/20/89)

peter@sersun1.essex.ac.uk (Allott P) writes:

>>But what if you want to sleep for less than one second, say, 0.5?

>It is possible to "sleep" for less than one second by doing a
>selcect(.......) with an appropriate value in the timeval (5th param I think)
>and with no channels to check (2nd through 4th params I think).

In SunOS there's a usleep() that sleeps in milliseconds.

--Anders

dskim@eng.umd.edu (Daeshik Kim) (12/28/89)

In article <107@mosh.UUCP> rolff@mosh.UUCP (Anders Rolff) writes:
>peter@sersun1.essex.ac.uk (Allott P) writes:
>
>>selcect(.......) with an appropriate value in the timeval (5th param I think)

	Why not 'setitimer' ?
--
	Daeshik Kim	H: (301) 445-0475/2147 O: (703) 689-7308 (M,W,F)
	SCHOOL:	dkim@cscwam.umd.edu (uunet!haven!cscwam.umd.edu!dkim)
		dskim@eng.umd.edu (uunet!haven!eng.umd.edu!dskim)
	WORK:	dkim@daffy.uu.net (uunet!daffy!dkim)

chris@mimsy.umd.edu (Chris Torek) (12/29/89)

(This is not C, but rather Unix; followups redirected there.)

>In article <107@mosh.UUCP> rolff@mosh.UUCP (Anders Rolff) writes:
>>>select(...) with an appropriate value in the timeval

In article <1989Dec28.091551.17731@eng.umd.edu> dskim@eng.umd.edu
(Daeshik Kim) writes:
>Why not 'setitimer' ?

select() is simpler.  To use setitimer(ITIMER_REAL) properly, you have
to do much more work.  (If you use it improperly, your program will
eventually fail.)

The only disadvantage to select over setitimer(ITIMER_REAL) is that
it is interrupted by signals.  This may be an advantage in some cases.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris