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

개요

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

pthread_getattr_np(3c)

Standard C Library Functions                            pthread_getattr_np(3C)



NAME
       pthread_getattr_np - get attributes of thread

SYNOPSIS
       #include <pthread.h>

       int pthread_getattr_np(pthread_t t, pthread_attr_t *attr);

DESCRIPTION
       The  pthread_getattr_np()  function  allocates and initializes a thread
       attribute object with values representing an existing thread. The  val‐
       ues  of the fields in the pthread_attr_t structure are usually the same
       as  those  provided  during  the  creation  of  thread  by  using   the
       pthread_create()  function  or  the thr_create() function. However, the
       following factors occur:

           o      Stack address is often different due to memory alignment  or
                  other platform requirements


           o      The schedule inheritance will always match the default value


           o      The  detach  or  daemon  states of a thread may have changed
                  after the thread gets created



       Some of these values are subject to  change.  The  pthread_getattr_np()
       function returns a snapshot of the current state. The thread attributes
       object  returned  as  attr,  is  intended  for  use  with  the  various
       pthread_attr_get*()  functions to extract individual pieces of informa‐
       tion such as the stack address. For example, the pthread_attr_getstack‐
       addr() function. The caller is responsible for freeing the memory allo‐
       cated for attr by calling the pthread_attr_destroy() function.

RETURN VALUES
       If successful, the pthread_getattr_np() function returns 0.  Otherwise,
       an  error  number is returned to indicate the error. It is not an error
       for the target thread to be a zombie thread.

ERRORS
       The pthread_getattr_np() function will fail if:


       EFAULT    One or more attributes of thread could not be determined


       EINVAL    attr is NULL


       ESRCH     The value specified by a thread does not refer to an existing
                 thread



EXAMPLES
       Example 1 Retrieve a Thread's Stack Address and Size



       The  following is an example that shows how to retrieve a thread's cur‐
       rent stack address and size.



         /* cc thisfile.c */
         # include <pthread.h>
         # include <stdio.h>

         int
         main(int argc, char *argv[])
         {
          pthread_attr_t attr;
          size_t stksize;
          void *stkaddr;

          (void) pthread_getattr_np(pthread_self(), &attr);
          (void) pthread_attr_getstack(&attr, &stkaddr, &stksize);
          (void) pthread_attr_destroy(&attr);

          printf("Stack Address = %p\n", stkaddr);
          printf("Stack Size = %zu\n", stksize);

          return (0);
         }



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


SEE ALSO
       pthread_attr_init(3C),       pthread_attr_destroy(3C),      threads(7),
       attributes(7), standards(7)



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