#include "stdio.h" #include "stdlib.h" #include "pvm3.h" #define N 10 void sendint(int tid, int data) { pvm_initsend(PvmDataDefault); // adat // hany darabot akarunk kuldeni // minden hanyadikat akarjuk elkuldeni (stride parameter, lsd manual) pvm_pkint(&data, 1, 1); pvm_send(tid, 1); } int receiveint() { pvm_recv(-1,-1); int num; pvm_upkint(&num, 1, 1); return num; } int main() { //where to send the information (received from the server) int to_tid = receiveint(); //the first number is the maximum int max = receiveint(); int i; //receive the N-1 number left for(i=0; i max) { //swap int tmp = max; max = num; num = tmp; } //forward the other number (store the maximum) sendint(to_tid, num); } //at the end send the last (maximum) number too sendint(to_tid, max); pvm_exit(); exit(EXIT_SUCCESS); }