<?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>High Water Mark feature in RTX</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/32615/high-water-mark-feature-in-rtx</link><description> 
I&amp;#39;m using the RTX RTOS and I noticed that in the latest version
there is a new feature which is a stack high water mark. I&amp;#39;ve been
able to use this while debugging in the IDE but was wondering if
there&amp;#39;s a way to get this information from the RTOS so</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: High Water Mark feature in RTX</title><link>https://community.arm.com/thread/82618?ContentTypeID=1</link><pubDate>Thu, 18 Jun 2015 05:54:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:15b3a8f0-d470-4271-8c43-23b999313d07</guid><dc:creator>Doug Burrell</dc:creator><description>&lt;p&gt;&lt;p&gt;
That&amp;#39;s great... exactly what I was looking for. I will incorporate
this into my code.&lt;/p&gt;

&lt;p&gt;
Thanks,&lt;br /&gt;
Doug&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High Water Mark feature in RTX</title><link>https://community.arm.com/thread/63784?ContentTypeID=1</link><pubDate>Thu, 18 Jun 2015 01:21:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:98cb7853-1aa3-40a7-aa1a-e5d868d35b21</guid><dc:creator>R.Kopsch</dc:creator><description>&lt;p&gt;&lt;p&gt;
This Knowledgebase-Article offers an idea in which the calculated
stack size left for each thread is made accessible for a further
optimization:&lt;br /&gt;
&lt;a href="http://www.keil.com/support/docs/3735.htm"&gt;http://www.keil.com/support/docs/3735.htm&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High Water Mark feature in RTX</title><link>https://community.arm.com/thread/140846?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2015 10:50:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:97146ed9-6002-47f6-9a9e-036f726afb21</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Remember that unless the hardware has special support for it, the
only normal way to check how much stack a task consumes is to
either&lt;br /&gt;
- poll the stack pointer at a reasonably high frequency&lt;br /&gt;
- to fill the stack with a magic pattern and scan how much of the
pattern that has been overwritten&lt;br /&gt;
- to instrument the generated code with special prologue/epilogue
code that checks the consumed stack when calling/returning.&lt;/p&gt;

&lt;p&gt;
An OS can detect an overrun stack by placing magic values directly
after the stack end and check if this pattern has been modified. But
except for that, it can only sample the stack pointer at situations
where it gets involved. So when a time slice is over, or when you
call one of the OS functions. And if it hooks all interrupts, it
could sample the usage even if there is no explicit OS call.&lt;/p&gt;

&lt;p&gt;
So the best in your case would, in my view, be either a
high-priority interrupt sampling the stack usage. Or a low-priority
background task that checks for amount of overwritten magic values.
The low-priority route has the advantage that it mostly just affects
the amount of power a bit - unless it gets totally starved so it
never gets a chance to collect any information. The disadvantage with
it is that it can only tell usage - but have no idea what code path
that might represent the costlies call tree.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High Water Mark feature in RTX</title><link>https://community.arm.com/thread/131507?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2015 06:35:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b2f6999a-c3ee-48de-8276-cf9ef4f18969</guid><dc:creator>Doug Burrell</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks! I wouldn&amp;#39;t say that the stack overflow protection in the
RTOS isn&amp;#39;t enough for our software rather the maximum stack usage is
just nice to have for our monitoring and logging scheme that we
implement. Again this isn&amp;#39;t essential it&amp;#39;s just a nice to have
feature and since the stack high water mark is new I just wondered if
it would be available to use to speed up and simplify our current
monitoring scheme.&lt;/p&gt;

&lt;p&gt;
Thanks,&lt;br /&gt;
Doug&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High Water Mark feature in RTX</title><link>https://community.arm.com/thread/128940?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2015 00:40:03 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f92a0d73-334f-452b-a64d-a2f5721bd90d</guid><dc:creator>re yoReinhard Keil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Doug, thanks for explanation. It looks like you are looking for a
feature that &amp;quot;warns&amp;quot; you in the run-time system when a certain stack
load is exceeded.&lt;/p&gt;

&lt;p&gt;
As you know, we have today a stack protection that stops the
system when a thread stack overflows. Looks like this is not enough
to cover your requirements.&lt;/p&gt;

