int main(int argc, char *argv[]) { cur_file = malloc(sizeof(v_file_text)); switch (argc) { default: case 1: cur_file_name[0] = 0; v_new_file(cur_file); break; case 2: strcpy(cur_file_name, argv[1]); v_load_file(cur_file_name, cur_file); break; } init_global(); redraw_ui(); init_display_back(); disable_display_back(); main_loop(); enable_display_back(); return 0; }
void test_with_multiple_threads(char*ip,int port) { pthread_t th[16]; int res, i; char local_ip[30]; strncpy(local_ip,ip,25); thread_struct thread_input[16]; for(i=0;i<16;i++) { thread_input[i].in_ip = local_ip; thread_input[i].in_port = port; thread_input[i].tid = i; } init_global();//shared memory which allows less than 16 threads int thread[16]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; for(i=0;i<16;i++){ res = pthread_create(&th[i],NULL,__db_function,(void*)(&thread_input[i])); if(res!=0){ printf("thread fail\n"); break; } } void* thread_result; for(i=0;i<16;i++){ res = pthread_join(th[i],&thread_result); if(res!=0){ printf("thread join fail\n"); break; } } }
int main(void) { char *cmd; t_node *tree; init_global(); while (!global.status) { tree = NULL; global.prompt = edit_prompt(global.config, global.env); if ((cmd = edit_cmd(&global, global.prompt)) == NULL && !global.status) global.status = !global.status; if (my_strlen(cmd) >= MAX_LINE_NUMBER) fprintf(stderr, "%s: File name too long\n", cmd); else if (!global.status) if (is_singlestr(' ', cmd) && (tree = parsing_func(cmd, &global, 0))) if ((exec_course_tree(tree, global.env, &global)) == EXIT_CHILD) { sh_free(&global, tree, cmd); (global.prompt) ? free(global.prompt) : (global.prompt = NULL); return (global.exit); } sh_free(NULL, tree, cmd); (global.prompt) ? free(global.prompt) : (global.prompt = NULL); } sh_free(&global, NULL, NULL); return (global.exit); }
int main(void) { init_global(); init_gdt(); init_idt(); init_tss(); init_virtual_memory_mapping(); init_process(); init_8259a(); init_clock(); init_keyboard(); init_syscall(); debug_helper(); restart(); }
static long init_global_bo(boRecord *prec) { assert(prec->out.type==INST_IO); init_global((dbCommon*)prec, prec->out.value.instio.string); return 0; }
void Cvode::init_prepare() { if (init_global()) { if (y_) { N_VDestroy(y_); y_ = nil; } if (mem_) { CVodeFree(mem_); mem_ = nil; } if (atolnvec_) { N_VDestroy(atolnvec_); atolnvec_ = nil; } if (daspk_) { delete daspk_; daspk_ = nil; } init_eqn(); if (neq_ > 0) { y_ = nvnew(neq_); if (use_daspk_) { alloc_daspk(); }else{ alloc_cvode(); } if (maxstate_) { activate_maxstate(false); activate_maxstate(true); } } } }
static long init_global_wf(waveformRecord *prec) { assert(prec->inp.type==INST_IO); if(prec->ftvl!=menuFtypeCHAR) return 0; init_global((dbCommon*)prec, prec->inp.value.instio.string); return 0; }
static int __init init_sys_xjob(void) { INFO("installed new sys_xjob module"); init_global(); if (sysptr == NULL) sysptr = xjob; return 0; }
bool pstorage_driver_init() { if (pstorage_init() != NRF_SUCCESS) { return false; } // Configure pstorage driver. if(!pstorage_driver_cfg(0x20)) { return false; } // Read SensorID from p_storage if(!init_global((uint8_t*)&sensor_bridge.sensorID, (uint8_t*)&DEFAULT_SENSOR_ID, sizeof(sensor_bridge.sensorID))) { return false; } // Read SensorBeaconFrequency from p_storage if(!init_global((uint8_t*)&sensor_bridge.beaconFrequency, (uint8_t*)&DEFAULT_SENSOR_BEACON_FREQUENCY, sizeof(sensor_bridge.beaconFrequency))) { return false; } // Read Config from p_storage if(!init_global((uint8_t*)&sensor_bridge.config, (uint8_t*)&DEFAULT_SENSOR_CONFIG, sizeof(sensor_bridge.config))) { return false; } // Read Passkey from p_storage if(!init_global((uint8_t*)sensor_bridge.passkey, (uint8_t*)DEFAULT_SENSOR_PASSKEY, sizeof(sensor_bridge.passkey))) { return false; } // Read mitm_req_flag from p_storage if(!init_global((uint8_t*)&sensor_bridge.mitm_req_flag, (uint8_t*)&DEFAULT_MITM_REQ_FLAG, sizeof(sensor_bridge.mitm_req_flag))) { return false; } return true; }
JNIEXPORT jint JNICALL Java_cgr_1jni_Libocgr_predictContacts (JNIEnv *env, jclass thisObj, jint nodeNum) { if (javaVM == NULL) (*env)->GetJavaVM(env, &javaVM); init_global(); setThreadLocalEnv(env); uvast unodeNum = (uvast) nodeNum; setNodeNum(unodeNum); predictContacts(); fflush(stdout); return 0; }
int main(int ac, char **argv) { init_global(ac, argv); if (init_env(&g_env, &g_lenv) == 1 || (a_init() == -1)) return (1); g_hash = hash_table(get_path(g_env, g_lenv)); xmalloc(100); if (sh21() == 1) { hash_del(&(g_hash)); return (1); } hash_del(&(g_hash)); return (0); }
JNIEXPORT jint JNICALL Java_cgr_1jni_Libocgr_contactDiscoveryLost (JNIEnv *env, jclass thisObj, jint nodeNum, jint neighborNum) { jint result; if (javaVM == NULL) (*env)->GetJavaVM(env, &javaVM); init_global(); setThreadLocalEnv(env); uvast unodeNum = (uvast) nodeNum; uvast uneighborNum = (uvast) neighborNum; setNodeNum(unodeNum); contactLost(uneighborNum); fflush(stdout); return 0; }
JNIEXPORT jint JNICALL Java_cgr_1jni_Libocgr_exchangeContactHistory (JNIEnv *env, jclass thisObj, jint nodeNum1, jint nodeNum2) { jint result; if (javaVM == NULL) (*env)->GetJavaVM(env, &javaVM); init_global(); setThreadLocalEnv(env); uvast unodeNum1 = (uvast) nodeNum1; uvast unodeNum2 = (uvast) nodeNum2; setNodeNum(unodeNum1); exchangeContactHistory(unodeNum1,unodeNum2); fflush(stdout); return 0; }
static HRESULT set_ctx_site(JScript *This) { HRESULT hres; This->ctx->lcid = This->lcid; hres = init_global(This->ctx); if(FAILED(hres)) return hres; IActiveScriptSite_AddRef(This->site); This->ctx->site = This->site; change_state(This, SCRIPTSTATE_INITIALIZED); return S_OK; }
JNIEXPORT jint JNICALL Java_cgr_1jni_Libocgr_applyDiscoveryInfos (JNIEnv *env, jclass thisObj, jint nodeNum, jlong fromNode, jlong toNode, jlong fromTime, jlong toTime, jint xmitRate) { jint result; if (javaVM == NULL) (*env)->GetJavaVM(env, &javaVM); init_global(); setThreadLocalEnv(env); uvast unodeNum = (uvast) nodeNum; setNodeNum(unodeNum); applyDiscoveryInfo((uvast) fromNode, (uvast) toNode, (uvast) fromTime, (uvast) toTime, (int) xmitRate); fflush(stdout); return 0; }
void disconnect_after_connect(){ init_global(); clusterInfo *cluster = connectRedis("127.0.0.1",6667); if(cluster != NULL) { printf("connected to cluster\n"); }else{ printf("panic\n"); } char key[10] = "key"; char value[10] = "value"; set(cluster,key,value,1,1); get(cluster,key,value,1,1); printf("get value= %s\n",value); disconnectDatabase(cluster); release_global(); }
/*===========================================================================* * fs_inodewalker * *===========================================================================*/ int fs_inodewalker() { /* Get the list of blocks in use by the system from the inode bitmap */ printf("Inode Walker\n"); printf("Getting super node from device %llu ...\n", fs_dev); type = IMAP; sb = get_super(fs_dev); read_super(sb); lsuper(); init_global(); imap_disk = alloc_bitmap(N_IMAP); printf("Loading inode bitmap from disk ...\n"); get_bitmap(imap_disk, IMAP); printf(" done.\n"); sleep(3); int *list_inodes = get_list_used(imap_disk, IMAP); free_bitmap(imap_disk); return 0; }
/*===========================================================================* * fs_zonewalker * *===========================================================================*/ int fs_zonewalker() { /* Get the list of blocks used by the system from the zone bitmap */ printf("Zone Walkder\n"); printf("Getting super node from device %llu ...\n", fs_dev); type = ZMAP; sb = get_super(fs_dev); read_super(sb); lsuper(); sleep(3); init_global(); zmap_disk = alloc_bitmap(N_ZMAP); printf("Loading zone bitmap from disk ...\n"); get_bitmap(zmap_disk, ZMAP); printf(" done.\n\n"); sleep(3); //print_bitmap(zmap_disk); int* list = get_list_used(zmap_disk, ZMAP); free_bitmap(zmap_disk); return 0; }
int main( int argc, char ** argv ) { /* 用于存储套接口文件描述符 */ int sockfd; /* 初始化全局变量 */ init_global( &global ); if( argc == 1 ) { /* 表示打印所有包头信息 */ global.print_flag_frame = 1; global.print_flag_arp = 1; global.print_flag_ip = 1; global.print_flag_rarp = 1; global.print_flag_tcp = 1; global.print_flag_udp = 1; global.print_flag_icmp = 1; global.print_flag_igmp = 1; } else { /* 帮助 或者 通过指定协议名称只打印某层些协议 */ if( !strcasecmp( argv[1], "-h" ) ){ help(); exit( 0 ); } else { int i; for( i=1; i < argc; i++ ){ if( !strcasecmp( argv[i], "frame" ) ) global.print_flag_frame = 1; else if( !strcasecmp( argv[i], "arp" ) ) global.print_flag_arp = 1; else if( !strcasecmp( argv[i], "rarp" ) ) global.print_flag_rarp = 1; else if( !strcasecmp( argv[i], "ip" ) ) global.print_flag_ip = 1; else if( !strcasecmp( argv[i], "tcp" ) ) global.print_flag_tcp = 1; else if( !strcasecmp( argv[i], "udp" ) ) global.print_flag_udp = 1; else if( !strcasecmp( argv[i], "icmp" ) ) global.print_flag_icmp = 1; else if( !strcasecmp( argv[i], "igmp" ) ) global.print_flag_igmp = 1; } } } /* 通过协议族AF_PACKET类信SOCK_RAW, 类型SOCK_RAW创建一个用于可以接受网卡帧数据的套接口,同时返回套就口文件描述符 */ if( (sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)) ) == -1 ) error_and_exit( "socket", 1 ); /* 如果发生错误,返回错误值, 并退出 */ /* 设定网卡eth0成混杂模式 */ set_card_promisc( "eth0", sockfd ); /* 设定信号处理函数, 下面是设置当我们按下ctrl-c时所调用的处理函数 */ signal( SIGINT, sig_int ); /* 无限循环接收以太网卡数据帧, 并进行数据分用,直到你按下ctrl-c */ while( 1 ){ do_frame( sockfd ); } return 0; }
/* ** Exported */ WORD Appl_do_init (GLOBAL_ARRAY * global) { C_APPL_INIT par; R_APPL_INIT ret; WORD apid = -1; DEBUG3("Appl_do_init: 1"); CHECK_APID(apid); DEBUG3("Appl_do_init: 2"); if(apid == -1) { #ifdef MINT_TARGET Psemaphore(SEM_LOCK, SHEL_WRITE_LOCK, -1); Psemaphore(SEM_UNLOCK, SHEL_WRITE_LOCK, 0); #endif DEBUG3 ("appl.c: Appl_do_init"); /* Open connection to server */ if (Client_open () == -1) { return -1; } DEBUG3("Appl_do_init: 3"); #ifdef TUNNEL_VDI_CALLS /* Tunnel VDI calls through oaesis' connection with the server */ vdi_handler = vdi_tunnel; #endif /* TUNNEL_VDI_CALLS */ DEBUG3("Appl_do_init: 4"); PUT_C_ALL(APPL_INIT, &par); DEBUG3("Appl_do_init: 5"); #ifdef MINT_TARGET get_process_name (par.common.pid, par.appl_name, sizeof (par.appl_name) - 1); #else DEBUG3 ("appl.c: Appl_do_init: program_invocation_short_name %s", program_invocation_short_name); strncpy (par.appl_name, program_invocation_short_name, sizeof (par.appl_name) - 1); #endif DEBUG3("Appl_do_init: 6"); par.appl_name[sizeof (par.appl_name) - 1] = 0; DEBUG3("Appl_do_init: 7"); CLIENT_SEND_RECV(&par, sizeof (C_APPL_INIT), &ret, sizeof (R_APPL_INIT)); DEBUG3("Appl_do_init: 8"); global->apid = ret.apid; DEBUG3("Appl_do_init: 9"); if(global->apid >= 0) { DEBUG3("Appl_do_init: 10"); init_global_appl (global->apid, ret.physical_vdi_id, par.appl_name); DEBUG3("Appl_do_init: 11"); #ifndef MINT_TARGET { GLOBAL_APPL * globals_appl = get_globals (global->apid); DEBUG3("Appl_do_init: 12"); init_global (globals_appl->vid); } #endif } } else { global->apid = apid; } DEBUG3("Appl_do_init: 13"); global->version = 0x0410; global->numapps = -1; global->appglobal = 0L; global->rscfile = 0L; global->rshdr = 0L; global->resvd1 = 0; global->resvd2 = 0; global->int_info = 0L; global->maxchar = 0; global->minchar = 0; return global->apid; }
void start_radiosity(long val) #endif { static long state = 0 ; long i; long total_rad_time, max_rad_time, min_rad_time; long total_refine_time, max_refine_time, min_refine_time; long total_wait_time, max_wait_time, min_wait_time; long total_vertex_time, max_vertex_time, min_vertex_time; #if defined(SGI_GL) && defined(GL_NASA) long val ; val = g_get_choice_val( ap, &choices[0] ) ; #endif if( val == CHOICE_RAD_RUN ) { if( state == -1 ) { printf( "Please reset first\007\n" ) ; return ; } /* Time stamp */ CLOCK( time_rad_start ) ; global->index = 0; /* Create slave processes */ for (i = 0 ; i < n_processors ; i++ ) { taskqueue_id[i] = assign_taskq(0) ; } /* And start processing */ CREATE(radiosity, n_processors); WAIT_FOR_END(n_processors); /* Time stamp */ CLOCK( time_rad_end ); /* Print out running time */ /* Print out running time */ printf("TIMING STATISTICS MEASURED BY MAIN PROCESS:\n"); print_running_time(0); if (dostats) { printf("\n\n\nPER-PROCESS STATISTICS:\n"); printf("%8s%20s%20s%12s%12s\n","Proc","Total","Refine","Wait","Smooth"); printf("%8s%20s%20s%12s%12s\n\n","","Time","Time","Time","Time") ; for (i = 0; i < n_processors; i++) printf("%8ld%20lu%20lu%12lu%12lu\n",i,timing[i]->rad_time, timing[i]->refine_time, timing[i]->wait_time, timing[i]->vertex_time); total_rad_time = timing[0]->rad_time; max_rad_time = timing[0]->rad_time; min_rad_time = timing[0]->rad_time; total_refine_time = timing[0]->refine_time; max_refine_time = timing[0]->refine_time; min_refine_time = timing[0]->refine_time; total_wait_time = timing[0]->wait_time; max_wait_time = timing[0]->wait_time; min_wait_time = timing[0]->wait_time; total_vertex_time = timing[0]->vertex_time; max_vertex_time = timing[0]->vertex_time; min_vertex_time = timing[0]->vertex_time; for (i = 1; i < n_processors; i++) { total_rad_time += timing[i]->rad_time; if (timing[i]->rad_time > max_rad_time) max_rad_time = timing[i]->rad_time; if (timing[i]->rad_time < min_rad_time) min_rad_time = timing[i]->rad_time; total_refine_time += timing[i]->refine_time; if (timing[i]->refine_time > max_refine_time) max_refine_time = timing[i]->refine_time; if (timing[i]->refine_time < min_refine_time) min_refine_time = timing[i]->refine_time; total_wait_time += timing[i]->wait_time; if (timing[i]->wait_time > max_wait_time) max_wait_time = timing[i]->wait_time; if (timing[i]->wait_time < min_wait_time) min_wait_time = timing[i]->wait_time; total_vertex_time += timing[i]->vertex_time; if (timing[i]->vertex_time > max_vertex_time) max_vertex_time = timing[i]->vertex_time; if (timing[i]->vertex_time < min_vertex_time) min_vertex_time = timing[i]->vertex_time; } printf("\n\n%8s%20lu%20lu%12lu%12lu\n","Max", max_rad_time, max_refine_time, max_wait_time, max_vertex_time); printf("\n%8s%20lu%20lu%12lu%12lu\n","Min", min_rad_time, min_refine_time, min_wait_time, min_vertex_time); printf("\n%8s%20lu%20lu%12lu%12lu\n","Avg", (long) (((double) total_rad_time) / ((double) (1.0 * n_processors))), (long) (((double) total_refine_time) / ((double) (1.0 * n_processors))), (long) (((double) total_wait_time) / ((double) (1.0 * n_processors))), (long) (((double) total_vertex_time) / ((double) (1.0 * n_processors)))); printf("\n\n"); } /* print_fork_time(0) ; */ print_statistics( stdout, 0 ) ; /* Display image */ display_scene( disp_fill_mode, disp_patch_switch, disp_mesh_switch, disp_interaction_switch, 0) ; state = -1 ; } else if( val == CHOICE_RAD_STEP ) { if( state == -1 ) { printf( "Please reset first\007\n" ) ; return ; } /* Step execution */ switch( state ) { case 0: /* Step execute as a single process */ global->index = 1; /* Create slave processes */ for ( i = 0 ; i < n_processors ; i++ ) { taskqueue_id[i] = assign_taskq(0) ; } CREATE(radiosity, n_processors/* - 1*/); /* Decompose model objects into patches and build the BSP tree */ /* Create the first tasks (MASTER only) */ init_modeling_tasks(0) ; process_tasks(0) ; state ++ ; break ; case 1: if( init_ray_tasks(0) ) { BARRIER(global->barrier, n_processors); process_tasks(0) ; } else state++ ; break ; default: BARRIER(global->barrier, n_processors); init_radavg_tasks( RAD_AVERAGING_MODE, 0 ) ; process_tasks(0) ; init_radavg_tasks( RAD_NORMALIZING_MODE, 0 ) ; process_tasks(0) ; WAIT_FOR_END(n_processors/* - 1*/) state = -1 ; } /* Display image */ display_scene( disp_fill_mode, disp_patch_switch, disp_mesh_switch, disp_interaction_switch, 0) ; } else if( val == CHOICE_RAD_RESET ) { /* Initialize global variables again */ init_global(0) ; init_visibility_module(0) ; g_clear() ; state = 0 ; } }
boolean Global::ChangeS1S5(int value) { boolean ret = false; int nbtap, tot, ct; if ( Menu->ChangeS1S5(value) ) { if ( Menu->FirstPage ) { switch (Menu->S1S5) { case 1 : // Tap Tempo for (ct=TAPTEMPO_MAX-1;ct>0;ct--) tapTempo[ct]=tapTempo[ct-1]; tapTempo[ 0 ] = millis(); nbtap=0; tot=0; for ( int ct=0;ct<TAPTEMPO_MAX-1; ct++ ) { if ( tapTempo[ ct ] - tapTempo[ ct + 1] < (60000/TEMPO_MIN) ) { tot += ( tapTempo[ct] - tapTempo[ct+1] ); nbtap++; } } if ( nbtap > 0 ) { ParamGlo.Tempo = (uint16_t)60000 / ( tot / nbtap ); if ( ParamGlo.Tempo < TEMPO_MIN ) ParamGlo.Tempo=TEMPO_MIN; if ( ParamGlo.Tempo > TEMPO_MAX ) ParamGlo.Tempo=TEMPO_MAX; Menu->SetM1(ParamGlo.Tempo); SClock.ChangeTempo(); } break; case 3 : if (!is_played) { ExStart(false); lcdM.setCursor(8,3); lcdM.print("Stop"); } else { ExStop(); lcdM.setCursor(8,3); lcdM.print("Play"); } break; case 2 : if (!is_played) { ExStart(true); lcdM.setCursor(8,3); lcdM.print("Stop"); } else { ExStop(); lcdM.setCursor(8,3); lcdM.print("Play"); } break; case 4 : switch (Recorder.mode_Record) { case RECORD_OFF: Recorder.mode_Record=RECORD_PLAY; lcdM.setCursor(13,3); lcdM.print("Ply"); Recorder.cur_Play_Record=0; clock_count=0; break; case RECORD_PLAY: if ( !is_played ) { Recorder.mode_Record=RECORD_ON; lcdM.setCursor(13,3); lcdM.print("Rec"); } else { Recorder.mode_Record=RECORD_OFF; lcdM.setCursor(13,3); lcdM.print("Off"); } break; case RECORD_ON: Recorder.mode_Record=RECORD_OFF; lcdM.setCursor(13,3); lcdM.print("Off"); break; } break; } } else { switch (Menu->S1S5) { case 3: switch( Menu->curCmd ) { case 0: /* Load */ SPOut.AutoOff( ParamGlo.UpperDest ); SPOut.AutoOff( ParamGlo.LowerDest ); if ( MySD.OpenFileForRead(MODE_PARAM, Menu->GetFName(FileName) ) ) { Restore(); MySD.CloseFile(); } PatLed.Show(0); UpdateRoute(0); DessinPage(); break; case 1: /* Save */ if ( MySD.OpenFileForWrite(MODE_PARAM, Menu->MenuFName(FileName) ) ) { Backup(); MySD.CloseFile(); } PatLed.Show(0); break; case 2: /* Load All*/ SPOut.AutoOff( ParamGlo.UpperDest ); SPOut.AutoOff( ParamGlo.LowerDest ); read_global(Menu->GetFName(FileName)); PatLed.Show(0); DessinPage(); break; case 3: /* Save All*/ write_global(Menu->MenuFName(FileName) ); PatLed.Show(0); break; case 4: /* Init */ SPOut.AutoOff( ParamGlo.UpperDest ); SPOut.AutoOff( ParamGlo.LowerDest ); if ( Menu->V1 == 0 ) Init(); else init_global(); PatLed.Show(0); DessinPage(); break; case 5: S4822.Send(CV_1, 400*Menu->V1 ); S4822.Send(CV_2, 400*Menu->V1); S4822.Send(CV_3, 400*Menu->V1 ); S4822.Send(CV_4, 400*Menu->V1 ); S4822.Send(CV_5, 400*Menu->V1 ); S4822.Send(CV_6, 400*Menu->V1 ); S4822.Send(CV_7, 400*Menu->V1 ); S4822.Send(CV_8, 400*Menu->V1 ); // analogWrite(DAC0, 400*Menu->V1 ); // analogWrite(DAC1, 400*Menu->V1 ); PatLed.Show(0); break; case 6: digitalWrite(TRIG_1, Menu->V1 ); digitalWrite(TRIG_2, Menu->V1 ); digitalWrite(TRIG_3, Menu->V1 ); digitalWrite(TRIG_4, Menu->V1 ); digitalWrite(TRIG_5, Menu->V1 ); digitalWrite(TRIG_6, Menu->V1 ); digitalWrite(TRIG_7, Menu->V1 ); digitalWrite(TRIG_8, Menu->V1 ); PatLed.Show(0); break; } break; } } } return ret; }
int main(int argc, char *argv[]) { long i; long total_rad_time, max_rad_time, min_rad_time; long total_refine_time, max_refine_time, min_refine_time; long total_wait_time, max_wait_time, min_wait_time; long total_vertex_time, max_vertex_time, min_vertex_time; /* Parse arguments */ parse_args(argc, argv) ; choices[2].init_value = model_selector ; /* Initialize graphic device */ if( batch_mode == 0 ) { g_init(argc, argv) ; setup_view( DFLT_VIEW_ROT_X, DFLT_VIEW_ROT_Y, DFLT_VIEW_DIST, DFLT_VIEW_ZOOM,0 ) ; } /* Initialize ANL macro */ MAIN_INITENV(,60000000) ; THREAD_INIT_FREE(); /* Allocate global shared memory and initialize */ global = (Global *) G_MALLOC(sizeof(Global)) ; if( global == 0 ) { printf( "Can't allocate memory\n" ) ; exit(1) ; } init_global(0) ; timing = (Timing **) G_MALLOC(n_processors * sizeof(Timing *)); for (i = 0; i < n_processors; i++) timing[i] = (Timing *) G_MALLOC(sizeof(Timing)); /* Initialize shared lock */ init_sharedlock(0) ; /* Initial random testing rays array for visibility test. */ init_visibility_module(0) ; /* POSSIBLE ENHANCEMENT: Here is where one might distribute the sobj_struct, task_struct, and vis_struct data structures across physically distributed memories as desired. One way to place data is as follows: long i; for (i=0;i<n_processors;i++) { Place all addresses x such that &(sobj_struct[i]) <= x < &(sobj_struct[i+1]) on node i Place all addresses x such that &(task_struct[i]) <= x < &(task_struct[i+1]) on node i Place all addresses x such that &(vis_struct[i]) <= x < &(vis_struct[i+1]) on node i } */ if( batch_mode ) { /* In batch mode, create child processes and start immediately */ /* Time stamp */ CLOCK( time_rad_start ); global->index = 0; for( i = 0 ; i < n_processors ; i++ ) { taskqueue_id[i] = assign_taskq(0) ; } /* And start processing */ CREATE(radiosity, n_processors); WAIT_FOR_END(n_processors); /* Time stamp */ CLOCK( time_rad_end ); /* Print out running time */ printf("TIMING STATISTICS MEASURED BY MAIN PROCESS:\n"); print_running_time(0); if (dostats) { printf("\n\n\nPER-PROCESS STATISTICS:\n"); printf("%8s%20s%20s%12s%12s\n","Proc","Total","Refine","Wait","Smooth"); printf("%8s%20s%20s%12s%12s\n\n","","Time","Time","Time","Time"); for (i = 0; i < n_processors; i++) printf("%8ld%20lu%20lu%12lu%12lu\n",i,timing[i]->rad_time, timing[i]->refine_time, timing[i]->wait_time, timing[i]->vertex_time); total_rad_time = timing[0]->rad_time; max_rad_time = timing[0]->rad_time; min_rad_time = timing[0]->rad_time; total_refine_time = timing[0]->refine_time; max_refine_time = timing[0]->refine_time; min_refine_time = timing[0]->refine_time; total_wait_time = timing[0]->wait_time; max_wait_time = timing[0]->wait_time; min_wait_time = timing[0]->wait_time; total_vertex_time = timing[0]->vertex_time; max_vertex_time = timing[0]->vertex_time; min_vertex_time = timing[0]->vertex_time; for (i = 1; i < n_processors; i++) { total_rad_time += timing[i]->rad_time; if (timing[i]->rad_time > max_rad_time) max_rad_time = timing[i]->rad_time; if (timing[i]->rad_time < min_rad_time) min_rad_time = timing[i]->rad_time; total_refine_time += timing[i]->refine_time; if (timing[i]->refine_time > max_refine_time) max_refine_time = timing[i]->refine_time; if (timing[i]->refine_time < min_refine_time) min_refine_time = timing[i]->refine_time; total_wait_time += timing[i]->wait_time; if (timing[i]->wait_time > max_wait_time) max_wait_time = timing[i]->wait_time; if (timing[i]->wait_time < min_wait_time) min_wait_time = timing[i]->wait_time; total_vertex_time += timing[i]->vertex_time; if (timing[i]->vertex_time > max_vertex_time) max_vertex_time = timing[i]->vertex_time; if (timing[i]->vertex_time < min_vertex_time) min_vertex_time = timing[i]->vertex_time; } printf("\n\n%8s%20lu%20lu%12lu%12lu\n","Max", max_rad_time, max_refine_time, max_wait_time, max_vertex_time); printf("\n%8s%20lu%20lu%12lu%12lu\n","Min", min_rad_time, min_refine_time, min_wait_time, min_vertex_time); printf("\n%8s%20lu%20lu%12lu%12lu\n","Avg", (long) (((double) total_rad_time) / ((double) (1.0 * n_processors))), (long) (((double) total_refine_time) / ((double) (1.0 * n_processors))), (long) (((double) total_wait_time) / ((double) (1.0 * n_processors))), (long) (((double) total_vertex_time) / ((double) (1.0 * n_processors)))); printf("\n\n"); } /* print_fork_time(0) ; */ print_statistics( stdout, 0 ) ; } else { /* In interactive mode, start workers, and the master starts notification loop */ /* Start notification loop */ g_start( expose_callback, N_SLIDERS, sliders, N_CHOICES, choices ) ; } MAIN_END; exit(0) ; }
void main(int argc, char **argv) { FILE *uheader, *server, *user; FILE *iheader, *sheader; set_program_name("mig"); parseArgs(argc, argv); init_global(); init_type(); LookNormal(); (void) yyparse(); if (errors > 0) exit(1); more_global(); uheader = myfopen(UserHeaderFileName, "w"); if (!UserFilePrefix) user = myfopen(UserFileName, "w"); server = myfopen(ServerFileName, "w"); if (ServerHeaderFileName) sheader = myfopen(ServerHeaderFileName, "w"); if (IsKernelServer) { iheader = myfopen(InternalHeaderFileName, "w"); } if (BeVerbose) { printf("Writing %s ... ", UserHeaderFileName); fflush(stdout); } WriteUserHeader(uheader, StatementList); fclose(uheader); if (ServerHeaderFileName) { if (BeVerbose) { printf ("done.\nWriting %s ...", ServerHeaderFileName); fflush (stdout); } WriteServerHeader(sheader, StatementList); fclose(sheader); } if (IsKernelServer) { if (BeVerbose) { printf("done.\nWriting %s ... ", InternalHeaderFileName); fflush(stdout); } WriteInternalHeader(iheader, StatementList); fclose(iheader); } if (UserFilePrefix) { if (BeVerbose) { printf("done.\nWriting individual user files ... "); fflush(stdout); } WriteUserIndividual(StatementList); } else { if (BeVerbose) { printf("done.\nWriting %s ... ", UserFileName); fflush(stdout); } WriteUser(user, StatementList); fclose(user); } if (BeVerbose) { printf("done.\nWriting %s ... ", ServerFileName); fflush(stdout); } WriteServer(server, StatementList); fclose(server); if (BeVerbose) printf("done.\n"); exit(0); }
VOID DFCIimcomp(int32 xdim, int32 ydim, const uint8 *in, uint8 out[], uint8 in_pal[], uint8 out_pal[], int mode) { unsigned char raster[48]; int blocks, nmbr; int32 i, j, k, l, x, y; init_global(xdim, ydim, (VOIDP) out, (VOIDP) out_pal); /* compress pixel blocks */ blocks = 0; for (i = 0; i < (ydim / 4); i++) for (j = 0; j < (xdim / 4); j++) { switch (mode) { case BIT8: /* 8 bit per pixel format */ k = 0; for (y = (i * 4); y < (i * 4 + 4); y++) for (x = (j * 4); x < (j * 4 + 4); x++) { l = y * xdim + x; raster[k++] = (unsigned char) in_pal[3 * (unsigned char) in[l]]; raster[k++] = (unsigned char) in_pal[3 * (unsigned char) in[l] + 1]; raster[k++] = (unsigned char) in_pal[3 * (unsigned char) in[l] + 2]; } /* end of for x */ compress(raster, blocks); break; case BIT24: /* 24 bit per pixel format */ k = 0; for (y = (i * 4); y < (i * 4 + 4); y++) for (x = (j * 4); x < (j * 4 + 4); x++) { l = 3 * (y * xdim + x); raster[k++] = (unsigned char) in[l]; raster[k++] = (unsigned char) in[l + 1]; raster[k++] = (unsigned char) in[l + 2]; } /* end of for x */ compress(raster, blocks); break; default: /* unsupported format */ break; } /* end of switch */ blocks++; } /* end of for j */ /* set palette */ nmbr = cnt_color(blocks); /* printf("Number of colors %d \n", nmbr); */ if (nmbr <= PALSIZE) set_palette(blocks); else { sel_palette(blocks, nmbr, color_pt); map(blocks); } fillin_color(blocks); if (color_pt) { HDfree((VOIDP) color_pt); color_pt = NULL; } /* end if */ } /* end of DFCIimcomp */
int main (int argc, char *argv[]) { int c, ret = 0; char *subopts; char *value; char *src_name = NULL; extern char *optarg; extern int optind; struct eq_lexer *lex = (struct eq_lexer *) malloc (sizeof (struct eq_lexer)); struct eq_parser *parser = (struct eq_parser *) malloc (sizeof (struct eq_parser)); init_global (); init_global_tree (); init_options (); progname = strrchr (argv[0], '/'); if (NULL == progname) progname = argv[0]; else progname++; while (-1 != (c = getopt (argc, argv, "B:P:V"))) switch (c) { case 'P': subopts = optarg; while (*subopts != '\0') switch (getsubopt (&subopts, p_opts, &value)) { case OPT_PRINT_PROGRAM: options.print_program = true; break; case OPT_PRINT_MATCHES: options.print_matches = true; break; case OPT_PRINT_TYPES: options.print_types = true; break; default: fprintf (stderr, "unknown -P suboption `%s'\n", value); goto cleanup; break; } break; case 'B': subopts = optarg; while (*subopts != '\0') switch (getsubopt (&subopts, b_opts, &value)) { case OPT_BREAK_PARSER: options.break_option = break_parser; break; case OPT_BREAK_TYPECHECK: options.break_option = break_typecheck; break; case OPT_BREAK_CONTROLFLOW: options.break_option = break_controlflow; case OPT_BREAK_DATAFLOW: options.break_option = break_dataflow; break; default: fprintf (stderr, "unknown -B suboption `%s'\n", value); goto cleanup; break; } break; case 'V': version (); goto cleanup; default: usage (); goto cleanup; } if (options.print_types && !(options.print_program || options.print_matches)) fprintf (stderr, "warning: 'types' flag is useless without either " "'program' flag or 'matches' flag\n"); argv += optind; /* FIXME: What if we have multiple files? */ if (NULL == *argv) { fprintf (stderr, "%s:error: filename argument required\n", progname); usage (); ret = -1; goto cleanup; } /* Initialize the lexer. */ if (!eq_lexer_init (lex, *argv)) { fprintf (stderr, "%s cannot create a lexer for file `%s'\n", progname, *argv); ret = -2; goto cleanup; } else { /* Discard extension from file to compile. */ char* start = strrchr (*argv, '/'); char* ext = strrchr (*argv, '.'); int size = 0; if (start == NULL) start = *argv; else start += 1; if (ext == NULL) size = strlen(start); else size = ext - start; src_name = strndup (start, size); } /* Initialize the parser. */ eq_parser_init (parser, lex); if ((ret += eq_parse (parser)) == 0 && options.break_option != break_parser) ret += typecheck (); /* printing debug routine. */ if (options.print_program) { xfile * xf = xfile_init_file_stdout (); printf ("\n######### Output ########\n"); print_program (xf); xfile_finalize (xf); } if (options.print_matches) { printf ("\n####### Transforms ########\n"); print_matches (); } if (options.break_option != break_typecheck && options.break_option != break_parser && !ret) controlflow (); if (options.break_option != break_controlflow && options.break_option != break_typecheck && options.break_option != break_parser && !ret) dataflow (); if (options.break_option != break_dataflow && options.break_option != break_controlflow && options.break_option != break_typecheck && options.break_option != break_parser && !ret) codegen (src_name); printf ("note: finished compiling.\n"); free (src_name); cleanup: eq_parser_finalize (parser); finalize_global_tree (); finalize_global (); /* That should be called at the very end. */ free_atomic_trees (); if (parser) free (parser); if (lex) free (lex); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }