Skip to contentSkip to conversation

how to stop a runaway task

Xenomai-help Carsten Spieß 3 participants 13 messages Oct 30, 2007 – Dec 23, 2007

lore
Share & tools
lore
#0 lore raw

Hello,

i'm running Xenomai 2.3.2 on a PPC target with Linux 2.4.25 kernel. I trying to programm a supervising task, that detects a runaway task and suspend it.

My aproach was to make a high priority periodic task to look if the low prio task is running correctly and suspend it when it detects failure.
But this approach didn't work, the higer prio task isn't called unless the lower prio task gives up cpu (by calling e.g. rt_task_yield or nanosleep) (see attached demo source)

When not being cooperative (removing the rt_task_yield in the demo) my system is reset after some seconds.

Why isn't my supervising task scheduled?

Tanks for help, regards

Carsten

Signature · 8 lines
Dipl.-Ing. Carsten Spieß
Softwareentwicklung - Beratung - Schulung
Lauterlech 39d
D-86152 Augsburg
Tel.: +49(821)15 999 765
Fax.: +49(821)15 999 767
mailto://[email protected]
http://www.carsten-spiess.de
#1 lore raw
Quoted 6 lines · Carsten Spieß

Hello,

i'm running Xenomai 2.3.2 on a PPC target with Linux 2.4.25 kernel. I trying to programm a supervising task, that detects a runaway task and suspend it.

Quoted 6 lines

My aproach was to make a high priority periodic task to look if the low prio task is running correctly and suspend it when it detects failure.
But this approach didn't work, the higer prio task isn't called unless the lower prio task gives up cpu (by calling e.g. rt_task_yield or nanosleep) (see attached demo source)

This would basically say that the core does not give any real-time guarantee. Please send some demo code showing this.

Quoted 6 lines

When not being cooperative (removing the rt_task_yield in the demo) my system is reset after some seconds.

Why isn't my supervising task scheduled?

Try enabling the nucleus watchdog (Xenomai debug options). It does kill runaway tasks. If this works on your setup, then your code must be wrong. If it does not trigger, then we need to understand why -- there is one case where it may not trigger, but this does not involve any breakage in task management.

Quoted 11 lines

Tanks for help, regards

Carsten

------------------------------------------------------------------------

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Signature · 1 line
Philippe.
#2 lore raw

Hello Philippe,

Quoted 5 lines
Quoted 3 lines

But this approach didn't work, the higer prio task isn't called unless the lower prio task gives up cpu (by calling e.g. rt_task_yield or nanosleep) (see attached demo source)

This would basically say that the core does not give any real-time guarantee.

I hope this is not the case.

Quoted 1 line

Please send some demo code showing this.

I've attached it, please remove the rt_task_yield to see the effect.

Quoted 9 lines
Quoted 6 lines

When not being cooperative (removing the rt_task_yield in the demo) my system is reset after some seconds.

Why isn't my supervising task scheduled?

Try enabling the nucleus watchdog (Xenomai debug options). It does kill runaway tasks.

O.k. i will try this.

Quoted 4 lines

If this works on your setup, then your code must be
wrong. If it does not trigger, then we need to understand why -- there is one case where it may not trigger, but this does not involve any breakage in task management.

Regards Carsten

#3 lore raw
Quoted 12 lines · Carsten Spieß

Hello Philippe,

Quoted 5 lines
Quoted 3 lines

But this approach didn't work, the higer prio task isn't called unless the lower prio task gives up cpu (by calling e.g. rt_task_yield or nanosleep) (see attached demo source)

This would basically say that the core does not give any real-time guarantee.

I hope this is not the case.

Quoted 1 line

Please send some demo code showing this.

I've attached it, please remove the rt_task_yield to see the effect.

Quoted 2 lines
Quoted 2 lines

When not being cooperative (removing the rt_task_yield in the demo) my system is reset after some seconds.

This works fine on 2.4-rc4/x86-2.6.22 here, so I need to switch to a similar ppc configuration to try reproducing it. More news later. Please send your kernel .config for 2.4.25 in the meantime.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

Why isn't my supervising task scheduled?

Try enabling the nucleus watchdog (Xenomai debug options). It does kill runaway tasks.

O.k. i will try this.

