M
mikegw
Hello all.
I am currently using an implementation of sysV shared memory. The entire
shared memory is allocated is one continuous block of which I get the
pointer to the head, everything should be done as offsets from this. At the
moment I have two data structures, a head to a linked list which in it
contains the pointer to the first element in the linked list( this is
redundant as far as I can work out) and the list itself. The data
structures are as follows
struct ipc_particle
{
int zone_id;
int zone[3];
int fur_flag;
double radiusR; //radius of repulsion (contact radius)
double radiusA; //radius of attraction (influence radius)
double mass; //mass
double poissons; //poissons ratio
double youngs; //Young's modulus
double zeta; //zeta potential
double force[3]; //force
double position[3]; //position psn[0]=x, psn[1]=y, psn[2]=z
double velocity[3]; //velocity
};
struct dem_mem
{
int particles;
int processors;
int run;
int time_semaphore;
double clock;
struct ipc_particle* particle_head;
};
to calculate the dem_mem->particle_head I currently use particle_head =
dem_mem_pointer+(sizeof(struct dem_mem))
to reference the elements in the linked list I just use
particle_head[offset].zone_id for example.
I don't like how I calculate the particle_head, for a start I get a warning
about adding an int to a pointer.
Basically I know that my first element is sizeof(struct dem_mem) away from
the header pointer. Is there a better way to get this?
Thanks and I hope my rambling made sense.
Mike
I am currently using an implementation of sysV shared memory. The entire
shared memory is allocated is one continuous block of which I get the
pointer to the head, everything should be done as offsets from this. At the
moment I have two data structures, a head to a linked list which in it
contains the pointer to the first element in the linked list( this is
redundant as far as I can work out) and the list itself. The data
structures are as follows
struct ipc_particle
{
int zone_id;
int zone[3];
int fur_flag;
double radiusR; //radius of repulsion (contact radius)
double radiusA; //radius of attraction (influence radius)
double mass; //mass
double poissons; //poissons ratio
double youngs; //Young's modulus
double zeta; //zeta potential
double force[3]; //force
double position[3]; //position psn[0]=x, psn[1]=y, psn[2]=z
double velocity[3]; //velocity
};
struct dem_mem
{
int particles;
int processors;
int run;
int time_semaphore;
double clock;
struct ipc_particle* particle_head;
};
to calculate the dem_mem->particle_head I currently use particle_head =
dem_mem_pointer+(sizeof(struct dem_mem))
to reference the elements in the linked list I just use
particle_head[offset].zone_id for example.
I don't like how I calculate the particle_head, for a start I get a warning
about adding an int to a pointer.
Basically I know that my first element is sizeof(struct dem_mem) away from
the header pointer. Is there a better way to get this?
Thanks and I hope my rambling made sense.
Mike