Fwd: Mixing realtime and non-realtime components in Xenomai deployer?

(Forwarding to Orocos-users because I accidentally replied directly to
Sagar Behere.)

---------- Forwarded message ----------
From: Johnathan Van Why <jrvanwhy [..] ...>
Date: Tue, Aug 21, 2012 at 9:09 AM
Subject: Re: [Orocos-users] Mixing realtime and non-realtime
components in Xenomai deployer?
To: sagar [dot] behere [..] ...

On Mon, Aug 20, 2012 at 11:22 PM, Sagar Behere <sagar [dot] behere [..] ...> wrote:
> On 08/21/2012 02:21 AM, Johnathan Van Why wrote:
>> We're trying to port our Orocos-based software from RT_PREEMPT to
>> Xenomai in order to obtain better realtime performance. If we just
>> launch the deployer-xenomai executable, both of our components (we
>> have more, but I'm only trying with 2 right now) run in hard realtime
>> using Xenomai. However, we'd like one to not be in realtime (it will
>> need to access ROS, which is not realtime) and the other to be in
>> realtime.
>>
>> How can we accomplish this?
>
> I think you need to use ORO_SCHED_OTHER. See
>
> http://www.orocos.org/stable/documentation/rtt/v2.x/doc-xml/orocos-compo...

Sagar,

We are trying to do that. Here is our deployment script:

import("atrias_shared")
import("atrias_rt_ops")
import("atrias_noop_conn")

# Load necessary components.
loadComponent("atrias_rt", "RTOps")
loadComponent("atrias_connector", "NoopConn")

# Let these see each other.
connectPeers("atrias_connector", "atrias_rt")

# Make the Noop Connector cyclic
setActivity("atrias_rt", 0, HighestPriority, ORO_SCHED_RT)
setActivity("atrias_connector", 0.001, 0, ORO_SCHED_OTHER)

# Configure components.
atrias_rt.configure()
atrias_connector.configure()

# Start components.
atrias_rt.start();
atrias_connector.start();

Does this not set atrias_noop_conn to use ORO_SCHED_OTHER?

Thank You,
Johnathan Van Why
Dynamic Robotics Laboratory
Oregon State University

Fwd: Mixing realtime and non-realtime components in Xenomai depl

On 08/21/2012 06:45 PM, Johnathan Van Why wrote:
> (Forwarding to Orocos-users because I accidentally replied directly to
> Sagar Behere.)
>
> ---------- Forwarded message ----------
> From: Johnathan Van Why<jrvanwhy [..] ...>
> Date: Tue, Aug 21, 2012 at 9:09 AM
> Subject: Re: [Orocos-users] Mixing realtime and non-realtime
> components in Xenomai deployer?
> To: sagar [dot] behere [..] ...
>
>
> On Mon, Aug 20, 2012 at 11:22 PM, Sagar Behere<sagar [dot] behere [..] ...> wrote:
>> On 08/21/2012 02:21 AM, Johnathan Van Why wrote:
>>> We're trying to port our Orocos-based software from RT_PREEMPT to
>>> Xenomai in order to obtain better realtime performance. If we just
>>> launch the deployer-xenomai executable, both of our components (we
>>> have more, but I'm only trying with 2 right now) run in hard realtime
>>> using Xenomai. However, we'd like one to not be in realtime (it will
>>> need to access ROS, which is not realtime) and the other to be in
>>> realtime.
>>>
>>> How can we accomplish this?
>>
>> I think you need to use ORO_SCHED_OTHER. See
>>
>> http://www.orocos.org/stable/documentation/rtt/v2.x/doc-xml/orocos-compo...
>
> Sagar,
>
> We are trying to do that. Here is our deployment script:
>
> import("atrias_shared")
> import("atrias_rt_ops")
> import("atrias_noop_conn")
>
> # Load necessary components.
> loadComponent("atrias_rt", "RTOps")
> loadComponent("atrias_connector", "NoopConn")
>
> # Let these see each other.
> connectPeers("atrias_connector", "atrias_rt")
>
> # Make the Noop Connector cyclic
> setActivity("atrias_rt", 0, HighestPriority, ORO_SCHED_RT)
> setActivity("atrias_connector", 0.001, 0, ORO_SCHED_OTHER)
>
> # Configure components.
> atrias_rt.configure()
> atrias_connector.configure()
>
> # Start components.
> atrias_rt.start();
> atrias_connector.start();
>
> Does this not set atrias_noop_conn to use ORO_SCHED_OTHER?

