Jump to content
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
HP.com home

Transition Impacts

Tru64 UNIX Software Transition Kit


» HP STK home
» Home
» Overview
» Tools
» Documentation
» Transition impacts
» Identifier types
» Impact list
» Porting to HP-UX
» Glossary
» Help
» Send us feedback
Site maps
» Tru64 UNIX STK
Content starts here

critical impact:

POSIX thread contention scope - implementation difference (CrCh136)

TH Impacts

Problem description

There are incompatible differences between the Tru64 UNIX and HP-UX implementation of the contention scope attribute. Application source code will generally need to change if these functions are used, and different environmental constraints may apply.

In Tru64 UNIX and HP-UX 11i v1.5 through HP-UX 11i v2 March 2004, the default contention scope is PTHREAD_SCOPE_PROCESS. This means that the threads within a process contend with each other for execution resources (processors), but that the contention between threads across different processes is undefined. (There is always contention at some level.)

In all other versions of HP-UX, the default contention scope is PTHREAD_SCOPE_SYSTEM. This means that the thread contends directly with unthreaded processes and other system contention scope threads running on the system. This can be useful for real-time programming, especially when a thread needs to compete with kernel operations such as a device driver.

On HP-UX, a thread is always created using the contention scope value in the attributes object, or the default contention scope if no attributes object is specified. On Tru64 UNIX, however, the contention scope is taken from the attributes object scope attribute only when the inheritsched attribute is set to PTHREAD_EXPLICIT_SCHED. If the inheritsched attribute is set to PTHREAD_INHERIT_SCHED (the default), then the created thread will inherit the contention scope of the thread calling pthread_create.

The POSIX 1003.1-1996 standard (on which HP-UX is based) and the Single UNIX Specification, Version 2 (on which Tru64 UNIX is based) are ambiguous on the relationship between scope and inheritsched, and despite the difference neither implementation is incorrect. POSIX 1003.1-2001 and the Single UNIX Specification, Version 3, however, require the implementation currently provided on Tru64 UNIX and a future version of HP-UX that supports these newer standards will need to change.

In addition to the inheritsched difference, there are assorted privilege requirements for scheduling policy and priority between the two operating systems. On Tru64 UNIX, a system contention scope thread may use any scheduling policy, but a nonprivileged process may not specify the SCHED_RR policy with a priority higher than 19, or a SCHED_FIFO policy with a priority higher than 18. On HP-UX, a nonprivileged process cannot use PTHREAD_EXPLICIT_SCHED with system contention scope threads.


C/C++ Functionspthread_attr_getscope C/C++ Misc. IdentifiersPTHREAD_SCOPE_PROCESS
C/C++ Functionspthread_attr_setscope C/C++ Misc. IdentifiersPTHREAD_SCOPE_SYSTEM

See also

Solution description

Review code that uses contention scope.

Code that sets an attribute object's contention scope to PTHREAD_SCOPE_PROCESS and then depends on the implementation ignoring it when a thread is created with inheritscope set to PTHREAD_INHERIT_SCHED may not work on HP-UX. If you use PTHREAD_EXPLICIT_SCHED and set contention scope to PTHREAD_SCOPE_SYSTEM, the application must run with privilege on HP-UX.

See also

Problem summary

classifications source types OS release severity type
TH C, C++ any HP-UX 11i version critical changed
Printable version
Privacy statement Using this site means you accept its terms Feedback to DSPP
© 2007 Hewlett-Packard Development Company, L.P.