INTERRUPT(3C++)

NAME
Interrupt_handler - signal handling for the C++ task library

SYNOPSIS
#include <task.h>
class Interrupt_handler : public object {
	virtual void	interrupt();
public:
			Interrupt_handler(int);
			~Interrupt_handler();
	objtype		o_type();
	int		pending();
};

DESCRIPTION

Class Interrupt_handler allows tasks to wait for external events in the form of UNIX system signals. Class Interrupt_handler is derived from class object so that tasks can wait for Interrupt_handler objects. Class object is described on the task(3C++) manual page.

The public member functions supplied in the task system class Interrupt_handler are listed and described below. The following symbols are used:

    ih  an Interrupt_handler object

    i   an int

    eo  an objtype enumeration

Interrupt_handler ih( i );
    Constructs a new Interrupt_handler object, ih, which is to wait for a signal number i. (See signal(2).) Once an Interrupt_handler object has been established for a particular signal, when that signal occurs, the private, virtual interrupt() function is called at real time. When it returns, control will resume at the point where the current task was interrupted. That is, signals do not cause the current task to be pre-empted. When the currently running task is suspended, a special, built-in task, the interrupt alerter will be scheduled. This task alerts the Interrupt_handler (and any others that have received interrupts since the interrupt alerter last ran), and thereby makes any tasks waiting for those Interrupt_handlers runnable. As long as any Interrupt_handler exists, the scheduler will wait for an interrupt, rather than exiting when the run chain becomes empty.

void interrupt()
    The private virtual function Interrupt_handler::interrupt() is a null function, but because it is virtual, the programmer can specify the action to be taken at interrupt time by defining an interrupt() function in a class derived from Interrupt_handler.

eo = ih.o_type()
    Returns the class type of the object (object::INTHANDLER). o_type() is a virtual function.

i = ih.pending()
    Returns TRUE except the first time it is called after a signal occurs.

DIAGNOSTICS
See task(3C++).

BUGS

UNIX System V Releases 3.1 and 3.2 (SVR3.1 and SVR3.2) for the Intel 386 machine will not call a signal handler when the current task is running on a stack in the free store, that is, when the current task has a DEDICATED stack. If you need to use the signal handling mechanisms on that configuration, you cannot use tasks which have DEDICATED stacks. In this case, compile the task library with _SHARED_ONLY defined, which will make SHARED the default mode for tasks. (Note: it is insufficient to declare all tasks as SHARED without compiling a _SHARED_ONLY version of the task library, because the internal system task, the interrupt alerter, is DEDICATED by default.)

SEE ALSO
TASK.INTRO(3C++), task(3C++), queue(3C++), tasksim(3C++), signal(2)
Stroustrup, B. and Shopiro, J. E., "A Set of C++ Classes for Co-routine Style Programming," in AT&T C++ Language System Release 2.0 Library Manual.
Shopiro, J. E., "Extending the C++ Task System for Real-Time Control," in AT&T C++ Language System Release 2.0 Library Manual.