const struct sigevent *intHandler(void *arg, int id)
{
start_clock = ClockCycles();
//printf("start clock: %lld\n", start_clock);
return(&event);
}
int ConfigureISR()
{
// Get IO privilege
//
ThreadCtl( _NTO_TCTL_IO, 0 );
//
// Setup COID and event
chid = ChannelCreate( 0 );
SIGEV_INTR_INIT( &event);
interruptID = InterruptAttach(7, intHandler, NULL, 0, 0);
if (interruptID == -1)
{
fprintf(stderr, "can't attach to IRQ\n");
perror (NULL);
exit (EXIT_FAILURE);
}
InterruptWait(0, NULL);
end_clock = ClockCycles();
// printf("end clock: %lld\n", end_clock);
//microseconds
InterruptLatency = (uint32) ((end_clock - start_clock)*1000000/(SYSPAGE_ENTRY(qtime)->cycles_per_sec));
printf("microseconds: %ld\n", InterruptLatency);
measurements[17] = InterruptLatency;
return (EXIT_SUCCESS);
}
int main()
{
ConfigureISR();
// my socket code here to receive data from client.
}
我在 c 中为 QNX 操作系统创建了一个中断处理程序。我的任务:只要 udp 层上有数据,内核就应该调用这个中断处理程序。我正在计算上述代码中的中断延迟。客户端正在发送数据,服务器(上面的代码)正在从客户端接收数据并发送回响应。上面的代码每次都不会中断,只要它在 udp 层接收数据。以上可能是什么错误?有人可以帮我吗?