base/libs/qdecoder/qShm.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <sys/shm.h>
#include "qDecoder.h"

Include dependency graph for qShm.c:

Go to the source code of this file.

FunctionsTitleTestFour

bool qShmFree (int shmid)
void * qShmGet (int shmid)
int qShmGetId (const char *keyfile, int keyid)
int qShmInit (const char *keyfile, int keyid, size_t size, bool ifexistdestroy)


Detailed Description

Shared Memory Handling API

Note:
   [your header file]
   struct SharedData {
     (... structrue definitions ...)
   }

   [shared memory creater]
   // create shared memory
   int shmid = qShmInit("/some/file/for/generating/unique/key", 's', sizeof(struct SharedData), true);
   if(shmid < 0) {
     printf("ERROR: Can't initialize shared memory.\n");
     return -1;
   }

   // get shared memory pointer
   struct SharedData *sdata = (SharedData *)qShmGet(shmid);
   if(sdata == NULL) {
     printf("ERROR: Can't get shared memory.\n");
     return -1;
   }

   [shared memory user]
   // get shared memory id
   int shmid = qShmGetId("/some/file/for/generating/unique/key", 's');
   if(shmid < 0) {
     printf("ERROR: Can't get shared memory id.\n");
     return -1;
   }

   // get shared memory pointer
   struct SharedData *sdata = (SharedData *)qShmGet(shmid);
   if(sdata == NULL) {
     printf("ERROR: Can't get shared memory.\n");
     return -1;
   }

Definition in file qShm.c.


Generated on Fri Apr 28 07:00:39 2017 for JSOC_Documentation by  doxygen 1.5.7.1