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:

  • Pthreads in Oracle Solaris has a priority scheduling attribute that does not exist in NPTL on Oracle Linux.

  • In the POSIX standard, all threads are assumed to be part of same process and so share a common nice value. NPTL threads on Oracle Linux are in effect separate processes and do not necessarily share a common nice value.

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


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.