/* example of using threads to split up the work */ #include #include #include #include typedef struct { double *array; int N; double sum; } threadInfo; void *fsum( void *ud ) { threadInfo *ti = (threadInfo *)ud; int i; for(i=0;iN;i++) { ti->sum += ti->array[i]; } } int main(int argc, char *argv[]) { const int size = 1000000; int i, mux; double *bigarray = malloc( sizeof(double) * size ); double sum; struct timeval start, end; double stime, ftime; threadInfo ti[4]; pthread_t thread[4]; for(i=0;i