Changing between Large and Small Address-Space Models


Contents

About this document
    Related documentation
About small and large address-space models
The script

About this document

This document describes how to change to the large address-space model, which may be required for some applications that manipulate large amounts of data. This document applies to all levels of AIX.

Related documentation

The AIX and product documentation library is also available:
http://www.rs6000.ibm.com/resource/aix_resource/Pubs/index.html


About small and large address-space models

Your computer divides the address space into sixteen equally sized segments of 256MB. When a program is loaded, by default, a single segment is allocated to program text (executable instructions) and a second segment is allocated to program data (heap, stack, and user block).

This arrangement is sufficient for most applications. However, applications that manipulate large amounts of data may require more than one segment for program data. Such allocation is facilitated with the large address-space model, which is described in InfoExplorer in the article "Large Program Support Overview". For AIX Version 4.3, check the product documentation for additional information.

When an application is compiled, the loader stores the maximum data-segment size in the executable file. This value may be changed with the two scripts in the following section. These two scripts modify the executable file header and cause the executable to use the large address-space model.


The script

Create the file, maxdata, and carefully enter the script text given below. Put the file in the system directory where local commands are stored. This directory must be in the $PATH environment variable for the commands to be found. Make the file executable with the chmod command. Enter chmod 555 maxdata.

This is the maxdata script: ---this is beginning of script-- do not put this line in script--------------

#! /bin/ksh
# This script modifies 32-bit XCOFF variable o_maxdata (+4C).
# This script CANNOT be use on a 64-bit XCOFF executable.
# This script MUST be run on the REAL executable, you CANNOT run
# this script on a symbolic link.
# See "AIX: General Programming Concepts, Writing and Debugging Pgms."
# To find the current maxdata setting for an executable
# run the command dump -ov executable  look for the maxDATA entry
# on the last line.
# This script requires exactly two parameters?
# 1st parm is name of executable
# 2nd parm is maxdata unit
# maxdata units are:
# 0 = 256mb
# 1 = 256mb
# 2 = 512mb
# 3 = 768mb
# 4 = 1024mb-1gb
# 5 = 1280mb
# 6 = 1536mb
# 7 = 1792mb
# 8 = 2048mb-2gb-max size for 32bit software/hardware
#
if [[ $# -ne 2 ]]
then
  print 'usage: "maxdata XCOFF [0-8]"' ;
  print '\tThe second parameter (maxdata size) specifies units of 256M.' ;
  print '\ie:  "maxdata /bin/xldb  4" sets /bin/xldb maxdata to 1G.' ;
  exit ;
fi
# first parm a 32-bit xcoff?
file $1 | grep -q 'executable (RISC System/6000) or object module' ;
if [[ $? -ne 0 ]]
then
  print "$1 isn't a readable 32-bit XCOFF file." ;
  exit ;
fi
# ... and writable?
if [[ ! -w $1 ]]
then
  print "$1 isn't a writable and executable file." ;
  exit ;
fi
# second parm equals 0,1,2,...,8 ?
case ${2:-4} in
[0-8] ) typeset -i8  d=${2:-4}*16  ;
        typeset -i10 m=${2:-4}*256 ;;
    * ) print 'The second parameter has to be an integer [0-8].' ;
        exit 1 ;;
esac
# Do it:
print -n "$1 o_maxdata before: " ; od -HAx -N4 -j76 $1 | head -1 ;
eval "print -n '\\0'${d#*#}'\\0\\0\\0' |
      dd of=$1 bs=4 count=1 seek=19 conv=notrunc 2>/dev/null" ;
print -n "$1 o_maxdata after:  " ; od -HAx -N4 -j76 $1 | head -1 ;
print "Maxdata in $1 now set to ${m}M." ;

----this is the end of the script -- do not put this line in script-----

How to check the current size of executable

Before using the maxdata script, you should check the current size of the executable. Enter the following command:

     dump -ov executable-name

This should produce output similar to:

executable-name:
                        ***Object Module Header***
# Sections      Symbol Ptr      # Symbols       Opt Hdr Len     Flags
         4      0x00000000              0                72     0x1007
Flags=( RELFLG EXEC LNNO DYNLOAD )
Timestamp = "Jun 09 20:51:49 1999"
Magic = 0x1df  (32-bit XCOFF)
                        ***Optional Header***
Tsize        Dsize       Bsize       Tstart      Dstart
0x00005cc4  0x000009a4  0x00000984  0x10000100  0x00000000
SNloader     SNentry     SNtext      SNtoc       SNdata
0x0004      0x0002      0x0001      0x0002      0x0002
TXTalign     DATAalign   TOC         vstamp      entry
0x0005      0x0003      0x00000898  0x0001      0x00000878
maxSTACK     maxDATA     SNbss       magic       modtype
0x00000000  0x00000000  0x0003      0x010b        1L

Check the second entry in the last line (maxDATA) this field shows the current size of the program. You can look at the maxdata script for a descript of maxDATA units.

How to use the maxdata script

You MUST have read and write authority to the executable to use the maxdata script.

Using the above output as an example, to increase from 0 maxDATA units to 4 (1gb) enter the command:

     maxdata executable-name 4

You should see output similar to:

     executable-name o_maxdata before: 0000000  00000000
     executable-name o_maxdata after:  0000000  40000000
     Maxdata in executable-name now set to 1024M.

To set the executable back to 0 maxDATA units enter the command:

     maxdata executable-name 0

You should see output similar to:

     executable-name o_maxdata before: 0000000  40000000
     executable-name o_maxdata after:  0000000  00000000
     Maxdata in executable-name now set to 0M.

You should always use dump -ov executable-name to confirm the change.




[ Doc Ref: 90605208414730     Publish Date: Feb. 06, 2001     4FAX Ref: 2942 ]