Ejemplo n.º 1
0
main (int argc, char **argv)
{
	int id;
    setvbuf (stdout, NULL, _IOLBF, 0);

    printf ("%s:  starting...\n", progname);

    // request I/O privity
	ThreadCtl(_NTO_TCTL_IO, 0 );
	
    // set up an event for the handler or the kernel to use to wake up
    // this thread.  Use whatever type of event and event handling you want
	
	SIGEV_INTR_INIT( &int_event );
    // either register an interrupt handler or the event
	
	id = InterruptAttach(0, hdlr, NULL, 0, _NTO_INTR_FLAGS_TRK_MSK );
	
    while (1) {
        // block here waiting for the event
		InterruptWait(0, NULL );
        // if using a high frequency interrupt, don't print every interrupt
      
        printf ("%s:  we got an event after 1500 timer ticks and unblocked\n", progname);
    }   
}
Ejemplo n.º 2
0
void *InterruptTask::IntThread(void *arg){
	static int interruptId;
	struct sigevent event;
	int s;

	InterruptTask *taskInst;
	taskInst = (InterruptTask *)arg;

	event.sigev_notify = SIGEV_INTR;
	interruptId = InterruptAttachEvent(taskInst->mIntNum, &event, 0);

	while(1){
		if(InterruptWait(0, NULL) == -1){
			continue;
		}
		
		InterruptUnmask(taskInst->mIntNum, interruptId);
		taskInst->mRunning = 1;
		taskInst->IntTask();
		taskInst->mRunning = 0;
		
	}

}