5.3 Differences Between Implementations of Pthreads

Minor differences in the implementations of Pthreads are largely due to edge cases that were either left unspecified by the standard or by permitted implementation dependences, for example:

The following table describes aspects of Pthread programming in Oracle Linux that can differ from other operating systems.

Function

Implementation Comments

int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));

The parent and child fork handlers are called in the order in which they were established by calls to pthread_atfork(). The prepare fork handlers are called in the opposite order.

int pthread_attr_destroy(pthread_attr_t *attr);

int pthread_attr_init(pthread_attr_t *attr);

These functions always succeed. For portability, applications should handle a possible error return.

int pthread_cancel(pthread_t thread);

void pthread_cleanup_push(void (*routine)(void *), void *arg);

void pthread_cleanup_pop(int execute)

NPTL implements thread cancellation by using the first real-time signal (signal 32).

int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);

The new thread inherits copies of the calling thread’s capability sets and CPU affinity mask.