title: Designing a Queue to be a shared memory
body: <p>I'm attempting to design/implement a (circular) queue (in C) as a shared memory so that it can be shared between multiple threads/processes. </p>
  
  <p>The queue structure is as follows:</p>
  
  <pre><code>typedef struct _q {
      int q_size;
      int q_front;
      int q_rear;
      int *q_data;
  }queue;
  </code></pre>
  
  <p>Which supports the following functions:</p>
  
  <pre><code>int empty_q(queue *q);
  int display_q(queue *q);
  int create_q(queue **q, int size);
  int delete_q(queue **q);
  int enqueue(queue *q, int data);
  int dequeue(queue *q, int *data);
  </code></pre>
  
  <p>As per the queue size mentioned by the user, the memory for q_data will be allocated in create_q().</p>
  
  <p>Question: How to create a shared memory for this queue using system functions provided in "sys/shm.h"? Any code snippet/example for creating/attaching/retrieving/deleting shared memory for the queue data-structure using shmget(), shmat(), shmctl(), etc would be a great help. </p>