1pthread_getconcurrency(3C)Standard C Library Functionspthread_getconcurrency(3C)
2
3
4
6 pthread_getconcurrency, pthread_setconcurrency - get or set level of
7 concurrency
8
10 cc -mt [ flag... ] file... -lpthread [ library... ]
11 #include <pthread.h>
12
13 int pthread_getconcurrency(void);
14
15
16 int pthread_setconcurrency(int new_level);
17
18
20 Unbound threads in a process may or may not be required to be simulta‐
21 neously active. By default, the threads implementation ensures that a
22 sufficient number of threads are active so that the process can con‐
23 tinue to make progress. While this conserves system resources, it may
24 not produce the most effective level of concurrency.
25
26
27 The pthread_setconcurrency() function allows an application to inform
28 the threads implementation of its desired concurrency level, new_level.
29 The actual level of concurrency provided by the implementation as a
30 result of this function call is unspecified.
31
32
33 If new_level is 0, it causes the implementation to maintain the con‐
34 currency level at its discretion as if pthread_setconcurrency() was
35 never called.
36
37
38 The pthread_getconcurrency() function returns the value set by a pre‐
39 vious call to the pthread_setconcurrency() function. If the
40 pthread_setconcurrency() function was not previously called, this func‐
41 tion returns 0 to indicate that the implementation is maintaining the
42 concurrency level.
43
44
45 When an application calls pthread_setconcurrency() it is informing the
46 implementation of its desired concurrency level. The implementation
47 uses this as a hint, not a requirement.
48
49
50 If an implementation does not support multiplexing of user threads on
51 top of several kernel scheduled entities, the pthread_setconcurrency()
52 and pthread_getconcurrency() functions will be provided for source
53 code compatibility but they will have no effect when called. To main‐
54 tain the function semantics, the new_level parameter will be saved when
55 pthread_setconcurrency() is called so that a subsequent call to
56 pthread_getconcurrency() returns the same value.
57
59 If successful, the pthread_setconcurrency() function returns 0. Oth‐
60 erwise, an error number is returned to indicate the error.
61
62
63 The pthread_getconcurrency() function always returns the concurrency
64 level set by a previous call to pthread_setconcurrency(). If the
65 pthread_setconcurrency() function has never been called, pthread_get‐
66 concurrency() returns 0.
67
69 The pthread_setconcurrency() function will fail if:
70
71 EINVAL The value specified by new_level is negative.
72
73
74 EAGAIN The value specific by new_level would cause a system resource
75 to be exceeded.
76
77
79 See attributes(5) for descriptions of the following attributes:
80
81
82
83
84 ┌─────────────────────────────┬─────────────────────────────┐
85 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
86 ├─────────────────────────────┼─────────────────────────────┤
87 │Interface Stability │Standard │
88 ├─────────────────────────────┼─────────────────────────────┤
89 │MT-Level │MT-Safe │
90 └─────────────────────────────┴─────────────────────────────┘
91
93 pthread_create(3C), pthread_attr_init(3C), attributes(5), standards(5)
94
95
96
97SunOS 5.11 23 Mar 2005 pthread_getconcurrency(3C)