pthread_attr_getguardsize(3c) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

pthread_attr_getguardsize(3c)

Standard C Library Functions
                                                 pthread_attr_getguardsize(3C)



NAME
       pthread_attr_getguardsize,   pthread_attr_setguardsize  -  get  or  set
       thread guardsize attribute

SYNOPSIS
       #include <pthread.h>

       int pthread_attr_getguardsize(const pthread_attr_t *restrict attr,
            size_t *restrict guardsize);


       int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);

DESCRIPTION
       The guardsize attribute controls the size of the  guard  area  for  the
       created  thread's  stack.  The  guardsize attribute provides protection
       against overflow of the stack pointer. If a thread's stack  is  created
       with guard protection, the implementation allocates extra memory at the
       overflow end of the stack as a buffer against  stack  overflow  of  the
       stack  pointer.  If  an application overflows into this buffer an error
       results (possibly in a SIGSEGV signal being delivered to the thread).


       The guardsize attribute is provided to the application for two reasons:

           1.     Overflow protection can potentially result in wasted  system
                  resources.  An  application  that  creates a large number of
                  threads, and which knows its  threads  will  never  overflow
                  their  stack, can save system resources by turning off guard
                  areas.


           2.     When threads allocate large data structures  on  the  stack,
                  large guard areas may be needed to detect stack overflow.




       The  pthread_attr_getguardsize()  function gets the guardsize attribute
       in the attr object. This attribute is returned in the guardsize parame‐
       ter.


       The  pthread_attr_setguardsize()  function sets the guardsize attribute
       in the attr object. The new value of this attribute  is  obtained  from
       the  guardsize  parameter.  If guardsize is 0, a guard area will not be
       provided for threads created with attr. If guardsize is greater than 0,
       a  guard  area  of  at  least size guardsize bytes is provided for each
       thread created with attr.


       A conforming implementation is permitted to round  up  the  value  con‐
       tained  in  guardsize to a multiple of the configurable system variable
       PAGESIZE. If an implementation rounds up the value of  guardsize  to  a
       multiple  of PAGESIZE, a call to pthread_attr_getguardsize() specifying
       attr will store in the guardsize parameter the guard size specified  by
       the previous pthread_attr_setguardsize() function call.


       The  default  value  of  the guardsize attribute is PAGESIZE bytes. The
       actual value of PAGESIZE is implementation-dependent and may not be the
       same on all implementations.


       If  the  stackaddr attribute has been set (that is, the caller is allo‐
       cating and managing its own thread stacks), the guardsize attribute  is
       ignored and no protection will be provided by the implementation. It is
       the responsibility of the application to manage  stack  overflow  along
       with stack allocation and management in this case.

RETURN VALUES
       If  successful,  the  pthread_attr_getguardsize() and pthread_attr_set‐
       guardsize() functions return 0. Otherwise, an error number is  returned
       to indicate the error.

ERRORS
       The  pthread_attr_getguardsize()  and pthread_attr_setguardsize() func‐
       tions will fail if:

       EINVAL    The attribute attr is invalid.


       EINVAL    The parameter guardsize is invalid.


       EINVAL    The parameter guardsize contains an invalid value.


ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE  TYPEAT‐
       TRIBUTE  VALUE _ Interface StabilityCommitted _ MT-LevelMT-Safe _ Stan‐
       dardSee standards(7).


SEE ALSO
       pthread_attr_init(3C), sysconf(3C), attributes(7), standards(7)



Oracle Solaris 11.4               19 May 2014
                                                 pthread_attr_getguardsize(3C)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3