OSDN Git Service

cd33633193cdc81a172e8cc178cd5167a2ff026d
[linuxjm/LDP_man-pages.git] / original / man3 / pthread_setconcurrency.3
1 .\" Copyright (c) 2009 Michael Kerrisk, <mtk.manpages@gmail.com>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .TH PTHREAD_SETCONCURRENCY 3 2009-04-10 "Linux" "Linux Programmer's Manual"
24 .SH NAME
25 pthread_setconcurrency, pthread_getconcurrency \- set/get
26 the concurrency level
27 .SH SYNOPSIS
28 .nf
29 .B #include <pthread.h>
30
31 .BI "int pthread_setconcurrency(int " new_level );
32 .BI "int pthread_getconcurrency(void);
33 .sp
34 Compile and link with \fI\-pthread\fP.
35 .SH DESCRIPTION
36 The
37 .BR pthread_setconcurrency ()
38 function informs the implementation of the application's
39 desired concurrency level, specified in
40 .IR new_level .
41 The implementation only takes this as a hint:
42 POSIX.1 does not specify the level of concurrency that
43 should be provided as a result of calling
44 .BR pthread_setconcurrency ().
45
46 Specifying
47 .I new_level
48 as 0 instructs the implementation to manage the concurrency level
49 as it deems appropriate.
50
51 .BR pthread_getconcurrency ()
52 returns the current value of the concurrency level for this process.
53 .SH RETURN VALUE
54 On success,
55 .BR pthread_setconcurrency ()
56 returns 0;
57 on error, it returns a nonzero error number.
58
59 .BR pthread_getconcurrency ()
60 always succeeds, returning the concurrency level set by a previous call to
61 .BR pthread_setconcurrency (),
62 or 0, if
63 .BR pthread_setconcurrency ()
64 has not previously been called.
65 .SH ERRORS
66 .BR pthread_setconcurrency ()
67 can fail with the following error:
68 .TP
69 .B EINVAL
70 .I new_level
71 is negative.
72 .PP
73 POSIX.1-2001 also documents an
74 .BR EAGAIN
75 error ("the value specified by
76 .I new_level
77 would cause a system resource to be exceeded").
78 .SH VERSIONS
79 These functions are available in glibc since version 2.1.
80 .SH CONFORMING TO
81 POSIX.1-2001.
82 .SH NOTES
83 The default concurrency level is 0.
84
85 Concurrency levels are only meaningful for M:N threading implementations,
86 where at any moment a subset of a process's set of user-level threads
87 may be bound to a smaller number of kernel-scheduling entities.
88 Setting the concurrency level allows the application to
89 give the system a hint as to the number of kernel-scheduling entities
90 that should be provided for efficient execution of the application.
91
92 Both LinuxThreads and NPTL are 1:1 threading implementations,
93 so setting the concurrency level has no meaning.
94 In other words,
95 on Linux these functions merely exist for compatibility with other systems,
96 and they have no effect on the execution of a program.
97 .SH SEE ALSO
98 .BR pthread_attr_setscope (3),
99 .BR pthreads (7)