<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>RTX stack overflow check problem</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/38296/rtx-stack-overflow-check-problem</link><description> 
I&amp;#39;ve now spent a lot of time debugging a problem/issue with the
built-in stack overflow check in the RTX OS. 

 
In my project I have a task that receives input from a UART (LPC
2368). The chacacters are read vith getchar(), which in turn calls
fgetc</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: RTX stack overflow check problem</title><link>https://community.arm.com/thread/101746?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2009 05:33:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5b526885-4c34-47af-a6b9-91347902d2f0</guid><dc:creator>Per Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
I recommend that you consider the use of a mailbox or event for
received data, so your task don&amp;#39;t have to busy-wait.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTX stack overflow check problem</title><link>https://community.arm.com/thread/77304?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2009 05:20:54 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:56869154-19d9-4ce6-90f1-57445dabded5</guid><dc:creator>Oyvind Kaurstad</dc:creator><description>&lt;p&gt;&lt;p&gt;
I know, but it is not sitting inside the SWI-function in a loop.
If that was the case, nothing would work, and I do have a few other
tasks also. Everything runs normally, but stack overflows in this one
task is not detected.&lt;/p&gt;

&lt;p&gt;
Here&amp;#39;s some pseudo-code to show the setup:&lt;/p&gt;

&lt;pre&gt;
void __task task1(void)
{
   int c;

   for(;;)
   {
      c = getchar();
      /* do_stuff with char */
   }
}

int getchar(void)
{
   int ch;

   do
   {
      ch = com_get();
   }
   while(ch == EOF);

   return ch;
}

int __SWI_8 com_get(void)
{
   if(char_available)
      return char;
   else
      return EOF;
}
&lt;/pre&gt;

&lt;p&gt;
As you can see, the task calls getchar, which in turn repeatedly
calls the SWI-function com_get until something is received.&lt;/p&gt;

&lt;p&gt;
If task1&amp;#39;s stack overflows, this is not detected by the mechanisms
in RTX. However, as I said, if a call to os_dly_wait (or os_tsk_pass)
is inserted in the loop in the task, like this:&lt;/p&gt;

&lt;pre&gt;
void __task task1(void)
{
   int c;

   for(;;)
   {
      c = getchar();
      os_tsk_pass();
      /* do_stuff with char */
   }
}
&lt;/pre&gt;

&lt;p&gt;
...then the stack check is performed.&lt;/p&gt;

&lt;p&gt;
Regards&lt;br /&gt;
-Oyvind&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTX stack overflow check problem</title><link>https://community.arm.com/thread/55731?ContentTypeID=1</link><pubDate>Thu, 26 Mar 2009 04:31:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6587ce96-6d38-4dff-9773-513d35235d24</guid><dc:creator>Franc  Urbanc</dc:creator><description>&lt;p&gt;&lt;p&gt;
When the cpu is in supervisor mode (SWI), tick timer IRQs are
blocked.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>