X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt-usertrace%2Fsample-thread-fast.c;h=46ffbd12ff3f5b27df1e307763204cf6e37fd1c0;hb=34a97fdc8a1c40616f352c4a20273038c1bd3eda;hp=69f1cf890c4770bb88e2297ede7bcf30fa1ec2b5;hpb=141274aac0c9dd34c0dac660d381a959a2ca5e15;p=lttv.git diff --git a/ltt-usertrace/sample-thread-fast.c b/ltt-usertrace/sample-thread-fast.c index 69f1cf89..46ffbd12 100644 --- a/ltt-usertrace/sample-thread-fast.c +++ b/ltt-usertrace/sample-thread-fast.c @@ -11,13 +11,13 @@ void *thr1(void *arg) { + int i; ltt_thread_init(); /* This init is not required : it will be done automatically anyways at the first tracing call site */ printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid()); - while(1) { + for(i=0; i<100000; i++) { trace_user_generic_string("Hello world! Have a nice day."); - sleep(2); } pthread_exit((void*)1); } @@ -26,12 +26,12 @@ void *thr1(void *arg) /* Example of a _bad_ thread, which still works with the tracing */ void *thr2(void *arg) { + int i; /* See ? no init */ printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid()); - sleep(1); - while(1) { + + for(i=0; i<100000; i++) { trace_user_generic_string("Hello world! Have a nice day."); - sleep(2); } /* This thread is a bad citizen : returning like this will cause its cancel * routines not to be executed. This is still detected by the tracer, but only @@ -48,9 +48,8 @@ int main() void *tret; printf("Will trace the following string : Hello world! Have a nice day.\n"); - printf("Press CTRL-C to stop.\n"); - printf("No file is created with this example : it logs through a kernel\n"); - printf("system call. See the LTTng lttctl command to start tracing.\n\n"); + printf("It will stop automatically.\n"); + printf("See the result file in /tmp/ltt-usertrace.\n"); printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid()); err = pthread_create(&tid1, NULL, thr1, NULL);