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.man.txt
+++ new/usr/src/man/man3c/pthread_attr_get_np.3c.man.txt
1 1 PTHREAD_ATTR_GET_NP(3C) Standard C Library Functions PTHREAD_ATTR_GET_NP(3C)
2 2
3 3 NAME
4 4 pthread_attr_get_np - get pthread attributes of a running thread
5 5
6 6 SYNOPSIS
7 7 #include <pthread.h>
8 8
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
9 9 int
10 10 pthread_attr_get_np(pthread_t thread, pthread_attr_t *attr);
11 11
12 12 DESCRIPTION
13 13 The pthread_attr_get_np() function provides a way to get the attributes
14 14 of the thread thread after it has been created. This function is most
15 15 commonly used to obtain the actual location and size of a thread's stack.
16 16
17 17 The attributes pointer, attr, will be filled in with the current
18 18 attributes for the thread. The attributes should be allocated by a call
19 - to pthread_attr_init(3C) prior to calling the pthrad_attr_get_np()
19 + to pthread_attr_init(3C) prior to calling the pthread_attr_get_np()
20 20 function. When attr is done being used, it should be destroyed through a
21 21 call to pthread_attr_destroy(3C).
22 22
23 23 The attributes of the thread thread will be the same as those passed in
24 24 at the time pthread_create(3C) was called (or the default set if none
25 25 were specified), except that the following values will be updated:
26 26
27 27 Thread Stack Size
28 28 If no explicit stack size was specified, then attr will contain
29 29 the actual size of the stack.
30 30
31 31 If the size of the stack was specified, then it may have been
32 32 changed to ensure that the required alignment of the platform is
33 33 satisfied.
34 34
35 35 The Stack Address
36 36 If no stack address was specified, then attr will contain the
37 37 actual address of the stack that the system allocated for the
38 38 thread.
39 39
40 40 Thread Detach State
41 41 The detach state, whether or not the thread may be joined by a
42 42 call to pthread_join(3C), may have changed since the process was
43 43 created due to a call to pthread_detach(3C). attr will reflect
44 44 the current setting of thread.
45 45
46 46 Thread Scheduling Parameter
47 47 The scheduling parameter attribute will be updated with the
48 48 current scheduling parameter of thread. This is the same
49 49 information as available through pthread_getschedparam(3C) and it
50 50 is the preferred interface for obtaining that information.
51 51
52 52 Thread Scheduling Policy
53 53 The scheduling policy attribute of attr will be updated with the
54 54 current scheduling policy being applied to the thread. This may
55 55 have changed, for example, due to a call to
56 56 pthread_setschedparam(3C). As with the thread's scheduling
57 57 parameter, the preferred interface for obtaining this information
58 58 is by using pthread_getschedparam(3C).
59 59
60 60 Thread Guard Size
61 61 The value of the guard size attribute for the thread will be
62 62 updated to reflect the actual size of the guard installed for
63 63 thread. For more information on the guard size of a thread and
64 64 its purpose, see pthread_attr_getguardsize(3C).
65 65
66 66 RETURN VALUES
67 67 Upon successful completion, the pthread_attr_get_np() and
68 68 pthread_getattr_np() functions return 0. Otherwise, an error number is
69 69 returned to indicate the error.
70 70
71 71 EXAMPLES
72 72 The following program demonstrates how to use these functions to get the
73 73 location and stack size of a newly created thread.
74 74
75 75 #include <assert.h>
76 76 #include <errno.h>
77 77 #include <pthread.h>
78 78 #include <stdio.h>
79 79 #include <stdlib.h>
80 80 #include <string.h>
81 81
82 82 static pthread_t g_thr;
83 83
84 84 void *
85 85 print_stackinfo(void *arg)
86 86 {
87 87 int ret;
88 88 pthread_attr_t attr;
89 89 pthread_t *thrp = arg;
90 90 void *stk;
91 91 size_t stksize;
92 92
93 93 if (pthread_attr_init(&attr) != 0) {
94 94 fprintf(stderr, "failed to init attr: %s\n",
95 95 strerror(errno));
96 96 exit(1);
97 97 }
98 98
99 99 if (pthread_attr_get_np(*thrp, &attr) != 0) {
100 100 fprintf(stderr, "failed to get thread attributes: %s\n",
101 101 strerror(errno));
102 102 exit(1);
103 103 }
104 104
105 105 ret = pthread_attr_getstackaddr(&attr, &stk);
106 106 assert(ret == 0);
107 107 ret = pthread_attr_getstacksize(&attr, &stksize);
108 108 assert(ret == 0);
109 109 (void) printf("stack base is at %p, it is %d bytes large\n",
110 110 stk, stksize);
111 111 return (NULL);
112 112 }
113 113
114 114 int
115 115 main(void)
116 116 {
117 117 int ret;
118 118
119 119 if ((ret = pthread_create(&g_thr, NULL, print_stackinfo,
120 120 &g_thr) != 0)) {
121 121 fprintf(stderr, "failed to create a thread: %s\n",
122 122 strerror(errno));
123 123 exit(1);
124 124 }
125 125
126 126 pthread_join(g_thr, NULL);
127 127 return (0);
128 128 }
129 129
130 130 ERRORS
131 131 The pthread_attr_get_np() function will fail if:
132 132
133 133 EINVAL The pthread_attr_t object attr was not properly
134 134 initialized with a call to pthread_attr_init(3C).
135 135
136 136 ESRCH No thread could be found corresponding to the
137 137 specified thread ID, thread.
138 138
139 139 INTERFACE STABILITY
140 140 Committed
141 141
142 142 MT-LEVEL
143 143 MT-Safe
↓ open down ↓ |
114 lines elided |
↑ open up ↑ |
144 144
145 145 SEE ALSO
146 146 pthread_attr_destroy(3C), pthread_attr_getdetachstate(3C),
147 147 pthread_attr_getguardsize(3C), pthread_attr_getinheritsched(3C),
148 148 pthread_attr_getschedparam(3C), pthread_attr_getschedpolicy(3C),
149 149 pthread_attr_getscope(3C), pthread_attr_getstackaddr(3C),
150 150 pthread_attr_getstacksize(3C), pthread_attr_init(3C), pthread_create(3C),
151 151 pthread_detach(3C), pthread_getschedparam(3C), pthread_setschedparam(3C),
152 152 attributes(5), threads(5)
153 153
154 -illumos February 7, 2015 illumos
154 +illumos August 20, 2019 illumos
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX