#include #include #include #include long N, P; int *a; long res = 0; void *prodvec(void *j) { long pos = (long) j; for (long i = (N/P)*pos; i < (N/P)*(pos+1); i++) { res += a[i]; } pthread_exit(0); } int main(int argc, char *argv[]) { void *status; if (argc != 3) fprintf(stderr, "Usage %s/ N P \n", argv[0]); N = atoi(argv[1]); P = atoi(argv[2]); pthread_t threads[P]; if (N%P != 0) fprintf(stderr, "N mod P != 0, not possible\n"); a = (int*) malloc (N*sizeof(int)); for (long i=0; i