xtang,请教一个中断的问题,我自己写了一个中断的测试代码(代码如下),编译运行后,电脑直接挂掉了!(我电脑直接装的QNX系统,不是用虚拟机装的);为什么会挂掉?是产生了中断,让系统挂了吗?
#include <stdio.h>
#include <sys/irqinfo.h>
#include <sys/proxy.h>
#include <sys/kernel.h>
pid_t proxy;
volatile unsigned counter;
/* The hardware interrupt handler */
pid_t far handler()
{
/* Kick a proxy every 100 timer interrupts */
if( (++counter % 100) == 0 )
return( proxy );
return( 0 );
}
void main()
{
int id, i;
/* Get a proxy for the interrupt handler to kick */
if( ( proxy = qnx_proxy_attach( 0, 0, 0, -1 ) )
== -1 ) {
printf( " Unable to attach proxy. " );
return;
}
/* Attach to the timer */
if( ( id = qnx_hint_attach( 0, &handler,
FP_SEG( &counter ) ) ) == -1 ) {
printf( "Unable to attach interrupt." );
return;
}
/* Wait for the proxy */
for( i = 0 ; i < 10 ; ++i ) {
Receive( proxy, 0, 0 );
printf( "100 ticks.\n" );
}
qnx_hint_detach( id );
}