1 .\" Copyright (c) 2009 Michael Kerrisk, <mtk.manpages@gmail.com>
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH PTHREAD_SETCONCURRENCY 3 2014-05-23 "Linux" "Linux Programmer's Manual"
27 pthread_setconcurrency, pthread_getconcurrency \- set/get
31 .B #include <pthread.h>
33 .BI "int pthread_setconcurrency(int " new_level );
34 .BI "int pthread_getconcurrency(void);
36 Compile and link with \fI\-pthread\fP.
40 .BR pthread_setconcurrency ()
41 function informs the implementation of the application's
42 desired concurrency level, specified in
44 The implementation takes this only as a hint:
45 POSIX.1 does not specify the level of concurrency that
46 should be provided as a result of calling
47 .BR pthread_setconcurrency ().
51 as 0 instructs the implementation to manage the concurrency level
52 as it deems appropriate.
54 .BR pthread_getconcurrency ()
55 returns the current value of the concurrency level for this process.
58 .BR pthread_setconcurrency ()
60 on error, it returns a nonzero error number.
62 .BR pthread_getconcurrency ()
63 always succeeds, returning the concurrency level set by a previous call to
64 .BR pthread_setconcurrency (),
66 .BR pthread_setconcurrency ()
67 has not previously been called.
69 .BR pthread_setconcurrency ()
70 can fail with the following error:
76 POSIX.1-2001 also documents an
78 error ("the value specified by
80 would cause a system resource to be exceeded").
82 These functions are available in glibc since version 2.1.
84 .SS Multithreading (see pthreads(7))
86 .BR pthread_setconcurrency ()
88 .BR pthread_getconcurrency ()
89 functions are thread-safe.
93 The default concurrency level is 0.
95 Concurrency levels are meaningful only for M:N threading implementations,
96 where at any moment a subset of a process's set of user-level threads
97 may be bound to a smaller number of kernel-scheduling entities.
98 Setting the concurrency level allows the application to
99 give the system a hint as to the number of kernel-scheduling entities
100 that should be provided for efficient execution of the application.
102 Both LinuxThreads and NPTL are 1:1 threading implementations,
103 so setting the concurrency level has no meaning.
105 on Linux these functions merely exist for compatibility with other systems,
106 and they have no effect on the execution of a program.
108 .BR pthread_attr_setscope (3),