// // Definitions of masterProcess, slaveProcess functions, // to be #include'd in main program. // // Starter version in which master process does all the // work. // ---- OKAY TO ADD FUNCTIONS, #include's HERE // // Function to be called from process 0 ("master"). // // Pre: myID is process ID (0). // nprocs is number of processes. // numsIn is of size N and contains the numbers to sort. // numsOut is of size N. // minVal, maxVal are the smallest and largest possible // values. // Post: numsOut contains the results of sorting numsIn. // (numsIn, as indicated by the "const" declaration, must // not be changed.) // void masterProcess(const int myID, const int nprocs, const int N, const int minVal, const int maxVal, const int numsIn[], int numsOut[]) { // REPLACE THE CONTENTS OF THIS FUNCTION WITH YOUR CODE #ifdef DEBUG cerr << "in master process\n"; #endif // DEBUG // use STL copy to copy numsIn array to numsOut array copy(numsIn, numsIn+N, numsOut); // use STL sort to sort numsOut sort(numsOut, numsOut+N); } // // Function to be called from processes other than 0 ("slave"). // // Pre: myID is process ID. // nprocs is number of processes. // N is the number of numbers that will be sorted (may be // helpful in allocating storage for local variables). // Post: this process has done whatever is necessary to help // the master process (running masterProcess, above). // void slaveProcess(const int myID, const int nprocs, const int N) { // REPLACE THE CONTENTS OF THIS FUNCTION WITH YOUR CODE #ifdef DEBUG cerr << "in slave process, id " << myID << endl; #endif }