rtems_iterate_over_all_threads hangs the application

Manuel Coutinho manuel.coutinho at edisoft.pt
Fri Apr 24 15:37:35 UTC 2009


On top of my head, I would say you are also suspending the idle thread
(which you should not)

 

  _____  

From: rtems-users-bounces at rtems.org [mailto:rtems-users-bounces at rtems.org]
On Behalf Of Leon Pollak
Sent: Thursday, April 23, 2009 1:59 PM
To: rtems-users at rtems.com.
Subject: rtems_iterate_over_all_threads hangs the application

 

Hello, all (mainly Joel :-)

I used the following code to stop the running system for "snapshot":
--------------------------------
inline rtems_id GetSelfTaskId() {
return(_Thread_Executing->Object.id); 
}

inline void __help_suspend__(Thread_Control *the_thread) {
if (GetSelfTaskId() != the_thread->Object.id) 
rtems_task_suspend(the_thread->Object.id);
}

inline void AllTasks() {
rtems_iterate_over_all_threads(__help_suspend__);
}
--------------------------------
And then the following code to run this:

AllTasks();
rtems_wake_after(400);
Reset();

When I stop after AllTasks() and print out the tasks state, I see that all
tasks except the current one are suspended - OK.
Now, when I try to sleep, the application hangs.
Looking into debugger, I see that control reaches the _Thread_Dispatch
function via _Thread_Set_state() and _Thread_Calculate_heir().
The last does
_Thread_Heir = (Thread_Control *)
_Thread_Ready_chain[ _Priority_Get_highest() ].first;

and returns very small value (0xc8), which goes to the _Thread_Heir value
with the crash result at the end.

---
I substituted call to AllTasks() with the code:
for(uint i = 0x0a010001; i <= 0x0a010020; i++) {
if (i == _Thread_Executing->Object.id) continue;
rtems_task_suspend(i); }
And everything worked fine.



 

My assumption is that _Priority_Get_highest() does not return correct value
(as there are no tasks), but...




 

Many thanks ahead for any comment.

Leon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20090424/05bef5a8/attachment-0001.html>


More information about the users mailing list