Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ pthread_self(3T) — DG/UX 5.4R3.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



pthread_self(3T)               DG/UX 5.4R3.00               pthread_self(3T)


NAME
       pthreadself - get calling thread's ID

SYNOPSIS
       #include <pthread.h>

       pthreadt pthreadself(void);

DESCRIPTION
       The pthreadself() function returns the thread ID of the calling
       thread.

DIAGNOSTICS
   Returns
       See DESCRIPTION.

SEE ALSO
       pthreadcreate(3T), pthreadequal(3T), pthreadexit(3T),
       dgpthreadgetlwpid(3T).

NOTES
       The pthreadself() function provides a capability similar to the
       getpid() function for processes, and the rationale is the same: the
       creation call does not provide the thread ID to the created thread.

       The only other portable operations allowed on thread IDs are
       assignment and comparison using pthreadequal().  An application
       cannot portably assume that a thread ID is implemented as a scalar
       value such as an unsigned int.  In fact, some implementations choose
       to implement thread IDs using structures.  For this reason, it is
       unportable to assume that thread IDs can be treated as integers and
       passed, for example, to printf() for display.  However, the
       corresponding LWPID for a thread ID is a scalar and can be obtained
       with a non-portable call to dgpthreadgetlwpid(3T).

       In the current DG/UX implementation, the thread ID is the same as the
       corresponding LWPID, and thread IDs start at 0 and count up in a
       process.  Hence thread IDs are not global across processes, but
       rather local to a process.  However, an application should not take
       advantage of this knowledge and assume that thread IDs can be used
       like integers in places such as array indexes.

       Moreover, because thread IDs can get reused within the same process,
       an application must not assume that thread IDs will be unique for the
       entire life of a process.   In fact, an application needs to take
       great care not to use a thread ID of a terminated, detached thread.











Licensed material--property of copyright holder(s)                         1


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