小弟教研室有一个项目,要用到定时中断,没个一段时间(小于1秒)产生一个中断,做相应的任务。
我看了看QNX的help和论坛,决定用timertimeout函数,做了个小程序实验了一下,结果基本达到效果,我是刚刚开始学qnx的,请各位看看我的程序有问题没,除了用timertimeout还可以用其他方法么,一下是我的程序!
#include <stdio.h>
#include <errno.h>
#include <stddef.h>
#include <unistd.h>
#include <hw/pci.h>
#include <pthread.h>
int count;
struct sigevent event;
void * thread_proc(void *arg)
{
int int_id;
const uint64_t onesecond=100000000;
const uint64_t timeoutSetTime;
const uint64_t SetTime=10onesecond;
timeoutSetTime=&SetTime;
int_id=InterruptAttach(_NTO_INTR_CLASS_SYNTHETIC,NULL,NULL,0,0);
event.sigev_notify=SIGEV_UNBLOCK;
while(1)
{
TimerTimeout(CLOCK_REALTIME,_NTO_TMIEOUT_INTR,&event,timeoutSetTime,NULL);
InterruptWait(0,NULL);
++count;
}
}
int main(void)
{
pthread_attr_t attr;
pthrea_attr_init(&attr);
pthread_attr_Setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
pthread_creat(NULL,&attr,&thread_proc,NULL);
while(1)
{
if(count==10)
{printf(“HELLO WORLD!”);
return EXIT_SUCCESS;
}
}
}