IBM Research

Shared memory allocator

Created: 7.96
Modified: 5.97

Synopsis


#include <sys/types.h>
#include "shmalloc.h"

void* shmcreate (char* path, char ch,
		int nKB, mode_t mode,
		int off,
		int* id);

void* shmattach (int shmid, void* addr);
void  shmlocate (int shmid, void* addr);

void* shmalloc (int nbytes);
void shmfree (void*);

void* shmemdup (void* mem, int nbytes);
void shmstat (FILE*);	/* prints allocation map to file */


Description

Shmcreate creates a shared memory segment. Path and ch are used to generate the Unix key (see ftok(3)). Mode sets the rwx permission bits. Off defines the offset in the shared memory segment from where the dynamic allocation begins, so that space can be reserved for static data at the head of the shared memory.

Shmattach grabs access to existing shared memory. The address is passed as argument to the shmat system call.

Shmlocate is used to initialize the allocator library in a newly loaded module (see load(2)). It should be called with the correct id and address preferably by the entry point function of the loaded module. The initialization is necessary because the allocator is not a shared library.


Files

  1. shmalloc.h C header
  2. libshmalloc.a AIX4.1 shared library (-lshmalloc)
  3. shmalloc.exp Exported symbols (-bI:shmalloc.exp)
  4. shmcreate.c Example
  5. shmstat.c Example

Caveat


[ Research home page | IBM home page | Search | ContactIBM | Legal | Author ]