Distributed programming: Difference between revisions

Content added Content deleted
(→‎{{header|C}}: using PVM)
(→‎{{header|C}}: correction and comments)
Line 140: Line 140:
printf("Spawning successful\n");
printf("Spawning successful\n");


/* pvm_recv(task_id, msgtag). msgtag identifies what kind of data it is,
/* pvm_recv(task_id, msgtag). msgtag identifies what kind of data it is,
* for here: 1 = (int, double), 2 = (int, int)
* for here: 1 = (int, double), 2 = (int, int)
* The receiving order is intentionally swapped, just to show.
*/
* task_id = -1 means "receive from any task"
*/
pvm_recv(-1, 2);
pvm_recv(-1, 2);
pvm_unpackf("%d %d", &i_data, &i2);
pvm_unpackf("%d %d", &i_data, &i2);
printf("got msg type 1: %d %d\n", i_data, i2);
printf("got msg type 2: %d %d\n", i_data, i2);


pvm_recv(-1, 1);
pvm_recv(-1, 1);
pvm_unpackf("%d %lf", &i_data, &f_data);
pvm_unpackf("%d %lf", &i_data, &f_data);
printf("got msg type 2: %d %f\n", i_data, f_data);
printf("got msg type 1: %d %f\n", i_data, f_data);
} else {
} else {
parent = pvm_parent();
parent = pvm_parent();