When a partition is created information from the MASTER_SIZE structure is used to size and initialized the shared memory partition.
Sometimes it is very useful to be able to allocate from a heap in the shared memory area. When the partition is created heap space is added and shm_malloc() is used to obtain blocks from the heap. The heap may also be used in place of the table allocation scheme to allocate AccelNET database records. One place where this has been used is in the AMS HIST system.
This function is part of tblmngr.
A pointer to the allocated block is returned.
int initSHM_CTL_BLOCK(
SHM_CTL_BLOCK *SHMpnt,
int size,
char *base
);
This function is used to initialize the SHM_CTL_BLOCK structure. It should be called by the code which creates and initializes the partition.
TBLalloc() and TBLdealloc() now work as follows using QLIST as an example) :
if (MASTER_SIZE.QLISTsize == 0) {
if (MASTER_TBL.SHMpnt == NULL)
malloc()
else shm_malloc()
}
It is up to the code creating the shared memory partition to set MASTER_TBL.SHMpnt and call initSHM_CTL_BLOCK() if usage of the shm_malloc() system is desired
What is this for ?
Usually when using shared memory and AccelNET tables one sets the table sizes > 0 and the normal AccelNET table allocation is used. This is fine for dbman and Xcrt.
In this case the listproc_v2 pkg was being modified to add functionality (user parameters) where we want to use LABEL, DESC, and DATA records in the shared memory. The dosimetry partition load software has never used a config file to set the AccelNET table sizes (’cause their use has been up to now very limited) and it’s annoying to have to add one.
This change gives us the flexibility to go either way when using shared memory. We can now choose to use the "traditional" table scheme with it’s benefits or when appropriate we can go with this scheme.