Print this page
11586 NAME field in man pages should match what's installed
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man3c/pthread_attr_get_np.3c
+++ new/usr/src/man/man3c/pthread_attr_get_np.3c
1 1 .\"
2 2 .\" This file and its contents are supplied under the terms of the
3 3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
4 4 .\" You may only use this file in accordance with the terms of version
5 5 .\" 1.0 of the CDDL.
6 6 .\"
7 7 .\" A full copy of the text of the CDDL should have accompanied this
8 8 .\" source. A copy of the CDDL is also available via the Internet at
9 9 .\" http://www.illumos.org/license/CDDL.
10 10 .\"
11 11 .\"
12 12 .\" Copyright 2016 Joyent, Inc.
13 13 .\"
14 -.Dd Feb 07, 2015
14 +.Dd Aug 20, 2019
15 15 .Dt PTHREAD_ATTR_GET_NP 3C
16 16 .Os
17 17 .Sh NAME
18 18 .Nm pthread_attr_get_np
19 19 .Nd get pthread attributes of a running thread
20 20 .Sh SYNOPSIS
21 21 .In pthread.h
22 22 .Ft int
23 23 .Fo pthread_attr_get_np
24 24 .Fa "pthread_t thread"
25 25 .Fa "pthread_attr_t *attr"
26 26 .Fc
27 27 .Sh DESCRIPTION
28 28 The
29 29 .Fn pthread_attr_get_np
30 30 function provides a way to get the attributes of the thread
31 31 .Fa thread
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
32 32 after it has been created.
33 33 This function is most commonly used to obtain the actual location and size of a
34 34 thread's stack.
35 35 .Pp
36 36 The attributes pointer,
37 37 .Fa attr ,
38 38 will be filled in with the current attributes for the thread.
39 39 The attributes should be allocated by a call to
40 40 .Xr pthread_attr_init 3C
41 41 prior to calling the
42 -.Fn pthrad_attr_get_np
42 +.Fn pthread_attr_get_np
43 43 function.
44 44 When
45 45 .Fa attr
46 46 is done being used, it should be destroyed through a call to
47 47 .Xr pthread_attr_destroy 3C .
48 48 .Pp
49 49 The attributes of the thread
50 50 .Fa thread
51 51 will be the same as those passed in at the time
52 52 .Xr pthread_create 3C
53 53 was called (or the default set if none were specified), except that the
54 54 following values will be updated:
55 55 .Bl -tag -width Sy
56 56 .It Sy Thread Stack Size
57 57 If no explicit stack size was specified, then
58 58 .Fa attr
59 59 will contain the actual size of the stack.
60 60 .Pp
61 61 If the size of the stack was specified, then it may have been changed to
62 62 ensure that the required alignment of the platform is satisfied.
63 63 .It Sy The Stack Address
64 64 If no stack address was specified, then
65 65 .Fa attr
66 66 will contain the actual address of the stack that the system allocated
67 67 for the thread.
68 68 .It Sy Thread Detach State
69 69 The detach state, whether or not the thread may be joined by a call to
70 70 .Xr pthread_join 3C ,
71 71 may have changed since the process was created due to a call to
72 72 .Xr pthread_detach 3C .
73 73 .Fa attr
74 74 will reflect the current setting of
75 75 .Fa thread .
76 76 .It Sy Thread Scheduling Parameter
77 77 The scheduling parameter attribute will be updated with the current
78 78 scheduling parameter of
79 79 .Fa thread .
80 80 This is the same information as available through
81 81 .Xr pthread_getschedparam 3C
82 82 and it is the preferred interface for obtaining that information.
83 83 .It Sy Thread Scheduling Policy
84 84 The scheduling policy attribute of
85 85 .Fa attr
86 86 will be updated with the current scheduling policy being applied to the
87 87 thread.
88 88 This may have changed, for example, due to a call to
89 89 .Xr pthread_setschedparam 3C .
90 90 As with the thread's scheduling parameter, the preferred interface for
91 91 obtaining this information is by using
92 92 .Xr pthread_getschedparam 3C .
93 93 .It Sy Thread Guard Size
94 94 The value of the guard size attribute for the thread will be updated to
95 95 reflect the actual size of the guard installed for
96 96 .Fa thread .
97 97 For more information on the guard size of a thread and its purpose, see
98 98 .Xr pthread_attr_getguardsize 3C .
99 99 .El
100 100 .Sh RETURN VALUES
101 101 Upon successful completion, the
102 102 .Fn pthread_attr_get_np
103 103 and
104 104 .Fn pthread_getattr_np
105 105 functions return
106 106 .Sy 0 .
107 107 Otherwise, an error number is returned to indicate the error.
108 108 .Sh EXAMPLES
109 109 The following program demonstrates how to use these functions to get
110 110 the location and stack size of a newly created thread.
111 111 .Bd -literal
112 112 #include <assert.h>
113 113 #include <errno.h>
114 114 #include <pthread.h>
115 115 #include <stdio.h>
116 116 #include <stdlib.h>
117 117 #include <string.h>
118 118
119 119 static pthread_t g_thr;
120 120
121 121 void *
122 122 print_stackinfo(void *arg)
123 123 {
124 124 int ret;
125 125 pthread_attr_t attr;
126 126 pthread_t *thrp = arg;
127 127 void *stk;
128 128 size_t stksize;
129 129
130 130 if (pthread_attr_init(&attr) != 0) {
131 131 fprintf(stderr, "failed to init attr: %s\\n",
132 132 strerror(errno));
133 133 exit(1);
134 134 }
135 135
136 136 if (pthread_attr_get_np(*thrp, &attr) != 0) {
137 137 fprintf(stderr, "failed to get thread attributes: %s\\n",
138 138 strerror(errno));
139 139 exit(1);
140 140 }
141 141
142 142 ret = pthread_attr_getstackaddr(&attr, &stk);
143 143 assert(ret == 0);
144 144 ret = pthread_attr_getstacksize(&attr, &stksize);
145 145 assert(ret == 0);
146 146 (void) printf("stack base is at %p, it is %d bytes large\\n",
147 147 stk, stksize);
148 148 return (NULL);
149 149 }
150 150
151 151 int
152 152 main(void)
153 153 {
154 154 int ret;
155 155
156 156 if ((ret = pthread_create(&g_thr, NULL, print_stackinfo,
157 157 &g_thr) != 0)) {
158 158 fprintf(stderr, "failed to create a thread: %s\\n",
159 159 strerror(errno));
160 160 exit(1);
161 161 }
162 162
163 163 pthread_join(g_thr, NULL);
164 164 return (0);
165 165 }
166 166 .Ed
167 167 .Sh ERRORS
168 168 The
169 169 .Fn pthread_attr_get_np
170 170 function will fail if:
171 171 .Bl -tag -width Er
172 172 .It Er EINVAL
173 173 The pthread_attr_t object
174 174 .Fa attr
175 175 was not properly initialized with a call to
176 176 .Xr pthread_attr_init 3C .
177 177 .It Er ESRCH
178 178 No thread could be found corresponding to the specified thread ID,
179 179 .Fa thread .
180 180 .El
181 181 .Sh INTERFACE STABILITY
182 182 .Sy Committed
183 183 .Sh MT-LEVEL
184 184 .Sy MT-Safe
185 185 .Sh SEE ALSO
186 186 .Xr pthread_attr_destroy 3C ,
187 187 .Xr pthread_attr_getdetachstate 3C ,
188 188 .Xr pthread_attr_getguardsize 3C ,
189 189 .Xr pthread_attr_getinheritsched 3C ,
190 190 .Xr pthread_attr_getschedparam 3C ,
191 191 .Xr pthread_attr_getschedpolicy 3C ,
192 192 .Xr pthread_attr_getscope 3C ,
193 193 .Xr pthread_attr_getstackaddr 3C ,
194 194 .Xr pthread_attr_getstacksize 3C ,
195 195 .Xr pthread_attr_init 3C ,
196 196 .Xr pthread_create 3C ,
197 197 .Xr pthread_detach 3C ,
198 198 .Xr pthread_getschedparam 3C ,
199 199 .Xr pthread_setschedparam 3C ,
200 200 .Xr attributes 5 ,
201 201 .Xr threads 5
↓ open down ↓ |
149 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX