![]() Shared Memory Segment Algorithm |
![]() Virtual Machine |
![]() |
The following defines the algorithm that PROISAM uses to calculate the size and allocation of the shared memory segment:
size = SHMTAB_SIZE + DEVTAB_SIZE + FABTAB_SIZE + RABTAB_SIZE + LOKTAB_SIZE
where:
SHMTAB_SIZE = 24 + OVERHEAD
which is constant but machine-dependent. The constant 24 is based on: roundup (1(long) + 3(int) + 2(short) +2(char).
DEVTAB_SIZE = (50 * sizeof (dev_t)) + OVERHEAD
which is constant but machine-dependent, the size of dev_t being either 2 or 4 bytes.
FABTAB_SIZE = (MAXFILES * 16) + OVERHEAD
which is variable depending on the size of pid_t, a machine-dependent parameter (process id) which is either 2 or 4 bytes. One FAB is allocated per file open, regardless of how many users open the file. The constant 16 is based on:
roundup(1(long) + 1(int) + 1(short) +2(char) + 1(pid_t).
RABTAB_SIZE = MAXUSERS * USRFILES * (20 + OVERHEAD)
which is variable according to the values of MAXUSERS and USRFILES and the size of pid_t, as above. One RAB is allocated for every file that each user opens. The constant 20 is based on:
roundup (2(int) + 4(short) + 1(pid_t)
LOKTAB_SIZE = MAXLOCKS * (AVGLOCK + OVERHEAD)
which is variable according to the number of MAXLOCKS and AVGLOCK size, but is machine-independent. One LOCK is allocated for each record lock taken and is the size of the key being locked, plus the OVERHEAD.
where:
(short) = 2
(int) = 4
(long) = 4
(pid_t) = 4
OVERHEAD = (int)
roundup() increments to next OVERHEAD boundary.
While 2 byte shorts and 4 byte longs are virtually the standard on most systems, other systems can and do have different values. If the size of shorts, ints, and/or longs on your system differ, then you should recalculate these constants accordingly.
The parameters RABTAB_SIZE and LOKTAB_SIZE are not absolute but dynamically vary based on the amount of shared memory available after the SHMTAB, DEVTAB and FABTAB tables are allocated. Allocating more RAB's makes less memory available for LOCKS and vice versa.
This memory is allocated and released dynamically as the processing requirements of the users vary. The memory size as calculated by the above formula (or as defined by SHMSIZE) is limited by the system limits or the size allowed by an unsigned integer.
Note that the MAXFILES, MAXUSERS and USRFILES parameters are subject to operating system constraints.
Topic ID: 720220