[Xenomai-git] Gilles Chanteperdrix : testsuite/latency: rebase on posix and timerfd

2014-05-16 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 349f6758a00528cc2e1cb41257c20cd9d379fdec
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=349f6758a00528cc2e1cb41257c20cd9d379fdec

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Thu Dec 26 23:45:36 2013 +0100

testsuite/latency: rebase on posix and timerfd

---

 testsuite/latency/Makefile.am |6 +-
 testsuite/latency/latency.c   |  285 +
 2 files changed, 180 insertions(+), 111 deletions(-)

diff --git a/testsuite/latency/Makefile.am b/testsuite/latency/Makefile.am
index 7acff32..55ba31b 100644
--- a/testsuite/latency/Makefile.am
+++ b/testsuite/latency/Makefile.am
@@ -1,5 +1,7 @@
 testdir = @XENO_TEST_DIR@
 
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
 test_PROGRAMS = latency
 
 latency_SOURCES = latency.c
@@ -8,7 +10,7 @@ latency_CPPFLAGS = \
$(XENO_USER_CFLAGS) \
-I$(top_srcdir)/include
 
-latency_LDFLAGS =
+latency_LDFLAGS = $(XENO_POSIX_WRAPPERS)
 
 core_libs =
 if XENO_COBALT
@@ -16,8 +18,6 @@ core_libs += ../../lib/cobalt/libcobalt.la
 endif
 
 latency_LDADD = \
-   ../../lib/alchemy/libalchemy.la \
-   ../../lib/copperplate/libcopperplate.la \
$(core_libs)\
 @XENO_USER_LDADD@  \
-lpthread -lrt -lm
diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c
index 5efc344..ddfe450 100644
--- a/testsuite/latency/latency.c
+++ b/testsuite/latency/latency.c
@@ -9,17 +9,21 @@
 #include sys/mman.h
 #include sys/time.h
 #include unistd.h
-#include copperplate/init.h
-#include alchemy/task.h
-#include alchemy/timer.h
-#include alchemy/sem.h
+#include pthread.h
+#include semaphore.h
+#include sys/timerfd.h
 #include rtdm/testing.h
+#include trace.h
 
-RT_TASK latency_task, display_task;
+pthread_t latency_task, display_task;
 
-RT_SEM display_sem;
+sem_t *display_sem;
 
-#define TEN_MILLION1000
+#define TEN_MILLION1000
+#define ONE_BILLION10
+
+#define HIPRIO 99
+#define LOPRIO 0
 
 unsigned max_relaxed;
 long minjitter, maxjitter, avgjitter;
@@ -33,9 +37,10 @@ int quiet = 0;   /* suppress printing of 
RTH, RTD lines when -T given */
 int benchdev_no = 0;
 int benchdev = -1;
 int freeze_max = 0;
-int priority = T_HIPRIO;
+int priority = HIPRIO;
 int stop_upon_switch = 0;
 sig_atomic_t sampling_relaxed = 0;
+char sem_name[16];
 
 #define USER_TASK   0
 #define KERNEL_TASK 1
@@ -69,38 +74,70 @@ int bucketsize = 1000;  /* default = 1000ns, -B 
size to override */
 static inline void add_histogram(long *histogram, long addval)
 {
/* bucketsize steps */
-   long inabs =
-   rt_timer_tsc2ns(addval = 0 ? addval : -addval) / bucketsize;
+   long inabs = (addval = 0 ? addval : -addval) / bucketsize;
histogram[inabs  histogram_size ? inabs : histogram_size - 1]++;
 }
 
