unsigned char dc;
int get_data_and_calc(t_event *event,void *allineed);
+int nop(t_event *event,void *allineed);
int usage(char *prog)
{
void send_data(int signum) {
int c;
+ unsigned char data;
c=gd3_l->max_x*gd3_l->max_y*gd3_l->max_z;
+ printf("%d <-\n",c);
+
network_send(gnet->connection[0].fd,&dc,1);
/*
network_send(gnet->connection[0].fd,(unsigned char *)gd3_l,
sizeof(d3_lattice));
network_send(gnet->connection[0].fd,(unsigned char *)gmy_info,sizeof(info));
*/
+ printf("debug: sent dc\n");
network_send(gnet->connection[0].fd,gd3_l->status,c*sizeof(unsigned char));
+ network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char));
+ printf("debug: sent ac\n");
network_send(gnet->connection[0].fd,(unsigned char *)gd3_l->extra,
c*sizeof(int));
+ network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char));
+ printf("debug: sent cc\n");
network_send(gnet->connection[0].fd,(unsigned char *)gi,sizeof(int));
+ network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char));
}
/* wait for job */
event_math(net.connection[0].fd,&event,READ,ADD);
printf("idle, waiting for jobs ...\n");
- event_start(&event,NULL,get_data_and_calc,NULL);
+ event_start(&event,NULL,get_data_and_calc,nop);
+
+ return 1;
+}
+
+int nop(t_event *event,void *allineed) {
return 1;
}
u32 x_c,y_c,z_c;
int i,j;
int c_step;
- unsigned char data[256];
+ unsigned char data;
t_net *net;
printf("got a new job ...\n");
/* get info (+data) */
- network_receive(net->connection[0].fd,data,1);
- if(data[0]==NLSOP_NJOB || data[0]==NLSOP_CJOB) {
+ network_receive(net->connection[0].fd,&data,sizeof(unsigned char));
+ if(data==NLSOP_NJOB || data==NLSOP_CJOB) {
network_receive(net->connection[0].fd,(unsigned char *)&d3_l,
sizeof(d3_lattice));
network_receive(net->connection[0].fd,(unsigned char *)&my_info,
printf("extra malloc failed\n");
return -1;
}
- if(data[0]==NLSOP_CJOB) {
+ if(data==NLSOP_CJOB) {
+ data=DATA_OK;
network_receive(net->connection[0].fd,d3_l.status,
j*sizeof(unsigned char));
+ network_send(net->connection[0].fd,&data,sizeof(unsigned char));
network_receive(net->connection[0].fd,(unsigned char *)d3_l.extra,
j*sizeof(int));
+ network_send(net->connection[0].fd,&data,sizeof(unsigned char));
network_receive(net->connection[0].fd,(unsigned char *)&c_step,
sizeof(int));
+ network_send(net->connection[0].fd,&data,sizeof(unsigned char));
}
}
+ else {
+ printf("unknown instruction, restarting ...\n");
+ return -1;
+ }
printf("starting simulation with following parameters:\n");
printf("b = %f | c = %f | s = %f\n",my_info.b,my_info.c,my_info.s);
dc=DC_QUIT;
/* shutdown/free/close everything now ... */
+ free(d3_l.status);
+ free(d3_l.extra);
return 1;
}