Section 12.2. Thread Limits

team bbl


12.2. Thread Limits

We discussed the sysconf function in Section 2.5.4. The Single UNIX Specification defines several limits associated with the operation of threads, which we didn't show in Figure 2.10. As with other system limits, the thread limits can be queried using sysconf. Figure 12.1 summarizes these limits.

Figure 12.1. Thread limits and name arguments to sysconf

Name of limit

Description

name argument

PTHREAD_DESTRUCTOR_ITERATIONS

maximum number of times an implementation will try to destroy the thread-specific data when a thread exits (Section 12.6)

_SC_THREAD_DESTRUCTOR_ITERATIONS

PTHREAD_KEYS_MAX

maximum number of keys that can be created by a process (Section 12.6)

_SC_THREAD_KEYS_MAX

PTHREAD_STACK_MIN

minimum number of bytes that can be used for a thread's stack (Section 12.3)

_SC_THREAD_STACK_MIN

PTHREAD_THREADS_MAX

maximum number of threads that can be created in a process (Section 12.3)

_SC_THREAD_THREADS_MAX


As with the other limits reported by sysconf, use of these limits is intended to promote application portability among different operating system implementations. For example, if your application requires that you create four threads for every file you manage, you might have to limit the number of files you can manage concurrently if the system won't let you create enough threads.

Figure 12.2 shows the values of the thread limits for the four implementations described in this book. When the implementation doesn't define the corresponding sysconf symbol (starting with _SC_), "no symbol" is listed. If the implementation's limit is indeterminate, "no limit" is listed. This doesn't mean that the value is unlimited, however. An "unsupported" entry means that the implementation defines the corresponding sysconf limit symbol, but the sysconf function doesn't recognize it.

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 a way to get at them using sysconf.

Figure 12.2. Examples of thread configuration limits

Limit

FreeBSD 5.2.1

Linux 2.4.22

Mac OS X 10.3

Solaris 9

PTHREAD_DESTRUCTOR_ITERATIONS

no symbol

unsupported

no symbol

no limit

PTHREAD_KEYS_MAX

no symbol

unsupported

no symbol

no limit

PTHREAD_STACK_MIN

no symbol

unsupported

no symbol

4,096

PTHREAD_THREADS_MAX

no symbol

unsupported

no symbol

no limit


    team bbl



    Advanced Programming in the UNIX Environment
    Advanced Programming in the UNIX Environment, Second Edition (Addison-Wesley Professional Computing Series)
    ISBN: 0321525949
    EAN: 2147483647
    Year: 2005
    Pages: 370

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net