Problem with rt_sleep() in kernel space

Marco Pantaleoni <[email protected]> Fri, 7 Oct 2016 14:57:44 +0200
Newsgroups gmane.linux.real-time.rtai
Message-ID <CAJhcQDi_YwET3mCNavT-AhZ5vp_-WUKyhjSb7Vb0f=hOh3FYEA@mail.gmail.com>
Dear RTAI'ers,

I'm porting a large codebase from RTAI-in-userspace to kernel space.
What I'm observing is that after an initial setup phase in which everything
seems to work correctly, from a certain point in time onward, rt_sleep()
called inside a thread seems to ignore the passed parameter: in fact,
looking at console times of a printk done both before and after the sleep,
the time spent inside rt_sleep() seems to be in every case around ~7ms,
while I've passed 100us, 100ms and even larger values. To be more precise,
I've called rt_sleep() in this way:

  rt_sleep(nano2count(100000)); /* 100us */

and

  rt_sleep(nano2count(100000000LL)); /* 100ms */

among other values.
It is called inside a cycle and the speed of the cycle remains the same,
confirming that the parameter seems to be ignored in these cases.

What I'm observing is that (a) before this point other threads (and this
one too) call rt_sleep() many times (and it seems to work correctly), (b)
just before the problem manifests itself the kernel emits the message:

[   66.634015] Clocksource tsc unstable (delta = 121203613 ns)

I suspect this could be in some way related to the problem. Maybe the
kernel performs some recalibrations of the timers / TSC / something and
this breaks RTAI timing?

I've tried both one shot and periodic timer modes.
I'm using RTAI 3.8 with kernel 2.6.32.2 on an 800MHz Vortex86DX, everything
compiled with gcc 4.4.1.

I'll appreciate any help or suggestion. Thanks in advance!

Cheers,
Marco

-- 
Marco Pantaleoni

_______________________________________________
Rtai mailing list
[email protected]
https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai