Millisecond clock

Tony Burzio burzio at mmlai.UUCP
Sat Aug 11 10:34:16 AEST 1990


The folowing program for millisecond sleep works under HP-UX SYSV,  so
it should work on an ATT (serious finger crossing :-).  Compile with:

cc -O timer.c -o timer

--------------------------------- cut here -----------------------------------

#include <signal.h>
#include <time.h>

void myhandler() {}
usleep(usec)
int usec;
{
	int sigret;
	struct itimerval rttimer;
	struct itimerval old_rttimer;
	struct sigaction *act, *oact ; 

	rttimer.it_value.tv_sec     = ( (float) usec)  / 1000000;
	rttimer.it_value.tv_usec    = 
		((float) usec) - ((float) rttimer.it_value.tv_sec * 1000000.0);
	rttimer.it_interval.tv_sec  = 0;
	rttimer.it_interval.tv_usec = 0;

	(void) signal(SIGALRM,(myhandler));
	setitimer (ITIMER_REAL, &rttimer, &old_rttimer);
	pause();
}

main ()
{
	usleep(500000);
}

--------------------------- cut here  --------------------------------------

*********************************************************************
Tony Burzio               * OH!  You have to turn it ON first!
Martin Marietta Labs      *
mmlab!burzio at uunet.uu.net *	- First day, DOS user.
*********************************************************************



More information about the Comp.unix.questions mailing list