[Xenomai-git] Gilles Chanteperdrix : Add timers benchmarks

2016-03-23 Thread git repository hosting
Module: xenomai-gch
Branch: timers-bench
Commit: f1b038b6d5a28d46223252661e558c288462a9e2
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=f1b038b6d5a28d46223252661e558c288462a9e2

Author: Gilles Chanteperdrix 
Date:   Mon Jan 11 08:22:34 2016 +0100

Add timers benchmarks

---

 include/cobalt/kernel/avl.h  |  317 +
 include/cobalt/kernel/stat_accumulator.h |   45 +++
 include/cobalt/kernel/timer.h|  225 +--
 kernel/cobalt/Kconfig|   12 +
 kernel/cobalt/Makefile   |2 +
 kernel/cobalt/avl.c  |  443 ++
 kernel/cobalt/clock.c|2 +-
 kernel/cobalt/posix/process.c|3 +
 kernel/cobalt/posix/timer.c  |1 +
 kernel/cobalt/stat_accumulator.c |  197 +
 kernel/cobalt/timer.c|   87 +-
 testsuite/xeno-test/dohell   |4 +-
 testsuite/xeno-test/xeno-test.in |   16 +-
 13 files changed, 1325 insertions(+), 29 deletions(-)

diff --git a/include/cobalt/kernel/avl.h b/include/cobalt/kernel/avl.h
new file mode 100644
index 000..8d22329
--- /dev/null
+++ b/include/cobalt/kernel/avl.h
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 2015 Gilles Chanteperdrix
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef CH_AVL_H
+#define CH_AVL_H
+
+#define AVL_DUMP 0
+
+typedef struct avlh {
+unsigned thr: 3;
+int type: 2;
+int balance :2;
+unsigned flags :25;/* Application-specific */
+struct avlh *link[3];
+} avlh_t;
+
+/* Using -1 and 1 for left and right is slightly faster than 0 and 1, using 0
+   for "up" is just here for orthogonality... and avoid wasting 4 bytes or
+   having to use a union in avlh_t. */
+#define AVL_LEFT -1
+#define AVL_UP0
+#define AVL_RIGHT 1
+/* maps AVL_LEFT to AVL_RIGHT and reciprocally. */
+#define avl_opposite(type)   (-(type))
+/* maps AVL_LEFT to -1 and AVL_RIGHT to 1. */
+#define avl_type2sign(type)  (type)
+/* maps AVL_LEFT and AVL_RIGHT to arrays index (or bit positions). */
+#define avl_type2index(type) ((type)+1)
+/* maps <0 to AVL_LEFT and >0 to AVL_RIGHT. */
+#define avl_sign2type(sign)  (sign)
+
+#define AVL_THR_LEFT  (1type))
+
+struct avl;
+typedef struct avl avl_t;
+
+typedef avlh_t *avl_search_t(const avl_t *, const avlh_t *, int *);
+
+typedef int avlh_cmp_t(const avlh_t *const, const avlh_t *const);
+
+struct avl {
+avlh_t anchor;
+avl_search_t *search;
+avlh_cmp_t *cmp;
+avlh_t *end[3];
+unsigned count;
+unsigned height;
+};
+
+#define avl_searchfn(avl) ((avl)->search)
+#define avl_cmp(avl)  ((avl)->cmp)
+#define avl_count(avl)((avl)->count)
+#define avl_height(avl)   ((avl)->height)
+#define avl_anchor(avl)   (&(avl)->anchor)
+#define avl_end(avl, dir) ((avl)->end[avl_type2index(dir)])
+#define avl_top(avl)  (avlh_right(avl_anchor(avl)))
+#define avl_head(avl) (avl_end((avl), AVL_LEFT))
+#define avl_tail(avl) (avl_end((avl), AVL_RIGHT))
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void avl_init(avl_t *avl, avl_search_t *search, avlh_cmp_t *cmp);
+
+void avl_destroy(avl_t *avl);
+
+void avl_clear(avl_t *avl, void (*destruct)(avlh_t *));
+
+int avl_insert(avl_t *avl, avlh_t *holder);
+
+int avl_prepend(avl_t *avl, avlh_t *holder);
+
+int avl_append(avl_t *avl, avlh_t *holder);
+
+avlh_t *avl_update(avl_t *avl, avlh_t *holder);
+
+avlh_t *avl_set(avl_t *avl, avlh_t *holder);
+
+int avl_delete(avl_t *avl, avlh_t *node);
+
+#

