Need urgent help for Programming with PThread

Hi guys, i'm trying to parallel this program using Pthread butall seems to going wrong someone can help with how can I parallelize the function named "selection sort"?

#include<stdio.h>
#include <stdlib.h>
#include <time.h>

#define MAX 100000

void selection_sort(int *a);

int main(){
FILE *arq;
time_t start, stop;
int x,i, vet[MAX];

time(&start);

arq = fopen("numeros.txt","r");

i=0;
while (!feof(arq)){

fscanf(arq, "%d",&vet[i]);
i++;
}
fclose(arq);

selection_sort(vet);


printf("Ordem \n");
for(i=0;i<MAX;i++){

printf("%d \n",vet[i]);

}

time(&stop);

printf("Finished in about %0.4f seconds. \n", difftime(stop, start));
return 0;

}

void selection_sort(int *a)
{
int i, j, k, tmp, troca;

for(i = 0; i < MAX-1; i++)
{
troca = 0;
k = i;
tmp = a[i];

for(j = i+1; j < MAX; j++) {
if(a[j] < tmp)
{
k = j;
tmp = a[j];
troca = 1;
}
}
if(troca)
{
a[k] = a[i];
a[i] = tmp;
}
}
}

I hope u guys can help me, please ill be thankful!
Last edited on
You need to use the code format tags (from the palette on the right) to format your code.

! don't see any call to pthread.
Topic archived. No new replies allowed.