HP-UX 11i Version 1.6 Release Notes
Programming
MxN Thread Model
Chapter 7
118
MxN Thread Model
Libpthread supporting the MxN thread model.
Summary of Change
At HP-UX 11i v1.6 and forward, HP-UX supports the “MxN” thread model that supports
creation of both
PTHREAD_SCOPE_PROCESS
and
PTHREAD_SCOPE_SYSTEM
threads. Prior to
HP-UX 11i v1.6, HP_UX only supported PTHREAD_SCOPE_SYSTEM threads (also
known as kernel or 1x1 threads). The MxN threads implementation is compliant with
the approved POSIX 1003.1-1996 standard.
Details of Change
The Posix threads library, libpthread, provided in HP-UX 11i v1.6 supports the MxN
model. The new libpthread is provided in the default directory where other libraries
are stored. The libpthread provided in releases prior to HP-UX 11i v1.6 supports only
the 1x1 model.
Threads created with contention scope of
PTHREAD_SCOPE_SYSTEM
contend for resources
with all other threads in the system. This attribute is generally used to indicate that the
user thread should be bound directly to a kernel-scheduled entity for its entire lifetime.
Hence these threads are also known as bound threads.
Threads created with contention scope of
PTHREAD_SCOPE_PROCESS
contend for CPU
resources only with other threads within their process that were created with the same
scheduling contention scope. This attribute is generally used to indicate that the user
thread should be unbound, meaning that the thread is not bound to a specific
kernel-scheduled entity. Hence these threads are also known as unbound threads.
In the MxN thread model, unbound threads are multiplexed over one or more
kernel-scheduled entities by the user space scheduler in libpthread. An unbound thread
may move from one kernel-scheduled entity to another in its lifetime. The
kernel-scheduled entities on which unbound thread is scheduled can be considered as
virtual processors.
Impact
A multi-threaded application running on a previous release compiles and runs on
HP-UX 11i v1.6 without any source changes. A multi-threaded application running on a
previous release, brought over to HP-UX 11i v1.6 without recompiling, also runs without
any change in functionality. In both cases, all pthread interfaces continue to work the
same way as documented in the manpages.
However, users should be aware of the following:
• An application can create both
PTHREAD_SCOPE_SYSTEM
and
PTHREAD_SCOPE_PROCESS
threads explicitly using the pthread_attr_setscope API.
When no contention scope is specified, a thread created by pthread_create has a
contention scope of
PTHREAD_SCOPE_PROCESS
. This change in default thread type is
due to POSIX standards requirement.