int main(int argc, char **argv) { get_statistics((argc > 1) ? argv[1] : "iwi0"); return EX_OK; }
void dnet_monitor_add_provider(void* monitor, struct stat_provider_raw stat, const char *name) { auto real_monitor = monitor_cast(monitor); if (real_monitor) { auto provider = new ioremap::monitor::raw_provider(stat); real_monitor->get_statistics().add_provider(provider, std::string(name)); } }
void add_provider(struct dnet_node *n, stat_provider *provider, const std::string &name) { auto real_monitor = get_monitor(n); if (real_monitor) real_monitor->get_statistics().add_provider(provider, name); else delete provider; }
/* log terrain data to dataflash log */ void AP_Terrain::log_terrain_data(DataFlash_Class &dataflash) { if (!enable) { return; } Location loc; if (!ahrs.get_position(loc)) { // we don't know where we are return; } float terrain_height = 0; float current_height = 0; uint16_t pending, loaded; height_amsl(loc, terrain_height); height_above_terrain(current_height, true); get_statistics(pending, loaded); struct log_TERRAIN pkt = { LOG_PACKET_HEADER_INIT(LOG_TERRAIN_MSG), time_us : hal.scheduler->micros64(), status : (uint8_t)status(), lat : loc.lat, lng : loc.lng, spacing : (uint16_t)grid_spacing, terrain_height : terrain_height, current_height : current_height, pending : pending, loaded : loaded };
void dnet_monitor_stats_update(struct dnet_node *n, const struct dnet_cmd *cmd, const int err, const int cache, const uint32_t size, const unsigned long time) { try { auto real_monitor = ioremap::monitor::get_monitor(n); if (real_monitor) { real_monitor->get_statistics().command_counter(cmd->cmd, cmd->trans, err, cache, size, time); auto top_stats = real_monitor->get_statistics().get_top_stats(); if (top_stats) { top_stats->update_stats(cmd, size); } } } catch (const std::exception &e) { dnet_log(n, DNET_LOG_DEBUG, "monitor: failed to update stats: %s", e.what()); } }
void monitor_command_counter(void *monitor, const int cmd, const int trans, const int err, const int cache, const uint32_t size, const unsigned long time) { auto real_monitor = monitor_cast(monitor); if (real_monitor) { real_monitor->get_statistics().command_counter(cmd, trans, err, cache, size, time); } }
bool irs_statistics_t::serialize(std::ofstream& stream) const { if(stream.is_open()) { stream << get_statistics(); return true; } return false; }
int main(int argc, char** argv) { int i; node *head = NULL; if (!strcmp(argv[2], "-c")) { get_statistics(statistics, argv[1]); // TODO // statistics = get_statistics(argv[1]) // build tree for (i = 0; i < 255; i++) { order[i] = i; }; qsort(order, 256, sizeof (int), comparator); while (statistics[order[size]] && size < 256) { size++; } printf("size %d\n", size); if (size == 0) { return 0; }; for (i = 0; i < size; i++) { node *n = malloc(sizeof(node)); n -> item = order[i]; n -> stat = statistics[order[i]]; n -> left = NULL; n -> right = NULL; n -> next = head; head = n; }; while (head -> next) { head = combine(head, head -> next); } // build map build_map(head, 0, 0); create_archive(argv[3]); for (i = 0; i < 256; i++) { if (map[i]){ printf("%d - %d - %d\n", i, map[i], statistics[i]); }; } return (EXIT_SUCCESS); }; if (!strcmp(argv[2], "-x")) { head = extract_tree(argv[1]); printf("extracted\n"); return (EXIT_SUCCESS); }; }
static int get_hashdb_info(const std::string& hashdb_dir, std::string& info) { info = ""; // make output stream std::stringstream ss; // zz not anymore int status = get_history(hashdb_dir, ss); int status = get_statistics(hashdb_dir, ss); // return stream as string info = ss.str(); return status; }
/* check that we have fetched all rally terrain data */ void AP_Terrain::update_rally_data(void) { if (last_rally_change_ms != rally.last_change_time_ms() || last_rally_spacing != grid_spacing) { // a rally point has changed - start again next_rally_index = 1; last_rally_change_ms = rally.last_change_time_ms(); last_rally_spacing = grid_spacing; } if (next_rally_index == 0) { // nothing to do return; } uint16_t pending, loaded; get_statistics(pending, loaded); if (pending && ahrs.get_gps().status() >= AP_GPS::GPS_OK_FIX_3D) { // wait till we have fully filled the current set of grids return; } while (true) { // get next rally point struct RallyLocation rp; if (!rally.get_rally_point_with_index(next_rally_index, rp)) { // nothing more to do next_rally_index = 0; return; } Location loc; loc.lat = rp.lat; loc.lng = rp.lng; float height; if (!height_amsl(loc, height)) { // if we can't get data for a rally item then return and // check again next time return; } #if TERRAIN_DEBUG hal.console->printf("checked rally point %u\n", (unsigned)next_rally_index); #endif // move to next rally point next_rally_index++; } }
static void init_top_provider(struct dnet_node *n, struct dnet_config *cfg) { try { bool top_loaded = false; const auto monitor = get_monitor(n); if (monitor) { auto top_stats = monitor->get_statistics().get_top_stats(); if (top_stats) { add_provider(n, new top_provider(top_stats), "top"); top_loaded = true; } } const auto monitor_cfg = get_monitor_config(n); if (top_loaded && monitor_cfg) { BH_LOG(*cfg->log, DNET_LOG_INFO, "monitor: top provider loaded: top length: %lu, events size: %lu, period: %d", monitor_cfg->top_length, monitor_cfg->events_size, monitor_cfg->period_in_seconds); } else { BH_LOG(*cfg->log, DNET_LOG_INFO, "monitor: top provider is disabled"); } } catch (const std::exception &e) { BH_LOG(*cfg->log, DNET_LOG_ERROR, "monitor: failed to initialize top_stat_provider: %s.", e.what()); } }
void wmifs_routine(int argc, char **argv) { rckeys wmifs_keys[] = { { "left", &left_action }, { "middle", &middle_action }, { "right", &right_action }, { NULL, NULL } }; int i, j; XEvent Event; int but_stat = -1; int stat_online; int stat_current; int first_time = 1; unsigned int curtime; unsigned int nexttime; struct timeval tv, tv2; long ipacket, opacket, istat, ostat; char temp[BUFFER_SIZE]; char *p; for (i = 0; i < MAX_STAT_DEVICES; i++) { stat_devices[i].name[0] = 0; for (j = 0; j < 48; j++) { stat_devices[i].his[j][0] = 0; stat_devices[i].his[j][1] = 0; } } stat_online = checknetdevs(); stat_current = 0; if (active_interface) { int isauto = !strcmp(active_interface, "auto"); for (i = 0; i < stat_online; i++) { if ((isauto && stillonline(stat_devices[i].name)) || !strcmp(stat_devices[i].name, active_interface)) { stat_current = i; break; } } } #ifdef LEFT_ACTION left_action = strdup(LEFT_ACTION); #endif #ifdef MIDDLE_ACTION middle_action = strdup(MIDDLE_ACTION); #endif #ifdef RIGHT_ACTION right_action = strdup(RIGHT_ACTION); #endif /* Scan throught the .rc files */ parse_rcfile(CONF"/wmifsrc", wmifs_keys); p = getenv("HOME"); if (p == NULL || *p == 0) { fprintf(stderr, "Unknown $HOME directory, please check your environment\n"); return; } strncpy(temp, p, BUFFER_SIZE - 10); strcat(temp, "/.wmifsrc"); parse_rcfile(temp, wmifs_keys); parse_rcfile(CONF"/wmifsrc.fixed", wmifs_keys); /* set user-defined colors */ if (color[0] != 0) { Window Root; XColor col; XWindowAttributes attributes; int screen; Pixel pixel; #define NUMSYMBOLS 4 XpmColorSymbol user_color[NUMSYMBOLS] = { {NULL, "#2081B2CAAEBA", 0}, /* + */ {NULL, "#28A23CF338E3", 0}, /* O */ {NULL, "#000049244103", 0}, /* @ */ {NULL, "#18618A288617", 0}, /* # */ }; /* code based on GetColor() from wmgeneral.c */ /* we need a temporary display to parse the color */ display = XOpenDisplay(NULL); screen = DefaultScreen(display); Root = RootWindow(display, screen); XGetWindowAttributes(display, Root, &attributes); col.pixel = 0; if (!XParseColor(display, attributes.colormap, color, &col)) { fprintf(stderr, "wmtime: can't parse %s.\n", color); goto draw_window; } else if (!XAllocColor(display, attributes.colormap, &col)) { fprintf(stderr, "wmtime: can't allocate %s.\n", color); goto draw_window; } pixel = col.pixel; /* replace colors from wmtime-master.xpm */ user_color[0].pixel = pixel; user_color[1].pixel = scale_pixel(pixel, .3); user_color[2].pixel = scale_pixel(pixel, .4); user_color[3].pixel = scale_pixel(pixel, .8); wmgen.attributes.valuemask |= XpmColorSymbols; wmgen.attributes.numsymbols = NUMSYMBOLS; wmgen.attributes.colorsymbols = user_color; XCloseDisplay(display); } draw_window: openXwindow(argc, argv, wmifs_master_xpm, (char*)wmifs_mask_bits, wmifs_mask_width, wmifs_mask_height); /* > Button */ AddMouseRegion(0, 5, 5, 35, 15); AddMouseRegion(1, 5, 20, 58, 58); gettimeofday(&tv2, NULL); nexttime = ScrollSpeed; DrawActiveIFS(stat_devices[stat_current].name); while (1) { struct timespec ts; gettimeofday(&tv, NULL); curtime = (tv.tv_sec - tv2.tv_sec) * 1000 + (tv.tv_usec - tv2.tv_usec) / 1000; waitpid(0, NULL, WNOHANG); for (i = 0; i < stat_online; i++) { get_statistics(stat_devices[i].name, &ipacket, &opacket, &istat, &ostat); if (first_time) { first_time = 0; } else { stat_devices[i].his[53][0] += istat - stat_devices[i].istatlast; stat_devices[i].his[53][1] += ostat - stat_devices[i].ostatlast; } if (i == stat_current) { if (!stillonline(stat_devices[i].name)) SetErrLED(LED_NET_POWER); else SetOnLED(LED_NET_POWER); if (stat_devices[i].istatlast == istat) SetOffLED(LED_NET_RX); else SetOnLED(LED_NET_RX); if (stat_devices[i].ostatlast == ostat) SetOffLED(LED_NET_TX); else SetOnLED(LED_NET_TX); } stat_devices[i].istatlast = istat; stat_devices[i].ostatlast = ostat; } RedrawWindow(); if (curtime >= nexttime) { nexttime = curtime + ScrollSpeed; DrawStats(&stat_devices[stat_current].his[0][0], 54, 40, 5, 58); for (i = 0; i < stat_online; i++) { if (stillonline(stat_devices[i].name)) { for (j = 1; j < 54; j++) { stat_devices[i].his[j-1][0] = stat_devices[i].his[j][0]; stat_devices[i].his[j-1][1] = stat_devices[i].his[j][1]; } stat_devices[i].his[53][0] = 0; stat_devices[i].his[53][1] = 0; } } RedrawWindow(); } while (XPending(display)) { XNextEvent(display, &Event); switch (Event.type) { case Expose: RedrawWindow(); break; case DestroyNotify: XCloseDisplay(display); exit(0); break; case ButtonPress: but_stat = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y); break; case ButtonRelease: i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y); if (but_stat == i && but_stat >= 0) { switch (but_stat) { case 0: /* re-read the table */ strcpy(temp, stat_devices[stat_current].name); stat_online = checknetdevs(); stat_current = 0; for (i = 0; i < stat_online; i++) { if (!strcmp(temp, stat_devices[i].name)) stat_current = i; } stat_current++; if (stat_current == stat_online) stat_current = 0; DrawActiveIFS(stat_devices[stat_current].name); DrawStats(&stat_devices[stat_current].his[0][0], 54, 40, 5, 58); break; case 1: switch (Event.xbutton.button) { case 1: if (left_action) execCommand(left_action); break; case 2: if (middle_action) execCommand(middle_action); break; case 3: if (right_action) execCommand(right_action); break; } break; } } but_stat = -1; RedrawWindow(); break; } } ts.tv_sec = 0; ts.tv_nsec = SampleInt * 1000000; nanosleep(&ts, NULL); } }
void remove_provider(dnet_node *n, const std::string &name) { auto real_monitor = get_monitor(n); if (real_monitor) real_monitor->get_statistics().remove_provider(name); }
int sys_syscall(CTXTdeclc int callno) { int result=-1; struct stat stat_buff; switch (callno) { case SYS_exit: { int exit_code; exit_code = (int)ptoc_int(CTXTc 3); xsb_error("\nXSB exited with exit code: %d", exit_code); exit(exit_code); break; } case SYS_getpid : #ifndef WIN_NT result = getpid(); #else result = _getpid(); #endif break; #if (!defined(WIN_NT)) case SYS_link : result = link(ptoc_longstring(CTXTc 3), ptoc_longstring(CTXTc 4)); break; #endif case SYS_mkdir: { #ifndef WIN_NT /* create using mode 700 */ result = mkdir(ptoc_longstring(CTXTc 3), 0700); #else result = _mkdir(ptoc_longstring(CTXTc 3)); #endif break; } case SYS_rmdir: { #ifndef WIN_NT result = rmdir(ptoc_longstring(CTXTc 3)); #else result = _rmdir(ptoc_longstring(CTXTc 3)); #endif break; } case SYS_unlink: result = unlink(ptoc_longstring(CTXTc 3)); break; case SYS_chdir : result = chdir(ptoc_longstring(CTXTc 3)); break; case SYS_access: { switch(*ptoc_string(CTXTc 4)) { case 'r': /* read permission */ result = access(ptoc_longstring(CTXTc 3), R_OK_XSB); break; case 'w': /* write permission */ result = access(ptoc_longstring(CTXTc 3), W_OK_XSB); break; case 'x': /* execute permission */ result = access(ptoc_longstring(CTXTc 3), X_OK_XSB); break; default: result = -1; } break; } case SYS_stat : { /* Who put this in??? What did s/he expect to get out of this call? stat_buff is never returned (and what do you do with it in Prolog?)!!! */ result = stat(ptoc_longstring(CTXTc 3), &stat_buff); break; } case SYS_rename: result = rename(ptoc_longstring(CTXTc 3), ptoc_longstring(CTXTc 4)); break; case SYS_cwd: { char current_dir[MAX_CMD_LEN]; /* returns 0, if != NULL, 1 otherwise */ result = (getcwd(current_dir, MAX_CMD_LEN-1) == NULL); if (result == 0) ctop_string(CTXTc 3,current_dir); break; } case SYS_filecopy: { char *from = ptoc_longstring(CTXTc 3); char *to = ptoc_longstring(CTXTc 4); result = (file_copy(CTXTc from,to,"w") == 0); break; } case SYS_fileappend: { char *from = ptoc_longstring(CTXTc 3); char *to = ptoc_longstring(CTXTc 4); result = (file_copy(CTXTc from,to,"a") == 0); break; } case SYS_create: { result = open(ptoc_longstring(CTXTc 3),O_CREAT|O_EXCL,S_IREAD|S_IWRITE); if (result >= 0) close(result); break; } case SYS_readlink: { char *inpath = ptoc_longstring(CTXTc 3); // char *outpath = file_readlink(CTXTc inpath); char *outpath = file_readlink(inpath); if (outpath == NULL) { // memory for this case is dealocated in file_readlink in pathname_xsb.c result = -1; } else { ctop_string(CTXTc 4,outpath); mem_dealloc(outpath,MAXPATHLEN,OTHER_SPACE); result = 0; } break; } case SYS_realpath: { char *inpath = ptoc_longstring(CTXTc 3); char *outpath = file_realpath(inpath); if (outpath == NULL) { // memory for this case is dealocated in file_readlink in pathname_xsb.c result = -1; } else { ctop_string(CTXTc 4,outpath); mem_dealloc(outpath,MAXPATHLEN,OTHER_SPACE); result = 0; } break; } case STATISTICS_2: { get_statistics(CTXT); break; } case SYS_epoch_seconds: { ctop_int(CTXTc 3,(Integer)time(0)); break; } case SYS_epoch_msecs: { static struct timeb time_epoch; ftime(&time_epoch); ctop_int(CTXTc 3,(Integer)(time_epoch.time)); ctop_int(CTXTc 4,(Integer)(time_epoch.millitm)); break; } case SYS_main_memory_size: { size_t memory_size = getMemorySize(); ctop_int(CTXTc 3,(UInteger)memory_size); break; } default: xsb_abort("[SYS_SYSCALL] Unknown system call number, %d", callno); } return result; }
int sys_syscall(CTXTdeclc int callno) { int result=-1; struct stat stat_buff; switch (callno) { case SYS_exit: { int exit_code; exit_code = ptoc_int(CTXTc 3); xsb_mesg("\nXSB exited with exit code: %d", exit_code); exit(exit_code); break; } #if (!defined(WIN_NT)) case SYS_getpid : result = getpid(); break; case SYS_link : result = link(ptoc_longstring(CTXTc 3), ptoc_longstring(CTXTc 4)); break; #endif case SYS_mkdir: { #ifndef WIN_NT /* create using mode 700 */ result = mkdir(ptoc_longstring(CTXTc 3), 0700); #else result = _mkdir(ptoc_longstring(CTXTc 3)); #endif break; } case SYS_rmdir: { #ifndef WIN_NT result = rmdir(ptoc_longstring(CTXTc 3)); #else result = _rmdir(ptoc_longstring(CTXTc 3)); #endif break; } case SYS_unlink: result = unlink(ptoc_longstring(CTXTc 3)); break; case SYS_chdir : result = chdir(ptoc_longstring(CTXTc 3)); break; case SYS_access: { switch(*ptoc_string(CTXTc 4)) { case 'r': /* read permission */ result = access(ptoc_longstring(CTXTc 3), R_OK_XSB); break; case 'w': /* write permission */ result = access(ptoc_longstring(CTXTc 3), W_OK_XSB); break; case 'x': /* execute permission */ result = access(ptoc_longstring(CTXTc 3), X_OK_XSB); break; default: result = -1; } break; } case SYS_stat : { /* Who put this in??? What did s/he expect to get out of this call? stat_buff is never returned (and what do you do with it in Prolog?)!!! */ result = stat(ptoc_longstring(CTXTc 3), &stat_buff); break; } case SYS_rename: result = rename(ptoc_longstring(CTXTc 3), ptoc_longstring(CTXTc 4)); break; case SYS_cwd: { char current_dir[MAX_CMD_LEN]; /* returns 0, if != NULL, 1 otherwise */ result = (getcwd(current_dir, MAX_CMD_LEN-1) == NULL); if (result == 0) ctop_string(CTXTc 3,current_dir); break; } case SYS_filecopy: { char *from = ptoc_longstring(CTXTc 3); char *to = ptoc_longstring(CTXTc 4); result = file_copy(from,to); break; } case SYS_create: { result = open(ptoc_longstring(CTXTc 3),O_CREAT|O_EXCL,S_IREAD|S_IWRITE); if (result >= 0) close(result); break; } case STATISTICS_2: { get_statistics(CTXT); break; } default: xsb_abort("[SYS_SYSCALL] Unknown system call number, %d", callno); } return result; }
// analyse the file order static void order (void) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n-> start testing order... \n"))); if (num_files <= 2) { if (num_files == 1) get_statistics (file_name); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Ordering...OK! - ") ACE_TEXT (" Only %d file (s) was (were) generated"), num_files)); } else { int tm_bk_1, tm_bk_2; ACE_TCHAR backup_1[MAXPATHLEN+1]; ACE_TCHAR backup_2[MAXPATHLEN+1]; ACE_OS::sprintf (backup_1, ACE_TEXT ("%s.%d"), file_name, 1); ACE_OS::sprintf (backup_2, ACE_TEXT ("%s.%d"), file_name, num_files - 1); tm_bk_1 = get_statistics (backup_1); tm_bk_2 = get_statistics (backup_2); if (tm_bk_1 > tm_bk_2 && !order_state) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %s (newest) ; %s (oldest)\n"), backup_1, backup_2)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Ordering...OK!"))); } else { if (tm_bk_1 < tm_bk_2 && order_state) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %s (newest);") ACE_TEXT ("%s (oldest)\n"), backup_2, backup_1)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Ordering...OK!"))); } else ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Ordering...FAILED!") ACE_TEXT ("- The files are disorderly"))); } } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n-< testing order finished...\n\n"))); }
/* check that we have fetched all mission terrain data */ void AP_Terrain::update_mission_data(void) { if (last_mission_change_ms != mission.last_change_time_ms() || last_mission_spacing != grid_spacing) { // the mission has changed - start again next_mission_index = 1; next_mission_pos = 0; last_mission_change_ms = mission.last_change_time_ms(); last_mission_spacing = grid_spacing; } if (next_mission_index == 0) { // nothing to do return; } uint16_t pending, loaded; get_statistics(pending, loaded); if (pending && ahrs.get_gps().status() >= AP_GPS::GPS_OK_FIX_3D) { // wait till we have fully filled the current set of grids return; } // don't do more than 20 waypoints at a time, to prevent too much // CPU usage for (uint8_t i=0; i<20; i++) { // get next mission command AP_Mission::Mission_Command cmd; if (!mission.read_cmd_from_storage(next_mission_index, cmd)) { // nothing more to do next_mission_index = 0; return; } // we only want nav waypoint commands. That should be enough to // prefill the terrain data and makes many things much simpler while ((cmd.id != MAV_CMD_NAV_WAYPOINT && cmd.id != MAV_CMD_NAV_SPLINE_WAYPOINT) || (cmd.content.location.lat == 0 && cmd.content.location.lng == 0)) { next_mission_index++; if (!mission.read_cmd_from_storage(next_mission_index, cmd)) { // nothing more to do next_mission_index = 0; next_mission_pos = 0; return; } } // we will fetch 5 points around the waypoint. Four at 10 grid // spacings away at 45, 135, 225 and 315 degrees, and the // point itself if (next_mission_pos != 4) { location_update(cmd.content.location, 45+90*next_mission_pos, grid_spacing.get() * 10); } // we have a mission command to check float height; if (!height_amsl(cmd.content.location, height)) { // if we can't get data for a mission item then return and // check again next time return; } next_mission_pos++; if (next_mission_pos == 5) { #if TERRAIN_DEBUG hal.console->printf("checked waypoint %u\n", (unsigned)next_mission_index); #endif // move to next waypoint next_mission_index++; next_mission_pos = 0; } } }
int main(int argc, char** argv) { MPI_Init(&argc, &argv); setup_globals(); /* Parse arguments. */ int SCALE = 16; int edgefactor = 16; /* nedges / nvertices, i.e., 2*avg. degree */ // if (argc >= 2) SCALE = atoi(argv[1]); // if (argc >= 3) edgefactor = atoi(argv[2]); char* name = argv[1]; if (argc >= 3) SCALE = atoi(argv[2]); if (argc >= 4) edgefactor = atoi(argv[3]); // if (argc <= 1 || argc >= 4 || SCALE == 0 || edgefactor == 0) { // if (rank == 0) { // fprintf(stderr, "Usage: %s SCALE edgefactor\n SCALE = log_2(# vertices) [integer, required]\n edgefactor = (# edges) / (# vertices) = .5 * (average vertex degree) [integer, defaults to 16]\n(Random number seed and Kronecker initiator are in main.c)\n", argv[0]); // } if (argc <= 2 || argc >= 5 || SCALE == 0 || edgefactor == 0) { if (rank == 0) { fprintf(stderr, "Usage: %s filename SCALE edgefactor\n SCALE = log_2(# vertices) [integer, required]\n edgefactor = (# edges) / (# vertices) = .5 * (average vertex degree) [integer, defaults to 16]\n(Random number seed and Kronecker initiator are in main.c)\n", argv[0]); } MPI_Abort(MPI_COMM_WORLD, 1); } uint64_t seed1 = 2, seed2 = 3; // const char* filename = getenv("TMPFILE"); const char* filename = name; /* If filename is NULL, store data in memory */ tuple_graph tg; tg.nglobaledges = (int64_t)(edgefactor) << SCALE; int64_t nglobalverts = (int64_t)(1) << SCALE; tg.data_in_file = (filename != NULL); if (tg.data_in_file) { printf("data in file \n"); MPI_File_set_errhandler(MPI_FILE_NULL, MPI_ERRORS_ARE_FATAL); // MPI_File_open(MPI_COMM_WORLD, (char*)filename, MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_EXCL | MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_UNIQUE_OPEN, MPI_INFO_NULL, &tg.edgefile); MPI_File_open(MPI_COMM_WORLD, (char*)filename, MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_EXCL | MPI_MODE_UNIQUE_OPEN, MPI_INFO_NULL, &tg.edgefile); MPI_File_set_size(tg.edgefile, tg.nglobaledges * sizeof(packed_edge)); MPI_File_set_view(tg.edgefile, 0, packed_edge_mpi_type, packed_edge_mpi_type, "native", MPI_INFO_NULL); MPI_File_set_atomicity(tg.edgefile, 0); } /* Make the raw graph edges. */ /* Get roots for BFS runs, plus maximum vertex with non-zero degree (used by * validator). */ int num_bfs_roots = 64; int64_t* bfs_roots = (int64_t*)xmalloc(num_bfs_roots * sizeof(int64_t)); int64_t max_used_vertex = 0; double make_graph_start = MPI_Wtime(); { /* Spread the two 64-bit numbers into five nonzero values in the correct * range. */ uint_fast32_t seed[5]; make_mrg_seed(seed1, seed2, seed); /* As the graph is being generated, also keep a bitmap of vertices with * incident edges. We keep a grid of processes, each row of which has a * separate copy of the bitmap (distributed among the processes in the * row), and then do an allreduce at the end. This scheme is used to avoid * non-local communication and reading the file separately just to find BFS * roots. */ MPI_Offset nchunks_in_file = (tg.nglobaledges + FILE_CHUNKSIZE - 1) / FILE_CHUNKSIZE; int64_t bitmap_size_in_bytes = int64_min(BITMAPSIZE, (nglobalverts + CHAR_BIT - 1) / CHAR_BIT); if (bitmap_size_in_bytes * size * CHAR_BIT < nglobalverts) { bitmap_size_in_bytes = (nglobalverts + size * CHAR_BIT - 1) / (size * CHAR_BIT); } int ranks_per_row = ((nglobalverts + CHAR_BIT - 1) / CHAR_BIT + bitmap_size_in_bytes - 1) / bitmap_size_in_bytes; int nrows = size / ranks_per_row; int my_row = -1, my_col = -1; unsigned char* restrict has_edge = NULL; MPI_Comm cart_comm; { int dims[2] = {size / ranks_per_row, ranks_per_row}; int periods[2] = {0, 0}; MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 1, &cart_comm); } int in_generating_rectangle = 0; if (cart_comm != MPI_COMM_NULL) { in_generating_rectangle = 1; { int dims[2], periods[2], coords[2]; MPI_Cart_get(cart_comm, 2, dims, periods, coords); my_row = coords[0]; my_col = coords[1]; } MPI_Comm this_col; MPI_Comm_split(cart_comm, my_col, my_row, &this_col); MPI_Comm_free(&cart_comm); has_edge = (unsigned char*)xMPI_Alloc_mem(bitmap_size_in_bytes); memset(has_edge, 0, bitmap_size_in_bytes); /* Every rank in a given row creates the same vertices (for updating the * bitmap); only one writes them to the file (or final memory buffer). */ packed_edge* buf = (packed_edge*)xmalloc(FILE_CHUNKSIZE * sizeof(packed_edge)); MPI_Offset block_limit = (nchunks_in_file + nrows - 1) / nrows; // fprintf(stderr, "%d: nchunks_in_file = %" PRId64 ", block_limit = %" PRId64 " in grid of %d rows, %d cols\n", rank, (int64_t)nchunks_in_file, (int64_t)block_limit, nrows, ranks_per_row); if (tg.data_in_file) { tg.edgememory_size = 0; tg.edgememory = NULL; } else { int my_pos = my_row + my_col * nrows; int last_pos = (tg.nglobaledges % ((int64_t)FILE_CHUNKSIZE * nrows * ranks_per_row) != 0) ? (tg.nglobaledges / FILE_CHUNKSIZE) % (nrows * ranks_per_row) : -1; int64_t edges_left = tg.nglobaledges % FILE_CHUNKSIZE; int64_t nedges = FILE_CHUNKSIZE * (tg.nglobaledges / ((int64_t)FILE_CHUNKSIZE * nrows * ranks_per_row)) + FILE_CHUNKSIZE * (my_pos < (tg.nglobaledges / FILE_CHUNKSIZE) % (nrows * ranks_per_row)) + (my_pos == last_pos ? edges_left : 0); /* fprintf(stderr, "%d: nedges = %" PRId64 " of %" PRId64 "\n", rank, (int64_t)nedges, (int64_t)tg.nglobaledges); */ tg.edgememory_size = nedges; tg.edgememory = (packed_edge*)xmalloc(nedges * sizeof(packed_edge)); } MPI_Offset block_idx; for (block_idx = 0; block_idx < block_limit; ++block_idx) { /* fprintf(stderr, "%d: On block %d of %d\n", rank, (int)block_idx, (int)block_limit); */ MPI_Offset start_edge_index = int64_min(FILE_CHUNKSIZE * (block_idx * nrows + my_row), tg.nglobaledges); MPI_Offset edge_count = int64_min(tg.nglobaledges - start_edge_index, FILE_CHUNKSIZE); packed_edge* actual_buf = (!tg.data_in_file && block_idx % ranks_per_row == my_col) ? tg.edgememory + FILE_CHUNKSIZE * (block_idx / ranks_per_row) : buf; /* fprintf(stderr, "%d: My range is [%" PRId64 ", %" PRId64 ") %swriting into index %" PRId64 "\n", rank, (int64_t)start_edge_index, (int64_t)(start_edge_index + edge_count), (my_col == (block_idx % ranks_per_row)) ? "" : "not ", (int64_t)(FILE_CHUNKSIZE * (block_idx / ranks_per_row))); */ if (!tg.data_in_file && block_idx % ranks_per_row == my_col) { assert (FILE_CHUNKSIZE * (block_idx / ranks_per_row) + edge_count <= tg.edgememory_size); } // debug char* wtxbuf = (char*)xmalloc(FILE_CHUNKSIZE * sizeof(packed_edge)); // generate_kronecker_range(seed, SCALE, start_edge_index, start_edge_index + edge_count, actual_buf); generate_kronecker_range(seed, SCALE, start_edge_index, start_edge_index + edge_count, actual_buf); if (tg.data_in_file && my_col == (block_idx % ranks_per_row)) { /* Try to spread writes among ranks */ // MPI_File_write_at(tg.edgefile, start_edge_index, actual_buf, edge_count, packed_edge_mpi_type, MPI_STATUS_IGNORE); // debug printf("%d: %d, %d\n", rank, start_edge_index, edge_count); int i; // for (i = start_edge_index; i < start_edge_index + 3; i++) { // if(block_idx == 0) { // for (i = 0; i < 3; i++) { // if (edge_count > 3) // printf("%d: %d\t%d\n", rank, actual_buf[i].v0, actual_buf[i].v1); // } // } MPI_File_write_at(tg.edgefile, start_edge_index, actual_buf, edge_count, packed_edge_mpi_type, MPI_STATUS_IGNORE); } ptrdiff_t i; #ifdef _OPENMP #pragma omp parallel for #endif for (i = 0; i < edge_count; ++i) { int64_t src = get_v0_from_edge(&actual_buf[i]); int64_t tgt = get_v1_from_edge(&actual_buf[i]); if (src == tgt) continue; if (src / bitmap_size_in_bytes / CHAR_BIT == my_col) { #ifdef _OPENMP #pragma omp atomic #endif has_edge[(src / CHAR_BIT) % bitmap_size_in_bytes] |= (1 << (src % CHAR_BIT)); } if (tgt / bitmap_size_in_bytes / CHAR_BIT == my_col) { #ifdef _OPENMP #pragma omp atomic #endif has_edge[(tgt / CHAR_BIT) % bitmap_size_in_bytes] |= (1 << (tgt % CHAR_BIT)); } } } free(buf); #if 0 /* The allreduce for each root acts like we did this: */ MPI_Allreduce(MPI_IN_PLACE, has_edge, bitmap_size_in_bytes, MPI_UNSIGNED_CHAR, MPI_BOR, this_col); #endif MPI_Comm_free(&this_col); } else { tg.edgememory = NULL; tg.edgememory_size = 0; } MPI_Allreduce(&tg.edgememory_size, &tg.max_edgememory_size, 1, MPI_INT64_T, MPI_MAX, MPI_COMM_WORLD); #ifndef GEN_ONLY /* Find roots and max used vertex */ { uint64_t counter = 0; int bfs_root_idx; for (bfs_root_idx = 0; bfs_root_idx < num_bfs_roots; ++bfs_root_idx) { int64_t root; while (1) { double d[2]; make_random_numbers(2, seed1, seed2, counter, d); root = (int64_t)((d[0] + d[1]) * nglobalverts) % nglobalverts; counter += 2; if (counter > 2 * nglobalverts) break; int is_duplicate = 0; int i; for (i = 0; i < bfs_root_idx; ++i) { if (root == bfs_roots[i]) { is_duplicate = 1; break; } } if (is_duplicate) continue; /* Everyone takes the same path here */ int root_ok = 0; if (in_generating_rectangle && (root / CHAR_BIT / bitmap_size_in_bytes) == my_col) { root_ok = (has_edge[(root / CHAR_BIT) % bitmap_size_in_bytes] & (1 << (root % CHAR_BIT))) != 0; } MPI_Allreduce(MPI_IN_PLACE, &root_ok, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); if (root_ok) break; } bfs_roots[bfs_root_idx] = root; } num_bfs_roots = bfs_root_idx; /* Find maximum non-zero-degree vertex. */ { int64_t i; max_used_vertex = 0; if (in_generating_rectangle) { for (i = bitmap_size_in_bytes * CHAR_BIT; i > 0; --i) { if (i > nglobalverts) continue; if (has_edge[(i - 1) / CHAR_BIT] & (1 << ((i - 1) % CHAR_BIT))) { max_used_vertex = (i - 1) + my_col * CHAR_BIT * bitmap_size_in_bytes; break; } } } MPI_Allreduce(MPI_IN_PLACE, &max_used_vertex, 1, MPI_INT64_T, MPI_MAX, MPI_COMM_WORLD); } } #endif if (in_generating_rectangle) { MPI_Free_mem(has_edge); } if (tg.data_in_file) { MPI_File_sync(tg.edgefile); } } double make_graph_stop = MPI_Wtime(); double make_graph_time = make_graph_stop - make_graph_start; if (rank == 0) { /* Not an official part of the results */ fprintf(stderr, "graph_generation: %f s\n", make_graph_time); } //debug #ifndef GEN_ONLY //!GEN_ONLY /* Make user's graph data structure. */ double data_struct_start = MPI_Wtime(); make_graph_data_structure(&tg); double data_struct_stop = MPI_Wtime(); double data_struct_time = data_struct_stop - data_struct_start; if (rank == 0) { /* Not an official part of the results */ fprintf(stderr, "construction_time: %f s\n", data_struct_time); } /* Number of edges visited in each BFS; a double so get_statistics can be * used directly. */ double* edge_counts = (double*)xmalloc(num_bfs_roots * sizeof(double)); /* Run BFS. */ int validation_passed = 1; double* bfs_times = (double*)xmalloc(num_bfs_roots * sizeof(double)); double* validate_times = (double*)xmalloc(num_bfs_roots * sizeof(double)); uint64_t nlocalverts = get_nlocalverts_for_pred(); int64_t* pred = (int64_t*)xMPI_Alloc_mem(nlocalverts * sizeof(int64_t)); int bfs_root_idx; for (bfs_root_idx = 0; bfs_root_idx < num_bfs_roots; ++bfs_root_idx) { int64_t root = bfs_roots[bfs_root_idx]; if (rank == 0) fprintf(stderr, "Running BFS %d\n", bfs_root_idx); /* Clear the pred array. */ memset(pred, 0, nlocalverts * sizeof(int64_t)); /* Do the actual BFS. */ double bfs_start = MPI_Wtime(); run_bfs(root, &pred[0]); double bfs_stop = MPI_Wtime(); bfs_times[bfs_root_idx] = bfs_stop - bfs_start; if (rank == 0) fprintf(stderr, "Time for BFS %d is %f\n", bfs_root_idx, bfs_times[bfs_root_idx]); /* Validate result. */ if (rank == 0) fprintf(stderr, "Validating BFS %d\n", bfs_root_idx); double validate_start = MPI_Wtime(); int64_t edge_visit_count; int validation_passed_one = validate_bfs_result(&tg, max_used_vertex + 1, nlocalverts, root, pred, &edge_visit_count); double validate_stop = MPI_Wtime(); validate_times[bfs_root_idx] = validate_stop - validate_start; if (rank == 0) fprintf(stderr, "Validate time for BFS %d is %f\n", bfs_root_idx, validate_times[bfs_root_idx]); edge_counts[bfs_root_idx] = (double)edge_visit_count; if (rank == 0) fprintf(stderr, "TEPS for BFS %d is %g\n", bfs_root_idx, edge_visit_count / bfs_times[bfs_root_idx]); if (!validation_passed_one) { validation_passed = 0; if (rank == 0) fprintf(stderr, "Validation failed for this BFS root; skipping rest.\n"); break; } } MPI_Free_mem(pred); free(bfs_roots); free_graph_data_structure(); #endif //!GEN_ONLY if (tg.data_in_file) { MPI_File_close(&tg.edgefile); } else { free(tg.edgememory); tg.edgememory = NULL; } #ifndef GEN_ONLY /* Print results. */ if (rank == 0) { if (!validation_passed) { fprintf(stdout, "No results printed for invalid run.\n"); } else { int i; fprintf(stdout, "SCALE: %d\n", SCALE); fprintf(stdout, "edgefactor: %d\n", edgefactor); fprintf(stdout, "NBFS: %d\n", num_bfs_roots); fprintf(stdout, "graph_generation: %g\n", make_graph_time); fprintf(stdout, "num_mpi_processes: %d\n", size); fprintf(stdout, "construction_time: %g\n", data_struct_time); double stats[s_LAST]; get_statistics(bfs_times, num_bfs_roots, stats); fprintf(stdout, "min_time: %g\n", stats[s_minimum]); fprintf(stdout, "firstquartile_time: %g\n", stats[s_firstquartile]); fprintf(stdout, "median_time: %g\n", stats[s_median]); fprintf(stdout, "thirdquartile_time: %g\n", stats[s_thirdquartile]); fprintf(stdout, "max_time: %g\n", stats[s_maximum]); fprintf(stdout, "mean_time: %g\n", stats[s_mean]); fprintf(stdout, "stddev_time: %g\n", stats[s_std]); get_statistics(edge_counts, num_bfs_roots, stats); fprintf(stdout, "min_nedge: %.11g\n", stats[s_minimum]); fprintf(stdout, "firstquartile_nedge: %.11g\n", stats[s_firstquartile]); fprintf(stdout, "median_nedge: %.11g\n", stats[s_median]); fprintf(stdout, "thirdquartile_nedge: %.11g\n", stats[s_thirdquartile]); fprintf(stdout, "max_nedge: %.11g\n", stats[s_maximum]); fprintf(stdout, "mean_nedge: %.11g\n", stats[s_mean]); fprintf(stdout, "stddev_nedge: %.11g\n", stats[s_std]); double* secs_per_edge = (double*)xmalloc(num_bfs_roots * sizeof(double)); for (i = 0; i < num_bfs_roots; ++i) secs_per_edge[i] = bfs_times[i] / edge_counts[i]; get_statistics(secs_per_edge, num_bfs_roots, stats); fprintf(stdout, "min_TEPS: %g\n", 1. / stats[s_maximum]); fprintf(stdout, "firstquartile_TEPS: %g\n", 1. / stats[s_thirdquartile]); fprintf(stdout, "median_TEPS: %g\n", 1. / stats[s_median]); fprintf(stdout, "thirdquartile_TEPS: %g\n", 1. / stats[s_firstquartile]); fprintf(stdout, "max_TEPS: %g\n", 1. / stats[s_minimum]); fprintf(stdout, "harmonic_mean_TEPS: %g\n", 1. / stats[s_mean]); /* Formula from: * Title: The Standard Errors of the Geometric and Harmonic Means and * Their Application to Index Numbers * Author(s): Nilan Norris * Source: The Annals of Mathematical Statistics, Vol. 11, No. 4 (Dec., 1940), pp. 445-448 * Publisher(s): Institute of Mathematical Statistics * Stable URL: http://www.jstor.org/stable/2235723 * (same source as in specification). */ fprintf(stdout, "harmonic_stddev_TEPS: %g\n", stats[s_std] / (stats[s_mean] * stats[s_mean] * sqrt(num_bfs_roots - 1))); free(secs_per_edge); secs_per_edge = NULL; free(edge_counts); edge_counts = NULL; get_statistics(validate_times, num_bfs_roots, stats); fprintf(stdout, "min_validate: %g\n", stats[s_minimum]); fprintf(stdout, "firstquartile_validate: %g\n", stats[s_firstquartile]); fprintf(stdout, "median_validate: %g\n", stats[s_median]); fprintf(stdout, "thirdquartile_validate: %g\n", stats[s_thirdquartile]); fprintf(stdout, "max_validate: %g\n", stats[s_maximum]); fprintf(stdout, "mean_validate: %g\n", stats[s_mean]); fprintf(stdout, "stddev_validate: %g\n", stats[s_std]); #if 0 for (i = 0; i < num_bfs_roots; ++i) { fprintf(stdout, "Run %3d: %g s, validation %g s\n", i + 1, bfs_times[i], validate_times[i]); } #endif } } free(bfs_times); free(validate_times); #endif cleanup_globals(); MPI_Finalize(); return 0; }
void dnet_monitor_log(void *monitor) { auto real_monitor = monitor_cast(monitor); if (real_monitor) { real_monitor->get_statistics().log(); } }
void yawmppp_routine (int argc, char **argv) { int i, j; int but_stat; long currenttime; long lasttime; long waittime; long ppptime; int hour, minute; long timetolog; long ppp_send, ppp_sl = -1; long ppp_recv, ppp_rl = -1; long ppp_sbytes, ppp_rbytes; long ppp_osbytes, ppp_orbytes; struct stat st; pid_t stop_child = 0; pid_t start_child = 0; int status; int isonline = 0; XEvent Event; int speed_ind = 10; /* Initialize some stuff */ get_statistics (active_interface, &ppp_rl, &ppp_sl, &ppp_orbytes, &ppp_osbytes); if (caution>0) close_ppp(); grab_isp_info(1); /* Open the display */ createXBMfromXPM (dock_mask_bits, dockxpm_xpm, dock_mask_width, dock_mask_height); openXwindow (argc, argv, dockxpm_xpm, dock_mask_bits, dock_mask_width, dock_mask_height); /* V Button */ AddMouseRegion (0, 35, 48, 46, 58); /* x Button */ AddMouseRegion (1, 47, 48, 58, 58); /* < Button */ AddMouseRegion (2, 5, 48, 16, 58); /* > Button */ AddMouseRegion (3, 17, 48, 28, 58); /* ISP display */ AddMouseRegion (4, 5, 6, 59, 43); starttime = 0; currenttime = time (0); ppptime = 0; but_stat = -1; waittime = 0; timetolog=0; /* 888k8 on bottom */ copyXPMArea (ERR_SRC_X+28, ERR_SRC_Y+9, 25, 8, ERR_DEST_X, ERR_DEST_Y); DrawISPName (); while (1) { lasttime = currenttime; currenttime = time (0); /* Check if any child has left the playground */ i = waitpid (0, &status, WNOHANG); if (i == stop_child && stop_child != 0) { starttime = 0; SetOffLED (LED_PPP_POWER); SetOffLED (LED_PPP_RX); SetOffLED (LED_PPP_TX); /* 888k8 on bottom */ copyXPMArea (ERR_SRC_X+28, ERR_SRC_Y+9, 25, 8, ERR_DEST_X, ERR_DEST_Y); RedrawWindow (); stop_child = 0; } if (i == start_child && start_child != 0) { if (WIFEXITED (status)) { if (WEXITSTATUS (status) == 10) { starttime = 0; /* 88k8 on bottom */ copyXPMArea (ERR_SRC_X+28, ERR_SRC_Y+9, 25, 8, ERR_DEST_X, ERR_DEST_Y); SetOffLED (LED_PPP_POWER); DrawTime (0, 1); RedrawWindow (); } start_child = 0; } } /* On-line detectie! 1x per second */ if (currenttime != lasttime) { i = 0; if (stillonline (active_interface)) { i = 1; if (!starttime) { starttime = currenttime; if (stat (STAMP_FILE, &st) == 0) starttime = st.st_mtime; SetOnLED (LED_PPP_POWER); waittime = 0; /* 88k8 on bottom */ copyXPMArea (ERR_SRC_X+28, ERR_SRC_Y+9, 25, 8, ERR_DEST_X, ERR_DEST_Y); if (IspData[current_isp].SpeedAction) DrawSpeedInd (IspData[current_isp].SpeedAction); speed_ind = currenttime + 10; RedrawWindow (); } } if (!i && starttime) { starttime = 0; SetErrLED (LED_PPP_POWER); logconn.status=1; /* Error */ copyXPMArea (ERR_SRC_X, ERR_SRC_Y+9, 25, 8, ERR_DEST_X, ERR_DEST_Y); if (IspData[current_isp].IfDownAction) execCommand (IspData[current_isp].IfDownAction); RedrawWindow (); } } if (waittime && waittime <= currenttime) { SetOffLED (LED_PPP_POWER); RedrawWindow (); waittime = 0; } if ((starttime)&&(!isonline)) { isonline=1; logconn.start=time(NULL); logconn.status=0; strcpy(logconn.longname,IspData[current_isp].LongName); strcpy(logconn.shortname,IspData[current_isp].ShortName); strcpy(logconn.user,IspData[current_isp].User); strcpy(logconn.phone,IspData[current_isp].Phone); if (!strlen(logconn.shortname)) strcpy(logconn.shortname,"empty"); if (!strlen(logconn.longname)) strcpy(logconn.longname,"empty"); if (!strlen(logconn.user)) strcpy(logconn.user,"empty"); if (!strlen(logconn.phone)) strcpy(logconn.phone,"empty"); make_guards(); } if ((!starttime)&&(isonline)) { isonline=0; logconn.end=time(NULL); write_log(); if (got_sched) make_delayed_update(); if (caution>0) close_ppp(); } /* If we are on-line. Print the time we are */ if (starttime) { i = currenttime - starttime; i /= TimerDivisor; if (TimerDivisor == 1) if (i > 59 * 60 + 59) i /= 60; minute = i % 60; hour = (i / 60) % 100; i = hour * 100 + minute; DrawTime (i, currenttime % 2); /* We are online, so we can check for send/recv packets */ get_statistics (active_interface, &ppp_recv, &ppp_send, &ppp_rbytes, &ppp_sbytes); if (caution>1) close_ppp(); if (ppp_send != ppp_sl) SetOnLED (LED_PPP_TX); else SetOffLED (LED_PPP_TX); if (ppp_recv != ppp_rl) SetOnLED (LED_PPP_RX); else SetOffLED (LED_PPP_RX); ppp_sl = ppp_send; ppp_rl = ppp_recv; /* Every five seconds we check to load on the line */ if (currenttime - timetolog >= 0) { timetolog=currenttime + 60; make_guards(); } if ((currenttime - ppptime >= 0) || (ppptime == 0)) { ppptime = currenttime + updaterate; ppp_history[PPP_STATS_HIS][0] = ppp_rbytes - ppp_orbytes; ppp_history[PPP_STATS_HIS][1] = ppp_sbytes - ppp_osbytes; ppp_orbytes = ppp_rbytes; ppp_osbytes = ppp_sbytes; DrawStats (54, 17, 5, 32); for (j = 1; j < 55; j++) { ppp_history[j - 1][0] = ppp_history[j][0]; ppp_history[j - 1][1] = ppp_history[j][1]; } if (currenttime > speed_ind) { DrawLoadInd ((ppp_history[54][0] + ppp_history[54][1]) / updaterate); } } RedrawWindow (); } while (XPending (display)) { XNextEvent (display, &Event); switch (Event.type) { case Expose: RedrawWindow (); break; case DestroyNotify: XCloseDisplay (display); while (start_child | stop_child) { i = waitpid (0, &status, WNOHANG); if (i == stop_child) stop_child = 0; if (i == start_child) start_child = 0; usleep (50000l); } exit (0); break; case ButtonPress: i = CheckMouseRegion (Event.xbutton.x, Event.xbutton.y); switch (i) { case 0: ButtonDown (BUT_V); break; case 1: ButtonDown (BUT_X); break; case 2: ButtonDown (BUT_REW); break; case 3: ButtonDown (BUT_FF); break; } but_stat = i; RedrawWindow (); break; case ButtonRelease: i = CheckMouseRegion (Event.xbutton.x, Event.xbutton.y); // Button but_stat omhoogdoen! switch (but_stat) { case 0: ButtonUp (BUT_V); break; case 1: ButtonUp (BUT_X); break; case 2: ButtonUp (BUT_REW); break; case 3: ButtonUp (BUT_FF); break; } if (i == but_stat && but_stat >= 0) { switch (i) { case 0: if (!starttime) { /* 888k8 */ copyXPMArea (ERR_SRC_X+28, ERR_SRC_Y+9, 25, 8, ERR_DEST_X, ERR_DEST_Y); DrawTime (0, 1); start_child = execCommand (IspData[current_isp].StartAction); SetWaitLED (LED_PPP_POWER); waittime = ORANGE_LED_TIMEOUT + currenttime; } break; case 1: if (stop_child == 0) { stop_child = execCommand (IspData[current_isp].StopAction); } break; case 2: if (!starttime) { current_isp--; if (current_isp < 0) current_isp = num_isps - 1; if (current_isp < 0) current_isp=0; DrawISPName (); } break; case 3: if (!starttime) { current_isp++; if (current_isp == num_isps) current_isp = 0; DrawISPName (); } break; case 4: if (Event.xbutton.button==Button1) run_pref_app(); else run_log_app(); break; } } RedrawWindow (); but_stat = -1; break; default: break; } } usleep (50000L); } }