pthread_join segment fault

635 views Asked by At

I'm doing parallel sorting using pthreads. Currently, I'm working with 4 threads and I have just started out , so right now no threads access same global locations. ( I have declared two variables globally, variables are arrays of large size and I'm making sure no two threads access the same index.)

Inside AASort , I have another function being called. This code works if I don't call any function within the AASort function.

unsigned  int Numbers [N/4] [4];
unsigned int vMergedArray[NumProcs][64][4];
unsigned int v[NumProcs][2][4];

main()
{
/* Initialize array of thread structures */
threads = (pthread_t *) malloc(sizeof(pthread_t) * NumProcs);
   assert(threads != NULL);

   for(threadId=0; threadId < NumProcs; threadId++) {

     ret = pthread_create(&threads[threadId], &attr, AASort, (void*) threadId);
     assert(ret == 0);

    }


     for(threadId=0; threadId < NumProcs; threadId++) {
      ret = pthread_join(threads[threadId], NULL);
      assert(ret == 0); 

}
}
0

There are 0 answers