/****************************************************************************** ** Function: CFE_PSP_AuxClkHandler() ** ** Purpose: ** A timer int handler to keep track of seconds. ** ** Arguments: ** ** Return: */ void CFE_PSP_AuxClkHandler(int arg) { static int auxCount = 0; if(++auxCount >= CFE_PSP_TIMER_AUX_TICK_PER_SEC) { auxCount = 0; ++g_nSecondsCount; /* calling enable every second, resets the counter to 0, allowing us * to use the higher resolution timestamp counter as a subsecond * time source */ sysTimestampEnable(); CFE_TIME_Local1HzISR(); /* FOR DEBUG OS_time_t LocalTime; CFE_PSP_GetTime(&LocalTime); logMsg("aux clk handler: %u %u\n", LocalTime.seconds,LocalTime.microsecs,0,0,0,0); */ } return; }
/****************************************************************************** ** Function: CFE_PSP_Init1HzTimer() ** ** Purpose: Initializes the 1Hz Timer and connects it to the cFE TIME 1Hz routine ** ** ** NOTE: This function has to be called after CFE_ES_Main() in CFE_PSP_Start() ** because the 1Hz ISR has a semaphore that is created in CFE_ES_Main(). ** ** Arguments: none ******************************************************************************/ void CFE_PSP_Init1HzTimer(void) { /* ** Attach a handler to the timer interrupt */ /* Either the Aux clock */ if(sysAuxClkConnect((FUNCPTR)CFE_PSP_AuxClkHandler, CFE_PSP_TIMER_AUX_TICK_PER_SEC) == ERROR) { printf("CFE_PSP: Unable to connect handler to Aux Clock!\n"); } /* ** Enable the Aux timer interrupt ** Enable the Timestamp timer, which also sets it to zero */ sysAuxClkEnable(); if(sysTimestampEnable() == ERROR) { OS_printf("CFE_PSP: Unable to enable the Timestamp timer!\n"); } g_bTimerInitialized = TRUE; }/* end CFE_PSP_Init1HzTimer */
void nested() { /* local variable definition */ sysClkRateSet(1000); sysTimestampEnable(); jiffies_per_tick = sysTimestampPeriod(); clock_frequency = sysTimestampFreq(); microseconds_per_tick = (jiffies_per_tick / clock_frequency)*1000000.0; microseconds_per_jiffy = microseconds_per_tick / jiffies_per_tick; int i, j, p; start_profiling(); for(i=2; i<100; i++) { start_profiling_in(); for(j=2; j <= (i/j); j++) if(!(i%j)) break; /* if factor found, not prime*/ stop_profiling_in(); if(j > (i/j)) p = i; } stop_profiling(); output_profiling("nested for outer loop including inner loop profiling"); start_profiling(); for(i=2; i<100; i++) { for(j=2; j <= (i/j); j++) if(!(i%j)) break; /* if factor found, not prime*/ if(j > (i/j)) p = i; } stop_profiling(); output_profiling("nested for outer loop without inner loop profiling"); }
int main() { int _p[4] = {200, 100, 100, 100}; char * word; DynArray * da = (DynArray *)malloc(sizeof(DynArray)); DynArray * clone1 = (DynArray *)malloc(sizeof(DynArray)); DynArray * clone2 = (DynArray *)malloc(sizeof(DynArray)); DynArray * clone3 = (DynArray *)malloc(sizeof(DynArray)); initDynArray(da, bulk_alloc); for (word = strtok(srcString, " "); word ; word = strtok(NULL, " ")) { addDynArray(da, word); } cloneDynArray(clone1, da); cloneDynArray(clone2, da); cloneDynArray(clone3, da); sysTimestampEnable(); TASK_ID qsTid; TASK_ID bsTid; TASK_ID ssTid; TASK_ID supTid; taskCreateHookAdd(taskCreateCallback); taskDeleteHookAdd(taskDeleteCallback); taskSwitchHookAdd(taskSwitchCallback); supTid = taskSpawn(sup, _p[0], VX_NO_STACK_FILL, 2048*1000, supEntry, \ da, clone1, clone2, clone3, compare,0,0,0,0,0); qsTid = taskSpawn(mqs, _p[1], VX_NO_STACK_FILL, 2048*1000, myqsortEntry, \ clone1, compare, supTid, 0,0,0,0,0,0,0); bsTid = taskSpawn(mbs, _p[2], VX_NO_STACK_FILL, 2048*1000, mybsortEntry, \ clone2, compare, supTid, 0,0,0,0,0,0,0); ssTid = taskSpawn(mns, _p[3], VX_NO_STACK_FILL, 2048*1000, mynsortEntry, \ clone3, compare, supTid, 0,0,0,0,0,0,0); return 0; }