DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

pthread_setconcurrency(PTHREAD)


pthread_setconcurrency, pthread_getconcurrency -- request, retrieve a level of concurrency

Synopsis

   cc [options] -Kthread file
   

#include <pthread.h>

int pthread_setconcurrency(int new_level); int pthread_getconcurrency(void);

Description

The Threads Library ensures that a sufficient number of threads are active so that the process can continue to make progress. While this conserves system resources, it might not produce the most effective level of concurrency.

pthread_setconcurrency tells the threads implementation the desired level, or degree, of concurrency. That is, it requests the number of lightweight processes (LWPs) that the user would like available to execute multiplexed (that is, PTHREAD_SCOPE_PROCESS) threads in the process. This value is used to affect the number of LWPs available for running multiplexed threads.

pthread_getconcurrency returns the level, or degree, of concurrency, requested from the most recent successful pthread_setconcurrency call (or zero, if there has been no call.

The new_level parameter specifies the requested level of concurrency. new_level must be a non-negative integer. pthread_setconcurrency interprets it as follows:

When the number of LWPs becomes greater than the number of threads in the process, the concurrency level might automatically decay over time to be equal to or less than the number of threads in the process. This process is called ``aging.'' If an LWP is inactive for a certain length of time, it will terminate itself if:

Return values

pthread_setconcurrency returns zero on success and an error number for failure, as described below.

pthread_getconcurrency always returns the concurrency level set by a previous successful call to pthread_setconcurrency. If pthread_setconcurrency has never been called, pthread_getconcurrency returns zero.

Diagnostics

pthread_setconcurrency returns the following values if the corresponding conditions are detected:

EINVAL
new_level is negative.

Standards compliance

The Single UNIX Specification, Version 2; The Open Group.

References

Intro(PTHREAD), pthread_create(PTHREAD), pthread(F)

Notices

The creation or termination of LWPs is not synchronous with the call to pthread_setconcurrency. If new_level causes a system limit to be exceeded no error is returned.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005