<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="country-region"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="place"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--p
        {white-space: pre-wrap;}
li
        {white-space: pre-wrap;}

 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Console;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p
        {mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

<meta name=qrichtext content=1>
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>On top of my head, I would say you are
also suspending the idle thread (which you should not)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> rtems-users-bounces@rtems.org
[mailto:rtems-users-bounces@rtems.org] <b><span style='font-weight:bold'>On
Behalf Of </span></b>Leon Pollak<br>
<b><span style='font-weight:bold'>Sent:</span></b> Thursday, April 23, 2009
1:59 PM<br>
<b><span style='font-weight:bold'>To:</span></b> rtems-users@rtems.com.<br>
<b><span style='font-weight:bold'>Subject:</span></b>
rtems_iterate_over_all_threads hangs the application</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=3 face=Console><span style='font-size:12.0pt;
font-family:Console'>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
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 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 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>
<o:p></o:p></span></font></p>

<p style='margin:0in;margin-bottom:.0001pt'><font size=3 face=Console><span
style='font-size:12.0pt;font-family:Console'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=3 face=Console><span style='font-size:12.0pt;
font-family:Console'>My assumption is that _Priority_Get_highest() does not
return correct value (as there are no tasks), but...<br>
<br>
<br>
<o:p></o:p></span></font></p>

<p style='margin:0in;margin-bottom:.0001pt'><font size=3 face=Console><span
style='font-size:12.0pt;font-family:Console'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=3 face=Console><span style='font-size:12.0pt;
font-family:Console'>Many thanks ahead for any comment.<br>
<br>
<st1:country-region w:st="on"><st1:place w:st="on">Leon</st1:place></st1:country-region><o:p></o:p></span></font></p>

</div>

</div>

</body>

</html>