void start_profiling_in(void){ last_jiffies1 = sysTimestampLock(); last_ticks1 = tickGet(); }
void start_profiling(void){ last_jiffies = sysTimestampLock(); last_ticks = tickGet(); }
void stop_profiling_in(void){ current_jiffies1 = sysTimestampLock(); current_ticks1 = tickGet(); tick_diff1 = (current_ticks1 - last_ticks1)*microseconds_per_tick; jiffy_diff1 = (current_jiffies1 - last_jiffies1)*microseconds_per_jiffy; micro_diff1 = tick_diff1 + jiffy_diff1; }
void stop_profiling(void){ current_jiffies = sysTimestampLock(); current_ticks = tickGet(); tick_diff = (current_ticks - last_ticks)*microseconds_per_tick; jiffy_diff = (current_jiffies - last_jiffies)*microseconds_per_jiffy; micro_diff = tick_diff + jiffy_diff; }
/****************************************************************************** ** Function: CFE_PSP_Get_Timebase() ** ** Purpose: ** Provides a common interface to system timebase. This routine ** is in the BSP because it is sometimes implemented in hardware and ** sometimes taken care of by the RTOS. ** ** Arguments: ** ** Return: ** Timebase register value */ void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32* Tbl) { uint32 upper = 0; uint32 lower = 0; int32 key = 0; /* ** We don't want an interrupt to occur when the time requested. ** According to notes from vxWorks, intLock does not stop reschededuling ** of the calling task, so we have lock the task as well. ** ** sysTimestampLock() automatically blocks interrupts during execution. ** ** taskLock() is not valid on SMP systems and taskCpuLock (VxWorks 6.6+) ** should be used instead. */ if(g_bTimerInitialized == TRUE) { #if _WRS_VXWORKS_MINOR >= 6 if (taskCpuLock() == OK) #else if (taskLock() == OK) #endif { /* ** Tbu is the upper 32 bits of a 64 bit counter. ** Tbl is the lower 32 bits of a 64 bit counter. ** The resolution of our timer is given by: ** one timer tick = 1 / sysTimestampFreq() in seconds */ upper = g_nSecondsCount; lower = sysTimestampLock(); lower /= sysTimestampFreq() / 1000000UL; #if _WRS_VXWORKS_MINOR >= 6 taskCpuUnlock(); #else taskUnlock(); #endif } else { /* ** What if you can't lock the task */ OS_printf("CFE PSP Get Timebase: Unable to lock task!"); } } else { OS_printf("CFE PSP Get Timebase: Timer is not initialized!"); } if(Tbu != NULL) { *Tbu = upper; } if(Tbl != NULL) { *Tbl = lower; } }
void CFE_PSP_GetTime(OS_time_t *LocalTime) { uint32 nTimeStamp = 0; uint32 nFrequency = 0; uint32 nScaler = 0; unsigned long long ullTimeStamp = 0; if(LocalTime == NULL) { return; } else { if(g_bTimerInitialized == FALSE) { LocalTime->seconds = 0; LocalTime->microsecs = 0; return; } else { /* ** Get the time stamp */ /* Lock interrupts - really should be using this one, over * sysTimestamp(), according to * documentation on these function calls */ nTimeStamp = sysTimestampLock(); /* the default frequency is 9,375,000 Hz, which equals the PSP * ticks per second value * frequency = ticks per second for this counter */ nFrequency = sysTimestampFreq(); /* could use seconds = nTimeStamp / nFrequency if the timestamp counter * was a 64-bit counter, but being a 32-bit counter, running at * 9375000 Hz, it rolls over every 458.129 seconds or 7.63 minutes, * so we have to increment seconds using the aux clk ISR and get * the subseconds from the timestamp timer */ LocalTime->seconds = g_nSecondsCount; /* convert to micro sec - this conversion assumes that nTimeStamp * is always less than a second, which it should be, because it is * reset at the top of each second (when the seconds counter is * incremented) -- this comp has to be performed as an unsigned * long long, as the result of the multiply will not fit in a 32-bit * var. After dividing by the frequency(ticks per second), the result * can be stored in a 32-bit value */ ullTimeStamp = ((unsigned long long)nTimeStamp * 1000000ULL) / (unsigned long long) nFrequency; LocalTime->microsecs = (uint32)ullTimeStamp; /* logMsg("time: %u.%u ts: %u sc: %u\n", LocalTime->seconds,LocalTime->microsecs, nTimeStamp,g_nSecondsCount,0,0); */ } } }/* end CFE_PSP_GetTime */