Multithreaded Programming Guide
  Search only this book
Download this book in PDF

Index

Symbols

__errno159
__t_errno159
_r227
_REENTRANT157

Numerics

32-bit architectures70

A

Ada140
adb161
adding
.....to LWP pool202
.....signals to mask32
aio_errno146
AIO_INPROGRESS146
aio_result_t145, 146
aiocancel(3)145, 146
aioread(3)145, 146
aiowait(3)146
aiowrite(3)145, 146
algorithms
.....faster with MT3
.....parallel244
.....sequential244
alternate signal stacks8, 132
ANSI C161
application-level threads
.....Seeuser-level threads
architecture
.....multiprocessor240
.....SPARC70, 241, 243
assert statement104, 231
asynchronous
.....event notification108
.....I/O144, 145, 146
.....semaphore use108
.....signals132 to 138
Async-Signal-Safe
.....category151
.....functions137, 153
.....and signal handlers140
atomic, defined70
automatic
.....arrays, problems160
.....LWP number adjustments130
.....stack allocation62

B

barrier synchronization244
binary semaphores107
binding
.....reasons to bind8, 130, 237, 239
.....threads to LWPs202
.....values to keys18, 208
bottlenecks233
bound threads6, 130, 237
.....See alsobinding
.....alternate signal stacks132
.....concurrency238
.....defined2
.....mixing with unbound threads237
.....no LWP caching237
.....priority128
.....reasons to bind8, 130
.....scheduling class128

C

C++161
cache, defined240
caching
.....not for bound thread LWPs237
.....threads data structure234
changing the signal mask32, 205
coarse-grained locking230
code lock229, 230
code monitor229, 231
completion semantics139
concurrency230, 238, 239
.....level202
.....unbound threads190
cond_broadcast(3T)215, 216
cond_init(3T)220, 221
cond_signal(3T)215
cond_wait(3T)143
condition variables69, 87 to 105, 142
contention232, 233
continue execution189
coroutine linkage236
counting semaphores Seesemaphores
creating
.....stacks62, 63, 64, 201, 203
.....threads12 to 15, 234, 238
......thread-specific keys18, 19, 20, 21, 207, 208
critical section242
custom stack62, 203, 204

D

-D_POSIX_C_SOURCE157
-D_REENTRANT157
daemon threads202
data
......global18
......local18
......lock229, 230
......profile126
......races149
......shared6, 242
......thread specific,Seethread-specificdata
dbx161
deadlock159, 231, 232
debugging159 to 162
......adb161
......dbx161
deleting signals from mask32
destructor function19, 25
detached threads15, 48, 201
Dijkstra, E. W.106

E

EAGAIN14, 19, 77, 93, 112, 191, 202
EBUSY77, 80, 81, 93, 101, 196, 197
EDEADLK15, 78, 111, 112
EFAULT194, 195, 196, 197 to 198
EINTR111, 112, 124, 133, 142, 143
EINVAL14, 15, 17, 20, 21, 27, 29, 31, 33, 38, 39, 47, 48, 49, 51, 52, 53, 54, 55, 56, 57, 58, 60, 64, 67, 72, 73, 74, 75, 77, 78, 79, 80, 81, 89, 90, 91, 93, 95, 96, 98, 100, 101, 109, 110, 111, 112, 113, 191, 194, 195, 196, 197 to 198, 203
ENOMEM19, 21, 72, 77, 89, 93, 202
ENOSPC109
ENOSYS28
ENOTSUP29, 53, 55
EPERM79, 109
errno22, 157, 159, 226
errno.h155
error checking31
ESRCH15, 17, 30, 31, 37, 189, 190
ETIME98
event notification108
examining the signal mask32, 205
exec(2)120, 122, 124
execution resources190, 191, 238
exit(2)124, 202
exit(3C)34

F

finding
.....minimum stack size203
.....thread concurrency level191
.....thread priority209
fine-grained locking230
flockfile(3S)147
flowchart of compile options158
fork(2)122, 124, 215
fork1(2)122, 124
FORTRAN161, 176
funlockfile(3S)147

G

getc(3S)147
getc_unlocked(3S)147
gethostbyname(3N)227
gethostbyname_r(3N)227
getrusage(3B)127
global
.....data229
.....memory159
.....side effects234
.....state229
......variables22, 23, 225
global variables226

