[comp.unix.internals] Millisecond timers

hue@island.uu.net (Jon "Outta my way - I'm going windsurfing" Hue) (09/30/90)

shawn@jdyx.UUCP (Shawn Hayes) writes:
>	After looking at AIX V1.2 for a while I've noticed that almost
>all of the timed functions are based on second resolution such as the
>select call.  Only the getitimer and setitimer calls support millisecond

Last time I used AIX V3, select() and poll() rounded to the second, only
setitimer had finer resolution.  IBM says the PS/2 won't be getting V3,
so I guess this doesn't matter to you, but it might be a rude suprise
for RS/6000 users.

-J

dattatri@metaphor.Metaphor.COM (Dattatri) (10/03/90)

As I see it, the easiest way to provide a millisecond timer is as follows.
	1. Set up a handler for SIGALRM.
	2. Set up and start the timer for the required amount of time.
	3. Then pause for a signal.

nap(time)
{
	int timerHandler();
	/* Set up handler for SIGALRM. Could use sigvec/sigaction also */
	signal(SIGALRM, timerHandler);
	/* Insert code to set timer for x milliseconds and start the timer */
	pause();
}
timerHandler()
{
}

If you expect other signal(s) to be received during the 'pause', necessary 
arrangements should be made to check the signal etc (which is trivial).
This method cannot be used if SIGALRM is already being used for other tasks.
Note that the pause() returns after the signal handler has completed.

Kayshav Dattatri -- (dattatri@metaphor.com)

jfh@rpp386.cactus.org (John F. Haugh II) (10/03/90)

In article <2017@island.uu.net> hue@island.uu.net (Jon "Outta my way - I'm going windsurfing" Hue) writes:
>Last time I used AIX V3, select() and poll() rounded to the second, only
>setitimer had finer resolution.  IBM says the PS/2 won't be getting V3,
>so I guess this doesn't matter to you, but it might be a rude suprise
>for RS/6000 users.

If you are actually seeing second resolution on the select() system
call in AIX V3, please contact your IBM account body and complain.
I've seen strange behavior in the past (a long time ago), but not
anything wierd recently.  Details?  Test case?
-- 
John F. Haugh II                             UUCP: ...!cs.utexas.edu!rpp386!jfh
Ma Bell: (512) 832-8832                           Domain: jfh@rpp386.cactus.org
"SCCS, the source motel!  Programs check in and never check out!"
		-- Ken Thompson