You will have to remove the printf() from the low prio task for the nucleus watchdog to detect the runaway situation, otherwise, your task would be considered as being under the control of the Linux scheduler until it issues a blocking Xenomai syscall (which it never does), and therefore escape the watchdog detection. That's the particular case I was talking about.

Quoted 7 lines
Quoted 5 lines

If this works on your setup, then your code must be
wrong. If it does not trigger, then we need to understand why -- there is one case where it may not trigger, but this does not involve any breakage in task management.

Regards Carsten

Signature · 1 line
Philippe.
#4 lore raw

Hello Philippe,

Quoted 6 lines

You will have to remove the printf() from the low prio task for the nucleus watchdog to detect the runaway situation, otherwise, your task would be considered as being under the control of the Linux scheduler until it issues a blocking Xenomai syscall (which it never does), and therefore escape the watchdog detection. That's the particular case I was talking about.

Meanwhile i got my sample code running:
When removing the printf it works fine.
So for me it looks like a problem when a task is switched to secondary domain.
Is there a way to force a thread to switch back to primary domain?

Now i unsuccesfully tried to get a posix skin variant running. (my real app is based on pthread)
Since i only can use signals to suspend a posix thread (correct me if i'm wrong) i run in the same problem with the secondary domain.

Is there a way to switch back to primary domain in posix skin?

Do i have a chance to do this with pthread or do i have to rewrite my code using rt_task* calls?

Thanks for your help, regards

Carsten

Signature · 8 lines
Dipl.-Ing. Carsten Spieß
Softwareentwicklung - Beratung - Schulung
Lauterlech 39d
D-86152 Augsburg
Tel.: +49(821)15 999 765
Fax.: +49(821)15 999 767
mailto://[email protected]
http://www.carsten-spiess.de
#5 lore raw
Quoted 15 lines · Carsten Spieß

Hello Philippe,

Quoted 6 lines

You will have to remove the printf() from the low prio task for the nucleus watchdog to detect the runaway situation, otherwise, your task would be considered as being under the control of the Linux scheduler until it issues a blocking Xenomai syscall (which it never does), and therefore escape the watchdog detection. That's the particular case I was talking about.

Meanwhile i got my sample code running:
When removing the printf it works fine.
So for me it looks like a problem when a task is switched to secondary domain.
Is there a way to force a thread to switch back to primary domain?

Quoted 6 lines

Now i unsuccesfully tried to get a posix skin variant running. (my real app is based on pthread)
Since i only can use signals to suspend a posix thread (correct me if i'm wrong) i run in the same problem with the secondary domain.

Is there a way to switch back to primary domain in posix skin?

In 99% of the cases, you do not need to do this, Xenomai switches threads to primary mode when they call a service which runs in primary mode.

For the remaining cases, there is pthread_set_mode_np, see the API documentation at:
http://www.xenomai.org/index.php/API_documentation

To suspend threads, you can use pthread_cond_wait, sem_wait, pthread_mutex_lock or clock_nanosleep, depending on what you are trying to achieve. Signals are no good if you want to remain in primary mode, because they cause a switch to secondary mode.

Quoted 2 lines

Do i have a chance to do this with pthread or do i have to rewrite my code using rt_task* calls?

Signature · 1 line
					    Gilles Chanteperdrix.
#6 lore raw
In reply to Carsten Spieß
Quoted 15 lines · Carsten Spieß

Hello Philippe,

Quoted 6 lines

You will have to remove the printf() from the low prio task for the nucleus watchdog to detect the runaway situation, otherwise, your task would be considered as being under the control of the Linux scheduler until it issues a blocking Xenomai syscall (which it never does), and therefore escape the watchdog detection. That's the particular case I was talking about.

Meanwhile i got my sample code running:
When removing the printf it works fine.
So for me it looks like a problem when a task is switched to secondary domain.
Is there a way to force a thread to switch back to primary domain?

Quoted 4 lines

Now i unsuccesfully tried to get a posix skin variant running. (my real app is based on pthread)
Since i only can use signals to suspend a posix thread (correct me if i'm wrong) i run in the same problem with the secondary domain.

Sorry, I wrote the previous answer without reading your previous mails. If you are trying to suspend a task from another task, then SIGSTOP is the only solution. Now, for the problem you have with secondary mode switches, it is probably a bug, so you should not design your application around this bug, it should work, and actually works on other platforms.

Signature · 1 line
					    Gilles Chanteperdrix.
#7 lore raw

Hello Gilles,

Quoted 2 lines

If you are trying to suspend a task from another task, then SIGSTOP is the only solution.

O.k., this will lead me again to use rt_task_* instead of pthread_* (i don't like signals at all)

Quoted 2 lines

Now, for the problem you have with secondary mode switches, it is probably a bug,

Is it a known bug? Can someone confirm it? (I can provide sample code) Is there already a fix for it?
If not, how to debug such things?
(until now, i'm only working on the user mode side)

Quoted 2 lines

so you should not design your application around this bug, it should work, and actually works on other platforms.

Regards Carsten

Signature · 8 lines
Dipl.-Ing. Carsten Spieß
Softwareentwicklung - Beratung - Schulung
Lauterlech 39d
D-86152 Augsburg
Tel.: +49(821)15 999 765
Fax.: +49(821)15 999 767
mailto://[email protected]
http://www.carsten-spiess.de
#8 lore raw
Quoted 7 lines · Carsten Spieß

Hello Gilles,

Quoted 2 lines

If you are trying to suspend a task from another task, then SIGSTOP is the only solution.

O.k., this will lead me again to use rt_task_* instead of pthread_* (i don't like signals at all)

Quoted 6 lines
Quoted 2 lines

Now, for the problem you have with secondary mode switches, it is probably a bug,

Is it a known bug? Can someone confirm it? (I can provide sample code) Is there already a fix for it?
If not, how to debug such things?
(until now, i'm only working on the user mode side)

Read Philippe's answer again:
https://mail.gna.org/public/xenomai-help/2007-10/msg00166.html

Signature · 1 line
					    Gilles Chanteperdrix.
#10 lore raw
Quoted 6 lines · Carsten Spieß

Hello Gilles,

Quoted 2 lines

Read Philippe's answer again:
https://mail.gna.org/public/xenomai-help/2007-10/msg00166.html

Hmm.., sorry, but i dont see what you mean.
Carsten

It means that the bug you observed can not be confirmed on other platforms, so depends probably on the kernel/I-pipe patch version combination you use, and that Philippe is trying to find a platform where it can be reproduced so as to be able to solve it.

Signature · 1 line
					    Gilles Chanteperdrix.
#11 lore raw
In reply to Carsten Spieß
Quoted 13 lines · Carsten Spieß

Hello,

i'm running Xenomai 2.3.2 on a PPC target with Linux 2.4.25 kernel. I trying to programm a supervising task, that detects a runaway task and suspend it.

My aproach was to make a high priority periodic task to look if the low prio task is running correctly and suspend it when it detects failure.
But this approach didn't work, the higer prio task isn't called unless the lower prio task gives up cpu (by calling e.g. rt_task_yield or nanosleep) (see attached demo source)

Quoted 5 lines

When not being cooperative (removing the rt_task_yield in the demo) my system is reset after some seconds.

Why isn't my supervising task scheduled?

This new I-pipe patch for 2.4.25 may fix the issue:
http://download.gna.org/adeos/patches/v2.4/ppc/adeos-ipipe-2.4.25-ppc-DENX-1.2-02.patch

Signature · 1 line
Philippe.
#12 lore raw

Thanks, i will try it when i´m back from holliday. regrads Carsten

Quoted 27 lines · Philippe Gerum
Quoted 13 lines · Carsten Spieß

Hello,

i'm running Xenomai 2.3.2 on a PPC target with Linux 2.4.25 kernel. I trying to programm a supervising task, that detects a runaway task and suspend it.

My aproach was to make a high priority periodic task to look if the low prio task is running correctly and suspend it when it detects failure.
But this approach didn't work, the higer prio task isn't called unless the lower prio task gives up cpu (by calling e.g. rt_task_yield or nanosleep) (see attached demo source)

Quoted 5 lines

When not being cooperative (removing the rt_task_yield in the demo) my system is reset after some seconds.

Why isn't my supervising task scheduled?

This new I-pipe patch for 2.4.25 may fix the issue:
http://download.gna.org/adeos/patches/v2.4/ppc/adeos-ipipe-2.4.25-ppc-DENX-1.2-02.patch

--
Philippe.

Signature · 1 line
Carsten Spieß