From 43c44a0687703db5b6eee271a5846154570b010a Mon Sep 17 00:00:00 2001 From: prasu Date: Sat, 29 Sep 2018 13:16:04 +0200 Subject: [PATCH 1/7] creted new structure for thread object --- assignment2/ex02/task2.c | 115 +++++++++++++++++++++++++++------------ 1 file changed, 80 insertions(+), 35 deletions(-) diff --git a/assignment2/ex02/task2.c b/assignment2/ex02/task2.c index ba1796d..d0ba59a 100644 --- a/assignment2/ex02/task2.c +++ b/assignment2/ex02/task2.c @@ -3,60 +3,105 @@ #include #include +/* Define a data type for the arguments to pass to the functions of threads. */ +struct thread_arg_t +{ + /* starting index */ + unsigned int startindex; + + /* upper index */ + unsigned int upperlimit; + + /* calclauted primes */ + int* primes; + + +}; + /* Returns the index of the next prime (non-zero, since we "knock out" non-primes by setting their value to zero) */ -int getNextPrime(int i, int x[]) { - while (x[i] == 0) { - i++; - } - return i; +int getNextPrime(int i, int x[]) +{ + while (x[i] == 0) + { + i++; + } + return i; } void displayPrimeNumbers(int primes[],int NPRIMES) { - for(int i=2; i < NPRIMES; i++) { - if ( primes[i] != 0 ) { - printf("Prime number: %d\n", primes[i]); + for(int i=2; i < NPRIMES; i++) + { + if ( primes[i] != 0 ) + { + printf("Prime number: %d\n", primes[i]); + } } - } } int *init(int primes[],int NPRIMES) { - /* we start at 2 because it is the smallest prime */ - /*list all numbers from 2 to max */ - for(int i=2; i < NPRIMES; i++) { - primes[i] = i; - printf("%d\n", i); - } -return primes; + /* we start at 2 because it is the smallest prime */ + /*list all numbers from 2 to max */ + for(int i=2; i < NPRIMES; i++) + { + primes[i] = i; + printf("%d\n", i); + } + return primes; } -int *filterPrimes(int startingindex,int primes[],int maxlimit){ -/*make iterations from 2 to NPRIMES and update counter with next prime number*/ - for(int i=startingindex; i < maxlimit; i = getNextPrime(i+1, primes)) { - /*find multiple i.e j=i*2 and j=j+i and marked that number by setting array[index]=0 */ - for(int j = (i*2); j < maxlimit; j += i) { - printf("i: %d, j: %d\n", i, j); - primes[j] = 0; +int *filterPrimes(int startingindex,int *primes,int maxlimit) +{ + /*make iterations from 2 to NPRIMES and update counter with next prime number*/ + for(int i=startingindex; i < maxlimit; i = getNextPrime(i+1, primes)) + { + /*find multiple i.e j=i*2 and j=j+i and marked that number by setting array[index]=0 */ + for(int j = (i*2); j < maxlimit; j += i) + { + printf("i: %d, j: %d\n", i, j); + primes[j] = 0; + + } } + return primes; +} - } -return primes; +int *approximate_pi_pthread_runnable(void *arg) +{ + /* Cast the argument from void* to its proper type. */ + struct thread_arg_t *targ = arg; + /* Add index to seed to make sure that different threads get different + * seeds even if they are created so close in time that time() returns + * the same value. */ + int* resultprimes,tempprimes; + unsigned int startingindex = targ->startindex; + unsigned int upperlimit = targ->upperlimit; + tempprimes= targ->primes; + resultprimes=filterPrimes(startingindex,tempprimes,upperlimit); + + return resultprimes; } -int main(int argc, char* argv[]) { - int* primes; - int NPRIMES; +int main(int argc, char* argv[]) +{ + pthread_t thread1, thread2; + int* primes; + int NPRIMES; - NPRIMES = 24; - primes = (int*)malloc(NPRIMES * sizeof(int)); -unsigned int sqrt_num = (int) ceil(sqrt((double) NPRIMES)); + NPRIMES = 24; + primes = (int*)malloc(NPRIMES * sizeof(int)); + unsigned int sqrt_num = (int) ceil(sqrt((double) NPRIMES)); -primes=init(primes,NPRIMES); -primes=filterPrimes(2,primes,sqrt_num); -displayPrimeNumbers(primes,NPRIMES); + primes=init(primes,NPRIMES); + filterPrimes(2,primes,24); +//displayPrimeNumbers(primes,NPRIMES); + /* displayPrimeNumbers(primes,NPRIMES); + */ + printf("hello \n"); + printf("world \n"); - return 0; + return 0; } From 0a07a04566ee25995b45fc367d1ab1892c0c0e5b Mon Sep 17 00:00:00 2001 From: prasu Date: Sat, 29 Sep 2018 15:17:56 +0200 Subject: [PATCH 2/7] threading not resolved --- assignment2/ex02/task2.c | 50 ++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/assignment2/ex02/task2.c b/assignment2/ex02/task2.c index d0ba59a..8b0c974 100644 --- a/assignment2/ex02/task2.c +++ b/assignment2/ex02/task2.c @@ -6,6 +6,9 @@ /* Define a data type for the arguments to pass to the functions of threads. */ struct thread_arg_t { + /* thread id */ + unsigned int id; + /* starting index */ unsigned int startindex; @@ -54,7 +57,7 @@ int *init(int primes[],int NPRIMES) int *filterPrimes(int startingindex,int *primes,int maxlimit) { /*make iterations from 2 to NPRIMES and update counter with next prime number*/ - for(int i=startingindex; i < maxlimit; i = getNextPrime(i+1, primes)) + for(int i=startingindex; i <= maxlimit; i = getNextPrime(i+1, primes)) { /*find multiple i.e j=i*2 and j=j+i and marked that number by setting array[index]=0 */ for(int j = (i*2); j < maxlimit; j += i) @@ -68,7 +71,7 @@ int *filterPrimes(int startingindex,int *primes,int maxlimit) return primes; } -int *approximate_pi_pthread_runnable(void *arg) +int *calculate_prime_pthread_runnable(void *arg) { /* Cast the argument from void* to its proper type. */ struct thread_arg_t *targ = arg; @@ -86,22 +89,55 @@ int *approximate_pi_pthread_runnable(void *arg) int main(int argc, char* argv[]) { - pthread_t thread1, thread2; int* primes; int NPRIMES; - - NPRIMES = 24; + int NUM_THREADS=1; + NPRIMES = 100; + pthread_t threads[NUM_THREADS]; /* An array of the threads. */ + struct thread_arg_t args[NUM_THREADS]; /* One argument struct per thread. */ primes = (int*)malloc(NPRIMES * sizeof(int)); unsigned int sqrt_num = (int) ceil(sqrt((double) NPRIMES)); primes=init(primes,NPRIMES); - filterPrimes(2,primes,24); + /* Create (and run) all the threads. */ + + primes=filterPrimes(2,primes,sqrt_num); + + for (int i = sqrt_num+1,j=0; j < NUM_THREADS; j++) + { + if(i>=NPRIMES) + { + break; + } + args[j].startindex = i; + args[j].upperlimit=NPRIMES; + args[j].primes=primes; + if (pthread_create(&threads[i], NULL,calculate_prime_pthread_runnable, &args[j])) + { + fprintf(stderr, "Error creating thread #%d!\n", j); + exit(1); + } + i=i+1; + + } + + /* Block until all threads are finished. */ + for (int i = 0; i < NUM_THREADS; i++) + { + pthread_join(threads[i], NULL); + } + //displayPrimeNumbers(primes,NPRIMES); /* displayPrimeNumbers(primes,NPRIMES); */ + int* result= args[0].primes; printf("hello \n"); - printf("world \n"); + printf("%d \n",result[13]); + printf("%d \n",result[3]); + printf("%d \n",result[14]); + printf("%d \n",result[15]); return 0; + } From ec7e45514ff9718bbbe2f529f82cea849194c5fe Mon Sep 17 00:00:00 2001 From: prasu Date: Sat, 29 Sep 2018 16:32:14 +0200 Subject: [PATCH 3/7] change implementation of function as by pass by reference --- assignment2/ex02/task2.c | 82 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/assignment2/ex02/task2.c b/assignment2/ex02/task2.c index 8b0c974..f92db51 100644 --- a/assignment2/ex02/task2.c +++ b/assignment2/ex02/task2.c @@ -22,39 +22,39 @@ struct thread_arg_t }; /* Returns the index of the next prime (non-zero, since we "knock out" non-primes by setting their value to zero) */ -int getNextPrime(int i, int x[]) +int getNextPrime(int i, int *x) { - while (x[i] == 0) + while (*(x + i) == 0) { i++; } return i; } -void displayPrimeNumbers(int primes[],int NPRIMES) +void displayPrimeNumbers(int *primes,int NPRIMES) { for(int i=2; i < NPRIMES; i++) { - if ( primes[i] != 0 ) + if ( *(primes +i) != 0 ) { - printf("Prime number: %d\n", primes[i]); + printf("Prime number: %d\n", *(primes +i)); } } } -int *init(int primes[],int NPRIMES) +int *init(int *primes,int NPRIMES) { /* we start at 2 because it is the smallest prime */ /*list all numbers from 2 to max */ for(int i=2; i < NPRIMES; i++) { - primes[i] = i; + *(primes +i) = i; printf("%d\n", i); } return primes; } -int *filterPrimes(int startingindex,int *primes,int maxlimit) +void *filterPrimes(int startingindex,int *primes,int maxlimit) { /*make iterations from 2 to NPRIMES and update counter with next prime number*/ for(int i=startingindex; i <= maxlimit; i = getNextPrime(i+1, primes)) @@ -68,10 +68,10 @@ int *filterPrimes(int startingindex,int *primes,int maxlimit) } } - return primes; + return NULL; } -int *calculate_prime_pthread_runnable(void *arg) +void *calculate_prime_pthread_runnable(void *arg) { /* Cast the argument from void* to its proper type. */ struct thread_arg_t *targ = arg; @@ -82,9 +82,9 @@ int *calculate_prime_pthread_runnable(void *arg) unsigned int startingindex = targ->startindex; unsigned int upperlimit = targ->upperlimit; tempprimes= targ->primes; - resultprimes=filterPrimes(startingindex,tempprimes,upperlimit); + filterPrimes(startingindex,targ->primes,upperlimit); - return resultprimes; + return NULL; } int main(int argc, char* argv[]) @@ -99,44 +99,42 @@ int main(int argc, char* argv[]) unsigned int sqrt_num = (int) ceil(sqrt((double) NPRIMES)); primes=init(primes,NPRIMES); - /* Create (and run) all the threads. */ - - primes=filterPrimes(2,primes,sqrt_num); + filterPrimes(2,primes,NPRIMES); + displayPrimeNumbers(primes,NPRIMES); - for (int i = sqrt_num+1,j=0; j < NUM_THREADS; j++) - { - if(i>=NPRIMES) - { - break; - } - args[j].startindex = i; - args[j].upperlimit=NPRIMES; - args[j].primes=primes; - if (pthread_create(&threads[i], NULL,calculate_prime_pthread_runnable, &args[j])) - { - fprintf(stderr, "Error creating thread #%d!\n", j); - exit(1); - } - i=i+1; - } + /* Create (and run) all the threads. */ - /* Block until all threads are finished. */ - for (int i = 0; i < NUM_THREADS; i++) - { - pthread_join(threads[i], NULL); - } +// primes=filterPrimes(2,primes,sqrt_num); +// +// for (int i = sqrt_num+1,j=0; j < NUM_THREADS; j++) +// { +// if(i>=NPRIMES) +// { +// break; +// } +// args[j].startindex = i; +// args[j].upperlimit=NPRIMES; +// args[j].primes=primes; +// if (pthread_create(&threads[i], NULL,calculate_prime_pthread_runnable, &args[j])) +// { +// fprintf(stderr, "Error creating thread #%d!\n", j); +// exit(1); +// } +// i=i+1; +// +// } +// +// /* Block until all threads are finished. */ +// for (int i = 0; i < NUM_THREADS; i++) +// { +// pthread_join(threads[i], NULL); +// } //displayPrimeNumbers(primes,NPRIMES); /* displayPrimeNumbers(primes,NPRIMES); */ - int* result= args[0].primes; - printf("hello \n"); - printf("%d \n",result[13]); - printf("%d \n",result[3]); - printf("%d \n",result[14]); - printf("%d \n",result[15]); return 0; From bdb5784bec745e00d2890abb15b308e80167f2e0 Mon Sep 17 00:00:00 2001 From: prasu Date: Sat, 29 Sep 2018 16:39:42 +0200 Subject: [PATCH 4/7] implemented for single thread --- assignment2/ex02/task2.c | 55 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/assignment2/ex02/task2.c b/assignment2/ex02/task2.c index f92db51..736e0f2 100644 --- a/assignment2/ex02/task2.c +++ b/assignment2/ex02/task2.c @@ -99,42 +99,41 @@ int main(int argc, char* argv[]) unsigned int sqrt_num = (int) ceil(sqrt((double) NPRIMES)); primes=init(primes,NPRIMES); - filterPrimes(2,primes,NPRIMES); - displayPrimeNumbers(primes,NPRIMES); - + filterPrimes(2,primes,sqrt_num); /* Create (and run) all the threads. */ -// primes=filterPrimes(2,primes,sqrt_num); -// -// for (int i = sqrt_num+1,j=0; j < NUM_THREADS; j++) -// { -// if(i>=NPRIMES) -// { -// break; -// } -// args[j].startindex = i; -// args[j].upperlimit=NPRIMES; -// args[j].primes=primes; -// if (pthread_create(&threads[i], NULL,calculate_prime_pthread_runnable, &args[j])) -// { -// fprintf(stderr, "Error creating thread #%d!\n", j); -// exit(1); -// } -// i=i+1; -// -// } -// -// /* Block until all threads are finished. */ -// for (int i = 0; i < NUM_THREADS; i++) -// { -// pthread_join(threads[i], NULL); -// } + primes=filterPrimes(2,primes,sqrt_num); + + for (int i = sqrt_num+1,j=0; j < NUM_THREADS; j++) + { + if(i>=NPRIMES) + { + break; + } + args[j].startindex = i; + args[j].upperlimit=NPRIMES; + args[j].primes=primes; + if (pthread_create(&threads[j], NULL,calculate_prime_pthread_runnable, &args[j])) + { + fprintf(stderr, "Error creating thread #%d!\n", j); + exit(1); + } + i=i+1; + + } + + /* Block until all threads are finished. */ + for (int i = 0; i < NUM_THREADS; i++) + { + pthread_join(threads[i], NULL); + } //displayPrimeNumbers(primes,NPRIMES); /* displayPrimeNumbers(primes,NPRIMES); */ + displayPrimeNumbers(primes,NPRIMES); return 0; From ae9e19e91d99b003ac97a85177d4be3ed03c4b94 Mon Sep 17 00:00:00 2001 From: prasu Date: Sat, 29 Sep 2018 20:12:12 +0200 Subject: [PATCH 5/7] added subtle bug in implementaion --- assignment2/ex02/task2.c | 106 ++++++++++++++++++++++++++------------- 1 file changed, 70 insertions(+), 36 deletions(-) diff --git a/assignment2/ex02/task2.c b/assignment2/ex02/task2.c index 736e0f2..6ebdec3 100644 --- a/assignment2/ex02/task2.c +++ b/assignment2/ex02/task2.c @@ -3,6 +3,8 @@ #include #include +pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; +int NPRIMES=100; /* Define a data type for the arguments to pass to the functions of threads. */ struct thread_arg_t { @@ -24,15 +26,21 @@ struct thread_arg_t /* Returns the index of the next prime (non-zero, since we "knock out" non-primes by setting their value to zero) */ int getNextPrime(int i, int *x) { + printf("inside getNextPrime"); + pthread_mutex_lock(&lock); while (*(x + i) == 0) { i++; } + pthread_mutex_unlock(&lock); + return i; } void displayPrimeNumbers(int *primes,int NPRIMES) { + printf("display all primes[] \n"); + for(int i=2; i < NPRIMES; i++) { if ( *(primes +i) != 0 ) @@ -49,21 +57,47 @@ int *init(int *primes,int NPRIMES) for(int i=2; i < NPRIMES; i++) { *(primes +i) = i; - printf("%d\n", i); + } + printf("init of primes[] \n"); return primes; } +//void *filterPrimes(int startingindex,int *primes,int maxlimit) +//{ +// printf("inside filterPrimes()"); +// /*make iterations from 2 to NPRIMES and update counter with next prime number*/ +// for(int i=startingindex; i <= maxlimit; i = getNextPrime(i+1, primes)) +// { +// /*find multiple i.e j=i*2 and j=j+i and marked that number by setting array[index]=0 */ +// for(int j = (i*i); j < maxlimit; j += i) +// { +//// printf("i: %d, j: %d\n", i, j); +// if(j%i==0) +// { +// *(primes +j) = 0; +// *(primes +i) = 0; +// +// } +// +// } +// +// } +// printf("exited filterPrimes()"); +// return NULL; +//} + void *filterPrimes(int startingindex,int *primes,int maxlimit) { /*make iterations from 2 to NPRIMES and update counter with next prime number*/ + startingindex=getNextPrime(startingindex, primes); for(int i=startingindex; i <= maxlimit; i = getNextPrime(i+1, primes)) { /*find multiple i.e j=i*2 and j=j+i and marked that number by setting array[index]=0 */ - for(int j = (i*2); j < maxlimit; j += i) + for(int j = (i*2); j <= NPRIMES; j += i) { printf("i: %d, j: %d\n", i, j); - primes[j] = 0; + *(primes +j) = 0; } @@ -73,24 +107,24 @@ void *filterPrimes(int startingindex,int *primes,int maxlimit) void *calculate_prime_pthread_runnable(void *arg) { + printf("inside runnable()"); /* Cast the argument from void* to its proper type. */ struct thread_arg_t *targ = arg; /* Add index to seed to make sure that different threads get different * seeds even if they are created so close in time that time() returns * the same value. */ - int* resultprimes,tempprimes; unsigned int startingindex = targ->startindex; unsigned int upperlimit = targ->upperlimit; - tempprimes= targ->primes; + filterPrimes(startingindex,targ->primes,upperlimit); + printf("exited runnable()"); return NULL; } int main(int argc, char* argv[]) { int* primes; - int NPRIMES; int NUM_THREADS=1; NPRIMES = 100; pthread_t threads[NUM_THREADS]; /* An array of the threads. */ @@ -100,36 +134,36 @@ int main(int argc, char* argv[]) primes=init(primes,NPRIMES); filterPrimes(2,primes,sqrt_num); - - /* Create (and run) all the threads. */ - - primes=filterPrimes(2,primes,sqrt_num); - - for (int i = sqrt_num+1,j=0; j < NUM_THREADS; j++) - { - if(i>=NPRIMES) - { - break; - } - args[j].startindex = i; - args[j].upperlimit=NPRIMES; - args[j].primes=primes; - if (pthread_create(&threads[j], NULL,calculate_prime_pthread_runnable, &args[j])) - { - fprintf(stderr, "Error creating thread #%d!\n", j); - exit(1); - } - i=i+1; - - } - - /* Block until all threads are finished. */ - for (int i = 0; i < NUM_THREADS; i++) - { - pthread_join(threads[i], NULL); - } - -//displayPrimeNumbers(primes,NPRIMES); + filterPrimes(sqrt_num+1,primes,NPRIMES); +// /* Create (and run) all the threads. */ +//args[0].primes=primes; +// for (int i = sqrt_num+1,j=0; j < NUM_THREADS; j++) +// { +// if(i>=NPRIMES) +// { +// break; +// } +// args[j].startindex = i; +// args[j].upperlimit=NPRIMES; +// +// if (pthread_create(&threads[j], NULL,calculate_prime_pthread_runnable, &args[j])) +// { +// fprintf(stderr, "Error creating thread #%d!\n", j); +// exit(1); +// } +// i=i+1; +// +// } +// +// /* Block until all threads are finished. */ +// for (int i = 0; i < NUM_THREADS; i++) +// { +// pthread_join(threads[i], NULL); +// } +// +// sleep(); +// primes=args[0].primes; +////displayPrimeNumbers(primes,NPRIMES); /* displayPrimeNumbers(primes,NPRIMES); */ From ea858f7bd3fd9a8c42119456edc9480ce7ae29e4 Mon Sep 17 00:00:00 2001 From: prasu Date: Sat, 29 Sep 2018 20:24:55 +0200 Subject: [PATCH 6/7] implementatio with single thread --- assignment2/ex02/task2.c | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/assignment2/ex02/task2.c b/assignment2/ex02/task2.c index 6ebdec3..cfc6eb6 100644 --- a/assignment2/ex02/task2.c +++ b/assignment2/ex02/task2.c @@ -134,36 +134,36 @@ int main(int argc, char* argv[]) primes=init(primes,NPRIMES); filterPrimes(2,primes,sqrt_num); + filterPrimes(sqrt_num+1,primes,NPRIMES); -// /* Create (and run) all the threads. */ -//args[0].primes=primes; -// for (int i = sqrt_num+1,j=0; j < NUM_THREADS; j++) -// { -// if(i>=NPRIMES) -// { -// break; -// } -// args[j].startindex = i; -// args[j].upperlimit=NPRIMES; -// -// if (pthread_create(&threads[j], NULL,calculate_prime_pthread_runnable, &args[j])) -// { -// fprintf(stderr, "Error creating thread #%d!\n", j); -// exit(1); -// } -// i=i+1; -// -// } -// -// /* Block until all threads are finished. */ -// for (int i = 0; i < NUM_THREADS; i++) -// { -// pthread_join(threads[i], NULL); -// } -// -// sleep(); -// primes=args[0].primes; -////displayPrimeNumbers(primes,NPRIMES); + /* Create (and run) all the threads. */ + for (int i = sqrt_num+1,j=0; j < NUM_THREADS; j++) + { + if(i>=NPRIMES) + { + break; + } + args[j].startindex = i; + args[j].upperlimit=NPRIMES; +args[0].primes=primes; + if (pthread_create(&threads[j], NULL,calculate_prime_pthread_runnable, &args[j])) + { + fprintf(stderr, "Error creating thread #%d!\n", j); + exit(1); + } + i=i+1; + + } + + /* Block until all threads are finished. */ + for (int i = 0; i < NUM_THREADS; i++) + { + pthread_join(threads[i], NULL); + } + + sleep(); + primes=args[0].primes; +//displayPrimeNumbers(primes,NPRIMES); /* displayPrimeNumbers(primes,NPRIMES); */ From 9ca0ae17c846199631a853099d20cda4e7472112 Mon Sep 17 00:00:00 2001 From: prasu Date: Sat, 29 Sep 2018 20:45:00 +0200 Subject: [PATCH 7/7] implemention with 2 threads->now creation of thread is based on number of core is remaining --- assignment2/ex02/task2.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/assignment2/ex02/task2.c b/assignment2/ex02/task2.c index cfc6eb6..12e863d 100644 --- a/assignment2/ex02/task2.c +++ b/assignment2/ex02/task2.c @@ -30,7 +30,7 @@ int getNextPrime(int i, int *x) pthread_mutex_lock(&lock); while (*(x + i) == 0) { - i++; + i=i+1; } pthread_mutex_unlock(&lock); @@ -96,8 +96,10 @@ void *filterPrimes(int startingindex,int *primes,int maxlimit) /*find multiple i.e j=i*2 and j=j+i and marked that number by setting array[index]=0 */ for(int j = (i*2); j <= NPRIMES; j += i) { - printf("i: %d, j: %d\n", i, j); + + pthread_mutex_lock(&lock); *(primes +j) = 0; + pthread_mutex_unlock(&lock); } @@ -124,8 +126,8 @@ void *calculate_prime_pthread_runnable(void *arg) int main(int argc, char* argv[]) { - int* primes; - int NUM_THREADS=1; + int* primes,prime1; + int NUM_THREADS=2; NPRIMES = 100; pthread_t threads[NUM_THREADS]; /* An array of the threads. */ struct thread_arg_t args[NUM_THREADS]; /* One argument struct per thread. */ @@ -145,7 +147,7 @@ int main(int argc, char* argv[]) } args[j].startindex = i; args[j].upperlimit=NPRIMES; -args[0].primes=primes; + args[j].primes=primes; if (pthread_create(&threads[j], NULL,calculate_prime_pthread_runnable, &args[j])) { fprintf(stderr, "Error creating thread #%d!\n", j); @@ -163,10 +165,7 @@ args[0].primes=primes; sleep(); primes=args[0].primes; -//displayPrimeNumbers(primes,NPRIMES); - /* displayPrimeNumbers(primes,NPRIMES); - */ displayPrimeNumbers(primes,NPRIMES); return 0;