Skip to contentSkip to conversation

Is rt_task_set_mode( T_PRIMARY, 0, 0 ) temporary ?

Xenomai-help Peter Soetens 3 participants 8 messages Jan 14, 2008 – Jan 15, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

Is it possible that this call only clears the T_PRIMARY flag temporary, and that after 'some' rt_ call, the flag is set again ?

I tried to check this with rt_task_inquire( task, &info ) and check
info.status & XNRELAX but that always returned false.

Peter

Signature · 1 line
Peter Soetens -- FMTC -- <http://www.fmtc.be>
#1 lore raw
Quoted 4 lines · Peter Soetens

Hi,

Is it possible that this call only clears the T_PRIMARY flag temporary, and that after 'some' rt_ call, the flag is set again ?

Any potentially blocking rt-syscall for instance, occurring between rt_task_set_mode() and rt_task_inquire(), would indeed switch the thread back to primary, clearing the XNRELAX bit from the status.

Quoted 3 lines

I tried to check this with rt_task_inquire( task, &info ) and check info.status & XNRELAX but that always returned false.

Peter

#2 lore raw
Quoted 9 lines · On Monday 14 January 2008 21:43:53 Philippe Gerum wrote:
Quoted 4 lines · Peter Soetens

Hi,

Is it possible that this call only clears the T_PRIMARY flag temporary, and that after 'some' rt_ call, the flag is set again ?

Any potentially blocking rt-syscall for instance, occurring between rt_task_set_mode() and rt_task_inquire(), would indeed switch the thread back to primary, clearing the XNRELAX bit from the status.

Thanks, It would be nice to add this sentence to the API docs.

So how do I run a task permanently in secondary mode ? The reason I want to do this is two fold: We want to share xenomai native mutexes and semaphores between threads running in primary domain and threads running under the Linux scheduler. And we want a thread type that allows user code to go in endless loops without hanging the machine. In RTAI we did this creating an RTAI task which was run in the soft-rt mode.
I believe a plain posix thread can not use the 'native' interface ?

Peter

Signature · 1 line
Peter Soetens -- FMTC -- <http://www.fmtc.be>
#3 lore raw
Quoted 11 lines · Peter Soetens
Quoted 9 lines · On Monday 14 January 2008 21:43:53 Philippe Gerum wrote:
Quoted 4 lines · Peter Soetens

Hi,

Is it possible that this call only clears the T_PRIMARY flag temporary, and that after 'some' rt_ call, the flag is set again ?

Any potentially blocking rt-syscall for instance, occurring between rt_task_set_mode() and rt_task_inquire(), would indeed switch the thread back to primary, clearing the XNRELAX bit from the status.

Quoted 6 lines

Thanks, It would be nice to add this sentence to the API docs.

So how do I run a task permanently in secondary mode ? The reason I want to do this is two fold: We want to share xenomai native mutexes and semaphores between threads running in primary domain and threads running under the Linux scheduler.

A thread which blocks on a xenomai native mutex or semaphore will switch to primary mode, it will not run under the Linux scheduler.

Quoted 3 lines

And we want a thread type that allows user code to go in endless loops without hanging the machine. In RTAI we did this creating an RTAI task which was run in the soft-rt mode.

You should probably use a native task with priority 0, this task will use the SCHED_OTHER policy when run by Linux scheduler, which means it will not hang the machine. But of course, you will have to take care that the loop does not take place in primary mode.

Quoted 1 line

I believe a plain posix thread can not use the 'native' interface ?

A plain posix thread can use some of the native interface services, but not the blocking ones. Blocking a thread requires xenomai tasks running in primary mode.

Signature · 1 line
                                               Gilles Chanteperdrix
#4 lore raw
Quoted 31 lines · Gilles Chanteperdrix
Quoted 11 lines · Peter Soetens
Quoted 9 lines · On Monday 14 January 2008 21:43:53 Philippe Gerum wrote:
Quoted 4 lines · Peter Soetens

Hi,

Is it possible that this call only clears the T_PRIMARY flag temporary, and that after 'some' rt_ call, the flag is set again ?

Any potentially blocking rt-syscall for instance, occurring between rt_task_set_mode() and rt_task_inquire(), would indeed switch the thread back to primary, clearing the XNRELAX bit from the status.

Quoted 6 lines

Thanks, It would be nice to add this sentence to the API docs.

So how do I run a task permanently in secondary mode ? The reason I want to do this is two fold: We want to share xenomai native mutexes and semaphores between threads running in primary domain and threads running under the Linux scheduler.

A thread which blocks on a xenomai native mutex or semaphore will switch to primary mode, it will not run under the Linux scheduler.

Quoted 3 lines

And we want a thread type that allows user code to go in endless loops without hanging the machine. In RTAI we did this creating an RTAI task which was run in the soft-rt mode.

You should probably use a native task with priority 0, this task will use the SCHED_OTHER policy when run by Linux scheduler, which means it will not hang the machine. But of course, you will have to take care that the loop does not take place in primary mode.

Quoted 5 lines
Quoted 1 line

I believe a plain posix thread can not use the 'native' interface ?

A plain posix thread can use some of the native interface services, but not the blocking ones. Blocking a thread requires xenomai tasks running in primary mode.

The only IPC which allows communication between Xenomai threads and Linux threads without one of them leaving its mode is the native message pipe:
http://www.xenomai.org/documentation/trunk/html/api/index.html

Signature · 1 line
                                               Gilles Chanteperdrix
