Skip to contentSkip to conversation

native rt_timer questions

Xenomai-core Fillod Stephane 2 participants 3 messages Sep 3, 2008 – Sep 21, 2008

lore
Share & tools
lore
#0 lore raw

Hi!

Why rt_timer functions, esp. rt_timer_tsc(), are not inlined in user-space
(with CONFIG_XENO_HW_DIRECT_TSC) ? Is it because some policy insists that every library function must have an overridable symbol? Even a branch is worrisome when doing repetitive micro-measurements. What about a patch along the following? or an extern inline?

native/timer.h 3 Sep 2008 09:10:31 -0000 renamed from native/timer.h 15 May 2008 07:40:30 -0000 +0 -1
@@ -46,7 +52,7 @@
 extern "C" {
 #endif
-#if (defined(__KERNEL__)  || defined(__XENO_SIM__)) &&

!defined(DOXYGEN_CPP)
+#if (defined(__KERNEL__) || defined(__XENO_SIM__) || defined(__NATIVE_INLINE)) && !defined(DOXYGEN_CPP)
static inline SRTIME rt_timer_ns2tsc(SRTIME ns)

 {
        return xnarch_ns_to_tsc(ns);

BTW, I had the bad surprise of rt_timer_read() doing a syscall, which is costly when doing fine measurement. Should it be documented?

The native rt_timer functions are documented in two locations:
http://www.xenomai.org/documentation/branches/v2.4.x/html/api/include_2n
ative_2timer_8h.html
http://www.xenomai.org/documentation/branches/v2.4.x/html/api/group__nat
ive__timer.html

Could they be gathered, maybe with the here below patch (untested, no doxy expert):

native/timer.h 3 Sep 2008 09:10:31 -0000 renamed from native/timer.h 15 May 2008 07:40:30 -0000 +0 -0
@@ -17,6 +17,8 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA

02111-1307, USA.
+ *
+ * \ingroup native_timer
*/

#ifndef _XENO_TIMER_H
@@ -26,6 +28,10 @@

#define TM_ONESHOT XN_APERIODIC_TICK

+/** Structure containing timer-information useful to users.
+ *
+ * @see rt_timer_inquire()
+ */
typedef struct rt_timer_info {

RTIME period; /* !< Current status (unset, aperiodic, period).
*/

Signature · 1 line
Stephane
#1 lore raw
Quoted 20 lines · Fillod Stephane

Hi!

Why rt_timer functions, esp. rt_timer_tsc(), are not inlined in user-space
(with CONFIG_XENO_HW_DIRECT_TSC) ? Is it because some policy insists that every library function must have an overridable symbol? Even a branch is worrisome when doing repetitive micro-measurements. What about a patch along the following? or an extern inline?

native/timer.h 3 Sep 2008 09:10:31 -0000 renamed from native/timer.h 15 May 2008 07:40:30 -0000 +1 -1
@@ -46,7 +52,7 @@
 extern "C" {
 #endif
-#if (defined(__KERNEL__)  || defined(__XENO_SIM__)) &&
 !defined(DOXYGEN_CPP)
+#if (defined(__KERNEL__)  || defined(__XENO_SIM__) ||
 defined(__NATIVE_INLINE)) && !defined(DOXYGEN_CPP)
 static inline SRTIME rt_timer_ns2tsc(SRTIME ns)
 {
Quoted 1 line
        return xnarch_ns_to_tsc(ns);

I am afraid we do not want this on every architecture. On ARM where the tsc is an emulation and contains a fair number of instructions using a fair number of registers (still faster than a syscall, of course), I think we do want an out of line function.

Quoted 3 lines

BTW, I had the bad surprise of rt_timer_read() doing a syscall, which is costly when doing fine measurement. Should it be documented?

I suggested once to use the tsc as well for the implementation of clock_gettime(CLOCK_REALTIME) (the posix equivalent of rt_timer_read()), but was told at the time that we may want, one day, to provide syscalls to compensate for clock drifts, so reading the system clock should remain a syscall.

Signature · 1 line
                                                 Gilles.
#2 lore raw
In reply to Fillod Stephane
Quoted 8 lines · Fillod Stephane

The native rt_timer functions are documented in two locations:
http://www.xenomai.org/documentation/branches/v2.4.x/html/api/include_2n
ative_2timer_8h.html
http://www.xenomai.org/documentation/branches/v2.4.x/html/api/group__nat
ive__timer.html

Could they be gathered, maybe with the here below patch (untested, no doxy expert):

Fixed, thanks ! But your MUA mangles patches (by adding newlines), so, you should rather send them as attachments.

Signature · 1 line
					    Gilles.