int main(int argc, char **argv) { int result, nr_of_plugins, x; t_tissue_stack *t; char serv_command[20], load_command[150]; prctl(PR_SET_NAME, "TS_CORE"); // initialisation of some variable t = malloc(sizeof(*t)); init_prog(t); srand((unsigned) time(NULL)); // intitialisation the volume if (argc > 2) { if (argv[2] != NULL && strcmp(argv[2], "--prompt") != 0) { t->volume_first = malloc(sizeof(*t->volume_first)); if ((result = init_volume(t->memory_mappings, t->volume_first, argv[2])) != 0) return (result); } else if (argv[3] != NULL && strcmp(argv[3], "--prompt") != 0) { t->volume_first = malloc(sizeof(*t->volume_first)); if ((result = init_volume(t->memory_mappings, t->volume_first, argv[3])) != 0) return (result); } } else t->volume_first = NULL; // lunch thread_pool t->tp = malloc(sizeof(*t->tp)); thread_pool_init(t->tp, 16); nr_of_plugins = sizeof(PLUGINS) / sizeof(PLUGINS[0]); for (x = 0; x < nr_of_plugins; x++) { sprintf(load_command, "load %s %s/%s", PLUGINS[x][0], PLUGINS_PATH, PLUGINS[x][1]); plugin_load_from_string(load_command, t); DEBUG("Loading: %s\n", load_command); } sprintf(serv_command, "start serv %s", argv[1]); // start plugins (t->plug_actions)(t, serv_command, NULL); (t->plug_actions)(t, "start comm", NULL); task_clean_up(t); task_lunch(t); signal_manager(t); if ((argv[2] != NULL && strcmp(argv[2], "--prompt") == 0) || (argv[3] != NULL && strcmp(argv[3], "--prompt") == 0)) prompt_start(t); else { INFO("TissueStackImageServer Running!"); pthread_mutex_lock(&t->main_mutex); pthread_cond_wait(&t->main_cond, &t->main_mutex); pthread_mutex_unlock(&t->main_mutex); } // free all the stuff mallocked INFO("Shutting down TissueStackImageServer!"); t->tp->loop = 0; thread_pool_destroy(t->tp); free_core_struct(t); return (0); }
void benchmark(void) { unsigned long i; int row, col; menu_settings_t* mset = &_menu_settings; menu_items_t * mitems = &_menu_items; int menu_selected; /* Init timer stuff. */ sc_tmr_start(); menu_reset_settings(mset); menu_reset_items(mitems); menu_set_title(mset, "Saturn Memory Benchmark"); menu_set_item(mitems, 0/*id*/, "Start Benchmarking ", 0/*tag*/); menu_set_item(mitems, 1/*id*/, "Init DRAM ", 1/*tag*/); menu_set_item(mitems, 2/*id*/, "Select test pattern ", 2/*tag*/); menu_set_item(mitems, 3/*id*/, "Hexedit on error ", 3/*tag*/); menu_set_pos(mset, -1/*x0*/, MENU_TOP_ROW/*y0*/, 30/*w*/, 7/*h*/, 1/*cols*/); menu_set_erase_on_exit(mset, 0); menu_set_callback_redraw(mset, display_bench_settings); menu_selected = 0; do { menu_selected = menu_start(mitems, mset, menu_selected/*selected_tag*/); if(mset->exit_code == MENU_EXIT_CANCEL) { return; } switch(menu_selected) { default: case(0): break; case(1): menu_clear_display(mset); my_RB_CartRAM_init(0/*CS0*/); bench_display_clear(); break; case(2): test_pattern = (test_pattern+1)%PATTERN_CNT; break; case(3): hexedit_on_error = hexedit_on_error ? 0 : 1; break; } } while(menu_selected != 0); /* User requested benchmark start, so clear settings menu. */ menu_clear_display(mset); /* Execute benchmarks. */ bench_display_clear(); row = 5, col = 2; for(i = 0; i < nBenches; i++) { unsigned short color; conio_printf(2, 4, COLOR_GREEN, "[%3d%%]Benchmarking \"%s\" ...", (100*i)/nBenches, benches[i].name); /* Perform bench. */ benches[i].function(benches + i); /* Display some data in order to keep user waiting ... */ display_bench_result(i); color = benches[i].status ? COLOR_YELLOW : COLOR_RED; conio_printf(col+ 0, row, color, "%s", benches[i].name); if(col==2) { col = 9; } else if(col==9) { col = 16; } else if(col==16) { col = 23; } else if(col==23) { col = 30; } else { col = 2; row++; } if(row >= BENCH_RESULT_STARTROW) { bench_display_clear(); row = 5; col = 2; } } prompt_start();//TMP? /* Display benchmark results. */ bench_display_clear(); menu_reset_settings(mset); menu_reset_items(mitems); menu_set_title(mset, "Benchmark Results"); menu_set_pos(mset, -1/*x0*/, MENU_TOP_ROW/*y0*/, 30/*w*/, 12/*h*/, 1/*cols*/); menu_set_erase_on_exit(mset, 1); menu_set_features(mset, MENU_FEATURES_TEXTCENTER); menu_set_callback_getstr(mset, get_bench_name); menu_set_callback_redraw(mset, display_bench_result); menu_selected = 0; menu_selected = menu_list_start(NULL/*Items Array*/, nBenches, mset, menu_selected, NULL/*selection*/); }