From 88fd5f42b3c4e1d619c970fdcc1e0799957fe6e2 Mon Sep 17 00:00:00 2001 From: hollings Date: Fri, 1 Oct 1993 18:15:53 +0000 Subject: [PATCH] Added filtering and resource discovery. --- rtinst/src/RTcm5_pn.c | 101 ++++++++++++++++++++++++++++++++++++++++---------- rtinst/src/RTfuncs.c | 21 ++++++++++- 2 files changed, 101 insertions(+), 21 deletions(-) diff --git a/rtinst/src/RTcm5_pn.c b/rtinst/src/RTcm5_pn.c index 4837802..20db47f 100644 --- a/rtinst/src/RTcm5_pn.c +++ b/rtinst/src/RTcm5_pn.c @@ -4,7 +4,10 @@ * * * $Log: RTcm5_pn.c,v $ - * Revision 1.4 1993/09/02 22:09:38 hollings + * Revision 1.5 1993/10/01 18:15:53 hollings + * Added filtering and resource discovery. + * + * Revision 1.4 1993/09/02 22:09:38 hollings * fixed race condition caused be no re-trying sampling of process time. * * Revision 1.3 1993/08/26 23:07:34 hollings @@ -58,12 +61,72 @@ #define NI_CLK_USEC 33 #define MILLION 1000000 + +#ifdef notdef +time64 inline getProcessTime() +{ + time64 end; + time64 ni_end; + time64 ni2; + +retry: + CMOS_get_NI_time(&ni_end); + CMOS_get_time(&end); + CMOS_get_NI_time(&ni2); + if (ni_end != ni2) goto retry; + return(end-ni_end); +} +#endif + +struct timer_buf { + unsigned int high; + unsigned int sync; + time64 ni_time; +}; + +typedef union { + struct { + unsigned int high; + unsigned int low; + } parts; + time64 value; +} timeParts; + +static volatile unsigned int *ni; +static volatile struct timer_buf timerBuffer; + +time64 inline getProcessTime() +{ + timeParts end; + time64 ni_end; + +retry: + timerBuffer.sync = 1; + ni_end = timerBuffer.ni_time; + end.parts.high = timerBuffer.high; + end.parts.low = *ni; + if (timerBuffer.sync != 1) goto retry; + return(end.value-ni_end); +} + +time64 inline getWallTime() +{ + timeParts end; + time64 ni_end; + +retry: + timerBuffer.sync = 1; + end.parts.high = timerBuffer.high; + end.parts.low = *ni; + if (timerBuffer.sync != 1) goto retry; + return(end.value); +} + void DYNINSTstartWallTimer(tTimer *timer) { if (timer->trigger && (!timer->trigger->value)) return; if (timer->counter == 0) { - CMOS_get_time(&timer->start); - timer->normalize = NI_CLK_USEC * MILLION; + timer->start = getWallTime(); } /* this must be last to prevent race conditions with the sampler */ timer->counter++; @@ -77,7 +140,7 @@ void DYNINSTstopWallTimer(tTimer *timer) if (!timer->counter) return; if (timer->counter == 1) { - CMOS_get_time(&now); + now = getWallTime(); timer->snapShot = timer->total + now - timer->start; timer->mutex = 1; timer->counter = 0; @@ -88,32 +151,23 @@ void DYNINSTstopWallTimer(tTimer *timer) } } -time64 inline getProcessTime() -{ - time64 end; - time64 ni_end; - time64 ni2; - -retry: - CMOS_get_NI_time(&ni_end); - CMOS_get_time(&end); - CMOS_get_NI_time(&ni2); - if (ni_end != ni2) goto retry; - return(end-ni_end); -} - - void DYNINSTstartProcessTimer(tTimer *timer) { if (timer->trigger && (!timer->trigger->value)) return; if (timer->counter == 0) { timer->start = getProcessTime(); - timer->normalize = NI_CLK_USEC * MILLION; } /* this must be last to prevent race conditions with the sampler */ timer->counter++; } +void set_timer_buf(struct timer_buf *param) +{ + asm("set 50,%g1"); + asm("retl"); + asm("ta 0x8"); +} + double previous[1000]; void DYNINSTstopProcessTimer(tTimer *timer) @@ -180,6 +234,7 @@ void DYNINSTreportTimer(tTimer *timer) abort(); } + timer->normalize = NI_CLK_USEC * MILLION; sample.value = total / (double) timer->normalize; sample.id = timer->id; @@ -198,6 +253,9 @@ void DYNINSTreportTimer(tTimer *timer) static time64 startWall; int DYNINSTnoHandlers; +#define NI_BASE (0x20000000) +#define NI_TIME_A (NI_BASE + 0x0070) + /* * should be called before main in each process. * @@ -221,6 +279,9 @@ void DYNINSTinit() startWall -= startNItime; + ni = (unsigned int *) NI_TIME_A; + set_timer_buf(&timerBuffer); + /* initTraceLibPN(); */ } diff --git a/rtinst/src/RTfuncs.c b/rtinst/src/RTfuncs.c index 95c04b3..aaeec48 100644 --- a/rtinst/src/RTfuncs.c +++ b/rtinst/src/RTfuncs.c @@ -3,7 +3,10 @@ * functions for a SUNOS SPARC processor. * * $Log: RTfuncs.c,v $ - * Revision 1.2 1993/08/26 19:43:58 hollings + * Revision 1.3 1993/10/01 18:15:53 hollings + * Added filtering and resource discovery. + * + * Revision 1.2 1993/08/26 19:43:58 hollings * new include syntax. * * Revision 1.1 1993/07/02 21:49:35 hollings @@ -44,6 +47,11 @@ void DYNINSTdecrementCounter(intCounter *counter) counter->value--; } +void DYNINSTclearCounter(intCounter *counter) +{ + counter->value = 0; +} + void DYNINSTreportCounter(intCounter *counter) { traceSample sample; @@ -80,6 +88,17 @@ void DYNINSTexitPrint(int arg) } /* + * For testing filter code. + * + */ +void DYNINSTtoyFilter(filterArgs *filt, parameters *params) +{ + if (filt->filterData == params->arg1) { + filt->toCall(filt->callData, params); + } +} + +/* * This is a function that should be called when we want to sample the * timers and counters. The code to do the sampling is added as func * entry dynamic instrumentation. -- 1.8.3.1