[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

General Programming Concepts: Writing and Debugging Programs


Threads Library Quick Reference

This section provides a summary of the threads library:

Supported Interfaces

On AIX systems, _POSIX_THREADS, _POSIX_THREAD_ATTR_STACKADDR, _POSIX_THREAD_ATTR_STACKSIZE and _POSIX_THREAD_PROCESS_SHARED are always defined. Therefore, the following threads interfaces are supported:

POSIX Interfaces

The following is a list of POSIX interfaces:

Single UNIX Specification Interfaces

The following is a list of single UNIX specification interfaces:

On AIX systems, _POSIX_THREAD_SAFE_FUNCTIONS is always defined. Therefore, the following interfaces are always supported:

AIX does not support the following interfaces; the symbols are provided but they always return an error and set the errno to ENOSYS:

Thread-safety

The following AIX interfaces are not thread-safe.

libc.a Library (Standard Functions):

libc.a Library (AIX Specific Functions):

libbsd.a library:

libm.a and libmsaa.a libraries:

None of the functions in the following libraries are thread safe:

The interfaces ctermid and tmpnam are not thread-safe if passed a NULL argument.

Note: Certain subroutines may be implemented as macros on some systems. You should avoid using the address of threads subroutines.

Threads Data Types

The following data types are defined for the threads library in the pthread.h header file.

pthread_t
Identifies a thread.

pthread_attr_t
Identifies a thread attributes object.

pthread_cond_t
Identifies a condition variable.

pthread_condattr_t
Identifies a condition attributes object.

pthread_key_t
Identifies a thread-specific data key.

pthread_mutex_t
Identifies a mutex.

pthread_mutexattr_t
Identifies a mutex attributes object.

pthread_once_t
Identifies a one time initialization object.

The definition of these data types can vary from one system to another.

Limits and Default Values

The threads library has some implementation-dependent limits and default values. These limits and default values can be retrieved by symbolic constants to enhance the portability of programs.

Maximum Number of Threads per Process

The maximum number of threads per process is 512. The maximum number of threads can be retrieved at compilation time using the PTHREAD_THREADS_MAX symbolic constant defined in the pthread.h header file.

Minimum Stack Size

The minimum stack size for a thread is 96KB. It is also the default stack size. This number can be retrieved at compilation time using the PTHREAD_STACK_MIN symbolic constant defined in the pthread.h header file.

Note that the maximum stack size is 256MB, the size of a segment. This limit is indicated by the PTHREAD_STACK_MAX symbolic constant in the pthread.h header file.

Maximum Number of Thread-Specific Data Keys

The number of thread-specific data keys is limited to 508. This number can be retrieved at compilation time using the PTHREAD_KEYS_MAX symbolic constant defined in the pthread.h header file.

Default Attribute Values

The default values for the thread attributes object are defined in the pthread.h header file by the following symbolic constants:

DEFAULT_DETACHSTATE
PTHREAD_CREATE_DETACHED. Specifies the default value for the detachstate attribute.

DEFAULT_INHERIT
PTHREAD_INHERIT_SCHED. Specifies the default value for the inheritsched attribute.

DEFAULT_PRIO
1 (one). Specifies the default value for the sched_prio field of the schedparam attribute.

DEFAULT_SCHED
SCHED_OTHER. Specifies the default value for the schedpolicy attribute of a thread attributes object.

DEFAULT_SCOPE
PTHREAD_SCOPE_LOCAL. Specifies the default value for the contention-scope attribute.

The actual values shown might vary from one release to another.

Related Information

Chapter 11, Threads Programming Guidelines.

Threads Library Options.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]