static void timer_cb(void *data) { char buff[64]; double d1, d2, d3; get_load_average(&d1, &d2, &d3); one = ((d1 > 100.0) ? (100) : ((int)d1)); five = ((d2 > 100.0) ? (100) : ((int)d2)); fifteen = ((d3 > 100.0) ? (100) : ((int)d3)); Epplet_gadget_data_changed(vbar1); Epplet_gadget_data_changed(vbar2); Epplet_gadget_data_changed(vbar3); Esnprintf(buff, sizeof(buff), "%3.2f", d1); Epplet_change_label(label1, buff); Esnprintf(buff, sizeof(buff), "%3.2f", d2); Epplet_change_label(label2, buff); Esnprintf(buff, sizeof(buff), "%3.2f", d3); Epplet_change_label(label3, buff); Epplet_timer(timer_cb, NULL, 5.0, "TIMER"); return; data = NULL; }
int main(void) { char status[STATUS_SIZ]; struct sysinfo sys; int i; for(i = 0; i < CPUSTATES; i++) sys.cpu_cycles[i] = .0; if (!(dpy = XOpenDisplay(NULL))) { fprintf(stderr, "Cannot open display.\n"); return 1; } for (;;sleep(UPDATE_INTERVAL)) { snprintf(status, sizeof status, "%s :: %s :: %s" , get_cpu_stats(&sys), get_load_average(), getdatetime()); setstatus(status); } XCloseDisplay(dpy); return 0; }
static void * manager_main(void *unused __attribute__ ((unused))) { //struct worker *wkr; unsigned int load_max = cpu_count; unsigned int worker_max, current_thread_count = 0; unsigned int worker_idle_seconds_accumulated = 0; unsigned int max_threads_to_stop = 0; unsigned int i; int cond_wait_rv = 0; sigset_t sigmask; struct timespec ts; struct timeval tp; worker_max = get_process_limit(); scoreboard.load = get_load_average(); /* Block all signals */ sigfillset(&sigmask); pthread_sigmask(SIG_BLOCK, &sigmask, NULL); /* Create the minimum number of workers */ scoreboard.count = 0; for (i = 0; i < worker_min; i++) worker_start(); for (;;) { #if DEADWOOD /* Examine each worker and update statistics */ scoreboard.sleeping = 0;