#include <pvm3.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/types.h> #include <time.h> #include <limits.h> #define VERSION "master" #define ENCODING PvmDataDefault int main(){ int mytid, mygid, child[16],i; if((mytid = pvm_mytid()) < 0){ return -1; } if((mygid = pvm_joingroup("master")) < 0){ pvm_exit(); return -1; } if(mygid == 0){ char nodes[16][64]; for(i = 0; i < 15; i++) sprintf(nodes[i], "b%d.une.edu.au", i+2); for(i = 0; i < 15; i++) pvm_spawn(VERSION,NULL,PvmTaskHost,nodes[i],1,&child[i]); for(i = 0; i < 15; i++){ int g; char hostname[100]; pvm_recv(-1,-1); pvm_upkstr(hostname); fprintf(stderr,"Got a hello from %s\n", hostname); } } else{ char hostname[100]; gethostname(hostname,64); pvm_initsend(ENCODING); pvm_pkstr(hostname); pvm_send(pvm_gettid("master",0),0); pvm_barrier("master",15); } pvm_exit(); exit(0); }