Add latency tracing capability to pthread_kill_latency as is already
done on a few other latency tests (gtod_latency, sched_latency, ...)
Signed-off-by: Sebastien Dugue <[EMAIL PROTECTED]>
Cc: Sripathi Kodi <[EMAIL PROTECTED]>
Cc: Darren Hart <[EMAIL PROTECTED]>
Cc: Tim Chavez <[EMAIL PROTECTED]>
---
.../pthread_kill_latency/pthread_kill_latency.c | 38 +++++++++++++++++++-
1 files changed, 37 insertions(+), 1 deletions(-)
diff --git
a/testcases/realtime/func/pthread_kill_latency/pthread_kill_latency.c
b/testcases/realtime/func/pthread_kill_latency/pthread_kill_latency.c
index 518bd2f..68e7e4f 100644
--- a/testcases/realtime/func/pthread_kill_latency/pthread_kill_latency.c
+++ b/testcases/realtime/func/pthread_kill_latency/pthread_kill_latency.c
@@ -42,6 +42,8 @@
* HISTORY
* 2006-Jun-28: Initial version by Sripathi Kodi <[EMAIL PROTECTED]>
* 2007-Nov-07: Added libstats support by Darren Hart <[EMAIL PROTECTED]>
+ * 2008-Jan-23: Latency tracing added by
+ * Sebastien Dugue <[EMAIL PROTECTED]>
*
*****************************************************************************/
@@ -64,6 +66,7 @@
/* Get the pthread structure corresponding to this thread id */
#define PTHREADOF(tid) get_thread(tid)->pthread
+static long latency_threshold = 0;
nsec_t begin, end;
int fail;
@@ -76,6 +79,7 @@ void usage(void)
rt_help();
printf("pthread_kill_latency specific options:\n");
printf(" -j enable jvmsim\n");
+ printf(" -l threshold trace latency with given threshold in us\n");
}
int parse_args(int c, char *v)
@@ -86,6 +90,9 @@ int parse_args(int c, char *v)
case 'j':
run_jvmsim = 1;
break;
+ case 'l':
+ latency_threshold = strtoull(v, NULL, 0);
+ break;
case 'h':
usage();
exit(0);
@@ -143,6 +150,11 @@ void *signal_receiving_thread(void *arg)
debug(DBG_DEBUG, "Signal receiving thread ready to receive\n");
+ if (latency_threshold) {
+ latency_trace_enable();
+ latency_trace_start();
+ }
+
/* Warm up */
for (i = 0; i < 5; i++) {
sigwait(&set, &sig);
@@ -152,6 +164,7 @@ void *signal_receiving_thread(void *arg)
max = min = 0;
fail = 0;
debug(DBG_INFO, "\n\n");
+
for (i = 0; i < ITERATIONS; i++) {
sigwait(&set, &sig);
end = rt_gettime();
@@ -172,9 +185,28 @@ void *signal_receiving_thread(void *arg)
fflush(stdout);
buffer_print();
+
+ if (latency_threshold && (delta > latency_threshold)) {
+ atomic_set(2, &flag);
+ break;
+ }
+
atomic_set(1, &flag);
}
+ if (latency_threshold) {
+ latency_trace_stop();
+
+ if (i != ITERATIONS) {
+ printf("Latency threshold (%luus) exceeded at iteration
%d\n",
+ latency_threshold, i);
+ fflush(stdout);
+ buffer_print();
+ latency_trace_print();
+ stats_container_resize(&dat, i + 1);
+ }
+ }
+
stats_hist(&hist, &dat);
stats_container_save("samples", "pthread_kill Latency Scatter Plot",
"Iteration", "Latency (us)", &dat, "points");
@@ -235,6 +267,10 @@ void *signal_sending_thread(void *arg)
while (!atomic_get(&flag)) {
usleep(100);
}
+
+ if (atomic_get(&flag) == 2)
+ break;
+
atomic_set(0, &flag);
}
return NULL;
@@ -247,7 +283,7 @@ int main(int argc, char *argv[])
atomic_set(0,&flag);
setup();
- rt_init("jh", parse_args, argc, argv); /* we need the buffered print
system */
+ rt_init("jl:h", parse_args, argc, argv); /* we need the buffered
print system */
printf("-------------------------------\n");
printf("pthread_kill Latency\n");
--
1.5.4.rc2.84.gf85fd-dirty
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list