-static void latency(void *cookie)
+static inline long long diff_ts(struct timespec *left, struct timespec *right)
+{
+   return (long long)(left-tv_sec - right-tv_sec) * ONE_BILLION
+   + left-tv_nsec - right-tv_nsec;
+}
+
+static void *latency(void *cookie)
 {
int err, count, nsamples, warmup = 1;
-   RTIME expected_tsc, period_tsc, start_ticks, fault_threshold;
-   RT_TIMER_INFO timer_info;
+   unsigned long long fault_threshold;
+   struct itimerspec timer_conf;
+   struct timespec expected;
unsigned old_relaxed = 0;
+   char task_name[16];
+   int tfd;
 
-   err = rt_timer_inquire(timer_info);
+   snprintf(task_name, sizeof(task_name), sampling-%d, getpid());
+   err = pthread_setname_np(pthread_self(), task_name);
+   if (err) {
+   fprintf(stderr, latency: setting name: error code %d\n, err);
+   return NULL;
+   }
 
+#ifdef CONFIG_XENO_COBALT
+   err = pthread_set_mode_np(0, PTHREAD_WARNSW, NULL);
if (err) {
-   fprintf(stderr, latency: rt_timer_inquire, code %d\n, err);
-   return;
+   fprintf(stderr, latency: setting WARNSW: error code %d\n, 
err);
+   return NULL;
+   }
+#endif
+
+   tfd = timerfd_create(CLOCK_MONOTONIC, 0);
+   if (tfd == -1) {
+   fprintf(stderr, latency: timerfd_create: %m\n);
+   return NULL;
}
 
-   fault_threshold = rt_timer_ns2tsc(CONFIG_XENO_DEFAULT_PERIOD);
+   err = clock_gettime(CLOCK_MONOTONIC, expected);
+   if (err) {
+   fprintf(stderr, latency: clock_gettime: %m\n);
+   return NULL;
+   }
+
+   fault_threshold = CONFIG_XENO_DEFAULT_PERIOD;
nsamples = ONE_BILLION / period_ns;
-   period_tsc = rt_timer_ns2tsc(period_ns);
/* start time: one millisecond from now. */
-   start_ticks = timer_info.date + rt_timer_ns2ticks(100);
-   

[Xenomai-git] Gilles Chanteperdrix : testsuite/latency: rebase on posix and timerfd

2014-05-15 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge-fd-rework
Commit: d0510efb1bd21a4af76cdcb48713803f4b29ed8d
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=d0510efb1bd21a4af76cdcb48713803f4b29ed8d

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Thu Dec 26 23:45:36 2013 +0100

testsuite/latency: rebase on posix and timerfd

---

 testsuite/latency/Makefile.am |6 +-
 testsuite/latency/latency.c   |  285 +
 2 files changed, 180 insertions(+), 111 deletions(-)

diff --git a/testsuite/latency/Makefile.am b/testsuite/latency/Makefile.am
index 7acff32..55ba31b 100644
--- a/testsuite/latency/Makefile.am
+++ b/testsuite/latency/Makefile.am
@@ -1,5 +1,7 @@
 testdir = @XENO_TEST_DIR@
 
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
 test_PROGRAMS = latency
 
 latency_SOURCES = latency.c
@@ -8,7 +10,7 @@ latency_CPPFLAGS = \
$(XENO_USER_CFLAGS) \
-I$(top_srcdir)/include
 
-latency_LDFLAGS =
+latency_LDFLAGS = $(XENO_POSIX_WRAPPERS)
 
 core_libs =
 if XENO_COBALT
@@ -16,8 +18,6 @@ core_libs += ../../lib/cobalt/libcobalt.la
 endif
 
 latency_LDADD = \
-   ../../lib/alchemy/libalchemy.la \
-   ../../lib/copperplate/libcopperplate.la \
$(core_libs)\
 @XENO_USER_LDADD@  \
-lpthread -lrt -lm
diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c
index 5efc344..ddfe450 100644
--- a/testsuite/latency/latency.c
+++ b/testsuite/latency/latency.c
@@ -9,17 +9,21 @@
 #include sys/mman.h
 #include sys/time.h
 #include unistd.h
-#include copperplate/init.h
-#include alchemy/task.h
-#include alchemy/timer.h
-#include alchemy/sem.h
+#include pthread.h
+#include semaphore.h
+#include sys/timerfd.h
 #include rtdm/testing.h
+#include trace.h
 
-RT_TASK latency_task, display_task;
+pthread_t latency_task, display_task;
 
-RT_SEM display_sem;
+sem_t *display_sem;
 
-#define TEN_MILLION1000
+#define TEN_MILLION1000
+#define ONE_BILLION10
+
+#define HIPRIO 99
+#define LOPRIO 0
 
 unsigned max_relaxed;
 long minjitter, maxjitter, avgjitter;
@@ -33,9 +37,10 @@ int quiet = 0;   /* suppress printing of 
RTH, RTD lines when -T given */
 int benchdev_no = 0;
 int benchdev = -1;
 int freeze_max = 0;
-int priority = T_HIPRIO;
+int priority = HIPRIO;
 int stop_upon_switch = 0;
 sig_atomic_t sampling_relaxed = 0;
+char sem_name[16];
 
 #define USER_TASK   0
 #define KERNEL_TASK 1
@@ -69,38 +74,70 @@ int bucketsize = 1000;  /* default = 1000ns, -B 
size to override */
 static inline void add_histogram(long *histogram, long addval)
 {
/* bucketsize steps */
-   long inabs =
-   rt_timer_tsc2ns(addval = 0 ? addval : -addval) / bucketsize;
+   long inabs = (addval = 0 ? addval : -addval) / bucketsize;
histogram[inabs  histogram_size ? inabs : histogram_size - 1]++;
 }
 
-static void latency(void *cookie)
+static inline long long diff_ts(struct timespec *left, struct timespec *right)
+{
+   return (long long)(left-tv_sec - right-tv_sec) * ONE_BILLION
+   + left-tv_nsec - right-tv_nsec;
+}
+
+static void *latency(void *cookie)
 {
int err, count, nsamples, warmup = 1;
-   RTIME expected_tsc, period_tsc, start_ticks, fault_threshold;
-   RT_TIMER_INFO timer_info;
+   unsigned long long fault_threshold;
+   struct itimerspec timer_conf;
+   struct timespec expected;
unsigned old_relaxed = 0;
+   char task_name[16];
+   int tfd;
 
-   err = rt_timer_inquire(timer_info);
+   snprintf(task_name, sizeof(task_name), sampling-%d, getpid());
+   err = pthread_setname_np(pthread_self(), task_name);
+   if (err) {
+   fprintf(stderr, latency: setting name: error code %d\n, err);
+   return NULL;
+   }
 
+#ifdef CONFIG_XENO_COBALT
+   err = pthread_set_mode_np(0, PTHREAD_WARNSW, NULL);
if (err) {
-   fprintf(stderr, latency: rt_timer_inquire, code %d\n, err);
-   return;
+   fprintf(stderr, latency: setting WARNSW: error code %d\n, 
err);
+   return NULL;
+   }
+#endif
+
+   tfd = timerfd_create(CLOCK_MONOTONIC, 0);
+   if (tfd == -1) {
+   fprintf(stderr, latency: timerfd_create: %m\n);
+   return NULL;
}
 
-   fault_threshold = rt_timer_ns2tsc(CONFIG_XENO_DEFAULT_PERIOD);
+   err = clock_gettime(CLOCK_MONOTONIC, expected);
+   if (err) {
+   fprintf(stderr, latency: clock_gettime: %m\n);
+   return NULL;
+   }
+
+   fault_threshold = CONFIG_XENO_DEFAULT_PERIOD;
nsamples = ONE_BILLION / period_ns;
-   period_tsc = rt_timer_ns2tsc(period_ns);
/* start time: one millisecond from now. */
-   start_ticks = timer_info.date + 

[Xenomai-git] Gilles Chanteperdrix : testsuite/latency: rebase on posix and timerfd

2014-02-10 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 7b5bdab1bde417bd98abc8556a75abf0d5c234e4
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=7b5bdab1bde417bd98abc8556a75abf0d5c234e4

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Thu Dec 26 23:45:36 2013 +0100

testsuite/latency: rebase on posix and timerfd

---

 testsuite/latency/Makefile.am |6 +-
 testsuite/latency/latency.c   |  284 +
 2 files changed, 179 insertions(+), 111 deletions(-)

diff --git a/testsuite/latency/Makefile.am b/testsuite/latency/Makefile.am
index 7acff32..55ba31b 100644
--- a/testsuite/latency/Makefile.am
+++ b/testsuite/latency/Makefile.am
@@ -1,5 +1,7 @@
 testdir = @XENO_TEST_DIR@
 
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
 test_PROGRAMS = latency
 
 latency_SOURCES = latency.c
@@ -8,7 +10,7 @@ latency_CPPFLAGS = \
$(XENO_USER_CFLAGS) \
-I$(top_srcdir)/include
 
-latency_LDFLAGS =
+latency_LDFLAGS = $(XENO_POSIX_WRAPPERS)
 
 core_libs =
 if XENO_COBALT
@@ -16,8 +18,6 @@ core_libs += ../../lib/cobalt/libcobalt.la
 endif
 
 latency_LDADD = \
-   ../../lib/alchemy/libalchemy.la \
-   ../../lib/copperplate/libcopperplate.la \
$(core_libs)\
 @XENO_USER_LDADD@  \
-lpthread -lrt -lm
diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c
index 12b90a9..cfa41e4 100644
--- a/testsuite/latency/latency.c
+++ b/testsuite/latency/latency.c
@@ -9,19 +9,22 @@
 #include sys/mman.h
 #include sys/time.h
 #include unistd.h
-#include copperplate/init.h
-#include alchemy/task.h
-#include alchemy/timer.h
-#include alchemy/sem.h
+#include pthread.h
+#include semaphore.h
+#include sys/timerfd.h
 #include rtdm/testing.h
+#include trace.h
 
-RT_TASK latency_task, display_task;
+pthread_t latency_task, display_task;
 
-RT_SEM display_sem;
+sem_t *display_sem;
 
 #define ONE_BILLION  10
 #define TEN_MILLION1000
 
+#define HIPRIO 99
+#define LOPRIO 0
+
 unsigned max_relaxed;
 long minjitter, maxjitter, avgjitter;
 long gminjitter = TEN_MILLION, gmaxjitter = -TEN_MILLION, goverrun = 0;
@@ -34,9 +37,10 @@ int quiet = 0;   /* suppress printing of 
RTH, RTD lines when -T given */
 int benchdev_no = 0;
 int benchdev = -1;
 int freeze_max = 0;
-int priority = T_HIPRIO;
+int priority = HIPRIO;
 int stop_upon_switch = 0;
 sig_atomic_t sampling_relaxed = 0;
+char sem_name[16];
 
 #define USER_TASK   0
 #define KERNEL_TASK 1
@@ -70,38 +74,70 @@ int bucketsize = 1000;  /* default = 1000ns, -B 
size to override */
 static inline void add_histogram(long *histogram, long addval)
 {
/* bucketsize steps */
-   long inabs =
-   rt_timer_tsc2ns(addval = 0 ? addval : -addval) / bucketsize;
+   long inabs = (addval = 0 ? addval : -addval) / bucketsize;
histogram[inabs  histogram_size ? inabs : histogram_size - 1]++;
 }
 
-static void latency(void *cookie)
+static inline long long diff_ts(struct timespec *left, struct timespec *right)
+{
+   return (long long)(left-tv_sec - right-tv_sec) * ONE_BILLION
+   + left-tv_nsec - right-tv_nsec;
+}
+
+static void *latency(void *cookie)
 {
int err, count, nsamples, warmup = 1;
-   RTIME expected_tsc, period_tsc, start_ticks, fault_threshold;
-   RT_TIMER_INFO timer_info;
+   unsigned long long fault_threshold;
+   struct itimerspec timer_conf;
+   struct timespec expected;
unsigned old_relaxed = 0;
+   char task_name[16];
+   int tfd;
+   
+   snprintf(task_name, sizeof(task_name), sampling-%d, getpid());
+   err = pthread_setname_np(pthread_self(), task_name);
+   if (err) {
+   fprintf(stderr, latency: setting name: error code %d\n, err);
+   return NULL;
+   }
+
+#ifdef CONFIG_XENO_COBALT
+   err = pthread_set_mode_np(0, PTHREAD_WARNSW, NULL);
+   if (err) {
+   fprintf(stderr, latency: setting WARNSW: error code %d\n, 
err);
+   return NULL;
+   }
+#endif
 
-   err = rt_timer_inquire(timer_info);
+   tfd = timerfd_create(CLOCK_MONOTONIC, 0);
+   if (tfd == -1) {
+   fprintf(stderr, latency: timerfd_create: %m\n);
+   return NULL;
+   }
 
+   err = clock_gettime(CLOCK_MONOTONIC, expected);
if (err) {
-   fprintf(stderr, latency: rt_timer_inquire, code %d\n, err);
-   return;
+   fprintf(stderr, latency: clock_gettime: %m\n);
+   return NULL;
}
 
-   fault_threshold = rt_timer_ns2tsc(CONFIG_XENO_DEFAULT_PERIOD);
+   fault_threshold = CONFIG_XENO_DEFAULT_PERIOD;
nsamples = ONE_BILLION / period_ns;
-   period_tsc = rt_timer_ns2tsc(period_ns);
/* start time: one millisecond from now. */
-   start_ticks = 

[Xenomai-git] Gilles Chanteperdrix : testsuite/latency: rebase on posix and timerfd

2014-02-02 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 74a5c201e994608e7fc48d6a87aaad75f7f3767e
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=74a5c201e994608e7fc48d6a87aaad75f7f3767e

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Thu Dec 26 23:45:36 2013 +0100

testsuite/latency: rebase on posix and timerfd

---

 testsuite/latency/Makefile.am |6 +-
 testsuite/latency/latency.c   |  284 +
 2 files changed, 179 insertions(+), 111 deletions(-)

diff --git a/testsuite/latency/Makefile.am b/testsuite/latency/Makefile.am
index 7acff32..55ba31b 100644
--- a/testsuite/latency/Makefile.am
+++ b/testsuite/latency/Makefile.am
@@ -1,5 +1,7 @@
 testdir = @XENO_TEST_DIR@
 
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
 test_PROGRAMS = latency
 
 latency_SOURCES = latency.c
@@ -8,7 +10,7 @@ latency_CPPFLAGS = \
$(XENO_USER_CFLAGS) \
-I$(top_srcdir)/include
 
-latency_LDFLAGS =
+latency_LDFLAGS = $(XENO_POSIX_WRAPPERS)
 
 core_libs =
 if XENO_COBALT
@@ -16,8 +18,6 @@ core_libs += ../../lib/cobalt/libcobalt.la
 endif
 
 latency_LDADD = \
-   ../../lib/alchemy/libalchemy.la \
-   ../../lib/copperplate/libcopperplate.la \
$(core_libs)\
 @XENO_USER_LDADD@  \
-lpthread -lrt -lm
diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c
index 12b90a9..cfa41e4 100644
--- a/testsuite/latency/latency.c
+++ b/testsuite/latency/latency.c
@@ -9,19 +9,22 @@
 #include sys/mman.h
 #include sys/time.h
 #include unistd.h
-#include copperplate/init.h
-#include alchemy/task.h
-#include alchemy/timer.h
-#include alchemy/sem.h
+#include pthread.h
+#include semaphore.h
+#include sys/timerfd.h
 #include rtdm/testing.h
+#include trace.h
 
-RT_TASK latency_task, display_task;
+pthread_t latency_task, display_task;
 
-RT_SEM display_sem;
+sem_t *display_sem;
 
 #define ONE_BILLION  10
 #define TEN_MILLION1000
 
+#define HIPRIO 99
+#define LOPRIO 0
+
 unsigned max_relaxed;
 long minjitter, maxjitter, avgjitter;
 long gminjitter = TEN_MILLION, gmaxjitter = -TEN_MILLION, goverrun = 0;
@@ -34,9 +37,10 @@ int quiet = 0;   /* suppress printing of 
RTH, RTD lines when -T given */
 int benchdev_no = 0;
 int benchdev = -1;
 int freeze_max = 0;
-int priority = T_HIPRIO;
+int priority = HIPRIO;
 int stop_upon_switch = 0;
 sig_atomic_t sampling_relaxed = 0;
+char sem_name[16];
 
 #define USER_TASK   0
 #define KERNEL_TASK 1
@@ -70,38 +74,70 @@ int bucketsize = 1000;  /* default = 1000ns, -B 
size to override */
 static inline void add_histogram(long *histogram, long addval)
 {
/* bucketsize steps */
-   long inabs =
-   rt_timer_tsc2ns(addval = 0 ? addval : -addval) / bucketsize;
+   long inabs = (addval = 0 ? addval : -addval) / bucketsize;
histogram[inabs  histogram_size ? inabs : histogram_size - 1]++;
 }
 
-static void latency(void *cookie)
+static inline long long diff_ts(struct timespec *left, struct timespec *right)
+{
+   return (long long)(left-tv_sec - right-tv_sec) * ONE_BILLION
+   + left-tv_nsec - right-tv_nsec;
+}
+
+static void *latency(void *cookie)
 {
int err, count, nsamples, warmup = 1;
-   RTIME expected_tsc, period_tsc, start_ticks, fault_threshold;
-   RT_TIMER_INFO timer_info;
+   unsigned long long fault_threshold;
+   struct itimerspec timer_conf;
+   struct timespec expected;
unsigned old_relaxed = 0;
+   char task_name[16];
+   int tfd;
+   
+   snprintf(task_name, sizeof(task_name), sampling-%d, getpid());
+   err = pthread_setname_np(pthread_self(), task_name);
+   if (err) {
+   fprintf(stderr, latency: setting name: error code %d\n, err);
+   return NULL;
+   }
+
+#ifdef CONFIG_XENO_COBALT
+   err = pthread_set_mode_np(0, PTHREAD_WARNSW, NULL);
+   if (err) {
+   fprintf(stderr, latency: setting WARNSW: error code %d\n, 
err);
+   return NULL;
+   }
+#endif
 
-   err = rt_timer_inquire(timer_info);
+   tfd = timerfd_create(CLOCK_MONOTONIC, 0);
+   if (tfd == -1) {
+   fprintf(stderr, latency: timerfd_create: %m\n);
+   return NULL;
+   }
 
+   err = clock_gettime(CLOCK_MONOTONIC, expected);
if (err) {
-   fprintf(stderr, latency: rt_timer_inquire, code %d\n, err);
-   return;
+   fprintf(stderr, latency: clock_gettime: %m\n);
+   return NULL;
}
 
-   fault_threshold = rt_timer_ns2tsc(CONFIG_XENO_DEFAULT_PERIOD);
+   fault_threshold = CONFIG_XENO_DEFAULT_PERIOD;
nsamples = ONE_BILLION / period_ns;
-   period_tsc = rt_timer_ns2tsc(period_ns);
/* start time: one millisecond from now. */
-   start_ticks = 

[Xenomai-git] Gilles Chanteperdrix : testsuite/latency: rebase on posix and timerfd

2014-02-02 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: e35aa2b810b20863892ef3fab95d9f976731905c
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=e35aa2b810b20863892ef3fab95d9f976731905c

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Thu Dec 26 23:45:36 2013 +0100

testsuite/latency: rebase on posix and timerfd

---

 testsuite/latency/Makefile.am |6 +-
 testsuite/latency/latency.c   |  284 +
 2 files changed, 179 insertions(+), 111 deletions(-)

diff --git a/testsuite/latency/Makefile.am b/testsuite/latency/Makefile.am
index 7acff32..55ba31b 100644
--- a/testsuite/latency/Makefile.am
+++ b/testsuite/latency/Makefile.am
@@ -1,5 +1,7 @@
 testdir = @XENO_TEST_DIR@
 
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
 test_PROGRAMS = latency
 
 latency_SOURCES = latency.c
@@ -8,7 +10,7 @@ latency_CPPFLAGS = \
$(XENO_USER_CFLAGS) \
-I$(top_srcdir)/include
 
-latency_LDFLAGS =
+latency_LDFLAGS = $(XENO_POSIX_WRAPPERS)
 
 core_libs =
 if XENO_COBALT
@@ -16,8 +18,6 @@ core_libs += ../../lib/cobalt/libcobalt.la
 endif
 
 latency_LDADD = \
-   ../../lib/alchemy/libalchemy.la \
-   ../../lib/copperplate/libcopperplate.la \
$(core_libs)\
 @XENO_USER_LDADD@  \
-lpthread -lrt -lm
diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c
index 12b90a9..cfa41e4 100644
--- a/testsuite/latency/latency.c
+++ b/testsuite/latency/latency.c
@@ -9,19 +9,22 @@
 #include sys/mman.h
 #include sys/time.h
 #include unistd.h
-#include copperplate/init.h
-#include alchemy/task.h
-#include alchemy/timer.h
-#include alchemy/sem.h
+#include pthread.h
+#include semaphore.h
+#include sys/timerfd.h
 #include rtdm/testing.h
+#include trace.h
 
-RT_TASK latency_task, display_task;
+pthread_t latency_task, display_task;
 
-RT_SEM display_sem;
+sem_t *display_sem;
 
 #define ONE_BILLION  10
 #define TEN_MILLION1000
 
+#define HIPRIO 99
+#define LOPRIO 0
+
 unsigned max_relaxed;
 long minjitter, maxjitter, avgjitter;
 long gminjitter = TEN_MILLION, gmaxjitter = -TEN_MILLION, goverrun = 0;
@@ -34,9 +37,10 @@ int quiet = 0;   /* suppress printing of 
RTH, RTD lines when -T given */
 int benchdev_no = 0;
 int benchdev = -1;
 int freeze_max = 0;
-int priority = T_HIPRIO;
+int priority = HIPRIO;
 int stop_upon_switch = 0;
 sig_atomic_t sampling_relaxed = 0;
+char sem_name[16];
 
 #define USER_TASK   0
 #define KERNEL_TASK 1
@@ -70,38 +74,70 @@ int bucketsize = 1000;  /* default = 1000ns, -B 
size to override */
 static inline void add_histogram(long *histogram, long addval)
 {
/* bucketsize steps */
-   long inabs =
-   rt_timer_tsc2ns(addval = 0 ? addval : -addval) / bucketsize;
+   long inabs = (addval = 0 ? addval : -addval) / bucketsize;
histogram[inabs  histogram_size ? inabs : histogram_size - 1]++;
 }
 
-static void latency(void *cookie)
+static inline long long diff_ts(struct timespec *left, struct timespec *right)
+{
+   return (long long)(left-tv_sec - right-tv_sec) * ONE_BILLION
+   + left-tv_nsec - right-tv_nsec;
+}
+
+static void *latency(void *cookie)
 {
int err, count, nsamples, warmup = 1;
-   RTIME expected_tsc, period_tsc, start_ticks, fault_threshold;
-   RT_TIMER_INFO timer_info;
+   unsigned long long fault_threshold;
+   struct itimerspec timer_conf;
+   struct timespec expected;
unsigned old_relaxed = 0;
+   char task_name[16];
+   int tfd;
+   
+   snprintf(task_name, sizeof(task_name), sampling-%d, getpid());
+   err = pthread_setname_np(pthread_self(), task_name);
+   if (err) {
+   fprintf(stderr, latency: setting name: error code %d\n, err);
+   return NULL;
+   }
+
+#ifdef CONFIG_XENO_COBALT
+   err = pthread_set_mode_np(0, PTHREAD_WARNSW, NULL);
+   if (err) {
+   fprintf(stderr, latency: setting WARNSW: error code %d\n, 
err);
+   return NULL;
+   }
+#endif
 
-   err = rt_timer_inquire(timer_info);
+   tfd = timerfd_create(CLOCK_MONOTONIC, 0);
+   if (tfd == -1) {
+   fprintf(stderr, latency: timerfd_create: %m\n);
+   return NULL;
+   }
 
+   err = clock_gettime(CLOCK_MONOTONIC, expected);
if (err) {
-   fprintf(stderr, latency: rt_timer_inquire, code %d\n, err);
-   return;
+   fprintf(stderr, latency: clock_gettime: %m\n);
+   return NULL;
}
 
-   fault_threshold = rt_timer_ns2tsc(CONFIG_XENO_DEFAULT_PERIOD);
+   fault_threshold = CONFIG_XENO_DEFAULT_PERIOD;
nsamples = ONE_BILLION / period_ns;
-   period_tsc = rt_timer_ns2tsc(period_ns);
/* start time: one millisecond from now. */
-   start_ticks = 

[Xenomai-git] Gilles Chanteperdrix : testsuite/latency: rebase on posix and timerfd

2014-02-01 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 4a965a47ff25dd4bd8cdba4116188f951200da4a
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=4a965a47ff25dd4bd8cdba4116188f951200da4a

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Thu Dec 26 23:45:36 2013 +0100

testsuite/latency: rebase on posix and timerfd

---

 testsuite/latency/Makefile.am |6 +-
 testsuite/latency/latency.c   |  284 +
 2 files changed, 179 insertions(+), 111 deletions(-)

diff --git a/testsuite/latency/Makefile.am b/testsuite/latency/Makefile.am
index 7acff32..55ba31b 100644
--- a/testsuite/latency/Makefile.am
+++ b/testsuite/latency/Makefile.am
@@ -1,5 +1,7 @@
 testdir = @XENO_TEST_DIR@
 
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
 test_PROGRAMS = latency
 
 latency_SOURCES = latency.c
@@ -8,7 +10,7 @@ latency_CPPFLAGS = \
$(XENO_USER_CFLAGS) \
-I$(top_srcdir)/include
 
-latency_LDFLAGS =
+latency_LDFLAGS = $(XENO_POSIX_WRAPPERS)
 
 core_libs =
 if XENO_COBALT
@@ -16,8 +18,6 @@ core_libs += ../../lib/cobalt/libcobalt.la
 endif
 
 latency_LDADD = \
-   ../../lib/alchemy/libalchemy.la \
-   ../../lib/copperplate/libcopperplate.la \
$(core_libs)\
 @XENO_USER_LDADD@  \
-lpthread -lrt -lm
diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c
index 12b90a9..cfa41e4 100644
--- a/testsuite/latency/latency.c
+++ b/testsuite/latency/latency.c
@@ -9,19 +9,22 @@
 #include sys/mman.h
 #include sys/time.h
 #include unistd.h
-#include copperplate/init.h
-#include alchemy/task.h
-#include alchemy/timer.h
-#include alchemy/sem.h
+#include pthread.h
+#include semaphore.h
+#include sys/timerfd.h
 #include rtdm/testing.h
+#include trace.h
 
-RT_TASK latency_task, display_task;
+pthread_t latency_task, display_task;
 
-RT_SEM display_sem;
+sem_t *display_sem;
 
 #define ONE_BILLION  10
 #define TEN_MILLION1000
 
+#define HIPRIO 99
+#define LOPRIO 0
+
 unsigned max_relaxed;
 long minjitter, maxjitter, avgjitter;
 long gminjitter = TEN_MILLION, gmaxjitter = -TEN_MILLION, goverrun = 0;
@@ -34,9 +37,10 @@ int quiet = 0;   /* suppress printing of 
RTH, RTD lines when -T given */
 int benchdev_no = 0;
 int benchdev = -1;
 int freeze_max = 0;
-int priority = T_HIPRIO;
+int priority = HIPRIO;
 int stop_upon_switch = 0;
 sig_atomic_t sampling_relaxed = 0;
+char sem_name[16];
 
 #define USER_TASK   0
 #define KERNEL_TASK 1
@@ -70,38 +74,70 @@ int bucketsize = 1000;  /* default = 1000ns, -B 
size to override */
 static inline void add_histogram(long *histogram, long addval)
 {
/* bucketsize steps */
-   long inabs =
-   rt_timer_tsc2ns(addval = 0 ? addval : -addval) / bucketsize;
+   long inabs = (addval = 0 ? addval : -addval) / bucketsize;
histogram[inabs  histogram_size ? inabs : histogram_size - 1]++;
 }
 
-static void latency(void *cookie)
+static inline long long diff_ts(struct timespec *left, struct timespec *right)
+{
+   return (long long)(left-tv_sec - right-tv_sec) * ONE_BILLION
+   + left-tv_nsec - right-tv_nsec;
+}
+
+static void *latency(void *cookie)
 {
int err, count, nsamples, warmup = 1;
-   RTIME expected_tsc, period_tsc, start_ticks, fault_threshold;
-   RT_TIMER_INFO timer_info;
+   unsigned long long fault_threshold;
+   struct itimerspec timer_conf;
+   struct timespec expected;
unsigned old_relaxed = 0;
+   char task_name[16];
+   int tfd;
+   
+   snprintf(task_name, sizeof(task_name), sampling-%d, getpid());
+   err = pthread_setname_np(pthread_self(), task_name);
+   if (err) {
+   fprintf(stderr, latency: setting name: error code %d\n, err);
+   return NULL;
+   }
+
+#ifdef CONFIG_XENO_COBALT
+   err = pthread_set_mode_np(0, PTHREAD_WARNSW, NULL);
+   if (err) {
+   fprintf(stderr, latency: setting WARNSW: error code %d\n, 
err);
+   return NULL;
+   }
+#endif
 
-   err = rt_timer_inquire(timer_info);
+   tfd = timerfd_create(CLOCK_MONOTONIC, 0);
+   if (tfd == -1) {
+   fprintf(stderr, latency: timerfd_create: %m\n);
+   return NULL;
+   }
 
+   err = clock_gettime(CLOCK_MONOTONIC, expected);
if (err) {
-   fprintf(stderr, latency: rt_timer_inquire, code %d\n, err);
-   return;
+   fprintf(stderr, latency: clock_gettime: %m\n);
+   return NULL;
}
 
-   fault_threshold = rt_timer_ns2tsc(CONFIG_XENO_DEFAULT_PERIOD);
+   fault_threshold = CONFIG_XENO_DEFAULT_PERIOD;
nsamples = ONE_BILLION / period_ns;
-   period_tsc = rt_timer_ns2tsc(period_ns);
/* start time: one millisecond from now. */
-   start_ticks = 

[Xenomai-git] Gilles Chanteperdrix : testsuite/latency: rebase on posix and timerfd

2014-02-01 Thread git repository hosting
Module: xenomai-gch
Branch: for-forge
Commit: 148810a3ca18fca21d86cc4de71929576e8c0235
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=148810a3ca18fca21d86cc4de71929576e8c0235

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Thu Dec 26 23:45:36 2013 +0100

testsuite/latency: rebase on posix and timerfd

---

 testsuite/latency/Makefile.am |6 +-
 testsuite/latency/latency.c   |  284 +
 2 files changed, 179 insertions(+), 111 deletions(-)

diff --git a/testsuite/latency/Makefile.am b/testsuite/latency/Makefile.am
index 7acff32..55ba31b 100644
--- a/testsuite/latency/Makefile.am
+++ b/testsuite/latency/Makefile.am
@@ -1,5 +1,7 @@
 testdir = @XENO_TEST_DIR@
 
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
 test_PROGRAMS = latency
 
 latency_SOURCES = latency.c
@@ -8,7 +10,7 @@ latency_CPPFLAGS = \
$(XENO_USER_CFLAGS) \
-I$(top_srcdir)/include
 
-latency_LDFLAGS =
+latency_LDFLAGS = $(XENO_POSIX_WRAPPERS)
 
 core_libs =
 if XENO_COBALT
@@ -16,8 +18,6 @@ core_libs += ../../lib/cobalt/libcobalt.la
 endif
 
 latency_LDADD = \
-   ../../lib/alchemy/libalchemy.la \
-   ../../lib/copperplate/libcopperplate.la \
$(core_libs)\
 @XENO_USER_LDADD@  \
-lpthread -lrt -lm
diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c
index 12b90a9..cfa41e4 100644
--- a/testsuite/latency/latency.c
+++ b/testsuite/latency/latency.c
@@ -9,19 +9,22 @@
 #include sys/mman.h
 #include sys/time.h
 #include unistd.h
-#include copperplate/init.h
-#include alchemy/task.h
-#include alchemy/timer.h
-#include alchemy/sem.h
+#include pthread.h
+#include semaphore.h
+#include sys/timerfd.h
 #include rtdm/testing.h
+#include trace.h
 
-RT_TASK latency_task, display_task;
+pthread_t latency_task, display_task;
 
-RT_SEM display_sem;
+sem_t *display_sem;
 
 #define ONE_BILLION  10
 #define TEN_MILLION1000
 
+#define HIPRIO 99
+#define LOPRIO 0
+
 unsigned max_relaxed;
 long minjitter, maxjitter, avgjitter;
 long gminjitter = TEN_MILLION, gmaxjitter = -TEN_MILLION, goverrun = 0;
@@ -34,9 +37,10 @@ int quiet = 0;   /* suppress printing of 
RTH, RTD lines when -T given */
 int benchdev_no = 0;
 int benchdev = -1;
 int freeze_max = 0;
-int priority = T_HIPRIO;
+int priority = HIPRIO;
 int stop_upon_switch = 0;
 sig_atomic_t sampling_relaxed = 0;
+char sem_name[16];
 
 #define USER_TASK   0
 #define KERNEL_TASK 1
@@ -70,38 +74,70 @@ int bucketsize = 1000;  /* default = 1000ns, -B 
size to override */
 static inline void add_histogram(long *histogram, long addval)
 {
/* bucketsize steps */
-   long inabs =
-   rt_timer_tsc2ns(addval = 0 ? addval : -addval) / bucketsize;
+   long inabs = (addval = 0 ? addval : -addval) / bucketsize;
histogram[inabs  histogram_size ? inabs : histogram_size - 1]++;
 }
 
-static void latency(void *cookie)
+static inline long long diff_ts(struct timespec *left, struct timespec *right)
+{
+   return (long long)(left-tv_sec - right-tv_sec) * ONE_BILLION
+   + left-tv_nsec - right-tv_nsec;
+}
+
+static void *latency(void *cookie)
 {
int err, count, nsamples, warmup = 1;
-   RTIME expected_tsc, period_tsc, start_ticks, fault_threshold;
-   RT_TIMER_INFO timer_info;
+   unsigned long long fault_threshold;
+   struct itimerspec timer_conf;
+   struct timespec expected;
unsigned old_relaxed = 0;
+   char task_name[16];
+   int tfd;
+   
+   snprintf(task_name, sizeof(task_name), sampling-%d, getpid());
+   err = pthread_setname_np(pthread_self(), task_name);
+   if (err) {
+   fprintf(stderr, latency: setting name: error code %d\n, err);
+   return NULL;
+   }
+
+#ifdef CONFIG_XENO_COBALT
+   err = pthread_set_mode_np(0, PTHREAD_WARNSW, NULL);
+   if (err) {
+   fprintf(stderr, latency: setting WARNSW: error code %d\n, 
err);
+   return NULL;
+   }
+#endif
 
-   err = rt_timer_inquire(timer_info);
+   tfd = timerfd_create(CLOCK_MONOTONIC, 0);
+   if (tfd == -1) {
+   fprintf(stderr, latency: timerfd_create: %m\n);
+   return NULL;
+   }
 
+   err = clock_gettime(CLOCK_MONOTONIC, expected);
if (err) {
-   fprintf(stderr, latency: rt_timer_inquire, code %d\n, err);
-   return;
+   fprintf(stderr, latency: clock_gettime: %m\n);
+   return NULL;
}
 
-   fault_threshold = rt_timer_ns2tsc(CONFIG_XENO_DEFAULT_PERIOD);
+   fault_threshold = CONFIG_XENO_DEFAULT_PERIOD;
nsamples = ONE_BILLION / period_ns;
-   period_tsc = rt_timer_ns2tsc(period_ns);
/* start time: one millisecond from now. */
-   start_ticks =