Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c,comp.unix.questions Subject: Re: msleep Message-ID: <9310@mimsy.UUCP> Date: Wed, 11-Nov-87 20:18:41 EST Article-I.D.: mimsy.9310 Posted: Wed Nov 11 20:18:41 1987 Date-Received: Sat, 14-Nov-87 06:01:38 EST References: <332@PT.CS.CMU.EDU> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 37 Keywords: sleep millisecs Xref: mnetor comp.lang.c:5384 comp.unix.questions:4885 In article <332@PT.CS.CMU.EDU> edw@IUS1.CS.CMU.EDU (Eddie Wyatt) writes: >/************************************************************************** > * * > * msleep * > * * > ************************************************************************** > > Purpose : What you all been waiting for -- A sleep that works in > microseconds!!!. Actually it depends on the granularity > of the interrupt timer, but at least its better than > the second wait. ... followed by code that uses setitimer. 0) Only certain 4BSD-based operating systems *have* setitimer. (What this *really* means is that if you need a sleep that works in milliseconds or microseconds or whatever, using a routine like msleep is imperative. Then the victim, er, user, of your code need rewrite only msleep.) 1) you can (and, I think, should) avoid the critical section by using sigblock and sigsetmask (see man 2 sigblock). 2) using setitimer is more expensive than calling select with three `(fd_set *)0' arguments. Select does have one problem: like sigpause, it is interrupted by signals; unlike sigpause, it does not take a signal mask, so it sometimes has unavoidable critical sections. (Yes, I want a sixth argument to select!) 3) The actual granularity of interval timers (including select timers): system granularity 4.[23]BSD Vax 10 ms Sun[23] running SunOS 3.x 20 ms -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris