unsigned char cpuusage(){ unsigned char usage; float load; int ncores; ncores = get_ncores(); load = get_load(); if(load>ncores)load=ncores; usage = 100*(load/(float)ncores); return usage; }
/****f* simple.c/flip_led * * SUMMARY * This function is used as a callback for timer tick events. * It inverts the state of LED 1 and sends packets. * * SYNOPSIS * void flip_led (uint ticks, uint null) * * INPUTS * uint ticks: simulation time (in ticks) - provided by the RTS * uint null: padding - all callbacks must have two uint arguments! * * SOURCE */ void flip_led (uint ticks, uint null) { /* flip led 1 */ /* Only 1 core should flip leds! */ if ((get_ncores(NUMBER_OF_CHIPS, core_map) == 1) || (coreID == 1)) { spin1_led_control(LED_INV (1)); } /* trigger user event to send packets */ if (spin1_trigger_user_event(ticks, NULL) == FAILURE) { ufailed++; } /* stop if desired number of ticks reached */ if (ticks >= TOTAL_TICKS) spin1_stop(); }