中断处理问题

const struct sigevent *b(void *arg, int id)
{
flag = 1;
return (&event);
}

void a (void arg)
{
unsigned long currentCount,runtimes;
unsigned long start_idx;
uint64_t stop,start,cps;
U16 intSta,status;
SIGEV_INTR_INIT(&event );
rs = InterruptAttach (card_array[0].irq, b, NULL, 0, 0);
if (rs == -1)
{
printf (“IntConnect ERR %d .\n”);
}
ThreadCtl(_NTO_TCTL_IO, 0);
while(1)
{
if (InterruptWait (NULL, NULL)!=-1)
{ _9116_AD_Int_Sts(0,&intSta);
if (intSta == 1)
{ runtimes=0;
do{
runtimes++;
}while(flag!=1);
if (runtimes>2)
printf(“Wait Intrrupt times:%d!\n”,runtimes);
flag = 0;
if( _9116_AD_DMA_ReStart(0)!=NoError)
printf(“9116 dma err!\n”);
}
}
}
}


问题:
1、我a线程的优先级设为了255
2、如果先执行b在执行a线程,应该在
do{
runtimes++;
}while(flag!=1);
段中不会有循环执行,即runtimes变量不会大于1
而现在的现象为,有时循环若干次,甚至会永远循环下去,flag永远不会等于1,好像b未执行
每次初始化等待中断事件发生,a线程阻塞在(InterruptWait (NULL, NULL))上,按中断服务程序的优先级最高来判断,应该中断时间来之后,先执行中断服务程序b,当执行完毕后,在执行InterruptWait后面的代码。
上面程序执行结果为,隔一段时间打印:
Wait Intrrupt times:105!
Wait Intrrupt times:65!
Wait Intrrupt times:128!
请帮忙分析,谢谢!

好像a的优先级大于22就会出现这个问题

一块儿学习中…


有两个疑问:
1 ThreadCtl(_NTO_TCTL_IO, 0); 应该在InterruptAttach ();前
2 flag是否应该用atomic函数


等待中。。。

问题已解
_9116_AD_Int_Sts(0,&intSta);
函数出的问题,本不应该是这块采集卡的中断,当从寄存器读出是,所以中断处理错误了
谢谢各位了