pthread_setconcurrency(3P)
pthread_setconcurrency, pthread_getconcurrency - modify scheduling concurrency
As shipped in IRIX 6.5.7. Unchanged since IRIX 6.5.
NAME pthread_setconcurrency, pthread_getconcurrency - modify scheduling concurrency C SYNOPSIS #include <pthread.h> int pthread_setconcurrency(int level); int pthread_getconcurrency(void); DESCRIPTION Threads which are created with the PTHREAD_SCOPE_PROCESS attribute (which is the default) [see pthread_attr_setscope()], are scheduled on a number of kernel execution vehicles. By default the number of execution vehicles used is adjusted by the library as the application runs and is called the concurrency level. This is different from the traditional notion of concurrency because it includes any threads blocked by the application in the kernel (for example to do IO). The library raises or lowers the level to maintain a balance between user context switches and CPU bandwidth. An application may choose to give the library a hint as to the best concurrency level by using the pthread_setconcurrency() interface. The level value indicates the concurrency that the application desires. This value will be used to compute the ideal number of execution vehicles for scheduling PTHREAD_SCOPE_PROCESS threads. If level is zero the library reverts to its default mode; adjusting the level itself. The pthread_getconcurrency() interface returns the current concurrency level requested by pthread_setconcurrency() or zero if the default concurrency mode is being used. Concurrency is a matter of performance not correctness; an application will function correctly using the default mode. However the result may be overly conservative in its use of execution vehicles (and therefore CPUs). In this case performance may be improved by setting the concurrency level explicitly. Conversely the library will not permit changes to the concurrency level to create starvation. Should the application set the concurrency level to n and then cause n threads to block in the kernel the library will activate additional execution vehicles as needed to enable other threads to run. In this case the concurrency level is temporarily raised and will eventually return to the requested level. DIAGNOSTICS On success pthread_setconcurrency() returns zero; otherwise an error number is returned: [EINVAL] The value of level is negative. pthread_getconcurrency() returns the current concurrency level (default is zero). SEE ALSO pthread_attr_setscope(3P).