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.  The error numbers that can be returned have the same  meaning
70       as the error numbers returned in errno by conventional system calls and
71       C library functions.  Note that the pthreads functions do not  set  er‐
72       rno.   For  each  of  the  pthreads functions that can return an error,
73       POSIX.1-2001 specifies that the function can never fail with the  error
74       EINTR.
75
76   Thread IDs
77       Each of the threads in a process has a unique thread identifier (stored
78       in the type pthread_t).  This identifier is returned to the  caller  of
79       pthread_create(3),  and  a  thread can obtain its own thread identifier
80       using pthread_self(3).
81
82       Thread IDs are guar