# pthread_getconcurrency

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## NAME



           pthread_getconcurrency, pthread_setconcurrency — get and set the
           level of concurrency
    


## SYNOPSIS



           #include <pthread.h>
    
           int pthread_getconcurrency(void);
           int pthread_setconcurrency(int _new_level_);
    


## DESCRIPTION



           Unbound threads in a process may or may not be required to be
           simultaneously active. By default, the threads implementation
           ensures that a sufficient number of threads are active so that the
           process can continue to make progress. While this conserves system
           resources, it may not produce the most effective level of
           concurrency.
    
           The _pthread_setconcurrency_() function allows an application to
           inform the threads implementation of its desired concurrency
           level, _new_level_.  The actual level of concurrency provided by the
           implementation as a result of this function call is unspecified.
    
           If _new_level_ is zero, it causes the implementation to maintain the
           concurrency level at its discretion as if _pthread_setconcurrency_()
           had never been called.
    
           The _pthread_getconcurrency_() function shall return the value set
           by a previous call to the _pthread_setconcurrency_() function. If
           the _pthread_setconcurrency_() function was not previously called,
           this function shall return zero to indicate that the
           implementation is maintaining the concurrency level.
    
           A call to _pthread_setconcurrency_() shall inform the implementation
           of its desired concurrency level.  The implementation shall use
           this as a hint, not a requirement.
    
           If an implementation does not support multiplexing of user threads
           on top of several kernel-scheduled entities, the
           _pthread_setconcurrency_() and _pthread_getconcurrency_() functions
           are provided for source code compatibility but they shall have no
           effect when called. To maintain the function semantics, the
           _new_level_ parameter is saved when _pthread_setconcurrency_() is
           called so that a subsequent call to _pthread_getconcurrency_() shall
           return the same value.
    


## RETURN VALUE



           If successful, the _pthread_setconcurrency_() function shall return
           zero; otherwise, an error number shall be returned to indicate the
           error.
    
           The _pthread_getconcurrency_() function shall always return the
           concurrency level set by a previous call to
           _pthread_setconcurrency_().  If the _pthread_setconcurrency_()
           function has never been called, _pthread_getconcurrency_() shall
           return zero.
    


## ERRORS



           The _pthread_setconcurrency_() function shall fail if:
    
           **EINVAL** The value specified by _new_level_ is negative.
    
           **EAGAIN** The value specified by _new_level_ would cause a system
                  resource to be exceeded.
    
           The _pthread_setconcurrency_() function shall not return an error
           code of **[EINTR]**.
    
           _The following sections are informative._
    


## EXAMPLES



           None.
    


## APPLICATION USAGE



           Application developers should note that an implementation can
           always ignore any calls to _pthread_setconcurrency_() and return a
           constant for _pthread_getconcurrency_().  For this reason, it is not
           recommended that portable applications use this function.
    


## RATIONALE



           None.
    


## FUTURE DIRECTIONS



           These functions may be removed in a future version.
    


* * *