J
Joy
i have a code that uses pthread, but when i use pthread_create()
method it returns error code 11. I have found out that this is often
because of exceeding the THREAD_MAX limit for the process. But i want
to use only about 24 threads at a given time, and i destroy the
threads (or atleast i thought so) can someone tell me what i am doing
wrong here it would be of great help! thanks!
for (i=0; i<no_pairs; ){
for (j=0; j<MAX_THREADS && i<no_pairs; j++,i++){
data[j].a = seeds[i/no_seeds];
data[j].b = seeds[i%no_seeds];
data[j].N = N;
data[j].L = nones+nzeros;
data[j].p1 = get_string (seeds[i/no_seeds], nzeros
+nones-1);
data[j].p2 = get_string (seeds[i%no_seeds], nzeros
+nones-1);
data[j].results = pairs;
rc = pthread_create (&threads[j], &attr, run_actree, (void
*)
&data[j]);
if (rc) {
printf ("ERROR; return code from pthread_create() is %d
\n", rc);
exit (-1);
}
}
for (k=0; k<j; k++){
rc = pthread_join (threads[k], &status);
if (rc) {
printf("ERROR; return code from pthread_join() is %d
\n", rc);
exit(-1);
}
}
}
pthread_attr_destroy (&attr);
Above is the main loop i create threads in, MAX_THREADS = 24
Any help as to where i am going wrong is greatly appreciated.
method it returns error code 11. I have found out that this is often
because of exceeding the THREAD_MAX limit for the process. But i want
to use only about 24 threads at a given time, and i destroy the
threads (or atleast i thought so) can someone tell me what i am doing
wrong here it would be of great help! thanks!
for (i=0; i<no_pairs; ){
for (j=0; j<MAX_THREADS && i<no_pairs; j++,i++){
data[j].a = seeds[i/no_seeds];
data[j].b = seeds[i%no_seeds];
data[j].N = N;
data[j].L = nones+nzeros;
data[j].p1 = get_string (seeds[i/no_seeds], nzeros
+nones-1);
data[j].p2 = get_string (seeds[i%no_seeds], nzeros
+nones-1);
data[j].results = pairs;
rc = pthread_create (&threads[j], &attr, run_actree, (void
*)
&data[j]);
if (rc) {
printf ("ERROR; return code from pthread_create() is %d
\n", rc);
exit (-1);
}
}
for (k=0; k<j; k++){
rc = pthread_join (threads[k], &status);
if (rc) {
printf("ERROR; return code from pthread_join() is %d
\n", rc);
exit(-1);
}
}
}
pthread_attr_destroy (&attr);
Above is the main loop i create threads in, MAX_THREADS = 24
Any help as to where i am going wrong is greatly appreciated.