DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
C++ Task Library

interrupt(C++)


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

Syntax

#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(C++) manual page.

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


Interrupt_handler ih(i);
Constructs a new Interrupt_handler object, ih, which is to wait for a signal number i. (See signal(S).) 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. This is a virtual function, and a derived class should define its own pending function, if its policy about pending is different.

Diagnostics

See task(C++).

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(C++), task(C++), queue(C++), tasksim(C++), signal(S)

``A Set of C++ Classes for Co-routine Style Programming,'' by Stroustrup, B. and Shopiro, J. E., in Chapter 2 of the C++ Library Manual.

``Extending the C++ task system for real-time control,'' by Shopiro, J. E., in the C++ Library Manual.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005