diff --git a/tp/tp6/src/pi.c b/tp/tp6/src/pi.c index dbc7de5..efd8a2e 100644 --- a/tp/tp6/src/pi.c +++ b/tp/tp6/src/pi.c @@ -6,10 +6,15 @@ void* nbDansCercleSeq( void* nbLancers ) { long nb = 0; - unsigned int seed; + struct drand48_data bf; + double x,y; + srand48_r(pthread_self(),&bf); // initialisation de la graine + // avec le numero du thread + for( long i = 0; i < (long) nbLancers; i++ ) { - double x = (double) rand_r(&seed) / RAND_MAX; - double y = (double) rand_r(&seed) / RAND_MAX; + drand48_r(&bf,&x); + drand48_r(&bf,&y); + if ( x * x + y * y <= 1.0 ) { nb += 1; }