Chapter Contents

Previous

Next
Coprocessing Functions

Introduction

Some large applications are most conveniently implemented as a set of communicating processes that run independently of each other except for occasional exchanges of messages or other information. The SAS/C coprocessing feature supports this sort of application in a natural, operating-system-independent way.

This feature enables you to implement a SAS/C program as several cooperative processes, or coprocesses. Each coprocess represents a single thread of sequential execution. Only one thread is allowed to execute at any particular time. Control is transferred from one coprocess to another using the cocall and coreturn functions; these functions also provide for the transfer of data between coprocesses. At the start of execution, a main coprocess is created automatically by the library. Additional coprocesses are created during execution using the costart function and are terminated via the coexit function so that the coprocess structure of a program is completely dynamic. Most of the data structures of a SAS/C program are shared among all coprocesses, including extern variables, storage allocated by malloc , and open files. (The structures that are not shared are listed later in this section.)

Note that coprocessing does not implement multitasking. That is, only a single coprocess can execute at a time. Furthermore, transfer of control is completely under program control. If the executing coprocess is suspended by the operating system to wait for an event, such as a signal or I/O completion, no other coprocess is allowed to execute. Finally, note that the implementation of coprocessing does not use any multitasking features of the host operating system.

Coprocesses are very similar to coroutines, as included in some other languages. The name coprocess was used rather than coroutine because many SAS/C functions can be called during the execution of a single coprocess.


Chapter Contents

Previous

Next

Top of Page

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