That looks about right. Are you doubting that the atrias_connector task
context is NOT running as non-realtime?

That is similar to how I set the scheduling my components, except that
instead of doing it from the deployment script, I do it using code in
the configureHook of the component. In fact, the simplest way to set
ORO_SCHED_RT is to not specify a priority, whereas specifying one sets
the default scheduler to ORO_SCHED_RT.

Regards,
Sagar

Fwd: Mixing realtime and non-realtime components in Xenomai depl

On Tue, Aug 21, 2012 at 10:02 AM, Sagar Behere <sagar [dot] behere [..] ...> wrote:
> On 08/21/2012 06:45 PM, Johnathan Van Why wrote:
>> (Forwarding to Orocos-users because I accidentally replied directly to
>> Sagar Behere.)
>>
>> ---------- Forwarded message ----------
>> From: Johnathan Van Why<jrvanwhy [..] ...>
>> Date: Tue, Aug 21, 2012 at 9:09 AM
>> Subject: Re: [Orocos-users] Mixing realtime and non-realtime
>> components in Xenomai deployer?
>> To: sagar [dot] behere [..] ...
>>
>>
>> On Mon, Aug 20, 2012 at 11:22 PM, Sagar Behere<sagar [dot] behere [..] ...> wrote:
>>> On 08/21/2012 02:21 AM, Johnathan Van Why wrote:
>>>> We're trying to port our Orocos-based software from RT_PREEMPT to
>>>> Xenomai in order to obtain better realtime performance. If we just
>>>> launch the deployer-xenomai executable, both of our components (we
>>>> have more, but I'm only trying with 2 right now) run in hard realtime
>>>> using Xenomai. However, we'd like one to not be in realtime (it will
>>>> need to access ROS, which is not realtime) and the other to be in
>>>> realtime.
>>>>
>>>> How can we accomplish this?
>>>
>>> I think you need to use ORO_SCHED_OTHER. See
>>>
>>> http://www.orocos.org/stable/documentation/rtt/v2.x/doc-xml/orocos-compo...
>>
>> Sagar,
>>
>> We are trying to do that. Here is our deployment script:
>>
>> import("atrias_shared")
>> import("atrias_rt_ops")
>> import("atrias_noop_conn")
>>
>> # Load necessary components.
>> loadComponent("atrias_rt", "RTOps")
>> loadComponent("atrias_connector", "NoopConn")
>>
>> # Let these see each other.
>> connectPeers("atrias_connector", "atrias_rt")
>>
>> # Make the Noop Connector cyclic
>> setActivity("atrias_rt", 0, HighestPriority, ORO_SCHED_RT)
>> setActivity("atrias_connector", 0.001, 0, ORO_SCHED_OTHER)
>>
>> # Configure components.
>> atrias_rt.configure()
>> atrias_connector.configure()
>>
>> # Start components.
>> atrias_rt.start();
>> atrias_connector.start();
>>
>> Does this not set atrias_noop_conn to use ORO_SCHED_OTHER?
>
>
> That looks about right. Are you doubting that the atrias_connector task
> context is NOT running as non-realtime?
>
> That is similar to how I set the scheduling my components, except that
> instead of doing it from the deployment script, I do it using code in
> the configureHook of the component. In fact, the simplest way to set
> ORO_SCHED_RT is to not specify a priority, whereas specifying one sets
> the default scheduler to ORO_SCHED_RT.

According to /proc/xenomai/schedclasses/rt/threads , atrias_noop_conn
is running in Xenomai context w/ a priority of 0.

Perhaps this is just how Orocos on Xenomai works?

Thank You,
Johnathan Van Why
Dynamic Robotics Laboratory
Oregon State University

