I have heard that system calls are never realtime safe in Linux, even
under a RT-PREEMPT kernel. Unless everyone I've asked is mistaken
(I've asked on StackOverflow and at LinuxQuestions.org, neither of
which focus on realtime software), not even system calls like
clock_gettime() are realtime-safe.
How does Orocos accomplish hard-realtime on Linux without using system
calls? Knowing might help keep me from unintentionally breaking
realtime within our Orocos-based components.
Thank You,
Johnathan Van Why
Dynamic Robotics Laboratory
Oregon State University
How does Orocos do real-time OS access?
Hi Jonathan,
On Wed, Aug 01, 2012 at 03:39:26PM -0700, Johnathan Van Why wrote:
> I have heard that system calls are never realtime safe in Linux, even
> under a RT-PREEMPT kernel. Unless everyone I've asked is mistaken
> (I've asked on StackOverflow and at LinuxQuestions.org, neither of
> which focus on realtime software), not even system calls like
> clock_gettime() are realtime-safe.
No, both correctly configured and validated RT_PREEMPT or Xenomai
kernels can run applications satisfying hard real-time constraints.
In a nutshell, the advantage of using RT_PREEMPT is that run're
running a single, less intrusively patched kernel. On the other hand
the real-time'ness of a Xenomai system (as a dual-kernel approach)
depends on a much smaller codebase, and (opposed to RT_PREEMPT) can
not be (so) easily screwed up due to buggy kernel drivers etc. Most
people start with RT_PREEMPT and then switch to Xenomai if necessary.
> How does Orocos accomplish hard-realtime on Linux without using system
> calls? Knowing might help keep me from unintentionally breaking
> realtime within our Orocos-based components.
OROCOS RTT is implemented using different techniques to avoid
non-deterministic behavior, including avoiding memory allocations in
critical paths, lock free buffers, real-time allocators, etc.
System calls may or may not be permitted in rt-paths,
i.e. clock_gettime(2) is, but malloc(2) is not.
Markus
How does Orocos do real-time OS access?
On Thu, Aug 2, 2012 at 8:54 AM, Markus Klotzbuecher <
markus [dot] klotzbuecher [..] ...> wrote:
> Hi Jonathan,
>
> On Wed, Aug 01, 2012 at 03:39:26PM -0700, Johnathan Van Why wrote:
> > I have heard that system calls are never realtime safe in Linux, even
> > under a RT-PREEMPT kernel. Unless everyone I've asked is mistaken
> > (I've asked on StackOverflow and at LinuxQuestions.org, neither of
> > which focus on realtime software), not even system calls like
> > clock_gettime() are realtime-safe.
>
> No, both correctly configured and validated RT_PREEMPT or Xenomai
> kernels can run applications satisfying hard real-time constraints.
>
> In a nutshell, the advantage of using RT_PREEMPT is that run're
> running a single, less intrusively patched kernel. On the other hand
> the real-time'ness of a Xenomai system (as a dual-kernel approach)
> depends on a much smaller codebase, and (opposed to RT_PREEMPT) can
> not be (so) easily screwed up due to buggy kernel drivers etc. Most
> people start with RT_PREEMPT and then switch to Xenomai if necessary.
>
> > How does Orocos accomplish hard-realtime on Linux without using system
> > calls? Knowing might help keep me from unintentionally breaking
> > realtime within our Orocos-based components.
>
> OROCOS RTT is implemented using different techniques to avoid
> non-deterministic behavior, including avoiding memory allocations in
> critical paths, lock free buffers, real-time allocators, etc.
>
> System calls may or may not be permitted in rt-paths,
> i.e. clock_gettime(2) is, but malloc(2) is not.
>
I don't know about RT_PREEMPT, but as far as I understand, calling
clock_gettime is _not_ realtime-safe in Xenomai, even when selecting the
CLOCK_REALTIME clock. See this previous thread for more details [1]. Of
worth noting, prior to Xenomai 2.6, there was no clean way to query a
timestamp in the same timebase as clock_gettime(CLOCK_REALTIME, &tv) from a
realtime context.
[1]
http://www.orocos.org/forum/orocos/orocos-users/comparing-timestamps-gen...
Adolfo.
> Markus
>
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
How does Orocos do real-time OS access?
>> On Wed, Aug 01, 2012 at 03:39:26PM -0700, Johnathan Van Why wrote:
>> > I have heard that system calls are never realtime safe in Linux, even
>> > under a RT-PREEMPT kernel. Unless everyone I've asked is mistaken
>> > (I've asked on StackOverflow and at LinuxQuestions.org, neither of
>> > which focus on realtime software), not even system calls like
>> > clock_gettime() are realtime-safe.
>>
>> No, both correctly configured and validated RT_PREEMPT or Xenomai
>> kernels can run applications satisfying hard real-time constraints.
That's good news -- I was wondering how RT_PREEMPT could promise hard
realtime performance if you had no realtime IO options.
>> System calls may or may not be permitted in rt-paths,
>> i.e. clock_gettime(2) is, but malloc(2) is not.
How can I tell? Is there some sort of list, or is it something people
Just Know (i.e. do I need to look through the kernel's source to check
for determinism)?
Thank You,
Johnathan Van Why
How does Orocos do real-time OS access?
Hi Jonathan,
On Thu, Aug 02, 2012 at 09:20:21AM -0700, Johnathan Van Why wrote:
> >> On Wed, Aug 01, 2012 at 03:39:26PM -0700, Johnathan Van Why wrote:
> >> > I have heard that system calls are never realtime safe in Linux, even
> >> > under a RT-PREEMPT kernel. Unless everyone I've asked is mistaken
> >> > (I've asked on StackOverflow and at LinuxQuestions.org, neither of
> >> > which focus on realtime software), not even system calls like
> >> > clock_gettime() are realtime-safe.
> >>
> >> No, both correctly configured and validated RT_PREEMPT or Xenomai
> >> kernels can run applications satisfying hard real-time constraints.
>
> That's good news -- I was wondering how RT_PREEMPT could promise hard
> realtime performance if you had no realtime IO options.
>
> >> System calls may or may not be permitted in rt-paths,
> >> i.e. clock_gettime(2) is, but malloc(2) is not.
>
> How can I tell? Is there some sort of list, or is it something people
> Just Know (i.e. do I need to look through the kernel's source to check
> for determinism)?
If it really matters, studying the code wouldn't be a bad idea... But
you can also ask on a real-time linux mailing list:
https://rt.wiki.kernel.org/index.php/Mailinglists
or the Xenomai ML. Generally system calls for which you have to link
with -lrt are safe, but YMMV. An other "test" is to see if it results
in Xenomai secondary mode switches.
HTH
Markus
How does Orocos do real-time OS access?
On Thu, 2 Aug 2012, Johnathan Van Why wrote:
>>> On Wed, Aug 01, 2012 at 03:39:26PM -0700, Johnathan Van Why wrote:
>>>> I have heard that system calls are never realtime safe in Linux, even
>>>> under a RT-PREEMPT kernel. Unless everyone I've asked is mistaken
>>>> (I've asked on StackOverflow and at LinuxQuestions.org, neither of
>>>> which focus on realtime software), not even system calls like
>>>> clock_gettime() are realtime-safe.
>>>
>>> No, both correctly configured and validated RT_PREEMPT or Xenomai
>>> kernels can run applications satisfying hard real-time constraints.
>
> That's good news -- I was wondering how RT_PREEMPT could promise hard
> realtime performance if you had no realtime IO options.
The difference between RT_PREEMPT and a _real_ RTOS (like Xenomai) begins
to show more and more when you start using your hardware close to its
saturation.
We have used vanilla Linux for hard realtime determinism too: for example,
when you have to do only one task, have a full point-to-point Ethernet
connection at your disposal, and configure out all kernel and application
stuff that your application does not need.
>>> System calls may or may not be permitted in rt-paths,
>>> i.e. clock_gettime(2) is, but malloc(2) is not.
>
> How can I tell? Is there some sort of list, or is it something people
> Just Know (i.e. do I need to look through the kernel's source to check
> for determinism)?
>
> Thank You,
> Johnathan Van Why
Herman
How does Orocos do real-time OS access?
On Thu, Aug 02, 2012 at 09:38:41AM +0200, Adolfo Rodríguez Tsouroukdissian wrote:
>
>
> On Thu, Aug 2, 2012 at 8:54 AM, Markus Klotzbuecher <
> markus [dot] klotzbuecher [..] ...> wrote:
>
> Hi Jonathan,
>
> On Wed, Aug 01, 2012 at 03:39:26PM -0700, Johnathan Van Why wrote:
> > I have heard that system calls are never realtime safe in Linux, even
> > under a RT-PREEMPT kernel. Unless everyone I've asked is mistaken
> > (I've asked on StackOverflow and at LinuxQuestions.org, neither of
> > which focus on realtime software), not even system calls like
> > clock_gettime() are realtime-safe.
>
> No, both correctly configured and validated RT_PREEMPT or Xenomai
> kernels can run applications satisfying hard real-time constraints.
>
> In a nutshell, the advantage of using RT_PREEMPT is that run're
> running a single, less intrusively patched kernel. On the other hand
> the real-time'ness of a Xenomai system (as a dual-kernel approach)
> depends on a much smaller codebase, and (opposed to RT_PREEMPT) can
> not be (so) easily screwed up due to buggy kernel drivers etc. Most
> people start with RT_PREEMPT and then switch to Xenomai if necessary.
>
> > How does Orocos accomplish hard-realtime on Linux without using system
> > calls? Knowing might help keep me from unintentionally breaking
> > realtime within our Orocos-based components.
>
> OROCOS RTT is implemented using different techniques to avoid
> non-deterministic behavior, including avoiding memory allocations in
> critical paths, lock free buffers, real-time allocators, etc.
>
> System calls may or may not be permitted in rt-paths,
> i.e. clock_gettime(2) is, but malloc(2) is not.
>
>
> I don't know about RT_PREEMPT, but as far as I understand, calling
> clock_gettime is _not_ realtime-safe in Xenomai, even when selecting the
> CLOCK_REALTIME clock. See this previous thread for more details [1]. Of worth
CLOCK_REALTIME always causes confusion because it does not refer to
real-time in the sense of this thread, it refers to "real" wall clock
time. Since in most real-time systems you don't care about that, but
rather want a stable clock source that doesn't change when the system
clock changes, most applications will want to use CLOCK_MONOTONIC.
> noting, prior to Xenomai 2.6, there was no clean way to query a timestamp in
> the same timebase as clock_gettime(CLOCK_REALTIME, &tv) from a realtime
> context.
You're right, but for the measurements that Jonathan is doing you
don't care about absolut time, hence the synchronization between
Xenomai and Linux should not be a problem.
> [1] http://www.orocos.org/forum/orocos/orocos-users/
> comparing-timestamps-generated-rt-and-non-rt-contexts
So, gettimeofday is not realtime safe, but clock_gettime is!
Markus
How does Orocos do real-time OS access?
2012/8/2 Johnathan Van Why <jrvanwhy [..] ...>:
> I have heard that system calls are never realtime safe in Linux, even
> under a RT-PREEMPT kernel. Unless everyone I've asked is mistaken
> (I've asked on StackOverflow and at LinuxQuestions.org, neither of
> which focus on realtime software), not even system calls like
> clock_gettime() are realtime-safe.
>
> How does Orocos accomplish hard-realtime on Linux without using system
> calls? Knowing might help keep me from unintentionally breaking
> realtime within our Orocos-based components.
>
Maybe you should have a look to xenomai :
http://www.xenomai.org/
> Thank You,
> Johnathan Van Why
> Dynamic Robotics Laboratory
> Oregon State University
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
How does Orocos do real-time OS access?
> Maybe you should have a look to xenomai :
> http://www.xenomai.org/
Is Xenomai required for hard real-time with Orocos? I was under the
impression that RT-PREEMPT was sufficient to ensure hard realtime
execution.
Thank You,
Johnathan Van Why
Dynamic Robotics Laboratory
Oregon State University
How does Orocos do real-time OS access?
2012/8/2 Johnathan Van Why <jrvanwhy [..] ...>:
>> Maybe you should have a look to xenomai :
>> http://www.xenomai.org/
>
> Is Xenomai required for hard real-time with Orocos?
> I was under the
> impression that RT-PREEMPT was sufficient to ensure hard realtime
> execution.
I don't know about RT-Preempt. The only thing I can say is that
xenomai may provide you for sure hard real time capabilities if used
correctly.
>
> Thank You,
> Johnathan Van Why
> Dynamic Robotics Laboratory
> Oregon State University