H
hugo.arregui
Hi!
I have two struts like that:
struct {
int num;
int num2;
struct b arrayOfB[SIZE];
} a;
struct {
int num3;
int num4
} b;
I put struct a into Shared Memory:
shmid = shmget(IPC_PRIVATE, sizeof(struct b), 0666)
and atach it in two process:
ptr = shmat(shmid, 0, 0);
This works fine, but now i must delete the constant SIZE:
I will obtain the SIZE in runtime, before execute the shmget function.
the new struct a:
struct {
int num;
int num2;
struct b *arrayOfB;
} a;
now:
I put struct a into Shared Memory:
shmid = shmget(IPC_PRIVATE, sizeof(struct a) + sizeof(struct b) *
size, 0666);
and atach it in two process:
ptr = shmat(shmid, 0, 0);
my question is: how can tell arrayOfB to point over the shared memory?
i thought:
struct a *ptr,p2*;
p2 = ptr; //ptr is the shmat return
p2++;
ptr->arrayOfB
but doesn't work. in another way i read about the shmat parametrs, but
don't understand how (if its possible) use to solve my trouble.
Thanks.
I have two struts like that:
struct {
int num;
int num2;
struct b arrayOfB[SIZE];
} a;
struct {
int num3;
int num4
} b;
I put struct a into Shared Memory:
shmid = shmget(IPC_PRIVATE, sizeof(struct b), 0666)
and atach it in two process:
ptr = shmat(shmid, 0, 0);
This works fine, but now i must delete the constant SIZE:
I will obtain the SIZE in runtime, before execute the shmget function.
the new struct a:
struct {
int num;
int num2;
struct b *arrayOfB;
} a;
now:
I put struct a into Shared Memory:
shmid = shmget(IPC_PRIVATE, sizeof(struct a) + sizeof(struct b) *
size, 0666);
and atach it in two process:
ptr = shmat(shmid, 0, 0);
my question is: how can tell arrayOfB to point over the shared memory?
i thought:
struct a *ptr,p2*;
p2 = ptr; //ptr is the shmat return
p2++;
ptr->arrayOfB
but doesn't work. in another way i read about the shmat parametrs, but
don't understand how (if its possible) use to solve my trouble.
Thanks.