DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

thr_setconcurrency(3thread)


thr_setconcurrency -- request a level of concurrency

Synopsis

   cc [options] -Kthread file
   

#include <thread.h>

int thr_setconcurrency(int new_level);

Description

thr_setconcurrency tells the implementation the number of lightweight processes (LWPs) that the user would like available for running multiplexed threads.

thr_setconcurrency sets to new_level the requested level, or degree, of concurrency, which is the number of LWPs that the user would like available to execute multiplexed threads in the process. The requested concurrency is a hint to the implementation as to the level of concurrency expected by the user; the implementation might use this value to affect the number of LWPs available for running multiplexed threads. thr_create(3thread) with the THR_INCR_CONC flag is another way to control concurrency.

Parameters


new_level
the requested level of concurrency

new_level parameter

new_level must be a non-negative integer. thr_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''. In this implementation, if an LWP is inactive for a certain length of time, it will terminate itself if:

Usage

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. thr_setconcurrency permits the application to give the Threads Library a hint about the desired level of concurrency.

Return values

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

Errors

If the following condition is detected, thr_setconcurrency returns the corresponding value:

EINVAL
new_level is negative.

References

Intro(3thread), thr_create(3thread), thr_getconcurrency(3thread)

Notices

The creation or termination of LWPs is not synchronous with the call to thr_setconcurrency. If new_level causes a system limit to be exceeded no error is returned.

The Threads Library will always ensure that an LWP is available to run multiplexed threads.


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004