void threadExp(char *asciiSize, char *asciiJobCount, char *asciiThreadCount) /* threadExp - Some pthread experiments. */ { int size = atoi(asciiSize); int jobCount = atoi(asciiJobCount); int threadCount = atoi(asciiThreadCount); pthread_t *threads; int i; double *results; double sumErr = 0; struct calcJob *jobList, *job; if (size <= 0) usage(); AllocArray(results, size); AllocArray(threads, threadCount); toDo = cacheQueueAlloc(); done = cacheQueueAlloc(); jobList = makeJobs(results, size, jobCount); uglyTime("To init and alloc %d\n", size); for (i=0; i<threadCount; ++i) pthreadCreate(&threads[i], NULL, workerBee, NULL); uglyTime("Thread spwan time"); doJobs(jobList); uglyTime("job time"); for (i=0; i<size; ++i) sumErr += (results[i]-i); uglyTime("summing err"); printf("Total error = %e\n", sumErr); printf("Total incer = %d\n", incer); }
/* Main Body */ int main(int argc, char *argv[]) { /* PRINTF OVERRIDE */ if (LOG_MODE) { FILE *log_file; if((log_file=freopen("JBUP_LOG_FILE", "a" ,stdout))==NULL) { printf("Cannot open LOG.\n"); exit(1); } } // END IF LOG_MODE jobs jlist [MAX_JOBS]; int result = 0; int number_of_jobs = 0; number_of_jobs = loadJobs( jlist ); result = doJobs( jlist, number_of_jobs ); if(BUGS) printf("\n\n\tNumber of jobs loaded : %i \n\n", number_of_jobs); /* DEV C++ */ system("PAUSE"); return EXIT_SUCCESS; }