Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

426 Thread Control Chapter 12


Name of limit Description nameargument
PTHREAD_DESTRUCTOR_ITERATIONS maximum number of times an _SC_THREAD_DESTRUCTOR_ITERATIONS
implementation will try to
destroy the thread-specific
data when a thread exits
(Section 12.6)
PTHREAD_KEYS_MAX maximum number of keys that can_SC_THREAD_KEYS_MAX
be created by a process
(Section 12.6)
PTHREAD_STACK_MIN minimum number of bytes that can_SC_THREAD_STACK_MIN
be used for a thread’s stack
(Section 12.3)
PTHREAD_THREADS_MAX maximum number of threads that _SC_THREAD_THREADS_MAX
can be created in a process
(Section 12.3)

Figure 12.1 Thread limits andnamearguments tosysconf

Figure12.2 shows the values of the thread limits for the four implementations
described in this book. If the implementation’s limit is indeterminate, ‘‘no limit’’is
listed. This doesn’t mean that the value is unlimited, however.

Note that although an implementation may not provide access to these limits, that doesn’t
mean that the limits don’t exist. It just means that the implementation doesn’t provide us with
away to get at them usingsysconf.

FreeBSD Linux Mac OS X Solaris
Limit 8.0 3.2.0 10.6.8 10

PTHREAD_DESTRUCTOR_ITERATIONS 444 no limit
PTHREAD_KEYS_MAX 256 1,024 512 no limit
PTHREAD_STACK_MIN 2,048 16,384 8,192 8,192
PTHREAD_THREADS_MAX no limit no limit no limit no limit

Figure 12.2Examples of thread configuration limits

12.3 Thread Attr ibutes


The pthread interface allows us to fine-tune the behavior of threads and
synchronization objects by setting various attributes associated with each object.
Generally,the functions for managing these attributes follow the same pattern:


  1. Each object is associated with its own type of attribute object (threads with
    thread attributes, mutexes with mutex attributes, and so on). An attribute object
    can represent multiple attributes. The attribute object is opaque to applications.
    This means that applications aren’t supposed to know anything about its
    internal structure, which promotes application portability.Instead, functions
    areprovided to manage the attributes objects.

Free download pdf