A/UX: Shared Memory Error Message (9/94)


I am an A/UX developer porting an HP X Window System application using the "Big C" C compiler on a Macintosh IIci with 8MB RAM. The issue is the use of the memory with swapping of shared memory.

I modified the kernel for use of shared memory with:

SHMMAX 2097152
SHMSEG 12

During the creation of the fifth partition of shared memory, the following
message appears:

shmget: Not enough space (errno:12)

Other information:

RAM: 8MB
Swap Space: 49352 blocks.
Size of the segments of shared memory:

1) 2020 bytes
2) 1004664 bytes
3) 381536 bytes
4) 386536 bytes

Why am I getting this error message? Does A/UX keep the shared memory in RAM? Can it not be swapped to disk?

The key is the "shmget: Not enough space (errno:12)" error message that occurred during the creation of the fifth segment of shared memory. It means that the available, system-wide, total, shared memory space (in pages) is not large enough to accommodate the shared memory segment to be created. The default maximum system-wide total shared memory size is 512 pages defined in the "shminfo" data structure (shminfo.shmall). The total size of your four shared memory segments is about 433.3 pages.

You may change the default size of "shmall" in the same way you modified for the "shmmax" and "shmseg" using "adb".

Generally, A/UX keeps the shared memory in its virtual address space after doing the "shmget" and "shmat" system calls. The "shmget" system call with the IPC_CREAT flag creates a new shared memory region, and the kernel verifies the size and allocates a region data structure. Then the kernel saves a pointer to the region table entry in the shared memory table and sets a flag to indicate that no memory is associated with the region. The kernel allocates memory for the region only when a process attaches the region to its address space via the "shmat" system call.

For the shared memory segment not to be swapped to disk, two commands (SHM_LOCK and SHM_UNLOCK) can be used in the "shmctl" system call (the shared memory control system call) to lock or unlock the specified shared memory segment into the physical memory. The SHM_LOCK and SHM_UNLOCK are defined in the /usr/include/sys/shm.h file.

For information on the shared memory, refer to the shmget(2), shmat(2), shmctl(2), ipcs(1), and ipcrm(1) manual pages.


Article Change History:
21 Sep 1994 - Reviewed.
31 Aug 1992 - Reviewed.

Support Information Services
Published Date: Feb 18, 2012