📄 c-browser14.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Browser </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="GuideIX.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-browser.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-browser13.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-browser15.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="84609">7.14 Troubleshooting with the Browser</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84611"> </a>Many problem conditions in target applications become much clearer with the browser's visual feedback on the state of tasks and critical objects in the target. The examples in this section illustrate some of the possibilities.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84612">7.14.1 Memory Leaks</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84614"> </a>The memory-consumption bar graphs in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Memory Usage</font></b> window makes memory leaks easy to notice. If the allocated portion of memory grows continually, you have a problem. The memory-consumption graph in <a href="c-browser14.html#84626">Figure 7-20</a> indicates a memory leak in an application that has run long enough to exhaust memory almost completely.<div class="frame"><h4 class="EntityTitle"><a name="84626"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 7-20: A Memory Leak as Seen in the Browser</font></a></h4><dl class="margin"><div class="Anchor"><a name="84623"> </a><img class="figure" border="0" src="images/c-browser32.gif"></div></dl></div></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84627">7.14.2 Memory Fragmentation</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84629"> </a>A more subtle memory-management problem occurs when small blocks of memory that are not freed for long periods are allocated interleaved with moderate-sized blocks of memory that are freed more frequently: memory can become fragmented, because the calls to <b class="routine"><i class="routine">free</i></b><b>( )</b> for the large blocks cannot coalesce the free memory back into a single large available-memory pool. This problem is easily observed by examining the affected memory partition (in many applications this is the VxWorks system memory partition, <b class="symbol_lc">memSysPartId</b>) with the browser. <a href="c-browser14.html#84644">Figure 7-21</a> shows an example of a growing free-list with many small blocks, characteristic of memory fragmentation.<div class="frame"><h4 class="EntityTitle"><a name="84644"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 7-21: Fragmented Memory as Seen in the Browser</font></a></h4><dl class="margin"><div class="Anchor"><a name="84641"> </a><img class="figure" border="0" src="images/c-browser33.gif"></div></dl></div></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84645">7.14.3 Stack Overflow</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84647"> </a>When a task exceeds its stack size, the resulting problem is often hard to trace, because the initial symptom may be in some other task altogether. The browser's stack-check window is useful when faced with behavior that is hard to explain: if the problem is a stack overflow, you can spot it immediately (<a href="c-browser14.html#84659">Figure 7-22</a>).<div class="frame"><h4 class="EntityTitle"><a name="84659"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 7-22: Stack Overflow on Task u9</font></a></h4><dl class="margin"><div class="Anchor"><a name="84656"> </a><img class="figure" border="0" src="images/c-browser34.gif"></div></dl></div></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84662">7.14.4 Priority Inversion</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84664"> </a>Browser displays are most useful when they complement each other. For example, suppose you notice in a task-list window (as in <a href="c-browser14.html#84676">Figure 7-23</a>) that a task <b class="task">uHi</b>, expected to be high priority, is blocked while two other tasks are ready to run.<div class="frame"><h4 class="EntityTitle"><a name="84676"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 7-23: Browser: uHi Pended</font></a></h4><dl class="margin"><div class="Anchor"><a name="84673"> </a><img class="figure" border="0" src="images/c-browser35.gif"></div></dl></div></p><dd><p class="Body"><a name="84677"> </a>An immediate thing to check is whether the three tasks really have the expected priority relationship (in this example, the names are chosen to suggest the intended priorities: <b class="task">uHi</b> is supposed to have highest priority, <b class="task">uMed</b> medium priority, and <b class="task">uLow</b> the lowest). You can check this immediately by clicking on each task's summary line, thus bringing up the windows shown in <a href="c-browser14.html#84691">Figure 7-24</a>. <div class="frame"><h4 class="EntityTitle"><a name="84691"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 7-24: Task Browsers for uHi, uMed, uLow</font></a></h4><dl class="margin"><div class="Anchor"><a name="84688"> </a><img class="figure" border="0" src="images/c-browser36.gif"></div></dl></div></p><dd><p class="Body"><a name="84692"> </a>Unfortunately, that turns out to be the wrong explanation; the priorities (shown for each task under <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Attributes</font></b>) are indeed as expected. Examining the CPU allocations with the spy window (<a href="c-browser14.html#84704">Figure 7-25</a>) reveals that the observed situation is ongoing; <b class="task">uMed</b> is monopolizing the target CPU. It should certainly execute by preference to the low-priority <b class="task">uLow</b>, but why is <b class="task">uHi</b> not getting to run?<div class="frame"><h4 class="EntityTitle"><a name="84704"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 7-25: uMed Monopolizing CPU (Spy Window Excerpt)</font></a></h4><dl class="margin"><div class="Anchor"><a name="84701"> </a><img class="figure" border="0" src="images/c-browser37.gif"></div></dl></div></p><dd><p class="Body"><a name="84705"> </a>At this point examining the code (not shown) may seem worthwhile. Doing so, you notice that <b class="task">uMed</b> uses no shared resources, but <b class="task">uHi</b> and <b class="task">uLow</b> synchronize their work with a semaphore. Could that be the problem?</p><dd><p class="Body"><a name="84709"> </a>Examining the semaphore with the browser (<a href="c-browser14.html#84719">Figure 7-26</a>) confirms this suspicion: <b class="command">uHi</b> is blocking on the semaphore, which <b class="command">uLow</b> cannot release because <b class="command">uMed</b> has preempted it.<div class="frame"><h4 class="EntityTitle"><a name="84719"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 7-26: uHi Blocked on Semaphore</font></a></h4><dl class="margin"><div class="Anchor"><a name="84715"> </a><img class="figure" border="0" src="images/c-browser38.gif"></div></dl></div></p><dd><p class="Body"><a name="84720"> </a>Having diagnosed the problem as a classic priority inversion, the fix is straightforward. As described in <i class="title">VxWorks Programmer's Guide: Basic OS</i>, you can revise the application to synchronize <b class="task">uLow</b> and <b class="task">uHi</b> with a mutual-exclusion semaphore created with the <b class="symbol_UC">SEM_INVERSION_SAFE</b> option.</p></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="GuideIX.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-browser.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-browser13.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-browser15.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc. conversion tool: Quadralay WebWorks Publisher 4.0.11 template: CSS Template, Jan 1998 - Jefro --->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -