What is UNIX

The Threads Extensions

A White Paper from the X/Open Base Working Group.

Version 1 Last update March 12 1997

Abstract

This white paper gives a brief outline of the threads extensions put forward by the Aspen group. Included are a comparison to DCE threads and POSIX pthreads.

This paper is part of a series of brief papers describing new and changed features in the UNIX specification.

1.1 The Benefits of Threads

Multi-threading capabilities give a large benefit to certain classes of applications, typically server or parallel processing applications, allowing them to

1.2 POSIX Threads (Pthreads)

The IEEE POSIX Threads standard, IEEE 1003.1c-1995 is incorporated into Eastwood. Pthreads is a general threads API, specifiying a robust set of threads facilities, including new thread specific APIs for the following:

All the Pthreads functionality is mandatory in UNIX apart from the interfaces covered by the POSIX Threads compile-time symbolic constants _POSIX_THREAD_PRIO_INHERIT, _POSIX_THREAD_PRIO_PROTECT, and _POSIX_THREAD_PRIORITY_SCHEDULING as defined in <unistd.h>. These collectively make up the X/Open Realtime Threads Feature Group.

1.3 Threads Extensions

Over the past few years almost all UNIX vendors have implemented some flavor of a threads package based on the POSIX Pthreads interfaces.

Each vendor found that the POSIX Pthreads interface was not complete in solving all requirements for a vendor. Consequently, each vendor implemented extensions to their thread packages to meet those requirements.

Unfortunately for the application developer, not all vendors implemented the same exact set of extensions. To make it worse, there have been examples of the same functionality being added, but using different interface names or parameter sets.

In short, this has resulted in proprietary interfaces that are not portable across implementations, yet applications are making heavy use of these interfaces. However, all (or almost all) of the extensions that have been made are general enough that they would be easily supported on any UNIX vendors thread implementation.

The Aspen group formed a subgroup to attempt to standardize all of the thread extensions that various UNIX vendors have implemented and these have been brought together as the UNIX threads extensions.

1.4 What are UNIX Threads

The UNIX Threads are built upon the foundation of IEEE Std POSIX 1003.1c-1995, known as Pthreads. Pthreads contains much optional functionality. In UNIX, the majority of Pthreads has been made mandatory, plus some extensions not in Pthreads added. UNIX threads therefore are a rich set of threads API, guaranteed to be present on X/Open branded systems.

The threads extensions that came out of the Aspen group comprise extensions that were made by DCE as well as SUN, HP, and DEC. The Aspen group agreed on a common API for these extensions for portability.

UNIX system threads are a superset of the POSIX pthreads. This relationship is illustrated in the diagram below.

Diagram showing eastwood superset over Pthreads

The following extensions are made over POSIX threads

1.5 Functional Overview

On systems conforming to the Single UNIX Specification, Version 2 the following symbols are always defined:

_POSIX_THREADS
_POSIX_THREAD_ATTR_STACKADDR
_POSIX_THREAD_SAFE_FUNCTIONS
_POSIX_THREAD_ATTR_STACKSIZE
_POSIX_THREAD_PROCESS_SHARED

The mandatory threads interfaces derived from Pthreads in the UNIX specification are:


<pthread.h> 

asctime_r()	    		ctime_r()

flockfile()			ftrylockfile()	
funlockfile()

getc_unlocked()			getchar_unlocked()	
getgrgid_r() 			getgrnam_r()	
getlogin_r()
getpwnam_r()			getpwuid_r()	
gmtime_r()

localtime_r()

pthread_addr_setstacksize()	pthread_atfork()
pthread_attr_destroy()		pthread_attr_getdetachstate()
pthread_attr_getschedparam()	pthread_attr_getstackaddr()
pthread_attr_getstacksize()	pthread_attr_init()
pthread_attr_setdetachstate()	pthread_attr_setschedparam()
pthread_attr_setstackaddr()	pthread_cancel()
pthread_cleanup_pop()		pthread_cleanup_push()
pthread_cond_broadcast()	pthread_cond_destroy()
pthread_cond_init()		pthread_cond_signal()
pthread_cond_timedwait()	pthread_cond_wait()
pthread_condattr_destroy()	pthread_condattr_getpshared()
pthread_condattr_init()		pthread_condattr_setpshared()
pthread_create()		pthread_detach()
pthread_equal()			pthread_exit()
pthread_getschedparam()		pthread_getspecific()
pthread_join()			pthread_key_create()
pthread_key_delete()	   	pthread_kill()
pthread_mutex_destroy()		pthread_mutex_init()
pthread_mutex_lock()		pthread_mutex_trylock()
pthread_mutex_unlock()		pthread_mutexattr_destroy()
pthread_mutexattr_getpshared()	pthread_mutexattr_init()
pthread_mutexattr_setpshared()	pthread_once()
pthread_self()			pthread_setcancelstate()
pthread_setcanceltype()		pthread_setschedparam()
pthread_setspecific()		pthread_sigmask()
pthread_testcancel()	

putc_unlocked()			putchar_unlocked()

rand_r()			readdir_r()

sigwait()			strtok_r()

ttyname_r()
The optional interfaces derived from Pthreads in the X/Open Realtime Threads Feature group are:


pthread_attr_getinheritsched()	pthread_attr_getschedpolicy()
pthread_attr_getscope() 	pthread_attr_setinheritsched()
pthread_attr_setschedpolicy() 	pthread_attr_setscope()
pthread_getschedparam() 	pthread_setschedparam()
pthread_mutexattr_setprotocol() pthread_mutexattr_getprotocol()
pthread_mutexattr_setprioceiling() pthread_mutexattr_getprioceiling()
pthread_mutex_getprioceiling() 	pthread_mutex_setprioceiling()	   
The mandatory X/Open Threads extensions are:

pthread_setconcurrency()	pthread_getconcurrency()

pthread_rwlock_destroy()	pthread_rwlock_init()
pthread_rwlock_rdlock()		pthread_rwlock_tryrdlock()
pthread_rwlock_trywrlock()	pthread_rwlock_unlock()
pthread_rwlock_wrlock()		pthread_rwlockattr_destroy()
pthread_rwlockattr_getpshared()	pthread_rwlockattr_init()
pthread_rwlockattr_setpshared()

pthread_mutexattr_gettype()	pthread_mutexattr_settype()	

pthread_attr_getguardsize()	pthread_attr_setguardsize()	

1.6 UNIX System Threads vs DCE Threads

DCE Threads are based on Draft 4 of the POSIX threads standard , whereas the UNIX system threads are based on the final standard (IEEE Std 1003.1c-1995).

Since DCE threads are based on Draft 4 (circa 1991) they are obsolete. It is likely that they will be supported by existing DCE vendors for some time due to the need for application source/binary compatibility. It is expected that in a future revision of DCE that the Draft 4 interfaces will not be available. At that time DCE would use the official threads interfaces from POSIX and the extensions from X/Open.

Programmers are recommended to move to use the final POSIX standard interfaces and the UNIX system extensions as implementations become available.


Read other technical papers.

Read or download the complete Single UNIX Specification from http://www.UNIX-systems.org/go/unix.

Copyright © 1997-1998 The Open Group

UNIX is a registered trademark of The Open Group.