<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Console'; font-size:12pt; font-weight:400; font-style:normal;">On Friday April 24 2009, Manuel Coutinho wrote:<br>
> On top of my head, I would say you are also suspending the idle thread<br>
> (which you should not)<br>
Thanks, Manuel.<br>
Your idea seems to me correct - this may be the only difference (as I can imagine) between my code and rtems_iterate_over_all_threads() call.<br>
So, I need to avoid suspension of the 0x0a010000 task, yes?<br>
Is there any other way to know the idle task ID?<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>Thanks.<br>
><br>
><br>
><br>
>   _____<br>
><br>
> From: rtems-users-bounces@rtems.org [mailto:rtems-users-bounces@rtems.org]<br>
> On Behalf Of Leon Pollak<br>
> Sent: Thursday, April 23, 2009 1:59 PM<br>
> To: rtems-users@rtems.com.<br>
> Subject: rtems_iterate_over_all_threads hangs the application<br>
><br>
><br>
><br>
> Hello, all (mainly Joel :-)<br>
><br>
> I used the following code to stop the running system for "snapshot":<br>
> --------------------------------<br>
> inline rtems_id GetSelfTaskId() {<br>
> return(_Thread_Executing->Object.id);<br>
> }<br>
><br>
> inline void __help_suspend__(Thread_Control *the_thread) {<br>
> if (GetSelfTaskId() != the_thread->Object.id)<br>
> rtems_task_suspend(the_thread->Object.id);<br>
> }<br>
><br>
> inline void AllTasks() {<br>
> rtems_iterate_over_all_threads(__help_suspend__);<br>
> }<br>
> --------------------------------<br>
> And then the following code to run this:<br>
><br>
> AllTasks();<br>
> rtems_wake_after(400);<br>
> Reset();<br>
><br>
> When I stop after AllTasks() and print out the tasks state, I see that all<br>
> tasks except the current one are suspended - OK.<br>
> Now, when I try to sleep, the application hangs.<br>
> Looking into debugger, I see that control reaches the _Thread_Dispatch<br>
> function via _Thread_Set_state() and _Thread_Calculate_heir().<br>
> The last does<br>
> _Thread_Heir = (Thread_Control *)<br>
> _Thread_Ready_chain[ _Priority_Get_highest() ].first;<br>
><br>
> and returns very small value (0xc8), which goes to the _Thread_Heir value<br>
> with the crash result at the end.<br>
><br>
> ---<br>
> I substituted call to AllTasks() with the code:<br>
> for(uint i = 0x0a010001; i <= 0x0a010020; i++) {<br>
> if (i == _Thread_Executing->Object.id) continue;<br>
> rtems_task_suspend(i); }<br>
> And everything worked fine.<br>
><br>
><br>
><br>
><br>
><br>
> My assumption is that _Priority_Get_highest() does not return correct value<br>
> (as there are no tasks), but...<br>
><br>
><br>
><br>
><br>
><br>
><br>
> Many thanks ahead for any comment.<br>
><br>
> Leon<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>-- <br>
            Dr.Leon M.Pollak<br>
                Director<br>
       PLR Information Systems Ltd.<br>
Tel.:+972-98657670  |  POB 8130, H'Aomanut 9,<br>
Fax.:+972-98657621  |  Poleg Industrial Zone,<br>
Mob.:+972-544739246 |  Netanya, 42160, Israel.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p></body></html>