Hi everyone:
I was thinking to use an Interval Timer for some real-time data
acquisition process. But when I tested it with the following small program,
it did not work. Specifically, the "getinterval" routine always returns a
zero value for its "it_value.tv_nsec" member.
Since this is the first time I've used an Interval Timer on AIX, I
wonder if someone can point out to me what I do wrong in the program, or
perhaps, should I use an Interval Timer for this purpose at all.
#include <stdio.h>
#include <sys/time.h>
#include <sys/events.h>
main()
{
int n=0;
timer_t tm_id;
struct timestruc_t res, max;
struct itimerstruc_t ctv,otv,stv;
/* establish timer */
/*tm_id=gettimerid(TIMERID_REAL,DELIVERY_SIGNALS);*/
tm_id=gettimerid(TIMEOFDAY,DELIVERY_SIGNALS);
/* find resolution */
resabs(tm_id,&res,&max);
printf("\nres=%ld/%ld\tmax=%ld/%ld\n\n",res.tv_sec,res.tv_nsec,
max.tv_sec,max.tv_nsec);
/* preset timer */
stv.it_interval.tv_sec=(unsigned long)0L;
stv.it_interval.tv_nsec=(long)500000000L;
stv.it_value.tv_sec=(unsigned long)0L;
stv.it_value.tv_nsec=(long)0L;
otv.it_interval.tv_sec=(unsigned long)0L;
otv.it_interval.tv_nsec=(long)0L;
otv.it_value.tv_sec=(unsigned long)0L;
otv.it_value.tv_nsec=(long)10000000L;
if (absinterval(tm_id,&stv,&otv)) {
printf("\nTimer not set!\n\n");
exit(1);
}
/* simple test */
while (getinterval(tm_id,&ctv)==0 && ++n<=10) {
if (ctv.it_value.tv_nsec>=300000000L) printf("\nPASS\n");
ctv.it_value.tv_nsec,ctv.it_interval.tv_nsec);
}
/* release timer */
reltimerid(tm_id);
Quote:}
Thanks in advance.
--