Goodd evening,
I would like to ask you sthg as far as dividing a shared memory segment into
8 buffers is concerned.
e.g. in the following code , we have allocated the shared memory segment and we want now to divide it into 8 stacks which every stack is going to consist of 4 integers.(4 * 8 =32 integers)
How do we do that?
Code:
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include<time.h>
#include <unistd.h>
#define SHMSZ 8
int main() {
key_t key;
int shmid;
int *buf;
if((key = ftok("path of user", 0)) < 0){
printf("\n%d Error in key\n",key);
return 0;
}
printf("%d\n",key);
shmid = shmget(key,SHMSZ * sizeof(int),(IPC_CREAT | 0666));
buf = shmat(shmid,NULL,0);
}
Thanks, in advance!