int main(int argc, const char * argv[]) { if(argc < 3){ return 0; } std::string cmd = argv[1]; std::string db_path = argv[2]; std::string collection; std::string key = "loadrec"; if(argc >= 4){ collection = argv[3]; } if(cmd == "csv"){ write_csv(db_path, key, collection); }else if(cmd == "rec"){ auto t = current_time(); auto l = load_average(); std::string value = t + ", " + l; kvsqlite::database db(db_path); std::deque<std::string> data; db.get(key, data, collection); data.push_back(value); int max_size = 12*24; if(data.size() > max_size) data.pop_front(); db.set(key, data, collection); } return 0; }
void timer_interrupt(void) { /* Increment processes and global tick counters. We can't do this mid swap because we might have half of the bits for one process and half of another.. */ if (!inswap && udata.u_ptab->p_status == P_RUNNING) { if (udata.u_insys) udata.u_stime++; else udata.u_utime++; } /* Do once-per-decisecond things - this doesn't work out well on boxes with 64 ticks/second.. need a better approach */ if (++ticks_this_dsecond == ticks_per_dsecond) { static ptptr p; /* Update global time counters */ ticks_this_dsecond = 0; ticks.full++; /* Update process alarm clocks and timeouts */ for (p = ptab; p < ptab_end; ++p) { if (p->p_alarm) { p->p_alarm--; if (!p->p_alarm) ssig(p, SIGALRM); } if (p->p_timeout > 1) { p->p_timeout--; if (p->p_timeout == 1) pwake(p); } } updatetod(); load_average(); #ifdef CONFIG_AUDIO audio_tick(); #endif } #ifndef CONFIG_SINGLETASK /* Check run time of current process. We don't charge time while swapping as the last thing we want to do is to swap a process in and decide it took time to swap in so needs to go away again! */ /* FIXME: can we kill off inint ? */ if (!inswap && (++runticks >= udata.u_ptab->p_priority) && !udata.u_insys && inint && nready > 1) { need_resched = 1; #ifdef DEBUG_PREEMPT kprintf("[preempt %p %d]", udata.u_ptab, udata.u_ptab->p_priority); #endif } #endif }
void timer_interrupt(void) { /* Increment processes and global tick counters */ if (udata.u_ptab->p_status == P_RUNNING) { if (udata.u_insys) udata.u_stime++; else udata.u_utime++; } /* Do once-per-decisecond things - this doesn't work out well on boxes with 64 ticks/second.. need a better approach */ if (++ticks_this_dsecond == ticks_per_dsecond) { static ptptr p; /* Update global time counters */ ticks_this_dsecond = 0; ticks.full++; /* Update process alarm clocks and timeouts */ for (p = ptab; p < ptab_end; ++p) { if (p->p_alarm) { p->p_alarm--; if (!p->p_alarm) ssig(p, SIGALRM); } if (p->p_timeout > 1) { p->p_timeout--; if (p->p_timeout == 1) pwake(p); } } updatetod(); load_average(); #ifdef CONFIG_AUDIO audio_tick(); #endif } #ifndef CONFIG_SINGLETASK /* Check run time of current process */ /* Time to switch out? */ if ((++runticks >= udata.u_ptab->p_priority) && !udata.u_insys && inint && nready > 1) { need_resched = 1; #ifdef DEBUG_PREEMPT kprintf("[preempt %x %d %x]", udata.u_ptab, udata.u_ptab->p_priority, *((uint16_t *)0xEAFE)); #endif } #endif }
// Write a performance monitoring packet void AP_Scheduler::Log_Write_Performance() { struct log_Performance pkt = { LOG_PACKET_HEADER_INIT(LOG_PERFORMANCE_MSG), time_us : AP_HAL::micros64(), num_long_running : perf_info.get_num_long_running(), num_loops : perf_info.get_num_loops(), max_time : perf_info.get_max_time(), ins_error_count : AP::ins().error_count(), mem_avail : hal.util->available_memory(), load : (uint16_t)(load_average() * 1000) }; DataFlash_Class::instance()->WriteCriticalBlock(&pkt, sizeof(pkt)); }
static int ev_handler(struct mg_connection *conn, enum mg_event ev) { char buffer[tamanho_buffer]; buffer[0] = '\x0'; switch (ev) { case MG_AUTH: return MG_MORE; case MG_REQUEST: //PAGE REQUEST //EVERY REQUEST, EITHER BY TYPING URL //OR CALL CSS OR JAVASCRIPT //ENABLE THIS FUNCTION //printf("[%d] %s\n", strlen(conn->uri), conn->uri); //IF THE URL IS THE NAME OF THE FUNCTIONS, THE MOONGOSE RETURNS THE HTML REFERS TO THEM if (strcmp (conn->uri, "/dinamic_versaoso") == 0){ mg_send_header(conn, "Content-Type", "text/html"); //ADDS INFORMATIONS O.S versaoso(buffer, sizeof(buffer)); mg_printf_data(conn, buffer); return MG_TRUE; } if (strcmp (conn->uri, "/dinamic_numprocessos") == 0){ mg_send_header(conn, "Content-Type", "text/html"); //ADDS INFORMATIONS ABOUT THE CṔU USAGE cpu_resultado(buffer, sizeof(buffer)); //ADDS INFORMATIONS ABOUT THE LOAD AVERAGE load_average(buffer, sizeof(buffer)); //ADDS INFORMATIONS ON THE NUMBER OS PROCESSES RUNNING numprocessos(buffer, sizeof(buffer)); mg_printf_data(conn, buffer); return MG_TRUE; } if (strcmp (conn->uri, "/dinamic_infomemoria") == 0){ mg_send_header(conn, "Content-Type", "text/html"); //ADDS INFORMATIONS FROM MEMORY RAM infomemoria(buffer, sizeof(buffer)); mg_printf_data(conn, buffer); return MG_TRUE; } if (strcmp (conn->uri, "/dinamic_bateria") == 0){ mg_send_header(conn, "Content-Type", "text/html"); //ADDS BATTERY INFORMATION bateria(buffer, sizeof(buffer)); mg_printf_data(conn, buffer); return MG_TRUE; } //IF YOU HAVE NOTHING IN THE URL IT PEFORMS THIS TEXT, OTHERWISE EXECUTE THE URL if(strlen(conn->uri)<=1){ mg_send_header(conn, "Content-Type", "text/html"); segmento_inicial(buffer, sizeof(buffer)); segmento_final(buffer, sizeof(buffer)); mg_printf_data(conn, buffer); return MG_TRUE; } default: return MG_FALSE; } }