&lt;p&gt;
I will discuss this with the development team.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High Water Mark feature in RTX</title><link>https://community.arm.com/thread/117789?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 12:23:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c9323eb3-8cd6-463e-91d7-3e9a03c66452</guid><dc:creator>Doug Burrell</dc:creator><description>&lt;p&gt;&lt;p&gt;
Yes, so the stack monitor thread runs when no other threads are
active so it can only ever see the other threads&amp;#39; stacks when they&amp;#39;re
in an idle state.&lt;/p&gt;

&lt;p&gt;
I see where you&amp;#39;re coming from with the idea of a high priority
interrupt to capture each threads&amp;#39; stack usage while it&amp;#39;s active.
That might be the next revision of our stack monitor.&lt;/p&gt;

&lt;p&gt;
So I guess there isn&amp;#39;t any way to access the stack high water mark
data that is in this latest version of RTX? Will there be plans to
add this to each thread&amp;#39;s task control block in future versions of
RTX?&lt;/p&gt;

&lt;p&gt;
Thanks,&lt;br /&gt;
Doug&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High Water Mark feature in RTX</title><link>https://community.arm.com/thread/108246?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2015 09:05:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4c91ffac-a964-4855-b808-2ce5313aebf9</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Note that an IDLE thread will only run when no other thread has
anything to do.&lt;/p&gt;

&lt;p&gt;
So if it looks at the stack pointer for any other thread, it will
only be able to see the stack pointer when the monitored thread have
reached an idle state, i.e. when it is sleeping in a delay or waiting
for events/messages/... So you will never see the fancy call trees
when it processes any received data.&lt;/p&gt;

&lt;p&gt;
So for an OS that doesn&amp;#39;t has specific support for watermarks, you
instead need a high-priority interrupt running from a reasonably
fast-ticking timer that will check current thread and current stack
pointer value for that thread. Then you will be able to get samples
even when runnable threads are deep into call trees (assumming you
sample often enough and it isn&amp;#39;t too seldom/short time that threads
do deeper call nesting (or maybe not so deep nesting but with
significant local state).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High Water Mark feature in RTX</title><link>https://community.arm.com/thread/82619?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2015 05:34:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:edbb8ab7-aa23-44a4-ae45-dc7dcf88dc6b</guid><dc:creator>Doug Burrell</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Reinhard,&lt;/p&gt;

&lt;p&gt;
I have a thread that I use to monitor all active thread&amp;#39;s current
and maximum stack usage. The monitor thread does this by running a
simple calculation using the thread&amp;#39;s current stack pointer and the
known size of the stack. It also keeps track of the maximum stack
usage it sees for any particular thread. But if this data already
exists in the form of the stack high water mark then I could avoid
these calculations thereby speeding up my monitoring thread. The
monitoring thread runs in the idle state. I should also mention that
whenever the monitor thread sees a thread&amp;#39;s stack usage go over 50%
then we record this in a log we store on an attached EEPROM chip. The
entry in EEPROM tells us what thread exceeded the limit and by how
much. We&amp;#39;ve implemented this monitoring thread as a debugging tool
and so we can fine tune our threads&amp;#39; stack requirements. Like I
mentioned, if the data already exists in the form of the stack high
water mark I would ideally be able to use this data instead of
calculating this myself. This would speed up the monitoring thread
enabling it to catch stack overflows earlier.&lt;/p&gt;

&lt;p&gt;
Thanks,&lt;br /&gt;
Doug&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High Water Mark feature in RTX</title><link>https://community.arm.com/thread/63785?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2015 00:58:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ff2728b0-7985-4179-81aa-5fcbe5c72c14</guid><dc:creator>re yoReinhard Keil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Doug,&lt;/p&gt;

&lt;p&gt;
what is your thread monitoring? The system has in general stack
protection. The Watermark feature allows you to optimize stack usage.
What exactly do you need?&lt;/p&gt;

&lt;p&gt;
Once we understand that we may consider it in future versions.&lt;/p&gt;

&lt;p&gt;
Thanks&lt;br /&gt;
Reinhard&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>