Chapter Contents |
Previous |
Next |
Coprocessing Functions |
During its execution, a coprocess may pass through up to five states:
The effect of cocalling a coprocess depends on its state
at the time of the call. (The function
costat
enables you to determine the state of a coprocess.)
A coprocess is created by a call to the
costart
function. After its creation by
costart
, a coprocess is in the starting state until its execution begins as
the result of a
cocall
. (Because the main coprocess
is active when program execution begins, it is never in the starting state.)
Each coprocess has an initial function, which is specified as
an argument to
costart
when the coprocess is created. This is the function that is given control
when the coprocess begins execution.
A coprocess is busy when it has issued
a
cocall
to some other
coprocess and that coprocess has not yet performed a
coreturn
or terminated. A busy coprocess cannot
be cocalled, and an attempt to do so returns an error indication. This means
that a coprocess cannot cocall itself, directly or indirectly. One implication
of this rule is that it is not possible to cocall the main coprocess.
A coprocess becomes idle (or suspended) when it has called
coreturn
, if the call was
legal. An idle coprocess remains idle until another
coprocess cocalls it, at which point it becomes active. The main coprocess
is not permitted to call
coreturn
and, therefore, cannot become idle.
A coprocess is ended after its execution
has terminated. Execution of a coprocess is terminated if it calls the
coexit
function, if its initial
function executes a
return
statement, or if any coprocess calls the
exit
function. In the last case, all coprocesses are ended. In the
other two cases, the coprocess that cocalled the terminating coprocess is
resumed, as if the terminated coprocess had issued a
coreturn
. You cannot cocall a coprocess after
it has ended.
The effect of the various routines that cause coprocess switching can be summarized as follows:
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.