1PTHREAD_SETCONCURRENCY(3) Linux Programmer's Manual PTHREAD_SETCONCURRENCY(3)
2
3
4
6 pthread_setconcurrency, pthread_getconcurrency - set/get the concur‐
7 rency level
8
10 #include <pthread.h>
11
12 int pthread_setconcurrency(int new_level);
13 int pthread_getconcurrency(void);
14
15 Compile and link with -pthread.
16
18 The pthread_setconcurrency() function informs the implementation of the
19 application's desired concurrency level, specified in new_level. The
20 implementation takes this only as a hint: POSIX.1 does not specify the
21 level of concurrency that should be provided as a result of calling
22 pthread_setconcurrency().
23
24 Specifying new_level as 0 instructs the implementation to manage the
25 concurrency level as it deems appropriate.
26
27 pthread_getconcurrency() returns the current value of the concurrency
28 level for this process.
29
31 On success, pthread_setconcurrency() returns 0; on error, it returns a
32 nonzero error number.
33
34 pthread_getconcurrency() always succeeds, returning the concurrency
35 level set by a previous call to pthread_setconcurrency(), or 0, if
36 pthread_setconcurrency() has not previously been called.
37
39 pthread_setconcurrency() can fail with the following error:
40
41 EINVAL new_level is negative.
42
43 POSIX.1 also documents an EAGAIN error ("the value specified by
44 new_level would cause a system resource to be exceeded").
45
47 These functions are available in glibc since version 2.1.
48
50 For an explanation of the terms used in this section, see at‐
51 tributes(7).
52
53 ┌────────────────────────────────────────────┬───────────────┬─────────┐
54 │Interface │ Attribute │ Value │
55 ├────────────────────────────────────────────┼───────────────┼─────────┤
56 │pthread_setconcurrency(), │ Thread safety │ MT-Safe │
57 │pthread_getconcurrency() │ │ │
58 └────────────────────────────────────────────┴───────────────┴─────────┘
59
61 POSIX.1-2001, POSIX.1-2008.
62
64 The default concurrency level is 0.
65
66 Concurrency levels are meaningful only for M:N threading implementa‐
67 tions, where at any moment a subset of a process's set of user-level
68 threads may be bound to a smaller number of kernel-scheduling entities.
69 Setting the concurrency level allows the application to give the system
70 a hint as to the number of kernel-scheduling entities that should be
71 provided for efficient execution of the application.
72
73 Both LinuxThreads and NPTL are 1:1 threading implementations, so set‐
74 ting the concurrency level has no meaning. In other words, on Linux
75 these functions merely exist for compatibility with other systems, and
76 they have no effect on the execution of a program.
77
79 pthread_attr_setscope(3), pthreads(7)
80
82 This page is part of release 5.12 of the Linux man-pages project. A
83 description of the project, information about reporting bugs, and the
84 latest version of this page, can be found at
85 https://www.kernel.org/doc/man-pages/.
86
87
88
89Linux 2021-03-22 PTHREAD_SETCONCURRENCY(3)