class pshm : public pipc

pshm is a simple encapsulation of the system V shared memory IPC

Inheritance:


Public Methods

static int exists(int size, key_t my_key, char *filename = NULL )
returns true if it exists
void* get_addr()
returns the address of the shared memory
pshm(int size, key_t key = IPC_PRIVATE, char *filename = NULL)
creates a shm of size bytes
pshm(int *pId )
attaches to a shared memory with identifier *pId
static int remove(int id)
forces the removal of the shm
int set_uid( uid_t new_uid )
sets the uid of the shm

Private Fields

void* addr
address where the memory is attached - different for different processes

Private Methods

void addToCleanupScript( int theId )
to add the shared memory into the cleanup script

Inherited from pipc:

Public Methods

int get_id()
key_t get_key()
int get_size()
int get_status()
int i_created()

Protected Methods

static key_t get_existing_key( char *filename, key_t key )
static key_t get_key( char *filename, key_t key = 1, int create = -1 )
static key_t get_new_key( char *filename, key_t key )

Protected

protected data members for access from derived class

int id
identifier
int size
size
key_t key
the unique key
int status
status of the last command
time_t time_created
time when the resource was created
int created
whether the process was the one that created the resource (or just attached to it)
static char* pcIpcCleanupFile
Pointer to the cleanup file name that has to be created if we want to have a script at the end that eliminates all IPC resources

Documentation

pshm is a simple encapsulation of the system V shared memory IPC.

USAGE:

 pshm::pshm( int size, key_t, char *file );
 pshm::pshm( int *pId ) : this constructor is used in
                          order to attach to an existing
                          shm.
                          NOTE: we use int and int* in  
                          to distinguish the two constructors
			  

MODIFICATIONS:

pshm(int size, key_t key = IPC_PRIVATE, char *filename = NULL)
creates a shm of size bytes

pshm(int *pId )
attaches to a shared memory with identifier *pId.
The identifier is passed as a pointer in order to distinguish from the other constructor. Note the difference between the normal constructor and this one: in the normal case we know only the key and the project file name. The parent class pipc will use this information to create a unique key, which is then used to get the unique identifier for the shared memory segment.
If one know already the shared memory identifier, then one can directly attach to it - thus use this constructor.

static int remove(int id)
forces the removal of the shm

static int exists(int size, key_t my_key, char *filename = NULL )
returns true if it exists

void* get_addr()
returns the address of the shared memory

int set_uid( uid_t new_uid )
sets the uid of the shm

void addToCleanupScript( int theId )
to add the shared memory into the cleanup script

void* addr
address where the memory is attached - different for different processes


This class has no child classes.
Author:
C.Witzig
Date: May 4, 97
Version:
Last update April 27, 99

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de