|
|
#include <task.h>class Interrupt_handler : public object { virtual void interrupt(); public: Interrupt_handler(int); ~Interrupt_handler(); objtype o_type(); int pending(); };
Interrupt_handler
allows task
s to wait
for external events in the form of UNIX system signals.
Class Interrupt_handler
is derived from class object
so that task
s 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
object
int
objtype
enumeration
Interrupt_handler
ih(
i);
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 task
s waiting for those
Interrupt_handler
s 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()
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
.
=
ih.o_type()
object::INTHANDLER
).
o_type()
is a virtual function.
=
ih.pending()
pending
function, if its policy about pending
is different.
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 task
s.
(Note: it is insufficient to declare all task
s as SHARED without
compiling a _SHARED_ONLY version of the task library,
because the internal system task
,
the
interrupt alerter,
is DEDICATED by default.)
``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.