All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Xenomai 2.5.3 vs gettimeofday() --> livelock?
@ 2011-07-06 20:38 Jeremy Friesner
  2011-07-07  4:54 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 4+ messages in thread
From: Jeremy Friesner @ 2011-07-06 20:38 UTC (permalink / raw)
  To: xenomai

Hi all,

I'm developing a product that consists of a small number of x86 Linux boxes connected over a LAN.  These boxes run Debian Linux with Xenomai 2.5.3 installed.  In order to co-ordinate their activities, they all run ptpd (as a Linux userspace daemon) to synchronize their clocks, as returned by gettimeofday().

The issue we're having is that occasionally (maybe once or twice a week, or even less), at a seemingly random time, one of these boxes (not always the same one) will simply quit working... it stops responding to pings, stops sending or receiving network traffic, etc.   We suspect (but haven't yet proved) that this is due to the box's Xenomai real-time thread spinning in-place somewhere, causing the Linux kernel to quit running.

Our Xenomai real-time thread doesn't do much (mainly ot just copies a fixed amount of data from one location to another), but it does occasionally call gettimeofday(), in order to record the current correlation between the PTP-based Linux clock and the Xenomai rt_timer_tsc() clock, so that it can account for drift between them.

From reading this post, it seems like the call to gettimeofday() might be the culprit:

	http://www.mail-archive.com/xenomai@xenomai.org

My first question is:  Am I right in suspecting that gettimeofday() can occasionally spin/livelock, when called from a Xenomai 2.5.3 real-time thread?  FWIW, it gets called from the real-time thread once every 333mS.

And if that is the case, my second question is:  Is there an alternative "safe" way to call gettimeofday() (or something equivalent) so that the real-time thread can find out the current PTP system time?  Or do I need to re-write my code so that the real-time thread never calls gettimeofday()?

Is there a recommended practice for using Xenomai threads in conjunction with PTP?

Thanks,
Jeremy



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Xenomai 2.5.3 vs gettimeofday() --> livelock?
  2011-07-06 20:38 [Xenomai-help] Xenomai 2.5.3 vs gettimeofday() --> livelock? Jeremy Friesner
@ 2011-07-07  4:54 ` Gilles Chanteperdrix
  2011-07-07  8:01   ` Uwe Fechner
  0 siblings, 1 reply; 4+ messages in thread
From: Gilles Chanteperdrix @ 2011-07-07  4:54 UTC (permalink / raw)
  To: Jeremy Friesner; +Cc: xenomai

On 07/06/2011 10:38 PM, Jeremy Friesner wrote:
> My first question is:  Am I right in suspecting that gettimeofday()
> can occasionally spin/livelock, when called from a Xenomai 2.5.3
> real-time thread?  FWIW, it gets called from the real-time thread
> once every 333mS.

Yes, this is a known issue.

> 
> And if that is the case, my second question is:  Is there an
> alternative "safe" way to call gettimeofday() (or something
> equivalent) so that the real-time thread can find out the current PTP
> system time?  Or do I need to re-write my code so that the real-time
> thread never calls gettimeofday()?
> 
> Is there a recommended practice for using Xenomai threads in
> conjunction with PTP?

There are several ways out:
- the rtdk library provides a version of gettimeofday which switches to
secondary mode before calling the real gettimeofday. In order to use it,
you have to link your application with:
-Wl,--wrap,gettimeofday -lrtdk
- you can forcibly emit the syscall like the clocktest application does.

-- 
                                                                Gilles.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Xenomai 2.5.3 vs gettimeofday() --> livelock?
  2011-07-07  4:54 ` Gilles Chanteperdrix
@ 2011-07-07  8:01   ` Uwe Fechner
  2011-07-11 11:14     ` Gilles Chanteperdrix
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Fechner @ 2011-07-07  8:01 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Jeremy Friesner, xenomai

 Hi,

where can I find the documentation of the rtdk library?
I googled it, but only found people talking about it, but no api
documentation.

Regards:

Uwe Fechner

On 07.07.2011 06:54, Gilles Chanteperdrix wrote:
> rtdk library




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Xenomai 2.5.3 vs gettimeofday() --> livelock?
  2011-07-07  8:01   ` Uwe Fechner
@ 2011-07-11 11:14     ` Gilles Chanteperdrix
  0 siblings, 0 replies; 4+ messages in thread
From: Gilles Chanteperdrix @ 2011-07-11 11:14 UTC (permalink / raw)
  To: Uwe Fechner; +Cc: Jeremy Friesner, xenomai

On 07/07/2011 10:01 AM, Uwe Fechner wrote:
>  Hi,
> 
> where can I find the documentation of the rtdk library?
> I googled it, but only found people talking about it, but no api
> documentation.

I do not think it has a documentation, but the code is relatively short.
The essential part of the API is rt_printf which essentially works as a
drop-in replacement for printf, except that you need some
initializations (rt_print_auto_init, or rt_print_init for each thread
which wants to log).

-- 
                                                                Gilles.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-07-11 11:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-06 20:38 [Xenomai-help] Xenomai 2.5.3 vs gettimeofday() --> livelock? Jeremy Friesner
2011-07-07  4:54 ` Gilles Chanteperdrix
2011-07-07  8:01   ` Uwe Fechner
2011-07-11 11:14     ` Gilles Chanteperdrix

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.