.\" '\" tep .\" to invoke 'tbl', 'eqn', 'pic' in the proper order .\" .\" @(#)interrupt.3 1.4 00/02/18 SMI; .\" .TH INTERRUPT 3CC4 "26 October 1992" .\" .SH NAME interrupt Interrupt_handler \- signal handling for the task library .SH SYNOPSIS .LP .nf .ft B #include .sp .5v class Interrupt_handler : public object { public: // exported constructor Interrupt_handler(int signo); .sp .5v // exported virtual function virtual int pending(); .sp .5v private: // private virtual function virtual void interrupt(); }; .ft R .fi .\" .SH DESCRIPTION .LP Class .B Interrupt_handler provides a way for a task to wait for an external Unix signal. It is derived from class .B object so that tasks may wait on a handler object. .\" .TP .B "Interrupt_handler ih(signo);" Constructs a new interrupt handler .BR ih, which will wait for signal number .B signo (see .BR signal (2)). When that signal occurs, the private virtual function .B interrupt() is called immediately, via the usual Unix signal mechanism. When the function returns, the task which was interrupted resumes. That is, interrupts do not cause preemption within the task model. A special task, the .IR "interrupt alerter" , is automatically created by the task system. When a running task is suspended and an interrupt has occurred since the last task suspension, the interrupt alerter is scheduled. The alerter alerts the .BR Interrupt_handler s associated with any interrupts which have occured since the last time the alerter ran. Any tasks waiting for such handlers therefore become runnable. In the absence of any interrupt handlers, the scheduling process terminates when there are no more tasks to be run. So long as there are any interrupt handlers, scheduling will not terminate, but will wait indefinitely for any interrupts which may occur. .\" .TP .B "int i = ih.pending();" Always returns ``true'' (non-zero) except the first time it is called after an interrupt occurs. .\" .TP .B "void interrupt()" This is a private virtual function. The base-class version does nothing. Normally you will derive a class from .B Interrupt_handler and define this function to do whatever is appropriate for that class. See the tutorial for an example. .\" .SH "DIAGNOSTICS" .LP See .BR task (3CC4). .\" .SH "SEE ALSO" .na .BR TASK.INTRO (3CC4), .BR queue (3CC4), .BR task (3CC4), .BR tasksim (3CC4), .BR signal (2) .LP .IR "Task Library Tutorial" .\" .TZ ????