int init_game(t_env *env) { key_t key; char path[1024]; getcwd(path, sizeof(path)); key = ftok("./lemipc", 0); init_share(env, key); init_semaphore(env, key); place_me(env); return (0); }
void init( dcp_info_t * info, unsigned long alloc_size ) { int wsize; MPI_Comm_size(MPI_COMM_WORLD, &wsize); MPI_Comm_rank(MPI_COMM_WORLD, &grank); dictionary* ini; if (access("config.fti", R_OK) == 0) { ini = iniparser_load("config.fti"); if (ini == NULL) { WARN_MSG("failed to parse FTI config file!"); exit(EXIT_FAILURE); } } else { EXIT_STD_ERR("cannot access FTI config file!"); } finalTag = (int)iniparser_getint(ini, "Advanced:final_tag", 3107); numHeads = (int)iniparser_getint(ini, "Basic:head", 0); int nodeSize = (int)iniparser_getint(ini, "Basic:node_size", -1); headRank = grank - grank%nodeSize; char* env = getenv( "TEST_MODE" ); if( env ) { if( strcmp( env, "ICP" ) == 0 ) { info->test_mode = TEST_ICP; INFO_MSG("TEST MODE -> ICP"); } else if ( strcmp( env, "NOICP") == 0 ) { info->test_mode = TEST_NOICP; INFO_MSG("TEST MODE -> NOICP"); } else { info->test_mode = TEST_NOICP; INFO_MSG("TEST MODE -> NOICP"); } } else { info->test_mode = TEST_NOICP; INFO_MSG("TEST MODE -> NOICP"); } //DBG_MSG("alloc_size: %lu",0,alloc_size); init_share(); // init pattern pat = (uint32_t) rand(); // protect pattern and xor_info FTI_InitType( &FTI_UI, UI_UNIT ); FTI_Protect( PAT_ID, &pat, 1, FTI_UI ); FTI_InitType( &FTI_XOR_INFO, sizeof(xor_info_t) ); FTI_Protect( XOR_INFO_ID, info->xor_info, NUM_DCKPT, FTI_XOR_INFO ); FTI_Protect( NBUFFER_ID, &info->nbuffer, 1, FTI_INTG ); // check if alloc_size is sufficiant large if ( alloc_size < 101 ) EXIT_CFG_ERR("insufficiant allocation size"); // determine number of buffers usleep(5000*grank); srand(get_seed()); if ( FTI_Status() == 0 ) { info->nbuffer = rand()%10+1; } else { FTI_RecoverVar( NBUFFER_ID ); } // initialize structure info->buffer = (void**) malloc(info->nbuffer*sizeof(void*)); info->size = (unsigned long*) malloc(info->nbuffer*sizeof(unsigned long)); info->oldsize = (unsigned long*) malloc(info->nbuffer*sizeof(unsigned long)); info->hash = (unsigned char**) malloc(info->nbuffer*sizeof(unsigned char*)); int idx; for ( idx=0; idx<info->nbuffer; ++idx ) { info->buffer[idx] = NULL; info->hash[idx] = (unsigned char*) malloc(MD5_DIGEST_LENGTH); } allocate_buffers( info, alloc_size ); generate_data( info ); init_srand(); }