/** * shell_perf_log_collect_statistics: * @perf_log: a #ShellPerfLog * * Calls all the update functions added with * shell_perf_log_add_statistics_callback() and then records events * for all statistics, followed by a perf.statisticsCollected event. */ void shell_perf_log_collect_statistics (ShellPerfLog *perf_log) { gint64 event_time = get_time (); gint64 collection_time; int i; if (!perf_log->enabled) return; for (i = 0; i < perf_log->statistics_closures->len; i++) { ShellPerfStatisticsClosure *closure; closure = g_ptr_array_index (perf_log->statistics_closures, i); closure->callback (perf_log, closure->user_data); } collection_time = get_time() - event_time; for (i = 0; i < perf_log->statistics->len; i++) { ShellPerfStatistic *statistic = g_ptr_array_index (perf_log->statistics, i); if (!statistic->initialized) continue; switch (statistic->event->signature[0]) { case 'i': if (!statistic->recorded || statistic->current_value.i != statistic->last_value.i) { record_event (perf_log, event_time, statistic->event, (const guchar *)&statistic->current_value.i, sizeof (gint32)); statistic->last_value.i = statistic->current_value.i; statistic->recorded = TRUE; } break; case 'x': if (!statistic->recorded || statistic->current_value.x != statistic->last_value.x) { record_event (perf_log, event_time, statistic->event, (const guchar *)&statistic->current_value.x, sizeof (gint64)); statistic->last_value.x = statistic->current_value.x; statistic->recorded = TRUE; } break; } } record_event (perf_log, event_time, g_ptr_array_index (perf_log->events, EVENT_STATISTICS_COLLECTED), (const guchar *)&collection_time, sizeof (gint64)); }
static void record_event (ShellPerfLog *perf_log, gint64 event_time, ShellPerfEvent *event, const guchar *bytes, size_t bytes_len) { ShellPerfBlock *block; size_t total_bytes; guint32 time_delta; guint32 pos; if (!perf_log->enabled) return; total_bytes = sizeof (gint32) + sizeof (gint16) + bytes_len; if (G_UNLIKELY (bytes_len > BLOCK_SIZE || total_bytes > BLOCK_SIZE)) { g_warning ("Discarding oversize event '%s'\n", event->name); return; } if (event_time > perf_log->last_time + G_GINT64_CONSTANT(0xffffffff)) { perf_log->last_time = event_time; record_event (perf_log, event_time, lookup_event (perf_log, "perf.setTime", "x"), (const guchar *)&event_time, sizeof(gint64)); time_delta = 0; } else if (event_time < perf_log->last_time) time_delta = 0; else time_delta = (guint32)(event_time - perf_log->last_time); perf_log->last_time = event_time; if (perf_log->blocks->tail == NULL || total_bytes + ((ShellPerfBlock *)perf_log->blocks->tail->data)->bytes > BLOCK_SIZE) { block = g_new (ShellPerfBlock, 1); block->bytes = 0; g_queue_push_tail (perf_log->blocks, block); } else { block = (ShellPerfBlock *)perf_log->blocks->tail->data; } pos = block->bytes; memcpy (block->buffer + pos, &time_delta, sizeof (guint32)); pos += sizeof (guint32); memcpy (block->buffer + pos, &event->id, sizeof (guint16)); pos += sizeof (guint16); memcpy (block->buffer + pos, bytes, bytes_len); pos += bytes_len; block->bytes = pos; }
void wakeup() { blip(); // serial interrupt detected a char if (wakeup_mode == WAKEON_COM_A) { // while an RTC wakeup has not occured while (wakeup_mode != WAKEON_RTC){ // flash LED blip(); // if serial wake-up is good if (serial_wakeup()){ sleep_mode = FALSE; start_heartbeat(); init_hardware(); init_rtc(); // This is the FAT RTC sd_status = init_sdcard(); bit_set(INTCON,PEIE); // Set Peripheral Interrupt Enable bit sprintf(event_str, ",serial wake-up,SD initialized\r\n"); record_event(); if(sd_status>0) msg_card_fail(); return; } else { // if serial_wakeup() == FALSE, then false alarm wakeup_mode = WAKEON_BAD; blip(); blip(); shutdown(); go_to_sleep(); } } } }
void reset_event() { switch ( restart_cause() ) { case WDT_TIMEOUT: { printf("@WDT\r\n"); sprintf(event_str, ",restart cause,WD time-out\r\n"); record_event(); recovery(); break; } case WDT_FROM_SLEEP: { printf("@WDS\r\n"); sprintf(event_str, ",restart cause,WD from sleep\r\n"); record_event(); recovery(); break; } case NORMAL_POWER_UP: { printf("@NPU\r\n"); sprintf(event_str, ",id#[%Lu],power applied,SD initialized\r\n", nv_serial); record_event(); break; } case RESET_INSTRUCTION: { printf("@RST\r\n"); sprintf(event_str, ",restart cause,reset instruction\r\n"); record_event(); break; } case BROWNOUT_RESTART: { printf("@BOR\r\n"); sprintf(event_str, ",restart cause,brown-out\r\n"); record_event(); recovery(); break; } case MCLR_FROM_SLEEP: { printf("@MRS\r\n"); sprintf(event_str, ",restart cause,MCLR from sleep\r\n"); record_event(); recovery(); break; } case MCLR_FROM_RUN: { printf("@MRR\r\n"); sprintf(event_str, ",restart cause,MCLR when running\r\n"); record_event(); recovery(); break; } } }
void Floor::need_new_main_cubby() { Sprites *remaining = alternative_body_cubbies; while (remaining != NULL) { Cubby *cubby = (Cubby *) (remaining->first()); if (cubby->vacuum_if_left_on_floor(NULL,0)) { // args are ignored record_event(NEW_MAIN_CUBBY,tt_programmer->pointer_to_appearance(),this,cubby); }; remaining = remaining->rest(); }; };
/** * shell_perf_log_event: * @perf_log: a #ShellPerfLog * @name: name of the event * * Records a performance event with no arguments. */ void shell_perf_log_event (ShellPerfLog *perf_log, const char *name) { ShellPerfEvent *event = lookup_event (perf_log, name, ""); if (G_UNLIKELY (event == NULL)) return; record_event (perf_log, get_time(), event, NULL, 0); }
/** * shell_perf_log_event_x: * @perf_log: a #ShellPerfLog * @name: name of the event * @arg: the argument * * Records a performance event with one 64-bit integer argument. */ void shell_perf_log_event_x (ShellPerfLog *perf_log, const char *name, gint64 arg) { ShellPerfEvent *event = lookup_event (perf_log, name, "x"); if (G_UNLIKELY (event == NULL)) return; record_event (perf_log, get_time(), event, (const guchar *)&arg, sizeof (arg)); }
/** * shell_perf_log_event_s: * @perf_log: a #ShellPerfLog * @name: name of the event * @arg: the argument * * Records a performance event with one string argument. */ void shell_perf_log_event_s (ShellPerfLog *perf_log, const char *name, const char *arg) { ShellPerfEvent *event = lookup_event (perf_log, name, "s"); if (G_UNLIKELY (event == NULL)) return; record_event (perf_log, get_time(), event, (const guchar *)arg, strlen (arg) + 1); }
/** * cinnamon_perf_log_event_i: * @perf_log: a #CinnamonPerfLog * @name: name of the event * @arg: the argument * * Records a performance event with one 32-bit integer argument. */ void cinnamon_perf_log_event_i (CinnamonPerfLog *perf_log, const char *name, gint32 arg) { CinnamonPerfEvent *event = lookup_event (perf_log, name, "i"); if (G_UNLIKELY (event == NULL)) return; record_event (perf_log, get_time(), event, (const guchar *)&arg, sizeof (arg)); }
/* signal_update_windows: return value needed to comply with the shared * header file in <URI: src/rts/src/os.h>. If window updates are started * (which is typically during compilation or computation within a * listener), then an event is recorded to handle Window messages sent to * the MLWorks environment, and to check for the interrupt button being * pressed. See <URI: src/rts/src/OS/Win32/os.c> and also * <URI: src/rts/src/OS/Win32/window.c:mlw_expose_windows>. */ static int signal_update_windows(unsigned int interval) { if (window_update_remaining < interval) { window_update_remaining = window_update_interval; if (window_updates_on) { record_event(EV_WINDOWS, (word) 0); return 1; } } else window_update_remaining -= interval; return 0; }
void det_temp(){ int8 store,display; int16 n,t; int16 current_temp = 0; int16 target_temp; switch (detector){ case 1 : target_temp = nv_d1_temp; break; case 2 : target_temp = nv_d2_temp; break; default : target_temp = 20000; break; } t = 60; // 5 mins = 300 sec >> delay = 300 / 5 = 60 n = 0; store=FALSE; display=FALSE; time_stamp(); sprintf(event_str, ",start heating,target[%Lu],actual[%Lu],readings[%Lu]\r\n", target_temp,current_temp,n); record_event(); for (n=1; n<t; ++n){ det_read(store, display); // detector read ~ 2.5 sec current_temp=parse_temp(); if (current_temp >= target_temp || current_temp == 0) break; // 0=fail (no detector) else delay_ms(2500); // completes the 5.0 loop } sprintf(event_str, ",end heating,target[%Lu],actual[%Lu],readings[%Lu]\r\n", target_temp,current_temp,n); record_event(); }
BOOL control_key_handler(DWORD ctrl_type) { switch (ctrl_type) { case CTRL_C_EVENT: record_event(EV_INTERRUPT, (word) 0); return TRUE; case CTRL_BREAK_EVENT: case CTRL_CLOSE_EVENT: case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: return FALSE; } }
void __po_hi_gqueue_store_out (__po_hi_task_id id, __po_hi_local_port_t port, __po_hi_request_t* request) { __po_hi_request_t* ptr; request->port = __PO_HI_GQUEUE_OUT_PORT; ptr = &__po_hi_gqueues_most_recent_values[id][port]; memcpy (ptr, request, sizeof (__po_hi_request_t)); __PO_HI_DEBUG_DEBUG ("\n__Po_hi_gqueue_store_out() from task %d on port %d\n", id, port); #if defined (MONITORING) __DEBUGMSG("\nThe last value is the request to be stored"); record_event(ANY, STORE_OUT, id, invalid_port_t, invalid_port_t, port, invalid_local_port_t, request); #endif }
static void signal_interval_alarm(void) { if (profile_on) { word *current_thread = suspend_current_thread(); time_profile_scan((struct stack_frame *) reconstruct_thread_sp(current_thread)); resume_current_thread(current_thread); } if (thread_preemption_on) { thread_preemption_pending = 1; record_event(EV_SWITCH, (word)0); } signal_update_windows (timer_interval); start_timer(timer_interval); }
boolean Thought_Bubble::receive_item(Sprite *item, Sprite *by, millisecond , Sprite *original_recipient, Sprite *original_item) { if (inside_vacuum()) { by->abort_action(IDS_ROBOT_MISSING_RECIPIENT_ABORT); return(FALSE); }; // cubby_vacuumed = FALSE; by->completed(); if (item->kind_of() != CUBBY) { // error check for robustness new on 111104 by->abort_action(IDS_THOUGHT_BUBBLE_RECEIVED_SOMETHING_OTHER_THAN_A_BOX,NONE_GIVEN,2,"a thought bubble received something other than a box"); // updated on 130205 // log("Thought bubble received something other than a box.",FALSE,TRUE); return(FALSE); }; Cubby *new_cubby = (Cubby *) item; new_cubby->now_inside_thought_bubble(FALSE); // was (by != NULL && by->kind_of() == ROBOT_IN_TRAINING)); // the following calls inside_thought_bubble -- combine the 2 protocols?? receive_cubby(new_cubby,(boolean) accept_item_duration); record_event(RELEASE_ITEM_ON,by,floor,item); return(TRUE); //RELEASED_CUBBY_ON_THOUGHT_BUBBLE); };
void __po_hi_gqueue_wait_for_incoming_event (__po_hi_task_id id, __po_hi_local_port_t* port) { /* Locking only the mutex of the semaphore */ int result = __po_hi_sem_mutex_wait_gqueue(__po_hi_gqueues_semaphores,id); __DEBUGMSG("GQUEUE_SEM_MUTEX_WAIT %d %d\n", id, result); assert(result == __PO_HI_SUCCESS); while(po_hi_gqueues_queue_is_empty(id) == 1) { __PO_HI_INSTRUMENTATION_VCD_WRITE("0t%d\n", id); /* Telling the semaphore to wait with putting its condvar on wait mode */ int res_sem = __po_hi_sem_wait_gqueue(__po_hi_gqueues_semaphores,id); __DEBUGMSG("GQUEUE_SEM_WAIT %d %d\n", id, res_sem); assert(res_sem == __PO_HI_SUCCESS); __PO_HI_INSTRUMENTATION_VCD_WRITE("1t%d\n", id); } *port = __po_hi_gqueues_global_history[id][__po_hi_gqueues_global_history_offset[id]]; #if defined (MONITORING) record_event(SPORADIC, WAIT_FOR, id, invalid_port_t, invalid_port_t, *port, invalid_local_port_t, NULL); #endif /** Releasing only the mutex of the semaphore*/ int res = __po_hi_sem_mutex_release_gqueue(__po_hi_gqueues_semaphores,id); __DEBUGMSG("GQUEUE_SEM_MTUEX_RELEASE %d %d\n", id, res); assert(res == __PO_HI_SUCCESS); #ifdef __PO_HI_GQUEUE_ASSERTIONS __DEBUGMSG("\nThe task queue must be considered not empty "); assert (*port == __po_hi_gqueues_global_history[id][__po_hi_gqueues_global_history_offset[id]]); #endif }
void command_prompt() { disable_interrupts(INT_EXT); nv_cmd_mode = TRUE; write8(ADDR_CMD_MODE, nv_cmd_mode); fputs("@CMD", COM_A); sprintf(event_str, ",command prompt\r\n"); record_event(); busy_clear(); cmd_set=0; // user do { fputc('>',COM_A); cmd=fgetc(COM_A); fputc(cmd,COM_A); if (cmd == '?') msg_busy(); else proc_cmd(); } while(nv_cmd_mode == TRUE); }
int16 det_read(int8 store, int8 display) { // get detector reading and write to a file on the SD card // the string to be stored is compiled into "data_buffer" // first the data_buffer is cleared // then time_stamp_str, flags, results & end-of-line are concatenated // append_data writes "data_buffer" to the file "all" and "new" files #define SHT 4 #define LNG 5 char comma[2] = {',' , '\0'}; char endofline[3] = {'\r' , '\n' , '\0'}; char err_msg[11]; //! char timeout[4] = {'T','-','O','\0'}; //! char at_rx[4] = {'@','R','x','\0'}; //! char nil_rx[4] = {'N','I','L','\0'}; int8 i, record, rec_len; clear_slave_reply(); clear_data_buffer(); time_stamp(); strcat(data_buffer, time_stmp_str); strcat(data_buffer, comma); decode_flag(); strcat(data_buffer, flag_str); strcat(data_buffer, comma); cmd = 'S'; arg = 1; for(i=0;i<3;i++){ record=get_slave_data(); if (record==2) break; // cr was found = string collected } rec_len=strlen(slave_reply); // if record either NIL or @ received, test the length if(rec_len>0 && rec_len<12) record=SHT; if(rec_len>30) record=LNG; switch(record){ case 0 : sprintf(err_msg, "nil"); strcat(slave_reply, err_msg); break; case 1 : sprintf(err_msg, "@rec"); strcat(slave_reply, err_msg); break; case 2: // do nothing break; case 3 : sprintf(err_msg, "time-out"); strcat(slave_reply, err_msg); break; case 4 : sprintf(err_msg, "data too short"); strcat(slave_reply, err_msg); break; case 5 : sprintf(err_msg, "data too long"); strcat(slave_reply, err_msg); break; } strcat(slave_reply, endofline); strcat(data_buffer, slave_reply); if(record!=2){ //housekeeping time_stamp(); sprintf(event_str, ",detector[%s],len[%u]",err_msg, rec_len); strcat(event_str, data_buffer); record_event(); } display_rec(store, display); return (record); }
int __po_hi_gqueue_get_value (__po_hi_task_id id, __po_hi_local_port_t port, __po_hi_request_t* request) { __po_hi_request_t* ptr; __PO_HI_DEBUG_DEBUG("before get_value for task-id %d , port = %d, offset = %d, woffset = %d, history_offset = %d, history_woffset = %d, port size = %d , fifo size = %d, gqueues_id adress = %d, \n\n", id, port, __po_hi_gqueues_offsets[id][port], __po_hi_gqueues_woffsets[id][port],__po_hi_gqueues_global_history_offset[id],__po_hi_gqueues_global_history_woffset[id], __po_hi_gqueues_sizes[id][port], __po_hi_gqueues_total_fifo_size[id], __po_hi_gqueues[id]); ptr = &__po_hi_gqueues_most_recent_values[id][port]; /* Locking only the mutex of the semaphore */ int result = __po_hi_sem_mutex_wait_gqueue(__po_hi_gqueues_semaphores,id); __DEBUGMSG("GQUEUE_SEM_MUTEX_WAIT %d %d\n", id, result); assert(result == __PO_HI_SUCCESS); /* * If the port is an OUTPUT, with no value queued, the function returns * nothing. */ if (__po_hi_gqueue_get_port_size(id,port) == -2) { __PO_HI_DEBUG_CRITICAL ("[GQUEUE] OUTPUT PORT, REQUEST NOT SET UP, task-id=%d, port=%d\n", id, port); __DEBUGMSG("THE PORT IS AN OUTPUT, REQUEST NOT SET UP"); /* Releasing only the mutex of the semaphore*/ int rel = __po_hi_sem_mutex_release_gqueue(__po_hi_gqueues_semaphores,id); __DEBUGMSG("GQUEUE_SEM_MUTEX_RELEASE %d %d\n", id, rel); assert(rel == __PO_HI_SUCCESS); return __PO_HI_INVALID; } /* * If the port is an event port, with no value queued, then we block * the thread. */ /* Empty port case 1 : NO FIFO INDATA */ if (__po_hi_gqueue_get_port_size(id,port) != __PO_HI_GQUEUE_FIFO_INDATA) { while (__po_hi_gqueues_port_is_empty[id][port] == 1) { /* Telling the semaphore to wait with putting its condvar on wait mode */ int res_sem = __po_hi_sem_wait_gqueue(__po_hi_gqueues_semaphores,id); __DEBUGMSG("GQUEUE_SEM_WAIT %d %d\n", id, result); assert(res_sem == __PO_HI_SUCCESS); } } /* Empty port case 2 : FIFO INDATA */ if ((__po_hi_gqueue_get_port_size(id,port) == __PO_HI_GQUEUE_FIFO_INDATA) && (__po_hi_gqueue_used_size(id,port) == 0)) { memcpy (request, ptr, sizeof (__po_hi_request_t)); //update_runtime (id, port, ptr); } else { /* The program ensures to read the information at the right place in the buffer. * The right first offset has to be applied so that the right port is chosen. * The right offset (read_offset) has to be applied not to erase fresh information. */ ptr = (__po_hi_gqueues[id]) + __po_hi_gqueues_first[id][port] + __po_hi_gqueues_offsets[id][port]; __PO_HI_DEBUG_DEBUG("Get_value if port not empty first + offsets = %d, gqueue_id adress = %d, first = %d, ptr (adress + first +offset) = %d, \n\n", __po_hi_gqueues_first[id][port] + __po_hi_gqueues_offsets[id][port],__po_hi_gqueues[id], __po_hi_gqueues_first[id][port], ptr); memcpy (request, ptr, sizeof (__po_hi_request_t)); } #if defined (MONITORING) record_event(ANY, GET_VALUE, id, invalid_port_t, invalid_port_t, port, invalid_local_port_t , request); #endif __PO_HI_DEBUG_INFO ("[GQUEUE] Task %d get a value on port %d\n", id, port); /* Releasing only the mutex of the semaphore*/ int res = __po_hi_sem_mutex_release_gqueue(__po_hi_gqueues_semaphores,id); __DEBUGMSG("GQUEUE_SEM_MUTEX_RELEASE %d %d\n", id, res); assert(res == __PO_HI_SUCCESS); __PO_HI_DEBUG_DEBUG("After get_value for task-id %d , port = %d, offset = %d, woffset = %d, history_offset = %d, history_woffset = %d, port size = %d, fifo size = %d, gqueues adress = %d \n\n", id, port, __po_hi_gqueues_offsets[id][port], __po_hi_gqueues_woffsets[id][port],__po_hi_gqueues_global_history_offset[id],__po_hi_gqueues_global_history_woffset[id], __po_hi_gqueues_sizes[id][port], __po_hi_gqueues_total_fifo_size[id], __po_hi_gqueues[id]); return __PO_HI_SUCCESS; }