1PTHREAD_GETCONCURRENCY(3P) POSIX Programmer's ManualPTHREAD_GETCONCURRENCY(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 pthread_getconcurrency, pthread_setconcurrency — get and set the level
13 of concurrency
14
16 #include <pthread.h>
17
18 int pthread_getconcurrency(void);
19 int pthread_setconcurrency(int new_level);
20
22 Unbound threads in a process may or may not be required to be simulta‐
23 neously active. By default, the threads implementation ensures that a
24 sufficient number of threads are active so that the process can con‐
25 tinue to make progress. While this conserves system resources, it may
26 not produce the most effective level of concurrency.
27
28 The pthread_setconcurrency() function allows an application to inform
29 the threads implementation of its desired concurrency level, new_level.
30 The actual level of concurrency provided by the implementation as a
31 result of this function call is unspecified.
32
33 If new_level is zero, it causes the implementation to maintain the con‐
34 currency level at its discretion as if pthread_setconcurrency() had
35 never been called.
36
37 The pthread_getconcurrency() function shall return the value set by a
38 previous call to the pthread_setconcurrency() function. If the
39 pthread_setconcurrency() function was not previously called, this func‐
40 tion shall return zero to indicate that the implementation is maintain‐
41 ing the concurrency level.
42
43 A call to pthread_setconcurrency() shall inform the implementation of
44 its desired concurrency level. The implementation shall use this as a
45 hint, not a requirement.
46
47 If an implementation does not support multiplexing of user threads on
48 top of several kernel-scheduled entities, the pthread_setconcurrency()
49 and pthread_getconcurrency() functions are provided for source code
50 compatibility but they shall have no effect when called. To maintain
51 the function semantics, the new_level parameter is saved when
52 pthread_setconcurrency() is called so that a subsequent call to
53 pthread_getconcurrency() shall return the same value.
54
56 If successful, the pthread_setconcurrency() function shall return zero;
57 otherwise, an error number shall be returned to indicate the error.
58
59 The pthread_getconcurrency() function shall always return the concur‐
60 rency level set by a previous call to pthread_setconcurrency(). If the
61 pthread_setconcurrency() function has never been called, pthread_get‐
62 concurrency() shall return zero.
63
65 The pthread_setconcurrency() function shall fail if:
66
67 EINVAL The value specified by new_level is negative.
68
69 EAGAIN The value specified by new_level would cause a system resource
70 to be exceeded.
71
72 The pthread_setconcurrency() function shall not return an error code of
73 [EINTR].
74
75 The following sections are informative.
76
78 None.
79
81 Application developers should note that an implementation can always
82 ignore any calls to pthread_setconcurrency() and return a constant for
83 pthread_getconcurrency(). For this reason, it is not recommended that
84 portable applications use this function.
85
87 None.
88
90 These functions may be removed in a future version.
91
93 The Base Definitions volume of POSIX.1‐2017, <pthread.h>
94
96 Portions of this text are reprinted and reproduced in electronic form
97 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
98 table Operating System Interface (POSIX), The Open Group Base Specifi‐
99 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
100 Electrical and Electronics Engineers, Inc and The Open Group. In the
101 event of any discrepancy between this version and the original IEEE and
102 The Open Group Standard, the original IEEE and The Open Group Standard
103 is the referee document. The original Standard can be obtained online
104 at http://www.opengroup.org/unix/online.html .
105
106 Any typographical or formatting errors that appear in this page are
107 most likely to have been introduced during the conversion of the source
108 files to man page format. To report such errors, see https://www.ker‐
109 nel.org/doc/man-pages/reporting_bugs.html .
110
111
112
113IEEE/The Open Group 2017 PTHREAD_GETCONCURRENCY(3P)