Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/10/2013, 07:52
numbersvj
 
Fecha de Ingreso: octubre-2013
Mensajes: 5
Antigüedad: 12 años, 11 meses
Puntos: 0
Problema con hebras posix

He estado toqueteando con hebras posix y estoy bastante perdido, no llego a entender el error de este código :/

Código PHP:
#include <iostream>
#include <pthread.h>

using namespace std;

unsigned long m=10;

double f (double x){
    return 
4.0/(1+x*x);
}

double calcula(){
    
double suma = 0.0;
    for (
unsigned long i=0 ; i < m ; i++)
            
suma += f ((i+0.5)/m);
    return 
suma/m;
}

int main (){

    
pthread_t hebra1, hebra2;

    
pthread_create (&hebra1, NULL , f, NULL);
    
pthread_create (&hebra2, NULL, calcula, NULL);

    
pthread_join (hebra1,NULL);

}