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:

mmap - behavior differences (CrCh334)

KN Impacts

Problem description

The mmap function has the following behavior differences on Tru64 UNIX and HP-UX:

  • Multiple maps - Tru64 UNIX allows a process to map the same portion of a file with MAP_SHARED multiple times. HP-UX does not allow this operation with its default address space layout, but does with its Mostly Private Address Space (MPAS) layout.

  • Implicit unmaps - Tru64 UNIX implicitly unmaps a mapped region if the process maps something else there later with MAP_FIXED. HP-UX does not support this operation.

  • /dev/zero - Tru64 UNIX and the HP-UX 11i v2 May 2005 release allow a process to map /dev/zero with MAP_SHARED. (Both also allow it to be mapped with MAP_PRIVATE.)

  • Writing beyond end of file - Tru64 UNIX grows a mapped file if the process attempts to write beyond the end of the file. HP-UX does not and generates a SIGBUS signal.

  • ETXTBSY - Tru64 UNIX does not set the ETXTBSY error code. HP-UX sets this error code when MAP_SHARED, MAP_FILE, and PROT_EXECUTE are set, when PROT_WRITE is not set, and the file being mapped is currently open for writing.

  • MAP_UNALIGNED and MMAP_INHERIT do not exist on HP-UX, and MAP_FIXED has different semantics. These differences are discussed in a separate impact statement.

  • Coherency - Tru64 UNIX and its Unified Buffer Cache (UBC) maintain data coherency when an application accesses a file using the read/write system calls and mmap simultaneously. HP-UX does not guarantee coherency because the same data resides in separate caches: the buffer cache and the page cache. HP-UX may integrate those two caches into a Unified File Cache (UFC) in a future release.

Starting with HPUX 11iv3, Unified File Cache features is provided to achieve coherency for file access.


C/C++ Functionsmmap              

See also

Solution description

Use the following solutions for each behavior difference:

  • Multiple maps - Use the MPAS layout. MPAS was introduced in HP-UX 11i v2 as part of the Adaptive Address Space (AAS) feature. To make an executable use MPAS, use the +as mpas option of ld or chatr. Review the Adaptive Address Space white paper for more information.

  • Implicit unmaps - HP-UX might allow implicit unmaps for MPAS processes in future releases. In the meantime, explicitly unmap a mapped region before mapping something else there.

  • /dev/zero - The HP-UX 11i v2 May 2005 release allows /dev/zero to be mapped with MAP_SHARED.

  • Writing beyond end of file - Remove any dependencies on the Tru64 UNIX behavior because it is an undocumented feature and is not portable.

  • ETXTBSY - Check that your code can handle the ETXTBSY error code.

  • Coherency - Flush the file data in the buffer cache and page cache and synchronize access to the files. fsync will flush the data in the buffer cache, and msync will flush the data in the page cache.

HPUX 11iv3 offers Unified File Cache to achive coherency for file access. mmap and mlock have been appropriately enhanced.

See also

Problem summary

classifications source types OS release severity type
KN 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.