Main Page | Namespace List | Class List | File List | Namespace Members | Class Members | File Members

SMcommon.c

Go to the documentation of this file.
00001 #include "SMcommon.h"
00002 
00010 int SharedMemory::shm_initialize(key_t shm_key, int shm_size,int *shrd_id,int *shm_ptr)
00011 {
00017   *shrd_id = shmget(shm_key, shm_size, IPC_CREAT|0666);
00018   //  std::cout<<shrd_id<<std::endl;
00019   if( *shrd_id < 0 ){
00020     printf("[shm_initialize]: Can't Access to the Shared Memory !! \n" );
00021     return -1;
00022   }
00023   *shm_ptr = (int)shmat( *shrd_id, NULL, 0);
00024   memset( (void *)*shm_ptr, 0, shm_size );
00025 
00026   return  *shrd_id;
00027 }
00028 
00029 
00039 int  SharedMemory::shm_access(key_t shm_key, int shm_size, int *shrd_id, int *shm_ptr)
00040 {
00041   /*-------- ACCESS TO CURRENT STATUS --------*/
00042   *shrd_id = shmget(shm_key, shm_size, 0444);
00043   if( *shrd_id < 0 ){
00044     printf("Can't Access to the Shared Memory !! \n" );
00045     return(-1);
00046   }
00047   *shm_ptr = (int)shmat( *shrd_id, (const void *)NULL, 0);
00048   
00049   /*-------- ENDING --------*/
00050   return *shrd_id;
00051 }
00052 
00053 
00054 
00057 int  SharedMemory::erase_shm(struct SHM_PARAM *param_ptr){
00058   shmctl(param_ptr->shd_param_id, IPC_RMID, 0);
00059   return(0);
00060 }
00061 
00062 
00065 SharedMemory::SharedMemory(){;}//std::cout<<"---constructer---"<<std::endl;}

Generated on Sun Dec 14 23:32:46 2008 by doxygen 1.3.5