OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / 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 2014-05-23 "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
33 .BI "int pthread_setconcurrency(int " new_level );
34 .BI "int pthread_getconcurrency(void);
35 .sp
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
49 Specifying
50 .I new_level
51 as 0 instructs the implementation to manage the concurrency level
52 as it deems appropriate.
53
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
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-2001 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 .SS Multithreading (see pthreads(7))
85 The
86 .BR pthread_setconcurrency ()
87 and
88 .BR pthread_getconcurrency ()
89 functions are thread-safe.
90 .SH CONFORMING TO
91 POSIX.1-2001.
92 .SH NOTES
93 The default concurrency level is 0.
94
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.
101
102 Both LinuxThreads and NPTL are 1:1 threading implementations,
103 so setting the concurrency level has no meaning.
104 In other words,
105 on Linux these functions merely exist for compatibility with other systems,
106 and they have no effect on the execution of a program.
107 .SH SEE ALSO
108 .BR pthread_attr_setscope (3),
109 .BR pthreads (7)
110 .SH COLOPHON
111 This page is part of release 3.79 of the Linux
112 .I man-pages
113 project.
114 A description of the project,
115 information about reporting bugs,
116 and the latest version of this page,
117 can be found at
118 \%http://www.kernel.org/doc/man\-pages/.