H

heap,malloc(3C) storage from16

I

I/O
......asynchronous144, 145
......nonsequential146
......standard147
......synchronous144
inheriting priority200
interrupt132
interval timer237
invariants104, 230

J

joining threads14, 48, 206

K

kernel context switching6
keys
......bind value to key208
......get specific key21, 208
......global into private23
......storing value of21, 208
kill(2)132, 135

L

-lc157, 158
ld157, 158
libC154
libc153, 155, 158
libdl_stubs153
libintl153, 155
libm153, 155
libmalloc153, 155
libmapmalloc153, 155
libnsl154, 155, 159
libposix4155
libpthread155, 158
library
.....C routines225
.....MT safety153
.....threads155, 235
libresolv154
libsocket154, 155
libthread5, 155, 158, 235
libw154, 155
libX11154
lightweight processes7, 127 to 130, 235, 236
.....adding an LWP202
.....creation236
.....debugging161
.....defined2
.....independence236
.....multiplexing236
.....not supported7
.....profile state126
.....shortage131
.....special capabilities236
.....in SunOS 4.07
.....and system calls237
limits, resources127
limits.h155
linking155
local variable227
lock hierarchy232
lock_lint83
locking
.....See alsolocks
.....coarse grained230, 233
.....code229
.....conditional84
.....data229
.....fine-grained230, 233
.....guidelines233
.....invariants230
LockLint tool163
LockLint usage172
locks
......See alsolocking
......mutual exclusion69 to 86, 122, 142
......readers/writer69, 198
longjmp(3C)127, 140
LoopTool for parallelization176
LoopTool reporter163
-lpthread157, 158
lseek(2)147
-lthread157, 158
LWPs,Seelightweight processes

M

main()234
malloc(3C)16
Mandelbrot program164
MAP_NORESERVE62
MAP_SHARED124
memory
......global159
......ordering, relaxed242
......strongly ordered241
mmap(2)62, 124
monitor, code229, 231
mprotect(2)63, 203
MT-Safe libraries153
multiple-readers, single-writer locks198
multiplexing with LWPs236
multiprocessors239 to 244
multithreading
......defined2
mutex Seemutual exclusion locks
mutex_init(3T)220, 221
mutex_trylock(3T)232
mutual exclusion locks69 to 86, 122, 142

N

NDEBUG104
netdir154
netselect154
nice(2)128, 129
nondetached threads15, 33
nonsequential I/O146
null
.....procedures158
.....threads63, 203

P

