Dear Managers,
Here is my summary for my question although it is a little bit late.
My original question was:
>Dear Managers,
>
>Is there any tool/utility to check the amount of Shared Memory
>configured in the running kernel? Is it possible to check it with
>either 'adb' or 'dbx'?
>
>I know the amount of shared memory is specified in files
>/usr/sys/sun4m/conf/* and checking these files can tell. But
>somebody may change the config file content without rebuilding
>the kernel. And therefore this method is not safe.
>
>Tony Poon
Thanks to :
Mike (Mehran) Salehi (mrs@cadem.mc.xerox.com)
pcteoh@formis.bass.com.my
Rich Kylawiec (rsk@itw.com)
Colin Melville (cmelville@bigfoot.com)
Nate Itkin (Nate-Itkin@ptdcs2.intel.com)
Peter Marelas (maral@fusion.mel.sprint.com.au)
The following is a list of 3 answer that I have got. However, I have
only tried item 1.
1. Run the following script:
#! /bin/sh
shmmax=`echo "shminfo?D" | /bin/adb -k /vmunix /dev/mem \
| tail -1 | awk '{print $2}'`
shmmni=`echo "shminfo+8?D" | /bin/adb -k /vmunix /dev/mem \
| tail -1 | awk '{print $2}'`
echo "Your maximum shared memory segment size is $shmmax"
echo "You have $shmmni shared memory identifiers available"
2. Check the command 'ipcs'
3. Compile and run the following sharchived program. It grabs and releases
shared memory in 64K chunks, increasing the size of the shared memory
segment each time until it fails. This will give you a pretty darn
good idea of what's configured in. If you need finer granularity, you
can reduce STEPSIZE down to whatever you'd like.
Or you could get really sophisticated and make a binary search out of it. :-)
But for all practical purposes, this should do the trick. It's been
tested on SunOS 4.1.2, 4.1.3, and 4.1.4 on Sun4C and Sun4 architectures;
I don't see why it wouldn't work on a Sun4M machine. Here's what it
prints out on my workstation (Sun4C, SunOS 4.1.4):
segment_size: 65536 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 131072 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 196608 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 262144 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 327680 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 393216 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 458752 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 524288 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 589824 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 655360 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 720896 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 786432 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 851968 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 917504 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 983040 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 1048576 shmget() ok shmat() ok shmdt() ok shmctl() ok
segment_size: 1114112 shmget() failed, segment size is 1114112, errno is 22
I believe the default SHMSIZE is 1 Mbyte, which is why it bumped into the
limit when it did.
Cheers,
Rich
#!/bin/sh
# This is a shell archive (produced by GNU shar 4.0).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1996-10-11 11:49 EDT by <rsk@wombat>.
# Source directory was `/tmp'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1487 -rw-r--r-- tshm.c
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo 'WARNING: not restoring timestamps'
fi
rm -f 1231235999 $$.touch
#
# ============= tshm.c ==============
if test -f 'tshm.c' && test X"$1" != X"-c"; then
echo 'x - skipping tshm.c (File already exists)'
else
echo 'x - extracting tshm.c (text)'
sed 's/^X//' << 'SHAR_EOF' > 'tshm.c' &&
/*
* SunOS shared memory tester.
*
* Allocates, attaches, detaches, deallocates shared memory segments
* of increasing size in order to find out what SHMSIZE is really set to.
*
* Copyright Rich Kulawiec, rsk@itw.com, 1996.
*/
X
#include <stdio.h>
#include <errno.h>
#include <time.h>
#include <sys/param.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
X
#define STEPSIZE 65536
X
extern int errno;
X
main(argc,argv)
int argc;
char *argv[];
{
X int segment_size;
X int segment_id;
X char *segment_place;
X struct shmid_bs *buf;
X
X
X for (segment_size = STEPSIZE; ;segment_size = segment_size + STEPSIZE)
X {
X printf("\nsegment_size: %8d ",segment_size);
X
X if (( segment_id = shmget((key_t)0x10,segment_size,0666 | IPC_CREAT)) == -1 ) {
X printf("shmget() failed, segment size is %d, errno is %d\n",segment_size,errno);
X
X exit(-1);
X } else {
X printf("shmget() ok ");
X }
X
X
X if ( (segment_place = shmat(segment_id,0,0)) == (char *)-1 ) {
X printf("shmat() 1 failed, segment size is %d, errno is %d\n",segment_size,errno);
X exit(-1);
X }else {
X printf("shmat() ok ");
X }
X if ( shmdt(segment_place) == -1 ) {
X printf("shmdt() failed, segment size is %d, errno is %d\n",segment_size,errno);
X exit(-1);
X }else {
X printf("shmdt() ok ");
X }
X
X if ( shmctl(segment_id,IPC_RMID,buf) == -1 ) {
X printf("shmctl() failed, segment size is %d, errno is %d\n",segment_size,errno);
X exit(-1);
X }else {
X printf("shmctl() ok ");
X }
X }
}
SHAR_EOF
$shar_touch -am 1011114996 'tshm.c' &&
chmod 0644 'tshm.c' ||
echo 'restore of tshm.c failed'
shar_count="`wc -c < 'tshm.c'`"
test 1487 -eq "$shar_count" ||
echo "tshm.c: original size 1487, current size $shar_count"
fi
exit 0
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:13 CDT