rtems_iterate_over_all_threads hangs the application

Leon Pollak leonp at plris.com
Thu Apr 23 12:58:59 UTC 2009


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/20090423/0b733e41/attachment.html>


More information about the users mailing list