1thr_min_stack(3C)        Standard C Library Functions        thr_min_stack(3C)
2
3
4

NAME

6       thr_min_stack - return the minimum-allowable size for a thread's stack
7

SYNOPSIS

9       cc -mt [ flag... ] file...[ library... ]
10       #include <thread.h>
11
12       size_t thr_min_stack(void);
13
14

DESCRIPTION

16       When  a  thread  is  created  with a user-supplied stack, the user must
17       reserve enough space to run this thread. In a dynamically linked execu‐
18       tion  environment,  it  is  very  hard  to  know what the minimum stack
19       requirments are for a thread. The function thr_min_stack() returns  the
20       amount  of space needed to execute a null thread. This is a thread that
21       was created to execute a null procedure. A thread that  does  something
22       useful  should have a stack size that is thr_min_stack() + <some incre‐
23       ment>.
24
25
26       Most users should not be creating threads  with  user-supplied  stacks.
27       This  functionality  was  provided  to support applications that wanted
28       complete control over their execution environment.
29
30
31       Typically, users should let the threads library  manage  stack  alloca‐
32       tion. The threads library provides default stacks which should meet the
33       requirements of any created thread.
34
35
36       thr_min_stack() will return the unsigned int  THR_MIN_STACK,  which  is
37       the minimum-allowable size for a thread's stack.
38
39
40       In  this  implementation  the default size for a user-thread's stack is
41       one mega-byte. If the second argument to thr_create(3C) is  NULL,  then
42       the  default stack size for the newly-created thread will be used. Oth‐
43       erwise, you may specify a stack-size that is  at  least  THR_MIN_STACK,
44       yet less than the size of your machine's virtual memory.
45
46
47       It is recommended that the default stack size be used.
48
49
50       To  determine the smallest-allowable size for a thread's stack, execute
51       the following:
52
53         /* cc thisfile.c -lthread */
54         #define _REENTRANT
55         #include <thread.h>
56         #include <stdio.h>
57         main()  {
58                 printf("thr_min_stack() returns %u\n",thr_min_stack());
59         }
60
61

ATTRIBUTES

63       See attributes(5) for descriptions of the following attributes:
64
65
66
67
68       ┌─────────────────────────────┬─────────────────────────────┐
69       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
70       ├─────────────────────────────┼─────────────────────────────┤
71       │MT-Level                     │MT-Safe                      │
72       └─────────────────────────────┴─────────────────────────────┘
73

SEE ALSO

75       attributes(5), standards(5)
76
77
78
79SunOS 5.11                        12 May 1998                thr_min_stack(3C)
Impressum