<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Embedded Gurus - Experts on Embedded Software</title>
	<atom:link href="http://embeddedgurus.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://embeddedgurus.com</link>
	<description>Experts on Embedded Software</description>
	<lastBuildDate>Wed, 07 Mar 2012 00:39:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Most Popular Embedded Gurus Blog Posts of 2011</title>
		<link>http://embeddedgurus.com/blog/2012/01/most-popular-embedded-gurus-blog-posts-of-2011/</link>
		<comments>http://embeddedgurus.com/blog/2012/01/most-popular-embedded-gurus-blog-posts-of-2011/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 12:28:41 +0000</pubDate>
		<dc:creator>Michael Barr</dc:creator>
				<category><![CDATA[Coding Standards]]></category>
		<category><![CDATA[Efficient C]]></category>
		<category><![CDATA[Embedded Systems]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/?p=165</guid>
		<description><![CDATA[Below are the top 10 most read blog posts from the Embedded Gurus in 2011. #1: Efficient C Tip #13: Use the Modulus (%) Operator with Caution #2: A Tutorial on Lookup Tables in C #3: Unintended Acceleration and Other Embedded Software Bugs #4: Don&#8217;t Follow These 5 Dangerous Coding Standard Rules #5: Protothreads versus [...]]]></description>
			<content:encoded><![CDATA[<p>Below are the top 10 most read blog posts from the Embedded Gurus in 2011.</p>
<p>#1: <a href="/stack-overflow/2011/02/efficient-c-tip-13-use-the-modulus-operator-with-caution/">Efficient C Tip #13: Use the Modulus (%) Operator with Caution</a></p>
<p>#2: <a href="/stack-overflow/2010/01/a-tutorial-on-lookup-tables-in-c/">A Tutorial on Lookup Tables in C</a></p>
<p>#3: <a href="/barr-code/2011/03/unintended-acceleration-and-other-embedded-software-bugs/">Unintended Acceleration and Other Embedded Software Bugs</a></p>
<p>#4: <a href="/barr-code/2011/08/dont-follow-these-5-dangerous-coding-standard-rules/">Don&#8217;t Follow These 5 Dangerous Coding Standard Rules</a></p>
<p>#5: <a href="/state-space/2011/06/protothreads-versus-state-machines/">Protothreads versus State Machines</a></p>
<p>#6: <a href="/barr-code/2010/11/what-belongs-in-a-c-h-header-file/">What Belongs in a C .h Header File?</a></p>
<p>#7: <a href="/stack-overflow/2009/03/computing-your-stack-size/">Computing Your Stack Size</a></p>
<p>#8: <a href="/barr-code/2011/03/do-inline-function-bodies-belong-in-c-header-files/">Do Inline Function Bodies Belong in C Header Files?</a></p>
<p>#9: <a href="/stack-overflow/2011/03/the-n_elements-macro/">The N_ELEMENTS Macro</a></p>
<p>#10: <a href="/barr-code/2011/06/is-uint16_t-1-portable-c-code/">Is &#8220;(unint16_t) -1&#8243; Portable C Code?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/blog/2012/01/most-popular-embedded-gurus-blog-posts-of-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reduce Energy Use via Power Debugging</title>
		<link>http://embeddedgurus.com/blog/2011/01/power-debugging/</link>
		<comments>http://embeddedgurus.com/blog/2011/01/power-debugging/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 16:17:24 +0000</pubDate>
		<dc:creator>Michael Barr</dc:creator>
				<category><![CDATA[Efficient C]]></category>
		<category><![CDATA[Low Power Design]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/?p=114</guid>
		<description><![CDATA[According a recent study by the European Union, approximately 10% of electricity used in homes and offices is &#8216;vampire power&#8217;. That is to say that even when many products, especially embedded systems, are turned &#8220;off&#8221; they are still consuming power! The same report puts the total amount of energy wasted in this way, within Europe [...]]]></description>
			<content:encoded><![CDATA[<p>According a recent study by the European Union, approximately 10% of electricity used in homes and offices is &#8216;vampire power&#8217;. That is to say that even when many products, especially embedded systems, are turned &#8220;off&#8221; they are still consuming power! The same report puts the total amount of energy wasted in this way, within Europe alone, at dozens of Terawatt hours per year.</p>
<p>Thus developers of all embedded software (not just those designing for battery-powered systems) should take note: A few months back, embedded C/C++ compiler vendor <a href="http://www.iar.com">IAR Systems</a> added a handy and innovative new debugging feature to the <a href="http://www.iar.com/ewarm">Embedded Workbench for ARM</a> (EWARM) IDE.  The new feature is called &#8220;Power Debugging&#8221;.</p>
<p>I&#8217;ve just now finally had a chance to play around with the Power Debugging feature in EWARM 6.  Here&#8217;s the kind of stuff you can do with this powerful new development tool:</p>
<ul>
<li>Capture a timeline graph of current consumption in a window in the debugger&#8211;with no need for an oscilloscope or any other external tool hookup.  (The power debugging feature gets its data from your JTAG interface, which is installed so it powers the target processor.)</li>
<li>Highlight individual datapoints in the power timeline to see how much current was consumed at that point, as well as where the program was at the time.  You can easily jump back and forth between the high-level source code debug window and the power graph!</li>
<li>Sort a list of functions by their average, minimum, or maximum current consumption&#8211;combining the time cost profiling capability already in EWARM with a power cost capability.</li>
</ul>
<p>With this new tool at your disposal, finding the right code to optimize to reduce power consumption is easier than it has ever been.  I applaud IAR for developing this innovative feature as well as for including power debugging free in the price of the EWARM IDE.</p>
<p>If you want to find out more, you could watch the short video overview at <a href="http://www.youtube.com/v/vrMpD3ttgCE">http://www.youtube.com/v/vrMpD3ttgCE</a> or read the white papers, FAQ, and press releases at <a href="http://www.iar.com/power">http://www.iar.com/power</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/blog/2011/01/power-debugging/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Most Popular Embedded Gurus Blog Posts of 2010</title>
		<link>http://embeddedgurus.com/blog/2010/12/most-popular-embedded-gurus-blog-posts-of-2010/</link>
		<comments>http://embeddedgurus.com/blog/2010/12/most-popular-embedded-gurus-blog-posts-of-2010/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 09:44:39 +0000</pubDate>
		<dc:creator>Michael Barr</dc:creator>
				<category><![CDATA[Efficient C]]></category>
		<category><![CDATA[Firmware Bugs]]></category>
		<category><![CDATA[RTOS Multithreading]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/?p=112</guid>
		<description><![CDATA[Below are the top 10 most read blog posts from the Embedded Gurus in 2010. #1: Take the Mutual Exclusion Challenge (Mutexes vs. Semaphores) #2: Toyota&#8217;s Embedded Software Image Problem #3: Setting a Bad Example, Part 1 #4: 3 Things Every Programmer Should Know About RMA #5: A Tutorial on Lookup Tables in C #6: [...]]]></description>
			<content:encoded><![CDATA[<p>Below are the top 10 most read blog posts from the Embedded Gurus in 2010.</p>
<p>#1: <a href="/barr-code/2009/09/take-the-mutual-exclusion-challenge/">Take the Mutual Exclusion Challenge (Mutexes vs. Semaphores)</a></p>
<p>#2: <a href="/barr-code/2010/03/toyotas-embedded-software-image-problem/">Toyota&#8217;s Embedded Software Image Problem</a></p>
<p>#3: <a href="/stack-overflow/2010/08/setting-a-bad-example-part-1/">Setting a Bad Example, Part 1</a></p>
<p>#4: <a href="/blog/2010/08/3-things-every-programmer-should-know-about-rma/">3 Things Every Programmer Should Know About RMA</a></p>
<p>#5: <a href="/stack-overflow/2010/01/a-tutorial-on-lookup-tables-in-c/">A Tutorial on Lookup Tables in C</a></p>
<p>#6: <a href="/stack-overflow/2010/04/efficient-c-tip-12-be-wary-of-switch-statements/">Efficient C Tip #12: Be Wary of Switch Statements</a></p>
<p>#7: <a href="/blog/2010/12/top-10-causes-of-nasty-firmware-bugs/">Top 10 Causes of Nasty Firmware Bugs</a></p>
<p>#8: <a href="/stack-overflow/2010/02/efficient-c-tip-11-avoid-passing-parameters-by-using-more-small-functions/">Efficient C Tip #11: Avoid Passing Parameters by Using More Small Functions</a></p>
<p>#9: <a href="/stack-overflow/2009/03/computing-your-stack-size/">Computing Your Stack Size</a></p>
<p>#10: <a href="/barr-code/2010/02/firmware-specific-bug-1-race-condition/">Firmware-Specific Bug #1: Race Condition</a></p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/blog/2010/12/most-popular-embedded-gurus-blog-posts-of-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 10 Causes of Nasty Firmware Bugs</title>
		<link>http://embeddedgurus.com/blog/2010/12/top-10-causes-of-nasty-firmware-bugs/</link>
		<comments>http://embeddedgurus.com/blog/2010/12/top-10-causes-of-nasty-firmware-bugs/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 16:53:54 +0000</pubDate>
		<dc:creator>Michael Barr</dc:creator>
				<category><![CDATA[Firmware Bugs]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/?p=110</guid>
		<description><![CDATA[Finding and killing latent bugs in embedded software is a difficult business. Heroic efforts and expensive tools are often required to trace backward from an observed crash, hang, or other unplanned run-time behavior to the root cause. In the worst case scenario, the root cause damages the code or data in a subtle way such [...]]]></description>
			<content:encoded><![CDATA[<p>Finding and killing latent bugs in embedded software is a difficult business. Heroic efforts and expensive tools are often required to trace backward from an observed crash, hang, or other unplanned run-time behavior to the root cause. In the worst case scenario, the root cause damages the code or data in a subtle way such that the system still <em>appears</em> to work fine or mostly fine&#8211;at least for a while.</p>
<p>Too often engineers give up trying to discover the cause of infrequent anomalies that cannot be easily reproduced in the lab&#8211;frequently dismissing them as &#8220;user errors&#8221; or &#8220;glitches.&#8221; Yet these ghosts in the machine live on. </p>
<p>So here&#8217;s a guide to the most frequent root causes of difficult-to-reproduce bugs. </p>
<p>#10: <a href="/barr-code/2010/12/firmware-specific-bug-10-jitter/">Jitter</a></p>
<p>#9: <a href="/barr-code/2010/11/firmware-specific-bug-9-incorrect-priority-assignment/">Incorrect Priority Assignment</a></p>
<p>#8: <a href="/barr-code/2010/11/firmware-specific-bug-8-priority-inversion/">Priority Inversion</a></p>
<p>#7: <a href="/barr-code/2010/11/firmware-specific-bug-7-deadlock/">Deadlock</a></p>
<p>#6: <a href="/barr-code/2010/11/firmware-specific-bug-6-memory-leak/">Memory Leak</a></p>
<p>#5: <a href="/barr-code/2010/03/firmware-specific-bug-5-heap-fragmentation/">Heap Fragmentation</a></p>
<p>#4: <a href="/barr-code/2010/03/firmware-specific-bug-4-stack-overflow/">Stack Overflow</a></p>
<p>#3: <a href="/barr-code/2010/02/firmware-specific-bug-3-missing-volatile-keyword/">Missing volatile Keyword</a></p>
<p>#2: <a href="/barr-code/2010/02/firmware-specific-bug-2-non-reentrant-function/">Non-Reentrant Function</a></p>
<p>#1: <a href="/barr-code/2010/02/firmware-specific-bug-1-race-condition/">Race Condition</a></p>
<p>Keep an eye out for all of these Top 10 Firmware Bugs whenever you are reviewing source code. And be sure to follow the recommended best practices to prevent them from happening to you again.</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/blog/2010/12/top-10-causes-of-nasty-firmware-bugs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Most Popular Embedded Gurus Blog Posts of 2009</title>
		<link>http://embeddedgurus.com/blog/2010/11/most-popular-embeddedgurus-blog-posts-of-2009/</link>
		<comments>http://embeddedgurus.com/blog/2010/11/most-popular-embeddedgurus-blog-posts-of-2009/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 19:53:26 +0000</pubDate>
		<dc:creator>Michael Barr</dc:creator>
				<category><![CDATA[Efficient C]]></category>
		<category><![CDATA[Firmware Bugs]]></category>
		<category><![CDATA[RTOS Multithreading]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/?p=104</guid>
		<description><![CDATA[The top 10 most read blog posts from the Embedded Gurus in 2009.]]></description>
			<content:encoded><![CDATA[<p>Below are the top 10 most read blog posts from the Embedded Gurus in 2009.</p>
<p>#1: <a href="/stack-overflow/2009/03/sorting-in-embedded-systems/">Sorting (in) Embedded Systems</a></p>
<p>#2: <a href="/stack-overflow/2009/02/electrical-engineers-versus-computer-scientists/">Electrical Engineers vs. Computer Scientists</a></p>
<p>#3: <a href="/barr-code/2009/09/binary-literals-in-c/">Binary Literals in C</a></p>
<p>#4: <a href="/barr-code/2009/09/robust-embedded-software-architecture-in-5-easy-steps/">Robust Embedded Software Architecture in 5 Easy Steps</a></p>
<p>#5: <a href="/stack-overflow/2007/06/understanding-stack-overflow/">Understanding Stack Overflow</a></p>
<p>#6: <a href="/stack-overflow/2009/05/signed-versus-unsigned-integers/">Signed vs. Unsigned Integers</a></p>
<p>#7: <a href="/stack-overflow/2009/03/computing-your-stack-size/">Computing Your Stack Size</a></p>
<p>#8: <a href="/stack-overflow/2008/06/efficient-c-tips-1-choosing-the-correct-integer-size/">Efficient C Tips #1: Choosing the Correct Integer Size</a></p>
<p>#9: <a href="/barr-code/2009/11/embedded-programmers-worldwide-earn-failing-grades-in-c-and-c/">Embedded Programmers Worldwide Earn Failing Grades in C and C++</a></p>
<p>#10: <a href="/stack-overflow/2009/04/pic-stack-overflow/">PIC Stack Overflow</a></p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/blog/2010/11/most-popular-embeddedgurus-blog-posts-of-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3 Things Every Programmer Should Know About RMA</title>
		<link>http://embeddedgurus.com/blog/2010/08/3-things-every-programmer-should-know-about-rma/</link>
		<comments>http://embeddedgurus.com/blog/2010/08/3-things-every-programmer-should-know-about-rma/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 11:19:28 +0000</pubDate>
		<dc:creator>Michael Barr</dc:creator>
				<category><![CDATA[Embedded Systems]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/?p=101</guid>
		<description><![CDATA[Real-time systems design and RMA go together like peanut butter and jelly.  So why is it that wherever I go in the embedded community, engineers are developing real-time systems without applying RMA?  This is a dangerous situation, but one that is easily remedied by ensuring every programmer knows three things about RMA. In case you [...]]]></description>
			<content:encoded><![CDATA[<p><em>Real-time systems design and RMA go together like peanut butter and jelly.  So why is it that wherever I go in the embedded community, engineers are developing real-time systems without applying RMA?  This is a dangerous situation, but one that is easily remedied by ensuring every programmer knows three things about RMA.</em></p>
<p>In case you are entirely unfamiliar with RMA, there&#8217;s a handy primer on the technique at <a href="http://www.netrino.com/Embedded-Systems/How-To/RMA-Rate-Monotonic-Algorithm/" target="_blank">http://www.netrino.com/Embedded-Systems/How-To/RMA-Rate-Monotonic-Algorithm/</a>. I’ve tried to write this blog post in a way that you can read that before or after, at your option.</p>
<p style="text-align: left"><strong>#1: RMA is Not Just for Academics</strong></p>
<p style="text-align: left">You have probably heard of RMA.  Maybe you can even expand the acronym.   Maybe you also know that the theoretical underpinnings of RMA were developed largely at <a href="http://www.sei.cmu.edu">Carnegie Mellon University’s Software Engineering Institute</a> and/or that the technique has been known for about three decades.</p>
<p style="text-align: left">If, however, you are like the vast majority of the thousands of firmware engineers I have communicated with on the subject during my years as a writer/editor, consultant, and trainer, you probably think RMA is just for academics.  I also thought that way years ago—but here’s the straight dope:</p>
<ul style="text-align: left">
<li>All of the popular commercial real-time operating systems (e.g., <a href="http://www.windriver.com/products/vxworks/">VxWorks</a>, <a href="http://www.rtos.com/page/product.php?id=2">ThreadX</a>, and <a href="http://micrium.com/page/products/rtos">MicroC/OS</a>) are built upon fixed-priority preemptive schedulers.<a href="#_ftn1">[1]</a></li>
<li>RMA is the optimal method of assigning fixed priorities to RTOS tasks.  That is to say that if a set of tasks cannot be scheduled using RMA, it can’t be scheduled using any fixed-priority algorithm.</li>
<li>RMA provides convenient rules of thumb regarding the percentage of CPU you can safely use while still meeting all deadlines.  If you don’t use RMA to assign priorities to your tasks, there is no rule of thumb that will ensure all of their deadlines will be met.<a href="#_ftn2">[2]</a></li>
</ul>
<p style="text-align: left">A key feature of RMA is the ability to prove <em>a priori</em> that a given set of tasks will always meet its deadlines—even during periods of transient overload.  Dynamic-priority operating systems cannot make this guarantee.  Nor can fixed-priority RTOSes running tasks prioritized in other ways.</p>
<p style="text-align: left">Too many of today&#8217;s real-time systems built with an RTOS are working by luck. Excess processing power may be masking design and analysis sins or the worst-case just hasn’t happened—yet.</p>
<p style="text-align: left"><em>Bottom line</em>: You’re playing with fire if you don’t use RMA to assign priorities to critical tasks; it might be just a matter of time before your product’s users get burned.<a href="#_ftn3">[3]</a></p>
<p style="text-align: left"><strong>#2: RMA Need Not Be Applied to Every Task</strong></p>
<p style="text-align: left"><strong> </strong></p>
<p style="text-align: left">As any programmer that’s already put RMA into practice will tell you, the hardest part of the analysis phase is establishing an upper bound for the worst-case execution time of each task. The CPU utilization of each task is computed as the ratio of its worst-case execution time to its worst-case period. <a href="#_ftn4">[4]</a></p>
<p style="text-align: left">There are three ways to place an upper bound on execution time: (1) by measuring the actual execution time during the tested worst-case scenario; (2) by performing a top-down analysis of the code in combination with a cycle-counter; or (3) by making an educated guess based on big-O notation.  I call these alternatives measuring, analyzing, and budgeting, respectively, and note that the decision of which to use involves tradeoffs of precision vs. level of effort. Measurement can be extremely precise, but requires the ability to instrument and test the actual working code—which must be remeasured after every code change.  Budgeting is easiest and can be performed even at the beginning of the project, but it is necessarily imprecise (in the conservative direction of requiring more CPU bandwidth than is actually required).</p>
<p style="text-align: left"><strong> </strong></p>
<p style="text-align: left">But there is at least some good news about the analysis.  RMA need not be performed across the entire set of tasks in the system.  It is possible to define a smaller (often much smaller, in my experience) critical set of tasks on which RMA needs to be performed, with the remaining non-critical tasks simply assigned lower priorities.</p>
<p style="text-align: left">This critical set of tasks should contain all of the tasks with deadlines that can’t be missed or else.  In addition, it should contain any other tasks the former set either share mutexes with or from which they require timely semaphore or message queue posts.  Every other task is considered non-critical.</p>
<p style="text-align: left">RMA can be meaningfully applied to the critical set tasks only, so long as we ensure that all of the non-critical tasks have priorities below the entire critical set.  We then need only determine worst-case periods and worst-case execution times for the critical set.  Furthermore, we need only follow the rate monotonic algorithm for assignment of priorities within the critical set.</p>
<p style="text-align: left"><em>Bottom line</em>: Anything goes at lower priorities where there are no deadlines.</p>
<p style="text-align: left"><strong> </strong></p>
<p style="text-align: left"><strong>#3: RMA Applies to Interrupt Service Routines Too</strong></p>
<p style="text-align: left"><strong> </strong></p>
<p style="text-align: left">With few exceptions, books, articles, and papers that mention RMA describe it as a technique for prioritizing the tasks on a preemptive fixed-priority operating system.  But the technique is also essential for correctly prioritizing interrupt handlers.</p>
<p style="text-align: left">Indeed, even if you have designed a real-time system that consists only of interrupt service routines (plus a do-nothing background loop in main), you should use the rate monotonic algorithm to prioritize them with respect to their worst-case frequency of occurrence.  Then you can use rate monotonic analysis to prove that they will all meet their real-time deadlines even during transient overload.</p>
<p style="text-align: left">Furthermore, if you have a set of critical tasks in addition to interrupt service routines the prioritization and analysis associated with RMA need to be performed across the entire set of those entities.<a href="#_ftn5">[5]</a> This can be complicated, as there is an arbitrary “priority boundary” imposed by the CPU hardware: even the lowest priority ISR is deemed more important than the highest priority task.</p>
<p style="text-align: left">For example, consider the conflict in the set of ISRs and tasks in Table 1.  RMA dictates that the priority of Task A should be higher than the priority of the ISR, because Task A can occur more frequently.  But the hardware demands otherwise, by limiting our ability to move ISRs down in priority.  If we leave things as they are, we cannot simply sum the CPU utilization of this set of entities to see if they are below the schedulable bound for four entities.</p>
<table style="text-align: left" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="89" valign="top">
<p style="text-align: center"><strong>Runnable   Entity</strong></p>
</td>
<td width="83" valign="top">
<p style="text-align: center"><strong>Priority   by RMA</strong></p>
</td>
<td width="99" valign="top">
<p style="text-align: center"><strong>Worst-Case   Execution Time</strong></p>
</td>
<td width="90" valign="top">
<p style="text-align: center"><strong>Worst-Case   Period</strong></p>
</td>
<td width="82" valign="top">
<p style="text-align: center"><strong>CPU Utilization</strong></p>
</td>
</tr>
<tr>
<td width="89" valign="top">
<p style="text-align: center"><strong>ISR</strong></p>
</td>
<td width="83" valign="top">
<p style="text-align: center">2</p>
</td>
<td width="99" valign="top">
<p style="text-align: center">500 us</p>
</td>
<td width="90" valign="top">
<p style="text-align: center">10 ms</p>
</td>
<td width="82" valign="top">
<p style="text-align: center">5%</p>
</td>
</tr>
<tr>
<td width="89" valign="top">
<p style="text-align: center"><strong>Task A</strong></p>
</td>
<td width="83" valign="top">
<p style="text-align: center">1</p>
</td>
<td width="99" valign="top">
<p style="text-align: center">750 us</p>
</td>
<td width="90" valign="top">
<p style="text-align: center">3 ms</p>
</td>
<td width="82" valign="top">
<p style="text-align: center">25%</p>
</td>
</tr>
<tr>
<td width="89" valign="top">
<p style="text-align: center"><strong>Task C</strong></p>
</td>
<td width="83" valign="top">
<p style="text-align: center">3</p>
</td>
<td width="99" valign="top">
<p style="text-align: center">300 us</p>
</td>
<td width="90" valign="top">
<p style="text-align: center">30 ms</p>
</td>
<td width="82" valign="top">
<p style="text-align: center">1%</p>
</td>
</tr>
<tr>
<td width="89" valign="top">
<p style="text-align: center"><strong>Task B</strong></p>
</td>
<td width="83" valign="top">
<p style="text-align: center">4</p>
</td>
<td width="99" valign="top">
<p style="text-align: center">8 ms</p>
</td>
<td width="90" valign="top">
<p style="text-align: center">40 ms</p>
</td>
<td width="82" valign="top">
<p style="text-align: center">20%</p>
</td>
</tr>
</tbody>
</table>
<p style="text-align: center"><em>Table 1.  A Misprioritized Interrupt Handler</em></p>
<p style="text-align: left"><em> </em></p>
<p style="text-align: left">So what should we do in a conflicted scenario like this?  There are two options.  Either we change the program’s structure, by moving the ISR code into a polling loop that operates as a 10 ms task at priority 2—in which case total utilization is 51%.  Or we treat the ISR, for purposes of proof via rate monotonic analysis anyway, as though it actually has a worst-case period of 3 ms.  In the latter option, the ISR has an appropriate top priority by RMA but the CPU bandwidth dedicated to the ISR increases from 5% to 16.7%&#8211;bringing the new total up to 62.7%  Either way, the full set is provably schedulable.<a href="#_ftn6">[6]</a></p>
<p style="text-align: left"><em>Bottom line</em>: Interrupt handlers must be considered part of the critical set, with RMA used to prioritize them in relation to the tasks they might steal the CPU away from.</p>
<p style="text-align: left"><strong> </strong></p>
<p style="text-align: left"><strong>Conclusion</strong></p>
<p style="text-align: left"><strong> </strong></p>
<p style="text-align: left">Every programmer should know three key things about RMA.  First, RMA is a technique that should be used to analyze any preemptive system with deadlines; it is not just for academics after all.  Second, the amount of effort involved in RMA analysis can be reduced by ignoring tasks outside the critical set; non-critical tasks can be assigned an arbitrary pattern of lower priorities and need not be analyzed.  Finally, if interrupts can preempt critical set tasks or even just each other, RMA should be used to analyze those too.</p>
<hr size="1" />
<p style="text-align: left"><a href="#_ftnref">[1]</a> Schedulers that tweak task priorities dynamically, as desktop flavors of Windows and Linux do, may miss deadlines indiscriminately during transient overload periods.   They should thus not be used in the design of safety-critical real-time systems.</p>
<p style="text-align: left"><a href="#_ftnref">[2]</a> For example, it is widely rumored that a system less than 50% loaded will always meet its deadlines.  Unfortunately, there is no such rule of thumb that’s correct.  By contrast, when you do use RMA there is a simple rule of thumb ranging from a high of 82.8% for 2 tasks to a low of 69.2% for N tasks.</p>
<p style="text-align: left"><a href="#_ftnref">[3]</a> Perhaps your failure to use RMA to prioritize tasks and prove they’ll meet deadlines explains one or more of those “glitches” your customers have been complaining about?</p>
<p style="text-align: left"><a href="#_ftnref">[4]</a> Establishing the worst-case period of a task is both easier and more stable.</p>
<p style="text-align: left"><a href="#_ftnref">[5]</a> Note this is necessary even if one or more of the interrupts doesn’t have a real-time deadline of its own.  That’s because the interrupts may occur during the transient overload and thus prevent one or more critical set tasks from meeting its real-time deadline.</p>
<p style="text-align: left"><a href="#_ftnref">[6]</a> However, switching the code to use polling actually consumes cycles that are only reserved for the worst-case in the other solution.  That could mean failing to find CPU time for low priority non-critical tasks in the average case.</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/blog/2010/08/3-things-every-programmer-should-know-about-rma/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

