Introduction

Thread Safe Usage

On systems that support either POSIX threads or WIN32 threads, IMSL C/Math/Library can be safely called from a multithreaded application.  When IMSL C/Math/Library is used in a multithreaded application, the calling program must adhere to a few important guidelines. In particular, IMSL C Math Library's implementation of signal handling, error handling, and I/O must be understood.

Signal Handling

When calling C/Math/Library from a multithreaded application it is necessary to turn C/Math/Library 's signal-handling capability off.  This is accomplished by making a single call to imsl_error_options before any calls are made to C Math Library. For an example of turning off C/Math/Library's internal signal handling , see “Utilities section chapter, Example 3 of imsl_error_options.

C Math Library 's error handling in a multithreaded application behaves similarly to how it behaves in a single-threaded application.  The major difference is that an error stack exists for each thread calling C Math Library  functions.  The result of separate error stacks for each thread is greater control of the error handler options for each thread.  Each thread can set its own options for the C Math Library error handler using imsl_error_options.  For an example of setting error handler options for separate threads, see the “Utilities” section chapter, Example 3 of imsl_error_options.

Routines that Produce Output

A number of routines in C Math Library can be used to produce output.  The function imsl_output_file can be used to control which file the output is directed.  In an application with a single thread of execution, a single call to imsl_output_file can be used to set the file to which the output will be directed.  In a multithreaded application each thread must call imsl_output_file to change the default setting of where output will be directed. See the “Utilities” section chapter, Example 2 of imsl_output_file for more details.

Input Arguments

In a multithreaded application attention must be given to the data sent to C Math Library. Some arguments that may appear to be input-only are temporarily modified during the call and restored before returning to the caller. Care must be used to avoid usage of the same data space in separate threads calling functions in
C Math Library.


Visual Numerics, Inc.
Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260