Debian Codegraph @

upstream/debian-trixie/man3/pthread_setconcurrency.3

raw
1 '\" t
2 .\" Copyright (c) 2009 Michael Kerrisk, <[email protected]>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH pthread_setconcurrency 3 2024-05-02 "Linux man-pages 6.9.1"
7 .SH NAME
8 pthread_setconcurrency, pthread_getconcurrency \- set/get
9 the concurrency level
10 .SH LIBRARY
11 POSIX threads library
12 .RI ( libpthread ", " \-lpthread )
13 .SH SYNOPSIS
14 .nf
15 .B #include <pthread.h>
16 .P
17 .BI "int pthread_setconcurrency(int " new_level );
18 .BI "int pthread_getconcurrency(" void );
19 .fi
20 .SH DESCRIPTION
21 The
22 .BR pthread_setconcurrency ()
23 function informs the implementation of the application's
24 desired concurrency level, specified in
25 .IR new_level .
26 The implementation takes this only as a hint:
27 POSIX.1 does not specify the level of concurrency that
28 should be provided as a result of calling
29 .BR pthread_setconcurrency ().
30 .P
31 Specifying
32 .I new_level
33 as 0 instructs the implementation to manage the concurrency level
34 as it deems appropriate.
35 .P
36 .BR pthread_getconcurrency ()
37 returns the current value of the concurrency level for this process.
38 .SH RETURN VALUE
39 On success,
40 .BR pthread_setconcurrency ()
41 returns 0;
42 on error, it returns a nonzero error number.
43 .P
44 .BR pthread_getconcurrency ()
45 always succeeds, returning the concurrency level set by a previous call to
46 .BR pthread_setconcurrency (),
47 or 0, if
48 .BR pthread_setconcurrency ()
49 has not previously been called.
50 .SH ERRORS
51 .BR pthread_setconcurrency ()
52 can fail with the following error:
53 .TP
54 .B EINVAL
55 .I new_level
56 is negative.
57 .P
58 POSIX.1 also documents an
59 .B EAGAIN
60 error ("the value specified by
61 .I new_level
62 would cause a system resource to be exceeded").
63 .SH ATTRIBUTES
64 For an explanation of the terms used in this section, see
65 .BR attributes (7).
66 .TS
67 allbox;
68 lbx lb lb
69 l l l.
70 Interface Attribute Value
71 T{
72 .na
73 .nh
74 .BR pthread_setconcurrency (),
75 .BR pthread_getconcurrency ()
76 T} Thread safety MT-Safe
77 .TE
78 .SH STANDARDS
79 POSIX.1-2008.
80 .SH HISTORY
81 glibc 2.1.
82 POSIX.1-2001.
83 .SH NOTES
84 The default concurrency level is 0.
85 .P
86 Concurrency levels are meaningful only for M:N threading implementations,
87 where at any moment a subset of a process's set of user-level threads
88 may be bound to a smaller number of kernel-scheduling entities.
89 Setting the concurrency level allows the application to
90 give the system a hint as to the number of kernel-scheduling entities
91 that should be provided for efficient execution of the application.
92 .P
93 Both LinuxThreads and NPTL are 1:1 threading implementations,
94 so setting the concurrency level has no meaning.
95 In other words,
96 on Linux these functions merely exist for compatibility with other systems,
97 and they have no effect on the execution of a program.
98 .SH SEE ALSO
99 .BR pthread_attr_setscope (3),
100 .BR pthreads (7)