title: How to Attach more than one semaphores to Shared memory using shmat?
body: <p>In Shared Memory, Data can be written anywhere on it by using the pointer attached to it <br>
  For Example if <b>id</b> is shared memory id (having size 1024B) and char* type is attached to it as follows<br></p>
  
  <pre><code>char* CharPointertoSm;
  CharPointertoSm=(char*)shmat(id, 0, 0);
  </code></pre>
  
  <p>then Data can be read or written anywhere on Shared memory using pointer <b>CharPointertoSm</b> <br>
  like, to write on index 10, we do    </p>
  
  <pre><code>CharPointertoSm[10]='a';
  </code></pre>
  
  <p>My Question is how do we use same scheme to attach more than one semaphores to shared memory? To Attach one semaphore we do</p>
  
  <pre><code>sem_t * semDecide = NULL;
  if ((semDecide = (sem_t *)shmat(id, 0, 0)) == (sem_t *) -1) 
  {
          printf("shmat-sem\r\n");
          shmctl(id,IPC_RMID, 0);            
          exit(1);
  }
  </code></pre>
  
  <p>and This semaphore(semDecide) will take first 32 Bytes of shared memory, How can we Assign next 32 bits to another semaphore? because using same as above for another semaphore as</p>
  
  <pre><code>sem_t * semDecide2 = NULL;
  if ((semDecide2 = (sem_t *)shmat(id, 0, 0)) == (sem_t *) -1) 
  {
          printf("shmat-sem\r\n");
          shmctl(id,IPC_RMID, 0);            
          exit(1);
  }
  </code></pre>
  
  <p>is not working(maybe because it uses first 32 bytes again, that has previously been assigned to first semaphore(i-e to semDecide)<br>
  <b>How to attach the second semaphore next to first semaphore using shmat?</b></p>