[En-Nut-Discussion] Can a thread determine its stack space?

Ulrich Prinz uprinz2 at netscape.net
Wed Sep 22 22:13:16 CEST 2010


Hi!

Can a stack determine its own stack space? I.e. I want a thread to 
monitor its own left free stack space. But I cannot find out how to do that.

There are functions that are only available if some debug settings are 
enabled. And some of them are never available as the #defines are never 
set and not available through nutconf.

But enabling heap debugging doesn't solve the problem if a thread 
silently hangs up while the rest of the system is still running fine. 
And the output of NutHeapAvailable() and NutHeapRootRegionAvailable()
in the main thread still show plenty of memory.

Is there a mechanism to find a mutex where a thread is blocked on?

Enabling debugging has another problem too as it multiplies some stacks 
for init and main and others with a factor what has a general impact on 
the system. So it is difficult to find the problem in a surrounding that 
is different from what you target on.
This might also get difficult if your application needs most of FLASH 
and RAM.

Best regards
Ulrich



More information about the En-Nut-Discussion mailing list