[Xenomai-git] Philippe Gerum : lib/cobalt: export service for reading the high resolution clock

2015-06-29 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: d584a57d8bd859269f63490e7e0f51877a44f399
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d584a57d8bd859269f63490e7e0f51877a44f399

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Jun 16 11:52:49 2015 +0200

lib/cobalt: export service for reading the high resolution clock

cobalt_read_hrclock() returns the current TSC value as defined by the
platform. This is a Cobalt-specific service, which is aimed at
measuring elapsed time accurately, with low overhead. The output is
the current raw count of ticks, as reported by the hrclock device used
by Cobalt for timing.

Such value is NOT converted to nanoseconds before return.
cobalt_ticks_to_ns() and cobalt_ticks_to_ns_rounded() are available
for converting raw tick counts to nanoseconds.

Application code should stick with clock_gettime(CLOCK_MONOTONIC, ...)
for portability.

This clock source is guaranteed continuous, monotonically increasing.

---

 include/cobalt/sys/cobalt.h |1 +
 include/cobalt/ticks.h  |2 ++
 lib/cobalt/ticks.c  |6 ++
 3 files changed, 9 insertions(+)

diff --git a/include/cobalt/sys/cobalt.h b/include/cobalt/sys/cobalt.h
index fd43086..9f9d03a 100644
--- a/include/cobalt/sys/cobalt.h
+++ b/include/cobalt/sys/cobalt.h
@@ -37,6 +37,7 @@
 #include cobalt/uapi/thread.h
 #include cobalt/uapi/cond.h
 #include cobalt/uapi/sem.h
+#include cobalt/ticks.h
 
 #define cobalt_commit_memory(p) __cobalt_commit_memory(p, sizeof(*p))
 
diff --git a/include/cobalt/ticks.h b/include/cobalt/ticks.h
index 2d0132d..d9abd39 100644
--- a/include/cobalt/ticks.h
+++ b/include/cobalt/ticks.h
@@ -24,6 +24,8 @@
 extern C {
 #endif
 
+xnticks_t cobalt_read_hrclock(void);
+
 xnsticks_t cobalt_ticks_to_ns(xnsticks_t ticks);
 
 xnsticks_t cobalt_ticks_to_ns_rounded(xnsticks_t ticks);
diff --git a/lib/cobalt/ticks.c b/lib/cobalt/ticks.c
index 43f3e3a..0e5682d 100644
--- a/lib/cobalt/ticks.c
+++ b/lib/cobalt/ticks.c
@@ -17,6 +17,7 @@
  */
 #include cobalt/arith.h
 #include cobalt/ticks.h
+#include asm/xenomai/tsc.h
 #include internal.h
 
 static unsigned long long clockfreq;
@@ -98,6 +99,11 @@ unsigned long long cobalt_divrem_billion(unsigned long long 
value,
 }
 #endif /* !XNARCH_HAVE_NODIV_LLIMD */
 
+xnticks_t cobalt_read_hrclock(void)
+{
+   return cobalt_read_tsc();
+}
+
 void cobalt_ticks_init(unsigned long long freq)
 {
clockfreq = freq;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/cobalt: export service for reading the high resolution clock

2015-06-16 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d584a57d8bd859269f63490e7e0f51877a44f399
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d584a57d8bd859269f63490e7e0f51877a44f399

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Jun 16 11:52:49 2015 +0200

lib/cobalt: export service for reading the high resolution clock

cobalt_read_hrclock() returns the current TSC value as defined by the
platform. This is a Cobalt-specific service, which is aimed at
measuring elapsed time accurately, with low overhead. The output is
the current raw count of ticks, as reported by the hrclock device used
by Cobalt for timing.

Such value is NOT converted to nanoseconds before return.
cobalt_ticks_to_ns() and cobalt_ticks_to_ns_rounded() are available
for converting raw tick counts to nanoseconds.

Application code should stick with clock_gettime(CLOCK_MONOTONIC, ...)
for portability.

This clock source is guaranteed continuous, monotonically increasing.

---

 include/cobalt/sys/cobalt.h |1 +
 include/cobalt/ticks.h  |2 ++
 lib/cobalt/ticks.c  |6 ++
 3 files changed, 9 insertions(+)

diff --git a/include/cobalt/sys/cobalt.h b/include/cobalt/sys/cobalt.h
index fd43086..9f9d03a 100644
--- a/include/cobalt/sys/cobalt.h
+++ b/include/cobalt/sys/cobalt.h
@@ -37,6 +37,7 @@
 #include cobalt/uapi/thread.h
 #include cobalt/uapi/cond.h
 #include cobalt/uapi/sem.h
+#include cobalt/ticks.h
 
 #define cobalt_commit_memory(p) __cobalt_commit_memory(p, sizeof(*p))
 
diff --git a/include/cobalt/ticks.h b/include/cobalt/ticks.h
index 2d0132d..d9abd39 100644
--- a/include/cobalt/ticks.h
+++ b/include/cobalt/ticks.h
@@ -24,6 +24,8 @@
 extern C {
 #endif
 
+xnticks_t cobalt_read_hrclock(void);
+
 xnsticks_t cobalt_ticks_to_ns(xnsticks_t ticks);
 
 xnsticks_t cobalt_ticks_to_ns_rounded(xnsticks_t ticks);
diff --git a/lib/cobalt/ticks.c b/lib/cobalt/ticks.c
index 43f3e3a..0e5682d 100644
--- a/lib/cobalt/ticks.c
+++ b/lib/cobalt/ticks.c
@@ -17,6 +17,7 @@
  */
 #include cobalt/arith.h
 #include cobalt/ticks.h
+#include asm/xenomai/tsc.h
 #include internal.h
 
 static unsigned long long clockfreq;
@@ -98,6 +99,11 @@ unsigned long long cobalt_divrem_billion(unsigned long long 
value,
 }
 #endif /* !XNARCH_HAVE_NODIV_LLIMD */
 
+xnticks_t cobalt_read_hrclock(void)
+{
+   return cobalt_read_tsc();
+}
+
 void cobalt_ticks_init(unsigned long long freq)
 {
clockfreq = freq;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git