OSDN Git Service

(split) LDP: Update original to LDP v3.38.
[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 .fi
36 .SH DESCRIPTION
37 The
38 .BR pthread_setconcurrency ()
39 function informs the implementation of the application's
40 desired concurrency level, specified in
41 .IR new_level .
42 The implementation only takes this as a hint:
43 POSIX.1 does not specify the level of concurrency that
44 should be provided as a result of calling
45 .BR pthread_setconcurrency ().
46
47 Specifying
48 .I new_level
49 as 0 instructs the implementation to manage the concurrency level
50 as it deems appropriate.
51
52 .BR pthread_getconcurrency ()
53 returns the current value of the concurrency level for this process.
54 .SH RETURN VALUE
55 On success,
56 .BR pthread_setconcurrency ()
57 returns 0;
58 on error, it returns a nonzero error number.
59
60 .BR pthread_getconcurrency ()
61 always succeeds, returning the concurrency level set by a previous call to
62 .BR pthread_setconcurrency (),
63 or 0, if
64 .BR pthread_setconcurrency ()
65 has not previously been called.
66 .SH ERRORS
67 .BR pthread_setconcurrency ()
68 can fail with the following error:
69 .TP
70 .B EINVAL
71 .I new_level
72 is negative.
73 .PP
74 POSIX.1-2001 also documents an
75 .BR EAGAIN
76 error ("the value specified by
77 .I new_level
78 would cause a system resource to be exceeded").
79 .SH VERSIONS
80 These functions are available in glibc since version 2.1.
81 .SH CONFORMING TO
82 POSIX.1-2001.
83 .SH NOTES
84 The default concurrency level is 0.
85
86 Concurrency levels are only meaningful 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
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)