TASK.INTRO(3CC4)TASK.INTRO(3CC4)NAMEtask.intro - introduction to the coroutine library and man pages
SYNOPSIS
#include <task.h>
class object { ... };
class sched: public object { ... };
class task: public sched { ... };
class timer: public sched { ... };
class Interrupt_handler : public object { ... };
class qhead: public object { ... };
class qtail: public object { ... };
struct histogram { ... };
class randint { ... };
class urand: public randint { ... };
class erand : public randint { ... };
DESCRIPTION
These man pages provide the reference material needed to understand the
details of the individual functions and classes which make up the task,
or coroutine, library. There is a separate tutorial which provides an
overview and some examples.
The task library was designed for use in simulation programs, and was
originally written in C at AT&T Bell Laboratories. It was adapted for
use with C++, but still shows its C heritage in places.
The task library provides a way to write programs with multiple threads
of control without incurring the overhead of a separate Unix process
for each thread. It is particularly useful for simulations where each
object in the simulation has an independent execution thread. When
there are hundreds or thousands of objects, it is impossible to have a
separate Unix process for each one. This library allows the entire
simulation to run as a single Unix process, while simulating separate
processes and the passage of time.
The task library provides for non-preemptive task scheduling. This
greatly simplifies program design, because no extra synchronization is
required. Each task runs until it gives up control explicitly (as by
executing a wait operation or terminating), or implicitly (as by
requesting a service which cannot be provided immediately). Tasks may
thus be suspended and resumed independently.
Task Classes
These classes are described in the man page task(3CC4).
object The base class for all task system classes. The system com‐
prises lists and queues of various kinds, and everything on a
list or queue is derived from class object.
sched Provides the basic scheduling functionality. No object of type
sched may be created, but all tasks and timers are derived from
this class. Thus, there is no ``scheduler'' as such, but rather
all task objects in the system cooperate in the scheduling
process by means of the member functions and data of this class.
timer A very simple form of task, which provides only the passage of
time. A task may initiate a timer, for example, and wait for it
to expire.
task The base class for all actual user tasks. No object of this
type may be created. A user task object must be of a type
derived immediately from class task. The constructor for the
user task type is the main program for an individual task.
Interrupt Class
Class Interrupt_handler provides an interface for dealing with external
events via Unix signals. This class is described in the man page
interrupt(3CC4).
Queue Classes
Classes qhead and qtail together make up a queue (a first-in first-out
list). Anything derived from class object may be placed on a queue.
These classes are described in the man page queue(3CC4).
Statistical Classes
These classes provide simulation and data gathering aids. They are
described in the man page tasksim(3CC4).
histogram
Allows data gathering in a histogram.
randint
Provides uniformly-distributed random values in the range 0 to
maxint.
urand Provides uniformly-distributed random values in a user-specified
range.
erand Provides exponentially-distributed random numbers around a spec‐
ified mean.
NOTE
As of the date of this release, the coroutine library will not be sup‐
ported beyond the current version.
SEE ALSOinterrupt(3CC4), queue(3CC4), task(3CC4), and tasksim(3CC4).
08 August 2000 TASK.INTRO(3CC4)