请教中断(SIGEV_INTR)!

请问大家我执行下列程序的时候(text 模式),执行完cout<<"interruptattach end. "<<endl;输出后,就死在这里了,中断程序没有执行,不知道怎么触发才能使中断程序执行!谢谢指教!

const struct sigevent *handler(void *area, int id)
{
cout<<“the isr is running…”<<endl;
return (&event);
}

int main(int argc, char *argv[])
{
int i;
int id;
ThreadCtl(_NTO_TCTL_IO,0);
event.sigev_notify = SIGEV_INTR;
cout<<“interruptattach begin.”<<endl;
id=InterruptAttach(SYSPAGE_ENTRY(qtime)->intr,&handler,NULL,0 , 0);
cout<<"interruptattach end. "<<endl;
InterruptWait(0,NULL);
InterruptDetach(id);
return 0;
}

You can’t call “cout” or “printf” in the interrupt handler attached by InterruptAttach().

那么中断程序里可以采集数据吗(AD采集卡),还有哪些不能在中断程序里执行呢,谢谢指点!

任何函数可能引起内核调用的,都不能在中断服务程序里使用。基本上C库里面,就是字符串函数还能用了。

其实,在QNX上最容易的是使用中断线程,你的程序稍改一下就行了。

int main(int argc, char *argv[]) 
{ 
    int i; 
    int id; 
    ThreadCtl(_NTO_TCTL_IO,0); 
    event.sigev_notify = SIGEV_INTR; 
    cout<<"interruptattach begin."<<endl; 
    id=InterruptAttachEvent(SYSPAGE_ENTRY(qtime)->intr,&handler,NULL,0 , 0); 
    cout<<"interruptattach end. "<<endl; 
    InterruptWait(0,NULL); 
    handle(NULL, id);
    InterruptDetach(id); 
    return 0; 
}

xtang: handle(NULL, id); 这句是不是调用中断服务程序的啊handle(NULL, id); 是handler吧,不需要在main里面调用吧,是不是写错了呢。 我去掉了中断服务程序里的cout输出语句,可以运行了,呵呵!

谢谢各位的指导!