Fwd: Mixing realtime and non-realtime components in Xenomai depl

On Tue, Aug 21, 2012 at 7:17 PM, Johnathan Van Why <jrvanwhy [..] ...> wrote:
> On Tue, Aug 21, 2012 at 10:02 AM, Sagar Behere <sagar [dot] behere [..] ...> wrote:
>> On 08/21/2012 06:45 PM, Johnathan Van Why wrote:
>>> (Forwarding to Orocos-users because I accidentally replied directly to
>>> Sagar Behere.)
>>>
>>> ---------- Forwarded message ----------
>>> From: Johnathan Van Why<jrvanwhy [..] ...>
>>> Date: Tue, Aug 21, 2012 at 9:09 AM
>>> Subject: Re: [Orocos-users] Mixing realtime and non-realtime
>>> components in Xenomai deployer?
>>> To: sagar [dot] behere [..] ...
>>>
>>>
>>> On Mon, Aug 20, 2012 at 11:22 PM, Sagar Behere<sagar [dot] behere [..] ...> wrote:
>>>> On 08/21/2012 02:21 AM, Johnathan Van Why wrote:
>>>>> We're trying to port our Orocos-based software from RT_PREEMPT to
>>>>> Xenomai in order to obtain better realtime performance. If we just
>>>>> launch the deployer-xenomai executable, both of our components (we
>>>>> have more, but I'm only trying with 2 right now) run in hard realtime
>>>>> using Xenomai. However, we'd like one to not be in realtime (it will
>>>>> need to access ROS, which is not realtime) and the other to be in
>>>>> realtime.
>>>>>
>>>>> How can we accomplish this?
>>>>
>>>> I think you need to use ORO_SCHED_OTHER. See
>>>>
>>>> http://www.orocos.org/stable/documentation/rtt/v2.x/doc-xml/orocos-compo...
>>>
>>> Sagar,
>>>
>>> We are trying to do that. Here is our deployment script:
>>>
>>> import("atrias_shared")
>>> import("atrias_rt_ops")
>>> import("atrias_noop_conn")
>>>
>>> # Load necessary components.
>>> loadComponent("atrias_rt", "RTOps")
>>> loadComponent("atrias_connector", "NoopConn")
>>>
>>> # Let these see each other.
>>> connectPeers("atrias_connector", "atrias_rt")
>>>
>>> # Make the Noop Connector cyclic
>>> setActivity("atrias_rt", 0, HighestPriority, ORO_SCHED_RT)
>>> setActivity("atrias_connector", 0.001, 0, ORO_SCHED_OTHER)
>>>
>>> # Configure components.
>>> atrias_rt.configure()
>>> atrias_connector.configure()
>>>
>>> # Start components.
>>> atrias_rt.start();
>>> atrias_connector.start();
>>>
>>> Does this not set atrias_noop_conn to use ORO_SCHED_OTHER?
>>
>>
>> That looks about right. Are you doubting that the atrias_connector task
>> context is NOT running as non-realtime?
>>
>> That is similar to how I set the scheduling my components, except that
>> instead of doing it from the deployment script, I do it using code in
>> the configureHook of the component. In fact, the simplest way to set
>> ORO_SCHED_RT is to not specify a priority, whereas specifying one sets
>> the default scheduler to ORO_SCHED_RT.
>
> According to /proc/xenomai/schedclasses/rt/threads , atrias_noop_conn
> is running in Xenomai context w/ a priority of 0.
>
> Perhaps this is just how Orocos on Xenomai works?

Yes. All the threads in one Orocos process are known to Xenomai,
because it's still possible that a RT and a non-RT thread share a
mutex or semaphore. You can't lock a Xenomai mutex/semaphore from a
non-Xenomai thread, so that's why even the not real-time threads need
this registration step. We do set the priority and scheduler to zero
and ORO_SCHED_OTHER such that the right scheduling happens.

Peter

Fwd: Mixing realtime and non-realtime components in Xenomai depl

