Table of Contents

Name

qthread_init, qthread_initialize - initialize the qthread library

Synopsis

#include <qthread.h>

int
qthread_init (const int nshepherds);

int
qthread_initialize ();

Description

Use these functions to initialize the qthreads environment before using any other qthread functions. The qthread_init() function is deprecated in favor of qthread_initialize() which will attempt to auto-detect the correct number of shepherds for the system. The number of shepherds can be forcibly specified with the environment variable QTHREAD_NUM_SHEPHERDS. The qthread_init() function is a wrapper around qthread_initialize() that simply exports the QTHREAD_NUM_SHEPHERDS environment variable. If QTHREAD_NUM_SHEPHERDS is 0 or unset, the library will attempt to guess the correct number of shepherds, defaulting to a single shepherd if no information about the system could be found. Shepherds will attempt to pin themselves to processors using whatever CPU affinity libraries are available.

Environment

The operation of qthread_init() is modified by the following environment variables:
QTHREAD_AFFINITY
If this variable is set to "no", then the shepherds will not pin themselves to specific locations.
QTHREAD_DEBUG_LEVEL
This variable is used to control the verbosity of debug messages that get printed at runtime. Higher numbers increase the verbosity; a value of 0 is the same as being unset, which prevents debug messages from being printed. This is only applicable if debugging has been enabled when the library was built.
QTHREAD_STACK_SIZE
This variable adjusts the size of the stacks that will be created for each thread. Changes to this value during the course of the program run are ignored; the value is only considered when qthread_init() is run.
QTHREAD_NUM_SHEPHERDS
This variable specifies how many shepherds to create.

Return Value

On success, the system is ready to fork threads and 0 is returned. On error, an non-zero error code is returned.

Errors

ENOMEM
Not enough memory could be allocated.

See Also

qthread_finalize(3)


Table of Contents