Les thread en C

sora -  
 sora -
Bonjour,
ben voila j'essay d'executé un programme en c avec les thread mais il m'affich rien, si vous pouvez m aider ça sré sympa
voila le pgm:

#include<stdio.h>

#include<math.h>

#include<stdlib.h>

#include<pthread.h>
#include <errno.h>

int fils1[6];

int fils2[6];

int tab[12];
int droit;
int gauche;
int t[10];

void tri( int t[], int gauche, int droit )

{

int i,j ;int pivot,x ;

i=gauche; j=droit; pivot =t[(i+j)/2] ;

do
{

do

{ i=i+1 ;

}
while (t[i] < pivot);

do

{ j=j-1 ;

}
while (t[j] > pivot);

if ( i<=j )

{

x=t[i];

t[i]=t[j];

t[j]=x;

i=i+1 ;

j=j-1 ;

}
}
while (i>j);

if (gauche<j)

{

tri(t,gauche,j) ;

}

if (i<droit)

{

tri(t,i,droit) ;

}

}

genererNombre(int t[]){//10 nbres aleatoires

int i;

for (i=0;i<11;i++){

t[i]=rand()%50;

//printf("num %d = %d\n",i,t[i]);

}

}

void affect_1()

{

int fils1[5];

int i,m=6;

for (i=0;i<m;i++){

fils1[i]=tab[i];

}

}

void affect_2()

{

int fils2 [6];

int i,p=11;

for (i=6;i<p;i++){

fils2[i]=tab[i];

}

}

main(int tab[])
{

pthread_t f1;
pthread_t f2;

genererNombre(tab);

int k,l ;int pivott,x ;

int p,y,i,j,h,g;
gauche=0;
droit=11;

k=gauche; l=droit; pivott =tab[(i+j)/2] ;

do

{

do
{

k=k+1 ;
}

while (tab[k] < pivott);

do

{

l=l-1 ;

}
while (tab[j] > pivott);

if ( k<=l){

x=t[k];

t[k]=t[l];

t[l]=x;

k=k+1 ;

l=l-1 ;

}

}

while (i<j);

if ( pthread_create(&f1,NULL,(void*(*)())affect_1,NULL)==-1)

perror("pb thread_create\n\n");

if (pthread_create(&f2,NULL,(void*(*)())affect_2,NULL)==-1)

perror("pb thread_create\n\n");

tri(fils1,0,j);

tri(fils2,i,11);

pthread_join(f1,NULL);

pthread_join(f2,NULL);

int v;

for (v=0;v<11;v++){

y=tab[v];

printf("l'element a la position",v,tab[v]);

}

}
A voir également:

1 réponse

sora
 
s'il vous plait c vraiment urgent, jetez y un coup d'oeil
0