/****************************************************************************** * PVM TEMPLATE CODES * FILE: pvm.ex1.worker.c * DESCRIPTION: See pvm.ex1.master.c * PVM VERSION: 2.4 * LAST REVISED: 6/27/93 bbarney ****************************************************************************/ #include #define ARRAYSIZE 60000 #define FROMMASTER_MSG 1 #define FROMWORKER_MSG 2 main() { int i, index, msgtype, rc, bytes, masternum, chunksize; float result[ARRAYSIZE]; char master[16]; /******************* enroll this component in pvm ***************************/ rc = enroll("ex1.w"); if (rc < 0) { printf("WORKER: Unable to enroll this component.\n"); printf(" Return code= %d\n", rc); printf(" Quitting.\n"); exit(0); } else printf("WORKER: Component enrolled as instance = %d\n", rc); /******************* receive data from master component **********************/ msgtype = FROMMASTER_MSG; rcv(msgtype); getnint(&index, 1); getnint(&chunksize, 1); getnfloat(&result[index], chunksize); rcvinfo(&bytes, &msgtype, master, &masternum); /******************* modify the array and then send back to master **********/ for(i=index; i< index + chunksize; i++) result[i] = i + 1; msgtype = FROMWORKER_MSG; initsend(); putnint(&index, 1); putnfloat(&result[index], chunksize); snd(master, masternum, msgtype); /*** leave PVM ***/ leave(); }