P operation106
parallel
.....algorithms244
.....array computation237
Pascal161
PC6
PC_GETCID128
PC_GETCLINFO128
PC_GETPARMS128
PC_SETPARMS128
per-process signal handler132
per-thread signal handler132
Peterson's Algorithm242
PL/1 language134
portability70
POSIX 1003.4a3
pread(2)145, 147
printf problem228
printf(3S)140
priocntl(2)128, 129
priority6, 127, 128, 129, 236
.....finding for a thread209
.....inheritance200, 208, 209
.....range209
.....and scheduling209
.....setting for a thread209
process
.....terminating34
.....traditional UNIX1
producer/consumer problem116, 221, 241
profil(2)126
profiling an LWP126
programmer-allocated stack62, 63, 203, 204
prolagen106
pthread.h155
pthread_atfork(3T)33
pthread_attr_getdetachstate(3T)49
pthread_attr_getinheritsched(3T)56
pthread_attr_getschedparam(3T)58
pthread_attr_getschedpolicy(3T)54
pthread_attr_getscope(3T)52
pthread_attr_getstackaddr(3T)67
pthread_attr_getstacksize(3T)61
pthread_attr_init(3T)45
pthread_attr_setdetachstate(3T)47
pthread_attr_setinheritsched(3T)55
pthread_attr_setschedparam(3T)57
pthread_attr_setschedpolicy(3T)52
pthread_attr_setscope(3T)50
pthread_attr_setstackaddr(3T)64
pthread_attr_setstacksize(3T)60
pthread_cancel(3T)36
pthread_cleanup_pop(3T)40
pthread_cleanup_push(3T)40
pthread_cond_broadcast(3T)94, 99, 102, 133
......example100
pthread_cond_destroy(3T)101
pthread_cond_init(3T)92
pthread_cond_signal(3T)94, 96, 102, 103, 133
.....example97
pthread_cond_timedwait(3T)98, 142
.....example99
pthread_cond_wait(3T)94, 102, 103, 133, 142
.....example97
pthread_condattr_destroy(3T)89
pthread_condattr_getpshared(3T)91
pthread_condattr_init(3T)88
pthread_condattr_setpshared(3T)90
pthread_create(3T)13
PTHREAD_CREATE_JOINABLE45
pthread_detach(3T)17
pthread_equal(3T)26
pthread_exit(3T)33, 34
pthread_getschedparam(3T)30
pthread_getspecific(3T)21, 23, 24
pthread_join(3T)14, 46, 61, 144
pthread_keycreate(3T)18, 24, 25
.....example24
pthread_keydelete(3T)19
pthread_kill(3T)31, 135
pthread_mutex_destroy(3T)81
pthread_mutex_init(3T)76
pthread_mutex_lock(3T)78
.....example82, 84, 85, 86
pthread_mutex_trylock(3T)80, 84
pthread_mutex_unlock(3T)79
.....example82, 84, 85, 86
pthread_mutexattr_destroy72
pthread_mutexattr_destroy(3T)73
pthread_mutexattr_getpshared(3T)75
pthread_mutexattr_init(3T)72
pthread_mutexattr_setpshared(3T)74
pthread_once(3T)27
PTHREAD_PROCESS_PRIVATE71, 72, 74, 75, 88, 90
PTHREAD_PROCESS_SHARED71, 72, 74, 75, 88, 90
PTHREAD_PROCESS_SHARED116
PTHREAD_SCOPE_PROCESS8, 45, 50
PTHREAD_SCOPE_SYSTEM8, 50
pthread_self(3T)25
pthread_setcancelstate(3T)37
pthread_setcanceltype(3T)38
pthread_setprio(3T)128, 130
pthread_setschedparam(3T)29
pthread_setspecific(3T)20, 24, 25
......example24
pthread_sigmask(3T)32
pthread_sigsetmask(3T)135
PTHREAD_STACK_MIN()63
pthread_testcancel(3T)39
pthread_yield(3T)28
putc(3S)147
putc_unlocked(3S)147
pwrite(2)145, 147

R

read(2)146, 147
readers/writer locks69, 198
realtime237
......scheduling127, 129
red zone62, 63, 203
reentrant229
......See also_REENTRANT
......described229
......functions151, 152
......strategies for making229
register state6
relaxed memory ordering242
remote procedure call SeeRPC
replacing signal mask32
resume execution189
RPC4, 154, 234
RT,Seerealtime
rw_rdlock(3T)195
rw_tryrdlock(3T)195
rw_trywrlock(3T)197
rw_unlock(3T)197
rw_wrlock(3T)196
rwlock_destroy(3T)198
rwlock_init(3T)193, 220

S