#5 lore raw
Quoted 36 lines · Gilles Chanteperdrix

On Jan 15, 2008 11:06 AM, Gilles Chanteperdrix

Quoted 33 lines · <[email protected]> wrote:
Quoted 11 lines · Peter Soetens
Quoted 9 lines · On Monday 14 January 2008 21:43:53 Philippe Gerum wrote:
Quoted 4 lines · Peter Soetens

Hi,

Is it possible that this call only clears the T_PRIMARY flag temporary, and that after 'some' rt_ call, the flag is set again ?

Any potentially blocking rt-syscall for instance, occurring between rt_task_set_mode() and rt_task_inquire(), would indeed switch the thread back to primary, clearing the XNRELAX bit from the status.

Quoted 6 lines

Thanks, It would be nice to add this sentence to the API docs.

So how do I run a task permanently in secondary mode ? The reason I want to do this is two fold: We want to share xenomai native mutexes and semaphores between threads running in primary domain and threads running under the Linux scheduler.

A thread which blocks on a xenomai native mutex or semaphore will switch to primary mode, it will not run under the Linux scheduler.

Quoted 3 lines

And we want a thread type that allows user code to go in endless loops without hanging the machine. In RTAI we did this creating an RTAI task which was run in the soft-rt mode.

You should probably use a native task with priority 0, this task will use the SCHED_OTHER policy when run by Linux scheduler, which means it will not hang the machine. But of course, you will have to take care that the loop does not take place in primary mode.

Quoted 1 line

I believe a plain posix thread can not use the 'native' interface ?

Quoted 8 lines
Quoted 3 lines

A plain posix thread can use some of the native interface services, but not the blocking ones. Blocking a thread requires xenomai tasks running in primary mode.

The only IPC which allows communication between Xenomai threads and Linux threads without one of them leaving its mode is the native message pipe:
http://www.xenomai.org/documentation/trunk/html/api/index.html

Frames got me. I meant:
http://www.xenomai.org/documentation/trunk/html/api/group__pipe.html

Signature · 1 line
                                               Gilles Chanteperdrix
#6 lore raw
In reply to Gilles Chanteperdrix
Quoted 4 lines · On Tuesday 15 January 2008 11:06:13 Gilles Chanteperdrix wrote:

A thread which blocks on a xenomai native mutex or semaphore will switch to primary mode, it will not run under the Linux scheduler.

Quoted 8 lines
Quoted 3 lines

And we want a thread type that allows user code to go in endless loops without hanging the machine. In RTAI we did this creating an RTAI task which was run in the soft-rt mode.

You should probably use a native task with priority 0, this task will use the SCHED_OTHER policy when run by Linux scheduler, which means it will not hang the machine. But of course, you will have to take care that the loop does not take place in primary mode.

The native API says that the lowest priority is '1' and not '0'.
<http://www.xenomai.org/documentation/branches/v2.4.x/html/api/group__task.html#g03387550693c21d0223f739570ccd992>

Or do you suggest I should use pthread_setschedparam or similar after a call to rt_task_set_mode(T_PRIMARY, 0, 0 ) ?

Quoted 6 lines
Quoted 2 lines

I believe a plain posix thread can not use the 'native' interface ?

A plain posix thread can use some of the native interface services, but not the blocking ones. Blocking a thread requires xenomai tasks running in primary mode.

Ok. Thanks for this clarification. It looks like I'll have to redesign some code to take into account these policies. I just wonder if staying in the primary domain after a 'blocking' call is what users of rt_task_set_mode() expect. Why are the flags not restored to what the user has set ? I'm just complaining from a user's perspective :-]

Peter

Signature · 1 line
Peter Soetens -- FMTC -- <http://www.fmtc.be>
#7 lore raw
Quoted 14 lines · Peter Soetens
Quoted 4 lines · On Tuesday 15 January 2008 11:06:13 Gilles Chanteperdrix wrote:

A thread which blocks on a xenomai native mutex or semaphore will switch to primary mode, it will not run under the Linux scheduler.

Quoted 8 lines
Quoted 3 lines

And we want a thread type that allows user code to go in endless loops without hanging the machine. In RTAI we did this creating an RTAI task which was run in the soft-rt mode.

You should probably use a native task with priority 0, this task will use the SCHED_OTHER policy when run by Linux scheduler, which means it will not hang the machine. But of course, you will have to take care that the loop does not take place in primary mode.

Quoted 5 lines

The native API says that the lowest priority is '1' and not '0'.
<http://www.xenomai.org/documentation/branches/v2.4.x/html/api/group__task.html#g03387550693c21d0223f739570ccd992>

Or do you suggest I should use pthread_setschedparam or similar after a call to rt_task_set_mode(T_PRIMARY, 0, 0 ) ?

The null priority is a (relatively) recent addition, so, maybe the docs are not yet up to date.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

I believe a plain posix thread can not use the 'native' interface ?

A plain posix thread can use some of the native interface services, but not the blocking ones. Blocking a thread requires xenomai tasks running in primary mode.

Quoted 5 lines

Ok. Thanks for this clarification. It looks like I'll have to redesign some code to take into account these policies. I just wonder if staying in the primary domain after a 'blocking' call is what users of rt_task_set_mode() expect. Why are the flags not restored to what the user has set ? I'm just complaining from a user's perspective :-]

The current policy is the lazy approach: mode switches occur only when needed. This results in fewer mode switches, but this may mean that you should use rt_task_set_mode from time to time if you want to force a mode.

Signature · 1 line
                                               Gilles Chanteperdrix