Chapter Contents

Previous

Next
costat

costat



Return Coprocess Status


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
EXAMPLE


SYNOPSIS

#include <coproc.h>

int costat(coproc_t id);


DESCRIPTION

The costat function returns information about the status of a coprocess. The id argument is the ID of the coprocess whose status is desired.


RETURN VALUE

The value returned by costat is one of the symbolic constants STARTING , ACTIVE , BUSY , IDLE , or ENDED . These constants have the following significance:

STARTING
indicates that the coprocess has been created by a call to costart but has never been cocalled.

ACTIVE
indicates that the coprocess is the one currently running.

BUSY
indicates that the coprocess has cocalled another coprocess and therefore has been suspended by the cocall function. A BUSY coprocess cannot be cocalled itself.

IDLE
indicates that the coprocess is suspended by a call to coreturn . The coprocess will not execute again until it is cocalled.

ENDED
indicates that the coprocess has terminated.


CAUTION

The effects of passing an invalid coprocess ID to costat are unpredictable. Usually, this causes the value ENDED to be returned.


EXAMPLE

#include <stddef.h>
#include <coproc.h>
#include <stdlib.h>

coproc_t err_proc;

/* Cocall the coprocess whose ID is in the variable err_proc. But  */
/* abort instead if that coprocess cannot be legally cocalled.     */
switch (costat(err_proc)) {
   case STARTED:
   case IDLE:
      cocall(err_proc,NULL);       /* Call the error coprocess if  */
      break;                       /* this is legal.               */
   default:
      abort();                     /* Abort if error coprocess not */
}                                 /* available for cocall.         */


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.