Three primary standardization efforts affect Pthreads programmers. X/Open's XSH5 is a new interface specification that includes POSIX.1b, Pthreads, and a set of additional thread functions (part of the Aspen fast-track submission). The POSIX.1j draft standard proposes to add barriers, read/write locks, spinlocks, and improved support for "relative time" waits on condition variables. The POSIX.14 draft standard (a "POSIX Standard Profile") gives direction for managing the various options of Pthreads in a multiprocessor environment.
10.1 X/OpenXSH5(UNIX98)
Mutex type attribute:
int pthread_mutexattr_gettype (
const pthread_mutexattr_t *attr, int *type); int pthread_mutexattr_settype (
pthread_mutexattr_t *attr, int type);
Read/write locks:
int pthread_rwlock_init (pthread_rwlock_t *rwlock,
const pthread_rwlockattr_t *attr); int pthread_rwlock_destroy (pthread_rwlock_t *rwlock); pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER; int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock); int pthread_rwlock_tryrdlock (
pthread_rwlock_t *rwlock); int pthread_rwlock_unlock (pthread_rwlock_t *rwlock); int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock); int pthread_rwlock_trywrlock (
pthread_rwlock_t *rwlock); int pthread_rwlockattr_init (
pthread_rwlockattr_t *attr); int pthread_rwlockattr_destroy (
pthread_rwlockattr_t *attr); int pthread_rwlockattr_getpshared (
const pthread_rwlockattr_t *attr, int *pshared); int pthread_rwlockattr_setpshared (
pthread_rwlockattr_t *attr, int pshared);
Parallel I/O:
size_t pread (int fildes,
void *buf, size_t nbyte, off_t offset); size_t pwrite (int fildes,
const void *buf, size_t nbyte, off_t offset);
Miscellaneous:
int pthread_attr_getguardsize (
const pthread_attr_t *attr, size_t *guardsize); int pthread_attr_setguardsize (
pthread_attr_t *attr, size_t guardsize); int pthread_getconcurrency (); int pthread_setconcurrency (int new_level);
X/Open, which is part of The Open Group, owns the UNIX trademark and develops UNIX industry portability specifications and brands. The X/Open brands include XPG3, XPG4, UNLX93, and UNLX95. UNLX95 is also known as "SPEC1170" or the "Single UNIX Specification."
X/Open recently published the
The most valuable contribution of UNLX98 to the threaded programming industry, however, is possibly the development of a standardized, portable testing system. A number of complicated issues arise when developing an implementation of Pthreads, and some subtle aspects of the standard are ambiguous. Such an industry-wide testing system will require all vendors implementing UNLX98 branded systems to agree on interpretations of Pthreads.
10.1.1 POSIX options for XSH5
Some of the features that are options in the Pthreads standard are required by XSH5. If your code relies on these Pthreads options, it will work on any system conforming to XSH5:
• _POSIX_THREADS: Threads are supported.
• _POSIX_THREAD_ATTR_STACKADDR: The stackaddr attribute is supported.
• _POSIX_THREAD_ATTR_STACKSIZE: The
• _POSIX_THREAD_PROCESS_SHARED: Mutexes, condition variables, and XSH5 read/write locks can be shared between processes.
• _POSIX_THREAD_SAFE_FUNCTIONS: The Pthreads thread-safe functions are supported.
Several additional Pthreads options are "bundled" into the XSH5 realtime threads option group. If your system conforms to XSH5 and supports the _XOPEN_ REALTIME_THREADS option, then these Pthreads options are also supported:
• _POSIX_THREAD_PRIORITY_SCHEDULING: Realtime priority scheduling is supported.
• _POSIX_THREAD_PRIO_PROTECT: Priority ceiling mutexes are supported.
• _POSIX_THREAD_PRIO_INHERIT: Priority inheritance mutexes are supported.
10.1.2 Mutex type
The DCE threads package provided an extension that allowed the programmer to specify the "kind" of mutex to be created. DCE threads supplied