//Takes the input data file and starts up the other processes int main (int argc, char *argv[]) { int id; int nSeniors; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &id); MPI_Comm_size(MPI_COMM_WORLD, &nSeniors); printf("Initialised senior with ID %d, number of seniors %d\n", id, nSeniors); //Seed random srand(time(NULL)); if (id == 0) { printf("Setting up spawn for initialiser thread\n"); pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); // Spawn audience threads pthread_t initialiserThread; int rc; printf("Attempting to spawn initialiser thread\n"); rc = pthread_create(&initialiserThread, &attr, initialiser, (void *)argv[1]); if (rc) { printf("***** Could not create thread. Return code from pthread_create() is: %d\n", rc); exit(-1); } } senior(id, nSeniors, atof(argv[2])); MPI_Finalize(); }
int junior (int x, short *y) { char name[10] = "cougars"; senior (x, 2); }