| 1 |
# SOME DESCRIPTIVE TITLE |
| 2 |
# Copyright (C) YEAR Free Software Foundation, Inc. |
| 3 |
# This file is distributed under the same license as the PACKAGE package. |
| 4 |
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 5 |
# |
| 6 |
#, fuzzy |
| 7 |
msgid "" |
| 8 |
msgstr "" |
| 9 |
"Project-Id-Version: PACKAGE VERSION\n" |
| 10 |
"POT-Creation-Date: 2026-06-05 06:38+0200\n" |
| 11 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
| 12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
| 13 |
"Language-Team: LANGUAGE <[email protected]>\n" |
| 14 |
"Language: \n" |
| 15 |
"MIME-Version: 1.0\n" |
| 16 |
"Content-Type: text/plain; charset=UTF-8\n" |
| 17 |
"Content-Transfer-Encoding: 8bit\n" |
| 18 |
|
| 19 |
#. type: TH |
| 20 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 21 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 22 |
#, no-wrap |
| 23 |
msgid "pthread_getattr_np" |
| 24 |
msgstr "" |
| 25 |
|
| 26 |
#. type: TH |
| 27 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 28 |
#: opensuse-tumbleweed |
| 29 |
#, no-wrap |
| 30 |
msgid "2025-09-25" |
| 31 |
msgstr "" |
| 32 |
|
| 33 |
#. type: TH |
| 34 |
#: archlinux debian-unstable |
| 35 |
#, no-wrap |
| 36 |
msgid "Linux man-pages 6.18" |
| 37 |
msgstr "" |
| 38 |
|
| 39 |
#. type: SH |
| 40 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 41 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 42 |
#, no-wrap |
| 43 |
msgid "NAME" |
| 44 |
msgstr "" |
| 45 |
|
| 46 |
#. type: Plain text |
| 47 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 48 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 49 |
msgid "pthread_getattr_np - get attributes of created thread" |
| 50 |
msgstr "" |
| 51 |
|
| 52 |
#. type: SH |
| 53 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 54 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 55 |
#, no-wrap |
| 56 |
msgid "LIBRARY" |
| 57 |
msgstr "" |
| 58 |
|
| 59 |
#. type: Plain text |
| 60 |
#: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron |
| 61 |
#: opensuse-leap-16-1 opensuse-tumbleweed |
| 62 |
msgid "POSIX threads library (I<libpthread>,\\ I<-lpthread>)" |
| 63 |
msgstr "" |
| 64 |
|
| 65 |
#. type: SH |
| 66 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 67 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 68 |
#, no-wrap |
| 69 |
msgid "SYNOPSIS" |
| 70 |
msgstr "" |
| 71 |
|
| 72 |
#. type: Plain text |
| 73 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 74 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 75 |
#, no-wrap |
| 76 |
msgid "" |
| 77 |
"B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n" |
| 78 |
"B<#include E<lt>pthread.hE<gt>>\n" |
| 79 |
msgstr "" |
| 80 |
|
| 81 |
#. type: Plain text |
| 82 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 83 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 84 |
#, no-wrap |
| 85 |
msgid "B<int pthread_getattr_np(pthread_t >I<thread>B<, pthread_attr_t *>I<attr>B<);>\n" |
| 86 |
msgstr "" |
| 87 |
|
| 88 |
#. type: SH |
| 89 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 90 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 91 |
#, no-wrap |
| 92 |
msgid "DESCRIPTION" |
| 93 |
msgstr "" |
| 94 |
|
| 95 |
#. type: Plain text |
| 96 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 97 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 98 |
msgid "" |
| 99 |
"The B<pthread_getattr_np>() function initializes the thread attributes " |
| 100 |
"object referred to by I<attr> so that it contains actual attribute values " |
| 101 |
"describing the running thread I<thread>." |
| 102 |
msgstr "" |
| 103 |
|
| 104 |
#. type: Plain text |
| 105 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 106 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 107 |
msgid "" |
| 108 |
"The returned attribute values may differ from the corresponding attribute " |
| 109 |
"values passed in the I<attr> object that was used to create the thread using " |
| 110 |
"B<pthread_create>(3). In particular, the following attributes may differ:" |
| 111 |
msgstr "" |
| 112 |
|
| 113 |
#. type: IP |
| 114 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 115 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 116 |
#, no-wrap |
| 117 |
msgid "\\[bu]" |
| 118 |
msgstr "" |
| 119 |
|
| 120 |
#. type: Plain text |
| 121 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 122 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 123 |
msgid "" |
| 124 |
"the detach state, since a joinable thread may have detached itself after " |
| 125 |
"creation;" |
| 126 |
msgstr "" |
| 127 |
|
| 128 |
#. type: Plain text |
| 129 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 130 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 131 |
msgid "" |
| 132 |
"the stack size, which the implementation may align to a suitable boundary." |
| 133 |
msgstr "" |
| 134 |
|
| 135 |
#. type: Plain text |
| 136 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 137 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 138 |
msgid "" |
| 139 |
"and the guard size, which the implementation may round upward to a multiple " |
| 140 |
"of the page size, or ignore (i.e., treat as 0), if the application is " |
| 141 |
"allocating its own stack." |
| 142 |
msgstr "" |
| 143 |
|
| 144 |
#. type: Plain text |
| 145 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 146 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 147 |
msgid "" |
| 148 |
"Furthermore, if the stack address attribute was not set in the thread " |
| 149 |
"attributes object used to create the thread, then the returned thread " |
| 150 |
"attributes object will report the actual stack address that the " |
| 151 |
"implementation selected for the thread." |
| 152 |
msgstr "" |
| 153 |
|
| 154 |
#. type: Plain text |
| 155 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 156 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 157 |
msgid "" |
| 158 |
"When the thread attributes object returned by B<pthread_getattr_np>() is no " |
| 159 |
"longer required, it should be destroyed using B<pthread_attr_destroy>(3)." |
| 160 |
msgstr "" |
| 161 |
|
| 162 |
#. type: SH |
| 163 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 164 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 165 |
#, no-wrap |
| 166 |
msgid "RETURN VALUE" |
| 167 |
msgstr "" |
| 168 |
|
| 169 |
#. type: Plain text |
| 170 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 171 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 172 |
msgid "" |
| 173 |
"On success, this function returns 0; on error, it returns a nonzero error " |
| 174 |
"number." |
| 175 |
msgstr "" |
| 176 |
|
| 177 |
#. type: SH |
| 178 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 179 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 180 |
#, no-wrap |
| 181 |
msgid "ERRORS" |
| 182 |
msgstr "" |
| 183 |
|
| 184 |
#. type: TP |
| 185 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 186 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 187 |
#, no-wrap |
| 188 |
msgid "B<ENOMEM>" |
| 189 |
msgstr "" |
| 190 |
|
| 191 |
#. Can happen (but unlikely) while trying to allocate memory for cpuset |
| 192 |
#. type: Plain text |
| 193 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 194 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 195 |
msgid "Insufficient memory." |
| 196 |
msgstr "" |
| 197 |
|
| 198 |
#. type: Plain text |
| 199 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 200 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 201 |
msgid "" |
| 202 |
"In addition, if I<thread> refers to the main thread, then " |
| 203 |
"B<pthread_getattr_np>() can fail because of errors from various underlying " |
| 204 |
"calls: B<fopen>(3), if I</proc/self/maps> can't be opened; and " |
| 205 |
"B<getrlimit>(2), if the B<RLIMIT_STACK> resource limit is not supported." |
| 206 |
msgstr "" |
| 207 |
|
| 208 |
#. type: SH |
| 209 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 210 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 211 |
#, no-wrap |
| 212 |
msgid "ATTRIBUTES" |
| 213 |
msgstr "" |
| 214 |
|
| 215 |
#. type: Plain text |
| 216 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 217 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 218 |
msgid "" |
| 219 |
"For an explanation of the terms used in this section, see B<attributes>(7)." |
| 220 |
msgstr "" |
| 221 |
|
| 222 |
#. type: tbl table |
| 223 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 224 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 225 |
#, no-wrap |
| 226 |
msgid "Interface" |
| 227 |
msgstr "" |
| 228 |
|
| 229 |
#. type: tbl table |
| 230 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 231 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 232 |
#, no-wrap |
| 233 |
msgid "Attribute" |
| 234 |
msgstr "" |
| 235 |
|
| 236 |
#. type: tbl table |
| 237 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 238 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 239 |
#, no-wrap |
| 240 |
msgid "Value" |
| 241 |
msgstr "" |
| 242 |
|
| 243 |
#. type: tbl table |
| 244 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 245 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 246 |
#, no-wrap |
| 247 |
msgid ".na\n" |
| 248 |
msgstr "" |
| 249 |
|
| 250 |
#. type: tbl table |
| 251 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 252 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 253 |
#, no-wrap |
| 254 |
msgid ".nh\n" |
| 255 |
msgstr "" |
| 256 |
|
| 257 |
#. type: tbl table |
| 258 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 259 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 260 |
#, no-wrap |
| 261 |
msgid "B<pthread_getattr_np>()" |
| 262 |
msgstr "" |
| 263 |
|
| 264 |
#. type: tbl table |
| 265 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 266 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 267 |
#, no-wrap |
| 268 |
msgid "Thread safety" |
| 269 |
msgstr "" |
| 270 |
|
| 271 |
#. type: tbl table |
| 272 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 273 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 274 |
#, no-wrap |
| 275 |
msgid "MT-Safe" |
| 276 |
msgstr "" |
| 277 |
|
| 278 |
#. type: SH |
| 279 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 280 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 281 |
#, no-wrap |
| 282 |
msgid "STANDARDS" |
| 283 |
msgstr "" |
| 284 |
|
| 285 |
#. type: Plain text |
| 286 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 287 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 288 |
msgid "GNU; hence the suffix \"_np\" (nonportable) in the name." |
| 289 |
msgstr "" |
| 290 |
|
| 291 |
#. type: SH |
| 292 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 293 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 294 |
#, no-wrap |
| 295 |
msgid "HISTORY" |
| 296 |
msgstr "" |
| 297 |
|
| 298 |
#. type: Plain text |
| 299 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 300 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 301 |
msgid "glibc 2.2.3." |
| 302 |
msgstr "" |
| 303 |
|
| 304 |
#. type: SH |
| 305 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 306 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 307 |
#, no-wrap |
| 308 |
msgid "EXAMPLES" |
| 309 |
msgstr "" |
| 310 |
|
| 311 |
#. type: Plain text |
| 312 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 313 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 314 |
msgid "" |
| 315 |
"The program below demonstrates the use of B<pthread_getattr_np>(). The " |
| 316 |
"program creates a thread that then uses B<pthread_getattr_np>() to retrieve " |
| 317 |
"and display its guard size, stack address, and stack size attributes. " |
| 318 |
"Command-line arguments can be used to set these attributes to values other " |
| 319 |
"than the default when creating the thread. The shell sessions below " |
| 320 |
"demonstrate the use of the program." |
| 321 |
msgstr "" |
| 322 |
|
| 323 |
#. type: Plain text |
| 324 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 325 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 326 |
msgid "" |
| 327 |
"In the first run, on an x86-32 system, a thread is created using default " |
| 328 |
"attributes:" |
| 329 |
msgstr "" |
| 330 |
|
| 331 |
#. type: Plain text |
| 332 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 333 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 334 |
#, no-wrap |
| 335 |
msgid "" |
| 336 |
"$B< ulimit -s> # No stack limit ==E<gt> default stack size is 2 MB\n" |
| 337 |
"unlimited\n" |
| 338 |
"$B< ./a.out>\n" |
| 339 |
"Attributes of created thread:\n" |
| 340 |
" Guard size = 4096 bytes\n" |
| 341 |
" Stack address = 0x40196000 (EOS = 0x40397000)\n" |
| 342 |
" Stack size = 0x201000 (2101248) bytes\n" |
| 343 |
msgstr "" |
| 344 |
|
| 345 |
#. type: Plain text |
| 346 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 347 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 348 |
msgid "" |
| 349 |
"In the following run, we see that if a guard size is specified, it is " |
| 350 |
"rounded up to the next multiple of the system page size (4096 bytes on " |
| 351 |
"x86-32):" |
| 352 |
msgstr "" |
| 353 |
|
| 354 |
#. type: Plain text |
| 355 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 356 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 357 |
#, no-wrap |
| 358 |
msgid "" |
| 359 |
"$B< ./a.out -g 4097>\n" |
| 360 |
"Thread attributes object after initializations:\n" |
| 361 |
" Guard size = 4097 bytes\n" |
| 362 |
" Stack address = (nil)\n" |
| 363 |
" Stack size = 0x0 (0) bytes\n" |
| 364 |
"\\&\n" |
| 365 |
"Attributes of created thread:\n" |
| 366 |
" Guard size = 8192 bytes\n" |
| 367 |
" Stack address = 0x40196000 (EOS = 0x40397000)\n" |
| 368 |
" Stack size = 0x201000 (2101248) bytes\n" |
| 369 |
msgstr "" |
| 370 |
|
| 371 |
#. type: Plain text |
| 372 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 373 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 374 |
msgid "" |
| 375 |
"In the last run, the program manually allocates a stack for the thread. In " |
| 376 |
"this case, the guard size attribute is ignored." |
| 377 |
msgstr "" |
| 378 |
|
| 379 |
#. type: Plain text |
| 380 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 381 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 382 |
#, no-wrap |
| 383 |
msgid "" |
| 384 |
"$B< ./a.out -g 4096 -s 0x8000 -a>\n" |
| 385 |
"Allocated thread stack at 0x804d000\n" |
| 386 |
"\\&\n" |
| 387 |
"Thread attributes object after initializations:\n" |
| 388 |
" Guard size = 4096 bytes\n" |
| 389 |
" Stack address = 0x804d000 (EOS = 0x8055000)\n" |
| 390 |
" Stack size = 0x8000 (32768) bytes\n" |
| 391 |
"\\&\n" |
| 392 |
"Attributes of created thread:\n" |
| 393 |
" Guard size = 0 bytes\n" |
| 394 |
" Stack address = 0x804d000 (EOS = 0x8055000)\n" |
| 395 |
" Stack size = 0x8000 (32768) bytes\n" |
| 396 |
msgstr "" |
| 397 |
|
| 398 |
#. type: SS |
| 399 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 400 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 401 |
#, no-wrap |
| 402 |
msgid "Program source" |
| 403 |
msgstr "" |
| 404 |
|
| 405 |
#. type: Plain text |
| 406 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 407 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 408 |
#, no-wrap |
| 409 |
msgid "" |
| 410 |
"#define _GNU_SOURCE /* To get pthread_getattr_np() declaration */\n" |
| 411 |
"#include E<lt>err.hE<gt>\n" |
| 412 |
"#include E<lt>errno.hE<gt>\n" |
| 413 |
"#include E<lt>pthread.hE<gt>\n" |
| 414 |
"#include E<lt>stdio.hE<gt>\n" |
| 415 |
"#include E<lt>stdlib.hE<gt>\n" |
| 416 |
"#include E<lt>unistd.hE<gt>\n" |
| 417 |
"\\&\n" |
| 418 |
"static void\n" |
| 419 |
"display_stack_related_attributes(pthread_attr_t *attr, char *prefix)\n" |
| 420 |
"{\n" |
| 421 |
" int s;\n" |
| 422 |
" size_t stack_size, guard_size;\n" |
| 423 |
" void *stack_addr;\n" |
| 424 |
"\\&\n" |
| 425 |
" s = pthread_attr_getguardsize(attr, &guard_size);\n" |
| 426 |
" if (s != 0)\n" |
| 427 |
" errc(EXIT_FAILURE, s, \"pthread_attr_getguardsize\");\n" |
| 428 |
" printf(\"%sGuard size = %zu bytes\\[rs]n\", prefix, guard_size);\n" |
| 429 |
"\\&\n" |
| 430 |
" s = pthread_attr_getstack(attr, &stack_addr, &stack_size);\n" |
| 431 |
" if (s != 0)\n" |
| 432 |
" errc(EXIT_FAILURE, s, \"pthread_attr_getstack\");\n" |
| 433 |
" printf(\"%sStack address = %p\", prefix, stack_addr);\n" |
| 434 |
" if (stack_size E<gt> 0)\n" |
| 435 |
" printf(\" (EOS = %p)\", (char *) stack_addr + stack_size);\n" |
| 436 |
" printf(\"\\[rs]n\");\n" |
| 437 |
" printf(\"%sStack size = %#zx (%zu) bytes\\[rs]n\",\n" |
| 438 |
" prefix, stack_size, stack_size);\n" |
| 439 |
"}\n" |
| 440 |
"\\&\n" |
| 441 |
"static void\n" |
| 442 |
"display_thread_attributes(pthread_t thread, char *prefix)\n" |
| 443 |
"{\n" |
| 444 |
" int s;\n" |
| 445 |
" pthread_attr_t attr;\n" |
| 446 |
"\\&\n" |
| 447 |
" s = pthread_getattr_np(thread, &attr);\n" |
| 448 |
" if (s != 0)\n" |
| 449 |
" errc(EXIT_FAILURE, s, \"pthread_getattr_np\");\n" |
| 450 |
"\\&\n" |
| 451 |
" display_stack_related_attributes(&attr, prefix);\n" |
| 452 |
"\\&\n" |
| 453 |
" s = pthread_attr_destroy(&attr);\n" |
| 454 |
" if (s != 0)\n" |
| 455 |
" errc(EXIT_FAILURE, s, \"pthread_attr_destroy\");\n" |
| 456 |
"}\n" |
| 457 |
"\\&\n" |
| 458 |
"static void * /* Start function for thread we create */\n" |
| 459 |
"thread_start(void *arg)\n" |
| 460 |
"{\n" |
| 461 |
" printf(\"Attributes of created thread:\\[rs]n\");\n" |
| 462 |
" display_thread_attributes(pthread_self(), \"\\[rs]t\");\n" |
| 463 |
"\\&\n" |
| 464 |
" exit(EXIT_SUCCESS); /* Terminate all threads */\n" |
| 465 |
"}\n" |
| 466 |
"\\&\n" |
| 467 |
"static void\n" |
| 468 |
"usage(char *pname, char *msg)\n" |
| 469 |
"{\n" |
| 470 |
" if (msg != NULL)\n" |
| 471 |
" fputs(msg, stderr);\n" |
| 472 |
" fprintf(stderr, \"Usage: %s [-s stack-size [-a]]\"\n" |
| 473 |
" \" [-g guard-size]\\[rs]n\", pname);\n" |
| 474 |
" fprintf(stderr, \"\\[rs]t\\[rs]t-a means program should allocate stack\\[rs]n\");\n" |
| 475 |
" exit(EXIT_FAILURE);\n" |
| 476 |
"}\n" |
| 477 |
"\\&\n" |
| 478 |
"static pthread_attr_t * /* Get thread attributes from command line */\n" |
| 479 |
"get_thread_attributes_from_cl(int argc, char *argv[],\n" |
| 480 |
" pthread_attr_t *attrp)\n" |
| 481 |
"{\n" |
| 482 |
" int s, opt, allocate_stack;\n" |
| 483 |
" size_t stack_size, guard_size;\n" |
| 484 |
" void *stack_addr;\n" |
| 485 |
" pthread_attr_t *ret_attrp = NULL; /* Set to attrp if we initialize\n" |
| 486 |
" a thread attributes object */\n" |
| 487 |
" allocate_stack = 0;\n" |
| 488 |
" stack_size = -1;\n" |
| 489 |
" guard_size = -1;\n" |
| 490 |
"\\&\n" |
| 491 |
" while ((opt = getopt(argc, argv, \"ag:s:\")) != -1) {\n" |
| 492 |
" switch (opt) {\n" |
| 493 |
" case \\[aq]a\\[aq]: allocate_stack = 1; break;\n" |
| 494 |
" case \\[aq]g\\[aq]: guard_size = strtoul(optarg, NULL, 0); break;\n" |
| 495 |
" case \\[aq]s\\[aq]: stack_size = strtoul(optarg, NULL, 0); break;\n" |
| 496 |
" default: usage(argv[0], NULL);\n" |
| 497 |
" }\n" |
| 498 |
" }\n" |
| 499 |
"\\&\n" |
| 500 |
" if (allocate_stack && stack_size == -1)\n" |
| 501 |
" usage(argv[0], \"Specifying -a without -s makes no sense\\[rs]n\");\n" |
| 502 |
"\\&\n" |
| 503 |
" if (argc E<gt> optind)\n" |
| 504 |
" usage(argv[0], \"Extraneous command-line arguments\\[rs]n\");\n" |
| 505 |
"\\&\n" |
| 506 |
" if (stack_size != -1 || guard_size E<gt> 0) {\n" |
| 507 |
" ret_attrp = attrp;\n" |
| 508 |
"\\&\n" |
| 509 |
" s = pthread_attr_init(attrp);\n" |
| 510 |
" if (s != 0)\n" |
| 511 |
" errc(EXIT_FAILURE, s, \"pthread_attr_init\");\n" |
| 512 |
" }\n" |
| 513 |
"\\&\n" |
| 514 |
" if (stack_size != -1) {\n" |
| 515 |
" if (!allocate_stack) {\n" |
| 516 |
" s = pthread_attr_setstacksize(attrp, stack_size);\n" |
| 517 |
" if (s != 0)\n" |
| 518 |
" errc(EXIT_FAILURE, s, \"pthread_attr_setstacksize\");\n" |
| 519 |
" } else {\n" |
| 520 |
" s = posix_memalign(&stack_addr, sysconf(_SC_PAGESIZE),\n" |
| 521 |
" stack_size);\n" |
| 522 |
" if (s != 0)\n" |
| 523 |
" errc(EXIT_FAILURE, s, \"posix_memalign\");\n" |
| 524 |
" printf(\"Allocated thread stack at %p\\[rs]n\\[rs]n\", stack_addr);\n" |
| 525 |
"\\&\n" |
| 526 |
" s = pthread_attr_setstack(attrp, stack_addr, stack_size);\n" |
| 527 |
" if (s != 0)\n" |
| 528 |
" errc(EXIT_FAILURE, s, \"pthread_attr_setstacksize\");\n" |
| 529 |
" }\n" |
| 530 |
" }\n" |
| 531 |
"\\&\n" |
| 532 |
" if (guard_size != -1) {\n" |
| 533 |
" s = pthread_attr_setguardsize(attrp, guard_size);\n" |
| 534 |
" if (s != 0)\n" |
| 535 |
" errc(EXIT_FAILURE, s, \"pthread_attr_setstacksize\");\n" |
| 536 |
" }\n" |
| 537 |
"\\&\n" |
| 538 |
" return ret_attrp;\n" |
| 539 |
"}\n" |
| 540 |
"\\&\n" |
| 541 |
"int\n" |
| 542 |
"main(int argc, char *argv[])\n" |
| 543 |
"{\n" |
| 544 |
" int s;\n" |
| 545 |
" pthread_t thr;\n" |
| 546 |
" pthread_attr_t attr;\n" |
| 547 |
" pthread_attr_t *attrp = NULL; /* Set to &attr if we initialize\n" |
| 548 |
" a thread attributes object */\n" |
| 549 |
"\\&\n" |
| 550 |
" attrp = get_thread_attributes_from_cl(argc, argv, &attr);\n" |
| 551 |
"\\&\n" |
| 552 |
" if (attrp != NULL) {\n" |
| 553 |
" printf(\"Thread attributes object after initializations:\\[rs]n\");\n" |
| 554 |
" display_stack_related_attributes(attrp, \"\\[rs]t\");\n" |
| 555 |
" printf(\"\\[rs]n\");\n" |
| 556 |
" }\n" |
| 557 |
"\\&\n" |
| 558 |
" s = pthread_create(&thr, attrp, &thread_start, NULL);\n" |
| 559 |
" if (s != 0)\n" |
| 560 |
" errc(EXIT_FAILURE, s, \"pthread_create\");\n" |
| 561 |
"\\&\n" |
| 562 |
" if (attrp != NULL) {\n" |
| 563 |
" s = pthread_attr_destroy(attrp);\n" |
| 564 |
" if (s != 0)\n" |
| 565 |
" errc(EXIT_FAILURE, s, \"pthread_attr_destroy\");\n" |
| 566 |
" }\n" |
| 567 |
"\\&\n" |
| 568 |
" pause(); /* Terminates when other thread calls exit() */\n" |
| 569 |
"}\n" |
| 570 |
msgstr "" |
| 571 |
|
| 572 |
#. SRC END |
| 573 |
#. type: SH |
| 574 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 575 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 576 |
#, no-wrap |
| 577 |
msgid "SEE ALSO" |
| 578 |
msgstr "" |
| 579 |
|
| 580 |
#. type: Plain text |
| 581 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 582 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 583 |
msgid "" |
| 584 |
"B<pthread_attr_getaffinity_np>(3), B<pthread_attr_getdetachstate>(3), " |
| 585 |
"B<pthread_attr_getguardsize>(3), B<pthread_attr_getinheritsched>(3), " |
| 586 |
"B<pthread_attr_getschedparam>(3), B<pthread_attr_getschedpolicy>(3), " |
| 587 |
"B<pthread_attr_getscope>(3), B<pthread_attr_getstack>(3), " |
| 588 |
"B<pthread_attr_getstackaddr>(3), B<pthread_attr_getstacksize>(3), " |
| 589 |
"B<pthread_attr_init>(3), B<pthread_create>(3), B<pthreads>(7)" |
| 590 |
msgstr "" |
| 591 |
|
| 592 |
#. type: TH |
| 593 |
#: debian-trixie |
| 594 |
#, no-wrap |
| 595 |
msgid "2024-06-15" |
| 596 |
msgstr "" |
| 597 |
|
| 598 |
#. type: TH |
| 599 |
#: debian-trixie |
| 600 |
#, no-wrap |
| 601 |
msgid "Linux man-pages 6.9.1" |
| 602 |
msgstr "" |
| 603 |
|
| 604 |
#. type: Plain text |
| 605 |
#: debian-trixie |
| 606 |
msgid "POSIX threads library (I<libpthread>, I<-lpthread>)" |
| 607 |
msgstr "" |
| 608 |
|
| 609 |
#. type: TH |
| 610 |
#: fedora-44 fedora-rawhide |
| 611 |
#, no-wrap |
| 612 |
msgid "2024-07-23" |
| 613 |
msgstr "" |
| 614 |
|
| 615 |
#. type: TH |
| 616 |
#: fedora-44 fedora-rawhide |
| 617 |
#, no-wrap |
| 618 |
msgid "Linux man-pages 6.13" |
| 619 |
msgstr "" |
| 620 |
|
| 621 |
#. type: TH |
| 622 |
#: mageia-cauldron |
| 623 |
#, no-wrap |
| 624 |
msgid "Linux man-pages 6.17" |
| 625 |
msgstr "" |
| 626 |
|
| 627 |
#. type: TH |
| 628 |
#: opensuse-leap-16-1 opensuse-tumbleweed |
| 629 |
#, no-wrap |
| 630 |
msgid "Linux man-pages (unreleased)" |
| 631 |
msgstr "" |