pthread_setconcurrency, pthread_getconcurrency --
request, retrieve a level of concurrency
cc [options] -Kthread file
int pthread_setconcurrency(int new_level);
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
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
(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:
If new_level is zero,
pthread_setconcurrency causes the implementation
to maintain the concurrency level at its discretion.
If new_level is greater than the current number of LWPs,
in this implementation,
will create LWPs until the number of LWPs in the pool
unless new_level exceeds a system limit.
In that case, LWPs will be created only up to the system limit.
However, if new_level exceeds
the number of threads in the process,
will create new LWPs so that the number of LWPs
equals the number of threads in the process.
If new_level is less than the current number of LWPs,
will allow LWPs to terminate themselves as the result of aging.
If new_level is equal to the current number of LWPs,
pthread_setconcurrency sets the new level of concurrency,
but does not create or terminate any LWPs.
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:
the number of LWPs is greater than the requested concurrency level
or the number of LWPs is greater than the number of threads in the process
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
If pthread_setconcurrency has never
been called, pthread_getconcurrency returns zero.
pthread_setconcurrency returns the following values
if the corresponding conditions are detected:
new_level is negative.
The Single UNIX Specification, Version 2; The Open Group.
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.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004