man3tbl/shm_malloc

Table of Contents

Name

shm_malloc - create a shared memory partition

Description

shm_malloc allocates scratch memory from a shared memory partition created and initialized for use by the AccelNET table management system.

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.

Syntax

char *shm_malloc(
   SHM_CTL_BLOCK *SHMpnt,

   int size,

   int *error

   );

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.

ARGUMENTS for shm_malloc()

*SHMpnt

Pointer to the SHM_CTL_BLOCK used to manage the heap.

size

The amount of memory desired.

*error

pointer to variable to return errors.

ARGUMENTS for initSHM_CTL_BLOCK()

*SHMpnt

Pointer to the SHM_CTL_BLOCK used to manage the heap.

size

The size of the area to be managed.

*base

The address of the base of the heap.

Notes

At this time a data structure exists to support free block management but free() operations have not been implemented.

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.

See Also

tblmngr(3tbl)

Manual page revision

$Id: shm_malloc.3,v 1.0 2004/04/14 14:25:07 kitchen Exp $


Table of Contents