[Xenomai-git] Gilles Chanteperdrix : Add timers benchmarks

2016-03-14 Thread git repository hosting
Module: xenomai-gch
Branch: timers-bench
Commit: 56b3390e7e7eb9c15ee096cdf65e594c520bcf07
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=56b3390e7e7eb9c15ee096cdf65e594c520bcf07

Author: Gilles Chanteperdrix 
Date:   Mon Jan 11 08:22:34 2016 +0100

Add timers benchmarks

---

 include/cobalt/kernel/avl.h  |  317 +
 include/cobalt/kernel/stat_accumulator.h |   45 +++
 include/cobalt/kernel/timer.h|  225 +--
 kernel/cobalt/Kconfig|   12 +
 kernel/cobalt/Makefile   |2 +
 kernel/cobalt/avl.c  |  443 ++
 kernel/cobalt/clock.c|2 +-
 kernel/cobalt/posix/process.c|3 +
 kernel/cobalt/posix/timer.c  |1 +
 kernel/cobalt/stat_accumulator.c |  197 +
 kernel/cobalt/timer.c|   87 +-
 testsuite/xeno-test/dohell   |2 +-
 testsuite/xeno-test/xeno-test.in |   16 +-
 13 files changed, 1324 insertions(+), 28 deletions(-)

diff --git a/include/cobalt/kernel/avl.h b/include/cobalt/kernel/avl.h
new file mode 100644
index 000..8d22329
--- /dev/null
+++ b/include/cobalt/kernel/avl.h
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 2015 Gilles Chanteperdrix
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef CH_AVL_H
+#define CH_AVL_H
+
+#define AVL_DUMP 0
+
+typedef struct avlh {
+unsigned thr: 3;
+int type: 2;
+int balance :2;
+unsigned flags :25;/* Application-specific */
+struct avlh *link[3];
+} avlh_t;
+
+/* Using -1 and 1 for left and right is slightly faster than 0 and 1, using 0
+   for "up" is just here for orthogonality... and avoid wasting 4 bytes or
+   having to use a union in avlh_t. */
+#define AVL_LEFT -1
+#define AVL_UP0
+#define AVL_RIGHT 1
+/* maps AVL_LEFT to AVL_RIGHT and reciprocally. */
+#define avl_opposite(type)   (-(type))
+/* maps AVL_LEFT to -1 and AVL_RIGHT to 1. */
+#define avl_type2sign(type)  (type)
+/* maps AVL_LEFT and AVL_RIGHT to arrays index (or bit positions). */
+#define avl_type2index(type) ((type)+1)
+/* maps <0 to AVL_LEFT and >0 to AVL_RIGHT. */
+#define avl_sign2type(sign)  (sign)
+
+#define AVL_THR_LEFT  (1type))
+
+struct avl;
+typedef struct avl avl_t;
+
+typedef avlh_t *avl_search_t(const avl_t *, const avlh_t *, int *);
+
+typedef int avlh_cmp_t(const avlh_t *const, const avlh_t *const);
+
+struct avl {
+avlh_t anchor;
+avl_search_t *search;
+avlh_cmp_t *cmp;
+avlh_t *end[3];
+unsigned count;
+unsigned height;
+};
+
+#define avl_searchfn(avl) ((avl)->search)
+#define avl_cmp(avl)  ((avl)->cmp)
+#define avl_count(avl)((avl)->count)
+#define avl_height(avl)   ((avl)->height)
+#define avl_anchor(avl)   (&(avl)->anchor)
+#define avl_end(avl, dir) ((avl)->end[avl_type2index(dir)])
+#define avl_top(avl)  (avlh_right(avl_anchor(avl)))
+#define avl_head(avl) (avl_end((avl), AVL_LEFT))
+#define avl_tail(avl) (avl_end((avl), AVL_RIGHT))
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void avl_init(avl_t *avl, avl_search_t *search, avlh_cmp_t *cmp);
+
+void avl_destroy(avl_t *avl);
+
+void avl_clear(avl_t *avl, void (*destruct)(avlh_t *));
+
+int avl_insert(avl_t *avl, avlh_t *holder);
+
+int avl_prepend(avl_t *avl, avlh_t *holder);
+
+int avl_append(avl_t *avl, avlh_t *holder);
+
+avlh_t *avl_update(avl_t *avl, avlh_t *holder);
+
+avlh_t *avl_set(avl_t *avl, avlh_t *holder);
+
+int avl_delete(avl_t *avl, avlh_t *node);
+
+#