Interfaces for libpthread

LSB systems support POSIX threads with the following exceptions. This list is intended to match the behavior of historical Linux implementations. Applications should be written to deal with either POSIX threads or the thread behaviors described here.

POSIX specifies a concept of per-process rather than per-thread signals. The LSB does not require this behavior; traditional Linux implementations have had per-thread signals only. A related issue is that applications cannot (using legacy Linux implementations, at least) rely on getpid() returning the same value in different threads.

Note: one implication of per-thread signals is that a core dump (for example) may not stop all threads in a given process. This may be an issue when designing ways to stop/start applications.

Applications which create child processes (using fork() and the like) must then wait for them (using waitpid() family of functions) in the same thread as they created them. Note that coding applications this way will work both with full POSIX threads and legacy Linux thread implementations.

POSIX specifies that changing the user or group id instantly affects the behavior of all threads. This behavior is not specified; applications must use their own lock if they need this behavior. Rationale: it seems unnecessary and it is a performance hit (an SMP kernel must lock the user id). (FIXME: is this our current understanding? It was discussed on lsb-spec on January 2000 but I'm not sure we reached a consensus).

Although this standard doesn't have a way to list processes (/proc or "ps" command line isn't in, right?), it is our intention to not specify one way or the other whether multiple threads appear as separate processes or as a single process.

Applications cannot rely on resource limits (getrusage and setrusage) being maintained per-process rather than per-thread.

Applications must disconnect from the controlling tty before pthread_create (FIXME: have I summarized this correctly?).

times() doesn't account for all threads, just the caller.

Applications must not call pthread_cancel if they call any system libraries (most notably X windows), as system libraries are not guaranteed to be thread safe. Likewise, for such libraries, only one thread per process may call them.

Applications cannot rely on fcntl/lockf locks being visible per-process rather than per-thread. Likewise for mandatory file locks.

Threaded applications cannot use SIGUSR1 or SIGUSR2.

The behaviour of the interfaces in this library is specified by the following Standards.

Linux Standard Base[1]
CAE Specification, January 1997, System Interfaces and Headers (XSH), Issue 5 (ISBN: 1-85912-181-0, C606)[2]

Posix Threads

Table 10-28. libpthread - Posix Threads Function Interfaces

pthread_attr_destroy(GLIBC_2.0)[2]pthread_attr_setscope(GLIBC_2.0)[2]pthread_exit(GLIBC_2.0)[2]pthread_mutexattr_settype(GLIBC_2.0)[2]pthread_setcanceltype(GLIBC_2.0)[2]
pthread_attr_getdetachstate(GLIBC_2.0)[2]pthread_attr_setstackaddr(GLIBC_2.0)[2]pthread_getschedparam(GLIBC_2.0)[2]pthread_once(GLIBC_2.0)[2]pthread_setschedparam(GLIBC_2.0)[2]
pthread_attr_getguardsize(GLIBC_2.1)[2]pthread_attr_setstacksize(GLIBC_2.1)[2]pthread_getspecific(GLIBC_2.1)[2]pthread_rwlock_destroy(GLIBC_2.1)[2]pthread_setspecific(GLIBC_2.1)[2]
pthread_attr_getinheritsched(GLIBC_2.0)[2]pthread_cancel(GLIBC_2.0)[2]pthread_join(GLIBC_2.0)[2]pthread_rwlock_init(GLIBC_2.0)[2]pthread_sigmask(GLIBC_2.0)[2]
pthread_attr_getschedparam(GLIBC_2.0)[2]pthread_cond_broadcast(GLIBC_2.0)[2]pthread_key_create(GLIBC_2.0)[2]pthread_rwlock_rdlock(GLIBC_2.0)[2]pthread_testcancel(GLIBC_2.0)[2]
pthread_attr_getschedpolicy(GLIBC_2.0)[2]pthread_cond_destroy(GLIBC_2.0)[2]pthread_key_delete(GLIBC_2.0)[2]pthread_rwlock_tryrdlock(GLIBC_2.0)[2]sem_close(GLIBC_2.0)[2]
pthread_attr_getscope(GLIBC_2.0)[2]pthread_cond_init(GLIBC_2.0)[2]pthread_kill(GLIBC_2.0)[2]pthread_rwlock_trywrlock(GLIBC_2.0)[2]sem_destroy(GLIBC_2.0)[2]
pthread_attr_getstackaddr(GLIBC_2.1)[2]pthread_cond_signal(GLIBC_2.1)[2]pthread_mutex_destroy(GLIBC_2.1)[2]pthread_rwlock_unlock(GLIBC_2.1)[2]sem_getvalue(GLIBC_2.1)[2]
pthread_attr_getstacksize(GLIBC_2.1)[2]pthread_cond_timedwait(GLIBC_2.1)[2]pthread_mutex_init(GLIBC_2.1)[2]pthread_rwlock_wrlock(GLIBC_2.1)[2]sem_init(GLIBC_2.1)[2]
pthread_attr_init(GLIBC_2.1)[2]pthread_cond_wait(GLIBC_2.1)[2]pthread_mutex_lock(GLIBC_2.1)[2]pthread_rwlockattr_destroy(GLIBC_2.1)[2]sem_open(GLIBC_2.1)[2]
pthread_attr_setdetachstate(GLIBC_2.0)[2]pthread_condattr_destroy(GLIBC_2.0)[2]pthread_mutex_trylock(GLIBC_2.0)[2]pthread_rwlockattr_getpshared(GLIBC_2.0)[2]sem_post(GLIBC_2.0)[2]
pthread_attr_setguardsize(GLIBC_2.1)[2]pthread_condattr_init(GLIBC_2.1)[2]pthread_mutex_unlock(GLIBC_2.1)[2]pthread_rwlockattr_init(GLIBC_2.1)[2]sem_timedwait(GLIBC_2.1)[1]
pthread_attr_setinheritsched(GLIBC_2.0)[2]pthread_create(GLIBC_2.0)[2]pthread_mutexattr_destroy(GLIBC_2.0)[2]pthread_rwlockattr_setpshared(GLIBC_2.0)[2]sem_trywait(GLIBC_2.0)[2]
pthread_attr_setschedparam(GLIBC_2.0)[2]pthread_detach(GLIBC_2.0)[2]pthread_mutexattr_gettype(GLIBC_2.0)[2]pthread_self(GLIBC_2.0)[2]sem_unlink(GLIBC_2.0)[2]
pthread_attr_setschedpolicy(GLIBC_2.0)[2]pthread_equal(GLIBC_2.0)[2]pthread_mutexattr_init(GLIBC_2.0)[2]pthread_setcancelstate(GLIBC_2.0)[2]sem_wait(GLIBC_2.0)[2]

Notes

[1]

Linux Standard Base

[2]

CAE Specification, January 1997, System Interfaces and Headers (XSH), Issue 5 (ISBN: 1-85912-181-0, C606)