Path: utzoo!attcan!uunet!wuarchive!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.unix.questions Subject: Re: Sleep time interval Message-ID: <10262@jpl-devvax.JPL.NASA.GOV> Date: 6 Nov 90 19:34:01 GMT References: <725@macuni.mqcc.mq.oz> <14347@smoke.brl.mil> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 25 In article <14347@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: : In article <725@macuni.mqcc.mq.oz> martin@macadam.mqcs.mq.oz.au (Martin Foord) writes: : >Is the smallest interval of sleep time the integer 1? Is there anyway of : >sleeping from a C program for a smaller period of time ? : : The first thing you need to be aware of is that all you can specify is a : MINIMUM amount of delay; the actual delay will depend on scheduling : issues such as system load, and could be arbitrarily large if you're : unlucky. The second thing you need to be aware of is that it doesn't necessarily specify the MINIMUM delay either. If you say sleep(1), some implementations will sleep till the top of the next second, which could be a very small fraction of a second away. So sleep(n) sleeps a minimum of n-1 seconds on such machines. In terms of portability, sleep(1) is virtually worthless (except in a statistical sense) without knowing when in the second it's going to sleep. Machines on which alarm() is implemented using setitimer() do not appear to have this problem. It's possible it's been fixed elsewhere too--some of my databanks haven't been updated in quite some time. I could even be getting confused with other OS's. Caveat Programmor. Larry Wall lwall@jpl-devvax.jpl.nasa.gov