]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/pthread_setconcurrency.3
share/mk/: distcheck: Run 'check' after 'build'
[thirdparty/man-pages.git] / man3 / pthread_setconcurrency.3
1 .\" Copyright (c) 2009 Michael Kerrisk, <mtk.manpages@gmail.com>
2 .\"
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.
7 .\"
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.
12 .\"
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
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH PTHREAD_SETCONCURRENCY 3 2017-09-15 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 pthread_setconcurrency, pthread_getconcurrency \- set/get
28 the concurrency level
29 .SH SYNOPSIS
30 .nf
31 .B #include <pthread.h>
32 .PP
33 .BI "int pthread_setconcurrency(int " new_level );
34 .BI "int pthread_getconcurrency(void);
35 .PP
36 Compile and link with \fI\-pthread\fP.
37 .fi
38 .SH DESCRIPTION
39 The
40 .BR pthread_setconcurrency ()
41 function informs the implementation of the application's
42 desired concurrency level, specified in
43 .IR new_level .
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 ().
48 .PP
49 Specifying
50 .I new_level
51 as 0 instructs the implementation to manage the concurrency level
52 as it deems appropriate.
53 .PP
54 .BR pthread_getconcurrency ()
55 returns the current value of the concurrency level for this process.
56 .SH RETURN VALUE
57 On success,
58 .BR pthread_setconcurrency ()
59 returns 0;
60 on error, it returns a nonzero error number.
61 .PP
62 .BR pthread_getconcurrency ()
63 always succeeds, returning the concurrency level set by a previous call to
64 .BR pthread_setconcurrency (),
65 or 0, if
66 .BR pthread_setconcurrency ()
67 has not previously been called.
68 .SH ERRORS
69 .BR pthread_setconcurrency ()
70 can fail with the following error:
71 .TP
72 .B EINVAL
73 .I new_level
74 is negative.
75 .PP
76 POSIX.1 also documents an
77 .BR EAGAIN
78 error ("the value specified by
79 .I new_level
80 would cause a system resource to be exceeded").
81 .SH VERSIONS
82 These functions are available in glibc since version 2.1.
83 .SH ATTRIBUTES
84 For an explanation of the terms used in this section, see
85 .BR attributes (7).
86 .TS
87 allbox;
88 lbw25 lb lb
89 l l l.
90 Interface Attribute Value
91 T{
92 .BR pthread_setconcurrency (),
93 .BR pthread_getconcurrency ()
94 T} Thread safety MT-Safe
95 .TE
96 .SH CONFORMING TO
97 POSIX.1-2001, POSIX.1-2008.
98 .SH NOTES
99 The default concurrency level is 0.
100 .PP
101 Concurrency levels are meaningful only for M:N threading implementations,
102 where at any moment a subset of a process's set of user-level threads
103 may be bound to a smaller number of kernel-scheduling entities.
104 Setting the concurrency level allows the application to
105 give the system a hint as to the number of kernel-scheduling entities
106 that should be provided for efficient execution of the application.
107 .PP
108 Both LinuxThreads and NPTL are 1:1 threading implementations,
109 so setting the concurrency level has no meaning.
110 In other words,
111 on Linux these functions merely exist for compatibility with other systems,
112 and they have no effect on the execution of a program.
113 .SH SEE ALSO
114 .BR pthread_attr_setscope (3),
115 .BR pthreads (7)