On 08/21/2012 07:17 PM, Johnathan Van Why wrote:
> On Tue, Aug 21, 2012 at 10:02 AM, Sagar Behere<sagar [dot] behere [..] ...> wrote:
>> On 08/21/2012 06:45 PM, Johnathan Van Why wrote:
>>> (Forwarding to Orocos-users because I accidentally replied directly to
>>> Sagar Behere.)
>>>
>>> ---------- Forwarded message ----------
>>> From: Johnathan Van Why<jrvanwhy [..] ...>
>>> Date: Tue, Aug 21, 2012 at 9:09 AM
>>> Subject: Re: [Orocos-users] Mixing realtime and non-realtime
>>> components in Xenomai deployer?
>>> To: sagar [dot] behere [..] ...
>>>
>>>
>>> On Mon, Aug 20, 2012 at 11:22 PM, Sagar Behere<sagar [dot] behere [..] ...> wrote:
>>>> On 08/21/2012 02:21 AM, Johnathan Van Why wrote:
>>>>> We're trying to port our Orocos-based software from RT_PREEMPT to
>>>>> Xenomai in order to obtain better realtime performance. If we just
>>>>> launch the deployer-xenomai executable, both of our components (we
>>>>> have more, but I'm only trying with 2 right now) run in hard realtime
>>>>> using Xenomai. However, we'd like one to not be in realtime (it will
>>>>> need to access ROS, which is not realtime) and the other to be in
>>>>> realtime.
>>>>>
>>>>> How can we accomplish this?
>>>>
>>>> I think you need to use ORO_SCHED_OTHER. See
>>>>
>>>> http://www.orocos.org/stable/documentation/rtt/v2.x/doc-xml/orocos-compo...
>>>
>>> Sagar,
>>>
>>> We are trying to do that. Here is our deployment script:
>>>
>>> import("atrias_shared")
>>> import("atrias_rt_ops")
>>> import("atrias_noop_conn")
>>>
>>> # Load necessary components.
>>> loadComponent("atrias_rt", "RTOps")
>>> loadComponent("atrias_connector", "NoopConn")
>>>
>>> # Let these see each other.
>>> connectPeers("atrias_connector", "atrias_rt")
>>>
>>> # Make the Noop Connector cyclic
>>> setActivity("atrias_rt", 0, HighestPriority, ORO_SCHED_RT)
>>> setActivity("atrias_connector", 0.001, 0, ORO_SCHED_OTHER)
>>>
>>> # Configure components.
>>> atrias_rt.configure()
>>> atrias_connector.configure()
>>>
>>> # Start components.
>>> atrias_rt.start();
>>> atrias_connector.start();
>>>
>>> Does this not set atrias_noop_conn to use ORO_SCHED_OTHER?
>>
>>
>> That looks about right. Are you doubting that the atrias_connector task
>> context is NOT running as non-realtime?
>>
>> That is similar to how I set the scheduling my components, except that
>> instead of doing it from the deployment script, I do it using code in
>> the configureHook of the component. In fact, the simplest way to set
>> ORO_SCHED_RT is to not specify a priority, whereas specifying one sets
>> the default scheduler to ORO_SCHED_RT.
>
> According to /proc/xenomai/schedclasses/rt/threads , atrias_noop_conn
> is running in Xenomai context w/ a priority of 0.
>
> Perhaps this is just how Orocos on Xenomai works?

