OSDN Git Service

(split) LDP: Update original to LDP v3.38.
[linuxjm/LDP_man-pages.git] / original / man3 / pthread_attr_setstacksize.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
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 .\"
24 .TH PTHREAD_ATTR_SETSTACKSIZE 3 2012-03-15 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 pthread_attr_setstacksize, pthread_attr_getstacksize \- set/get stack size
27 attribute in thread attributes object
28 .SH SYNOPSIS
29 .nf
30 .B #include <pthread.h>
31
32 .BI "int pthread_attr_setstacksize(pthread_attr_t *" attr \
33 ", size_t " stacksize );
34 .BI "int pthread_attr_getstacksize(pthread_attr_t *" attr \
35 ", size_t *" stacksize );
36 .sp
37 Compile and link with \fI\-pthread\fP.
38 .fi
39 .SH DESCRIPTION
40 The
41 .BR pthread_attr_setstacksize ()
42 function sets the stack size attribute of the
43 thread attributes object referred to by
44 .I attr
45 to the value specified in
46 .IR stacksize .
47
48 The stack size attribute determines the minimum size (in bytes) that
49 will be allocated for threads created using the thread attributes object
50 .IR attr .
51
52 The
53 .BR pthread_attr_getstacksize ()
54 function returns the stack size attribute of the
55 thread attributes object referred to by
56 .I attr
57 in the buffer pointed to by
58 .IR stacksize .
59 .SH RETURN VALUE
60 On success, these functions return 0;
61 on error, they return a nonzero error number.
62 .SH ERRORS
63 .BR pthread_attr_setstacksize ()
64 can fail with the following error:
65 .TP
66 .B EINVAL
67 The stack size is less than
68 .BR PTHREAD_STACK_MIN
69 (16384) bytes.
70 .PP
71 On some systems,
72 .\" e.g., MacOS
73 .BR pthread_attr_setstacksize ()
74 can fail with the error
75 .B EINVAL
76 if
77 .I stacksize
78 is not a multiple of the system page size.
79 .SH VERSIONS
80 These functions are provided by glibc since version 2.1.
81 .SH CONFORMING TO
82 POSIX.1-2001.
83 .SH NOTES
84 For details on the default stack size of new threads, see
85 .BR pthread_create (3).
86
87 A thread's stack size is fixed at the time of thread creation.
88 Only the main thread can dynamically grow its stack.
89
90 The
91 .BR pthread_attr_setstack (3)
92 function allows an application to set both the size and location
93 of a caller-allocated stack that is to be used by a thread.
94 .SH BUGS
95 As at glibc 2.8,
96 if the specified
97 .I stacksize
98 is not a multiple of
99 .BR STACK_ALIGN
100 (16 bytes on most architectures), it may be rounded
101 .IR downward ,
102 in violation of POSIX.1-2001, which says that the allocated stack will
103 be at least
104 .I stacksize
105 bytes.
106 .SH EXAMPLE
107 See
108 .BR pthread_create (3).
109 .SH SEE ALSO
110 .BR getrlimit (2),
111 .BR pthread_attr_init (3),
112 .BR pthread_attr_setguardsize (3),
113 .BR pthread_attr_setstack (3),
114 .BR pthread_create (3),
115 .BR pthreads (7)