/* slave program for PVM-first-try */ /* returns string consisting of machine name and local time */ #include #include #include main() { time_t now; char name[12], buf[60]; int ptid; ptid = pvm_parent(); /* the ID of the master process */ pvm_setopt(PvmRoute, PvmRouteDirect); gethostname(name, 64); /* find name of machine */ now=time(NULL); /* get time */ strcpy(buf, name); /* put name into string */ strcat(buf, "'s time is "); strcat(buf, ctime(&now)); /* add time to string */ pvm_initsend(PvmDataDefault); /* allocate message buffer */ pvm_pkstr(buf); /* pack string into buffer */ pvm_send(ptid, 2); /* send buffer to master */ pvm_exit; /* slave is done and exits */ }