Ah! I am out of my depth here :(
Perhaps someone else on the list can help out..

Regards,
Sagar

Fwd: Mixing realtime and non-realtime components in Xenomai depl

Hi,

You could try to call rt_task_inquire and check the information in the
RT_TASK_INFO. exectime should be close to zero, since this is the
execution time in primary mode (in nanoseconds), but your thread should
be in secondary mode (non-RT context). Have a look at the Xenomai API at
http://www.xenomai.org/documentation/xenomai-2.6/html/api/index.html.
Calling the function with tast=NULL should the current thread is inquired.

I also guess that modeswitches should be one or zero. You could try to
add a file operation and then measure the number of mode switches. If
your thread is in primary mode (RT context) it will have to change to
secondary mode (non-RT context) to perform the file operation. If your
thread already is in secondary mode the modeswitches will not increase.
If the counter is increasing during run-time, your thread is running in
the real-time context.

But the running context and the scheduler is two different things.
Xenomai and the linux kernel have a common priority scheme, and
therefore I think that it is not a problem that it runs in primary mode,
as long as the thread ha low priority. I recommend reading "Life with
Adeos" from http://www.xenomai.org/index.php/Publications for more
information.

Kim

On 08/21/2012 10:51 PM, Sagar Behere wrote:
> On 08/21/2012 07:17 PM, Johnathan Van Why wrote:
>> On Tue, Aug 21, 2012 at 10:02 AM, Sagar Behere<sagar [dot] behere [..] ...> wrote:
>>> On 08/21/2012 06:45 PM, Johnathan Van Why wrote:
>>>> (Forwarding to Orocos-users because I accidentally replied directly to
>>>> Sagar Behere.)
>>>>
>>>> ---------- Forwarded message ----------
>>>> From: Johnathan Van Why<jrvanwhy [..] ...>
>>>> Date: Tue, Aug 21, 2012 at 9:09 AM
>>>> Subject: Re: [Orocos-users] Mixing realtime and non-realtime
>>>> components in Xenomai deployer?
>>>> To: sagar [dot] behere [..] ...
>>>>
>>>>
>>>> On Mon, Aug 20, 2012 at 11:22 PM, Sagar Behere<sagar [dot] behere [..] ...> wrote:
>>>>> On 08/21/2012 02:21 AM, Johnathan Van Why wrote:
>>>>>> We're trying to port our Orocos-based software from RT_PREEMPT to
>>>>>> Xenomai in order to obtain better realtime performance. If we just
>>>>>> launch the deployer-xenomai executable, both of our components (we
>>>>>> have more, but I'm only trying with 2 right now) run in hard realtime
>>>>>> using Xenomai. However, we'd like one to not be in realtime (it will
>>>>>> need to access ROS, which is not realtime) and the other to be in
>>>>>> realtime.
>>>>>>
>>>>>> How can we accomplish this?
>>>>> I think you need to use ORO_SCHED_OTHER. See
>>>>>
>>>>> http://www.orocos.org/stable/documentation/rtt/v2.x/doc-xml/orocos-compo...
>>>> Sagar,
>>>>
>>>> We are trying to do that. Here is our deployment script:
>>>>
>>>> import("atrias_shared")
>>>> import("atrias_rt_ops")
>>>> import("atrias_noop_conn")
>>>>
>>>> # Load necessary components.
>>>> loadComponent("atrias_rt", "RTOps")
>>>> loadComponent("atrias_connector", "NoopConn")
>>>>
>>>> # Let these see each other.
>>>> connectPeers("atrias_connector", "atrias_rt")
>>>>
>>>> # Make the Noop Connector cyclic
>>>> setActivity("atrias_rt", 0, HighestPriority, ORO_SCHED_RT)
>>>> setActivity("atrias_connector", 0.001, 0, ORO_SCHED_OTHER)
>>>>
>>>> # Configure components.
>>>> atrias_rt.configure()
>>>> atrias_connector.configure()
>>>>
>>>> # Start components.
>>>> atrias_rt.start();
>>>> atrias_connector.start();
>>>>
>>>> Does this not set atrias_noop_conn to use ORO_SCHED_OTHER?
>>>
>>> That looks about right. Are you doubting that the atrias_connector task
>>> context is NOT running as non-realtime?
>>>
>>> That is similar to how I set the scheduling my components, except that
>>> instead of doing it from the deployment script, I do it using code in
>>> the configureHook of the component. In fact, the simplest way to set
>>> ORO_SCHED_RT is to not specify a priority, whereas specifying one sets
>>> the default scheduler to ORO_SCHED_RT.
>> According to /proc/xenomai/schedclasses/rt/threads , atrias_noop_conn
>> is running in Xenomai context w/ a priority of 0.
>>
>> Perhaps this is just how Orocos on Xenomai works?
> Ah! I am out of my depth here :(
> Perhaps someone else on the list can help out..
>
> Regards,
> Sagar