From owner-freebsd-hackers Thu Jun 27 13:16:34 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id NAA21010 for hackers-outgoing; Thu, 27 Jun 1996 13:16:34 -0700 (PDT) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id NAA21002 for ; Thu, 27 Jun 1996 13:16:31 -0700 (PDT) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id NAA05677; Thu, 27 Jun 1996 13:15:01 -0700 From: Terry Lambert Message-Id: <199606272015.NAA05677@phaeton.artisoft.com> Subject: Re: portable microsecond sleeps To: brandon@tombstone.sunrem.com (Brandon Gillespie) Date: Thu, 27 Jun 1996 13:15:01 -0700 (MST) Cc: freebsd-hackers@FreeBSD.ORG In-Reply-To: from "Brandon Gillespie" at Jun 27, 96 12:08:34 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > We have a server package that talks to a visa pos port. We run this on a > unixware box and on a freebsd box. At one point in the code we need to > have a microsecond sleep. BSD has usleep(), however unixware does not > (unless you use /usr/ucb/cc, which is EXTREMELY broken and buggy, so its > not really an option :) > > Instead we have tried using select to achieve a microsecond sleep, but > when we run this on the unixware system it munches CPU time. > > Any suggestions for other ways to achieve microsecond sleeps? UnixWare is broken. The smalles sleep increment for select is 10uS. UnixWare does not conform to SVID III(RT), though it claims to implement the RT extenstions. The difference is "system clock frequency" vs. "system time update frequency". This problem is inherited by the setitimer(RT)/getitimer(RT) alarm signal generation interfaces. The only real way to handle this on UnixWare required root provildeges. You must use the undocumented HRT system calls ("High Resoloution Timer") to implement small interval timings. The interfaces are in the header files in /usr/include/sys. One caveat: for the timer to fire *and* be acted upon in as short a period of time (sub quanta) as needed, you have to set the process into a RT scheduling class. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.