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
» 

DSPP Home

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

critical impact:

pthread_lock_global_np, pthread_unlock_global_np - not supported; temporarily available (CrUn38)

ME Impacts TH Impacts

Problem description

The pthread_lock_global_np and pthread_unlock_global_np functions exist only on Tru64 UNIX, and not on HP-UX. These functions will be available on a temporary basis in the Tru64 UNIX Migration Environment for HP-UX.

The pthread_lock_global_np and pthread_unlock_global_np functions are holdovers from DCE threads when few libraries (whether third party or bundled with a UNIX system) were safe for use with threads; often including the system's C runtime library (for example, libc). Functions that are not thread safe in preexisting libraries must be externally protected through the use of a mutex. However, if two separate libraries each call an unsafe malloc, protecting it each with its own private mutex, the resulting situation remains unsafe -- all consumers of such an interface must use the same mutex. Furthermore, if malloc were to later become thread safe, but relied on a thread-unsafe brk function, then malloc would also need to lock this global mutex, which would deadlock if the caller of malloc already holds the mutex. To solve this quandary, the global lock was devised. It is a single global recursive mutex; that is, all callers use a single mutex, and each thread can lock that mutex recursively without fear of deadlock.

The Migration Environment contains Tru64 UNIX APIs, development tools, and commands and utilities to assist customers in migrating their applications from Tru64 UNIX to HP-UX.

Identifiers

C/C++ Functionspthread_lock_global_np C/C++ Functionspthread_unlock_global_np

Old behavior

void *a (size_t n) {
void *addr;
pthread_mutex_lock_np ();
addr = malloc (n);
pthread_mutex_unlock_np ();
return addr;
}

See also

Solution description

The pthread_lock_global_np and pthread_unlock_global_np functions are in the Tru64 UNIX Migration Environment.

Applications will be able to use these functions from the Tru64 UNIX Migration Environment for HP-UX. Please note that the Migration Environment is temporary. Recursive mutexes, in general, and a single recursive mutex, like the global lock in particular, are not efficient mechanisms to deal with data contention. A recursive mutex is more expensive than a normal mutex, and when different regions of code share dependency on a single mutex the overall concurrency (efficiency) of a threaded program is reduced, often substantially. Applications and libraries should be redesigned to apply synchronization locally and minimally, where necessary. Threaded applications should avoid reliance on thread-unsafe libraries where possible.

See also


Problem summary

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