MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Standard C Library Functions        pthreadattrgetguardsize(3C)



NAME
     pthreadattrgetguardsize, pthreadattrsetguardsize  -  get
     or set thread guardsize attribute

SYNOPSIS
     cc -mt [ flag... ] file... -lpthread [ library... ]
     #include 

     int pthreadattrgetguardsize(const pthreadattrt *restrict attr,
          sizet *restrict guardsize);


     int pthreadattrsetguardsize(pthreadattrt *attr, sizet guardsize);


DESCRIPTION
     The guardsize attribute controls the size of the guard  area
     for the created thread's stack. The guardsize attribute pro-
     vides protection against overflow of the stack pointer. If a
     thread's  stack is created with guard protection, the imple-
     mentation 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  pthreadattrgetguardsize() function gets the guardsize
     attribute  in the attr object. This attribute is returned in
     the guardsize parameter.


     The  pthreadattrsetguardsize() function sets the guardsize
     attribute  in  the attr object. The new value of this attri-
     bute 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



SunOS 5.11          Last change: 23 mar 2005                    1






Standard C Library Functions        pthreadattrgetguardsize(3C)



     created with attr.


     A conforming implementation is permitted  to  round  up  the
     value  contained in guardsize to a multiple of the configur-
     able system variable  PAGESIZE. If an implementation  rounds
     up the value of guardsize to a multiple of  PAGESIZE, a call
     to pthreadattrgetguardsize() specifying attr will store in
     the guardsize parameter the guard size specified by the pre-
     vious  pthreadattrsetguardsize() 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  allocating  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    pthreadattrgetguardsize()    and
     pthreadattrsetguardsize()  functions return  0. Otherwise,
     an error number is returned to indicate the error.

ERORS
     The             pthreadattrgetguardsize()              and
     pthreadattrsetguardsize() functions will fail if:

     EINVAL     The attribute attr is invalid.


     EINVAL     The parameter guardsize is invalid.


     EINVAL     The  parameter  guardsize  contains  an   invalid
                value.


ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:









SunOS 5.11          Last change: 23 mar 2005                    2






Standard C Library Functions        pthreadattrgetguardsize(3C)



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
    
     Interface Stability          Standard                    
    
     MT-Level                     MT-Safe                     
    


SEE ALSO
     sysconf(3C),  pthreadattrinit(3C),  attributes(5),   stan-
     dards(5)











































SunOS 5.11          Last change: 23 mar 2005                    3



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™