Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ pthread_attr_setdetachstate(3T) — DG/UX R4.11

Media Vault

Software Library

Restoration Projects

Artifacts Sought



pthread_attr_setdetachstate(3T)   SDK R4.11  pthread_attr_setdetachstate(3T)


NAME
       pthreadattrsetdetachstate, pthreadattrgetdetachstate - manipulate
       thread detachstate attribute

SYNOPSIS
       #include <pthread.h>

       int pthreadattrsetdetachstate(pthreadattrt *attr,
                                       int *detachstate);

       int pthreadattrgetdetachstate(pthreadattrt *attr);

   where:
       attr        A pointer to a thread attributes object, which should
                   have been initialized by a previous call to
                   pthreadattrinit().
       detachstate A pointer to the detachstate attribute, which should have
                   the value 0 or 1; default attribute value = 0 (not
                   created as detached)

DESCRIPTION
       The detachstate attribute specifies whether or not a thread is
       created as detached.  If a thread is created as detached, it will
       automatically cleanup for itself when it terminates and make its id
       available for reuse by the system.

       The detachstate attribute is either 0 or 1.  A value of 0 causes all
       threads created with the attributes object pointed to by attr to be
       created as undetached (default).  A value of 1 causes all threads
       created with the attributes object pointed to by attr to be created
       as detached.

       Detached threads are not joinable.  Under DG/UX, any call to
       pthreadjoin() on a detached thread will fail with errno set to
       ESRCH.  This is similar to the case where an existing thread is
       detached with a call to pthreaddetach().

       Creating a thread as detached is encouraged when it makes sense for
       the thread at hand.  It is more efficient to have a thread clean up
       after itself than to require a call to pthreadjoin().  A detached
       thread can more efficiently perform the cleanup during its exit.

DIAGNOSTICS
   Returns
       If successful, pthreadattrsetdetachstate() returns 0.  Otherwise it
       returns -1 and sets errno to indicate the error.

       If successful, pthreadattrgetdetachstate() returns 0 or 1,
       indicating the detachstate attribute.  Otherwise it returns -1 and
       sets errno to indicate the error.

   Errors
       For each of the following conditions, pthreadattrsetdetachstate()
       and pthreadattrgetdetachstate() return -1 and set errno to the
       corresponding value:

       [EINVAL]  An invalid attributes object has been specified.  This
                 occurs when DG/UX has detected that the attributes object
                 pointed to by attr has not been initialized by a previous
                 call to pthreadattrinit() or has been corrupted.

       For each of the following conditions, pthreadattrsetdetachstate()
       returns -1 and sets errno to the corresponding value:

       [EINVAL]  The value pointed to by detachstate is not 0 or 1.

SEE ALSO
       pthreadattrinit(3T), pthreadattrdestroy(3T), pthreadcreate(3T),
       pthreaddetach(3T), pthreadjoin(3T), pthreadexit(3T).

NOTES
       The fact that the detachstate argument to pthreadattrsetdetachstate
       is a pointer to the detachstate instead of the detachstate itself
       arrises from a typo in Draft 6 of the Posix 1003.4a standard.  DG/UX
       chose to mimick this mistake in order "conform fully" to Draft 6.
       This typo has been corrected in subsequent drafts of the standard.
       Other problems have also been corrected in future drafts.  These
       include using symbolic constants instead of 0 and 1, and returning
       the detachstate via an (int *) parameter to pthreadgetdetachstate().

       Creating threads as detached is preferrable to the using
       pthreaddetach() on an existing thread, as the latter call will not
       likely make it into the final standard.  Moreover, creating a thread
       as detached is more efficient than detaching it after it has been
       created.


Licensed material--property of copyright holder(s)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026