legacy_sources/v1/libparallel.c
/*----------------------------------------------------------*/
/* Init structures, scheduler and launch threads			*/
/*----------------------------------------------------------*/
Init structures, scheduler and launch threads
Init structures scheduler and launch threads
int InitParallel(int NmbCpu)
{
	int i;
	pthread_attr_init(&PthAtr);
	pthread_attr_setdetachstate(&PthAtr, PTHREAD_CREATE_JOINABLE);
	if(!(par = calloc(1, sizeof(ParSct))))
		return(0);
	par->NmbCpu = NmbCpu;
	par->mtx = &mtx;
	for(i=0;i<NmbCpu;i++)
	{
		par->PthTab[i].idx = i;
		par->PthTab[i].sta = ParIdl;
		par->PthTab[i].wrk = NULL;
		memset(&par->PthTab[i].pth, 0, sizeof(pthread_t));
		pthread_create(&par->PthTab[i].pth, &PthAtr, PthSch, (void *)&par->PthTab[i]);
	}
	return(1);
}
int InitParallel ( int NmbCpu ) { int i ; pthread_attr_init ( & PthAtr ) ; pthread_attr_setdetachstate ( & PthAtr , PTHREAD_CREATE_JOINABLE ) ; if ( ! ( par = calloc ( 1 , sizeof ( ParSct ) ) ) ) return ( 0 ) ; par -> NmbCpu = NmbCpu ; par -> mtx = & mtx ; for ( i = 0 ; i < NmbCpu ; i ++ ) { par -> PthTab [ i ] . idx = i ; par -> PthTab [ i ] . sta = ParIdl ; par -> PthTab [ i ] . wrk = NULL ; memset ( & par -> PthTab [ i ] . pth , 0 , sizeof ( pthread_t ) ) ; pthread_create ( & par -> PthTab [ i ] . pth , & PthAtr , PthSch , ( void * ) & par -> PthTab [ i ] ) ; } return ( 1 ) ; }
Init structures, scheduler and launch threads
Init structures scheduler and launch threads
/* Alloc and init Pthreads */ /* Allocate and build main parallel structure */ /* Launch Pthreads */