SA_RESTART143
safety, threads interfaces149 to 154
scheduling
.....class127 to 130
.....compute-bound threads191
.....priorities208
.....realtime127, 129
.....system class127
.....timeshare127, 128
sem_destroy(3T)113
sem_init(3T)108
.....example114
sem_post(3T)106, 110
.....example115
sem_trywait(3T)106, 112
sem_wait(3T)111
.....example115
sema_init(3T)220
sema_post(3T)153
semaphores69, 106 to 118
.....binary107
.....counting, defined2
sending signal to thread31, 205
sequential algorithms244
setjmp(3C)127, 139, 140
shared data6, 229
shared-memory multiprocessor241
SIG_BLOCK32
SIG_DFL132
SIG_IGN132
SIG_SETMASK32
SIG_UNBLOCK32
sigaction(2)132, 133, 143
sigaltstack(2)132
SIGFPE133, 139
SIGILL133
SIGINT133, 138, 143
SIGIO133, 146
siglongjmp(3C)139, 140
signal(2)132
signal(5)132
signal.h31, 32, 155, 205
signals
......access mask32, 205
......add to mask32
......asynchronous132 to 138
......delete from mask32
......handler132, 137
......inheritance200
......masks6
......pending189, 200
......replace current mask32
......send to thread31, 205
......SIG_BLOCK32
......SIG_SETMASK32
......SIG_UNBLOCK32
......SIGSEGV61
......stack132
......unmasked and caught142
sigprocmask(2)135
SIGPROF125
SIGSEGV61, 133
sigsend(2)132
sigsetjmp(3C)140
sigtimedwait(2)137
SIGVTALRM125
sigwait(2)135, 137, 138, 140
SIGWAITING131
single-threaded
......assumptions225
......code70
......defined2
......processes124
size of stack60, 62, 201, 203, 204
stack234, 237
.....address64, 201
.....boundaries61
.....creation64, 201
.....custom203
.....deallocation203
.....minimum size62, 203
.....overflows62
.....parameters16
.....pointer6
.....programmer-allocated62, 63, 203, 204
.....red zone62, 63, 203
.....returning a pointer to151
.....size60, 62, 201, 203, 204
stack_base64, 201
stack_size60, 201
standard I/O147
standards3
start_routine201
static storage159, 225
stdio22, 157
store buffer243
storing thread key value21, 208
streaming a tape drive145
strongly ordered memory241
strtoaddr154
suspending a new thread201
swap space62
synchronization objects69 to 118
.....condition variables69, 87 to 105
.....mutex locks69 to 86
.....readers/writer locks198
.....semaphores69, 106 to 116, 216 to 222
synchronous I/O144, 145
system calls
.....handling errors226
.....and LWPs237
system scheduling class127

T

tape drive, streaming145
terminating
......a process34
......threads15
THR_BOUND202
thr_continue(3T)201
thr_create(3T)200, 203, 208
THR_DAEMON202
THR_DETACHED201
thr_exit(3T)202, 205
thr_getconcurrency(3T)191
thr_getprio(3T)209
thr_getspecific(3T)208
thr_join(3T)206
thr_keycreate(3T)207
thr_kill(3T)153
thr_min_stack(3T)201, 203
THR_NEW_LWP191, 202, 238
thr_self(3T)204
thr_setconcurrency(3T)190, 202, 237, 238
thr_setprio(3T)209
thr_setspecific(3T)208
thr_sigsetmask(3T)153
THR_SUSPENDED201
thr_yield(3T)204, 233
Thread Analyzer main window166
Thread Analyzer tool163
thread.h155
thread-directed signal137
thread-private storage6
threads
......compute-bound191
......concurrency Seeconcurrency
......creating12 to 15, 200 to 203, 234, 238
......daemon202
......defined2
......detached15, 48, 201
......exit codes15
......identifiers15, 25, 26, 27, 33, 201, 202, 204
......initial34
......joining14, 34, 206
......keys Seekeys
.....library155, 235
.....lightweight processes Seelightweightprocesses
.....nondetached15, 33
.....null63, 203
.....priority Seepriority
.....private data18
.....safety149 to 154
.....signals Seesignals
.....stacks Seestack151
.....suspended189
.....suspending201
.....synchronizing69 to 118
.....terminating15, 33, 205
.....thread-specific data Seethread-specific data226
.....unbound Seeunbound threads
.....user-level2, 5, 6
thread-specific data18 to 25
.....global22, 23, 24
.....global into private23
.....new storage class226
.....private22
time slicing130
time-out99, 215
timeshare scheduling class127, 128, 129
tiuser.h159
TLI154, 159
tools
.....adb161
.....dbx161
.....debugger161
.....lock_lint83
total store order243
trap132
TS,Seetimeshare scheduling class
TSD,Seethread-specific data

U

unbound threads127
.....alternate signal stacks132
.....caching234
.....concurrency190, 238
......defined2
......disadvantage237
......mixing with bound threads237
......priorities127, 208
......reasons not to bind234, 237
......and scheduling127, 130
......andthr_setconcurrency(3T)19 0, 238
......andpthread_setprio(3T)128, 130
unistd.h155
UNIX1, 3, 5, 133, 144, 146, 226
user space6
user-level threads2, 5, 6
USYNC_PROCESS71, 88, 193, 210, 213, 217, 220, 221, 238
USYNC_THREAD71, 88, 193, 210, 213, 217, 220

V

V operation106
variables
......condition69, 87 to 105, 118
......global225, 226
......primitive70
verhogen106
vfork(2)122

W

write(2)146, 147

X

XDR154