3 # @(#)usermem.sh 1.1 86/09/25 SMI; from UCB 5.4 85/09/17
5 : This shell
script snoops around to
find the maximum amount of available
6 : user memory. These variables need to be
set only
if there is no
7 : /usr
/adm
/messages. KMEM
, UNIX
, and CLICKSIZE can be
set on the
command
8 : line
, if desired
, e.g. UNIX
=/unix
9 KMEM
=/dev
/kmem
# User needs read access to KMEM
11 # VAX CLICKSIZE=512, UNIX=/vmunix
12 # PDP-11 CLICKSIZE=64, UNIX=/unix
13 # CADLINC 68000 CLICKSIZE=4096, UNIX=/unix
14 # Perkin-Elmer 3205 CLICKSIZE=4096, UNIX=/edition7
15 # Perkin-Elmer all others, CLICKSIZE=2048, UNIX=/edition7
21 : User must have specified it already.
25 if [ -r /bin
/sun2
] && /bin
/sun2
27 CLICKSIZE
=2048 # Sun-2
28 elif [ -r /bin
/sun3
] && /bin
/sun3
30 CLICKSIZE
=8192 # Sun-3
32 CLICKSIZE
=512 # Probably VAX
34 elif test -r /edition7
37 CLICKSIZE
=2048 # Perkin-Elmer: change to 4096 on a 3205
40 UNIX
=/unix
# Could be anything
44 # messages: probably the most transportable
45 if test -r /usr
/adm
/messages
-a -s /usr
/adm
/messages
47 SIZE
=`grep avail /usr/adm/messages | sed -n '$s/.*[ ]//p'`
50 if test 0$SIZE -le 0 # no SIZE in /usr/adm/messages
52 if test -r $KMEM # Readable KMEM
56 SIZE
=`echo maxmem/D | adb $UNIX $KMEM | sed -n '$s/.*[ ]//p'`
59 SIZE
=`echo physmem/D | adb $UNIX $KMEM | sed -n '$s/.*[ ]//p'`
61 SIZE
=`expr 0$SIZE '*' $CLICKSIZE`
67 /vmunix
) # Assume 4.2bsd: check for resource limits
68 MAXSIZE
=`csh -c limit | awk 'BEGIN { MAXSIZE = 1000000 }
69 /datasize|memoryuse/ && NF == 3 { if ($2 < MAXSIZE) MAXSIZE = $2 }
70 END { print MAXSIZE * 1000 }'`
71 if test $MAXSIZE -lt $SIZE