1PTHREADS(7)                Linux Programmer's Manual               PTHREADS(7)
2
3
4

NAME

6       pthreads - POSIX threads
7

DESCRIPTION

9       POSIX.1  specifies  a  set  of interfaces (functions, header files) for
10       threaded programming commonly known as POSIX threads, or  Pthreads.   A
11       single process can contain multiple threads, all of which are executing
12       the same program.  These threads share the same global memory (data and
13       heap  segments),  but  each  thread  has its own stack (automatic vari‐
14       ables).
15
16       POSIX.1 also requires that threads share a range  of  other  attributes
17       (i.e., these attributes are process-wide rather than per-thread):
18
19       -  process ID
20
21       -  parent process ID
22
23       -  process group ID and session ID
24
25       -  controlling terminal
26
27       -  user and group IDs
28
29       -  open file descriptors
30
31       -  record locks (see fcntl(2))
32
33       -  signal dispositions
34
35       -  file mode creation mask (umask(2))
36
37       -  current directory (chdir(2)) and root directory (chroot(2))
38
39       -  interval timers (setitimer(2)) and POSIX timers (timer_create(2))
40
41       -  nice value (setpriority(2))
42
43       -  resource limits (setrlimit(2))
44
45       -  measurements of the consumption of CPU time (times(2)) and resources
46          (getrusage(2))
47
48       As well as the stack, POSIX.1 specifies that various  other  attributes
49       are distinct for each thread, including:
50
51       -  thread ID (the pthread_t data type)
52
53       -  signal mask (pthread_sigmask(3))
54
55       -  the errno variable
56
57       -  alternate signal stack (sigaltstack(2))
58
59       -  real-time scheduling policy and priority (sched(7))
60
61       The following Linux-specific features are also per-thread:
62
63       -  capabilities (see capabilities(7))
64
65       -  CPU affinity (sched_setaffinity(2))
66
67   Pthreads function return values
68       Most  pthreads  functions  return  0 on success, and an error number on
69       failure.  Note that the pthreads functions do not set errno.  For  each
70       of the pthreads functions that can return an error, POSIX.1-2001 speci‐
71       fies that the function can never fail with the error EINTR.
72
73   Thread IDs
74       Each of the threads in a process has a unique thread identifier (stored
75       in  the  type pthread_t).  This identifier is returned to the caller of
76       pthread_create(3), and a thread can obtain its  own  thread  identifier
77       using pthread_self(3).
78
79       Thread  IDs are guaranteed to be unique only within a process.  (In all
80       pthreads functions that accept a thread ID as an argument, that  ID  by
81       definition refers to a thread in