[comp.unix.questions] "usleep" routine in HP's

rosa@maui.cs.ucla.edu (04/28/89)

I have a C program with real time restrictions that uses the "usleep"
routine provided in the SUN's C library ("usleep" gives precision of
micro-seconds). In the HP's, there is not this routine. I was told
a "nap" routine for HP machines was posted in the "comp.unix.sources"
some time ago. Where can I find a copy of this routine? 

Thanks in advance,

	--Berthier

decot@hpisod2.HP.COM (Dave Decot) (05/02/89)

Or, if nap() doesn't show up, you could use getitimer(2) to do it yourself.

Dave

rml@hpfcdc.HP.COM (Bob Lenk) (05/06/89)

> Or, if nap() doesn't show up, you could use getitimer(2) to do it yourself.

Even easier, use select(2).  Pass zero as the first argument (nfds) and
it will sleep for as long as requested by the fifth argument (timeout).

		Bob Lenk
		hplabs!hpfcla!rml
		rml@hpfcla.hp.com

adtaiwo@athena.mit.edu (Ademola Taiwo) (05/07/89)

In article <5740041@hpfcdc.HP.COM> rml@hpfcdc.HP.COM (Bob Lenk) writes:
>> Or, if nap() doesn't show up, you could use getitimer(2) to do it yourself.
>
>Even easier, use select(2).  Pass zero as the first argument (nfds) and
>it will sleep for as long as requested by the fifth argument (timeout).
>
Okay guys, How does one implement select, sigrelse, sigpause and
sighold with signals.
I have Xenix socalled SYSV which does not have those functions. I would
like to emulate them in some form. I have a feeling this could be done
by combining signals with wait. Any help?
Thanks.

chris@mimsy.UUCP (Chris Torek) (05/07/89)

In article <11166@bloom-beacon.MIT.EDU> adtaiwo@athena.mit.edu
(Ademola Taiwo) writes:
>Okay guys, How does one implement select, sigrelse, sigpause and
>sighold with signals.

If you have neither a 4.1-style `jobs library' nor 4.2-style signals,
you cannot implement sighold, sigpause, and sigrelse reliably.

You cannot reliably implement select with anything other than poll().
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

adtaiwo@athena.mit.edu (Ademola Taiwo) (05/08/89)

In article <17358@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>In article <11166@bloom-beacon.MIT.EDU> adtaiwo@athena.mit.edu
>(Ademola Taiwo) writes:
>>Okay guys, How does one implement select, sigrelse, sigpause and
>>sighold with signals.
>
>If you have neither a 4.1-style `jobs library' nor 4.2-style signals,
>you cannot implement sighold, sigpause, and sigrelse reliably.
>
>You cannot reliably implement select with anything other than poll().
>-- 
>In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
>Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

Wait! That is not true. Emacs has implemented select, but only for
read fds. There is ecsh, I believe it is the early CSH, correct me if
I am wrong, but has Bill Joy written all over it. They implemented
sigrelse, sigset and sigignore. The trick was to keep an array of all
the available signals and later full around with them.
You ma ask what else do I want? sigsetmask. This is the missing link
in my search for the 4.2 compat signals library. I can always use the
signal facility provided with GNUemacs and not the "standard" library
that came with my C compiler.
Thanks again.

chris@mimsy.UUCP (Chris Torek) (05/08/89)

>In article <17358@mimsy.UUCP> I wrote:
>>If you have neither a 4.1-style `jobs library' nor 4.2-style signals,
>>you cannot implement sighold, sigpause, and sigrelse reliably.
>>
>>You cannot reliably implement select with anything other than poll().

In article <11215@bloom-beacon.MIT.EDU> adtaiwo@athena.mit.edu
(Ademola Taiwo) writes:
>Wait! That is not true. Emacs has implemented select, but only for
>read fds.

In other words, it has not implemented select.  (You also cannot get
read timeouts to work reliably.)

>There is ecsh, I believe it is the early CSH, correct me if
>I am wrong, but has Bill Joy written all over it. They implemented
>sigrelse, sigset and sigignore. The trick was to keep an array of all
>the available signals and later full around with them.

This is not reliable.

The key word is *reliable*; that was the whole point of the 4.1BSD
jobs library, and later the 4.2BSD reliable signals.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

adtaiwo@athena.mit.edu (Ademola Taiwo) (05/09/89)

In article <17374@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>>In article <17358@mimsy.UUCP> I wrote:
>>>you cannot implement sighold, sigpause, and sigrelse reliably.
>>>You cannot reliably implement select with anything other than poll().
>The key word is *reliable*; that was the whole point of the 4.1BSD
>jobs library, and later the 4.2BSD reliable signals.
>In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)

Okay, you guys are right. What to do? I need these routines
desperately and since I have been fooling around with
my kernel and I am willing to add more stuff to it if this is the only
way to implement them reliably.
Maybe the quetion is, Is there a way to implememnt these routines
under xenix? I really need them. -Thanks.