📄 c-shell8.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Shell </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-shell.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-shell7.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-browser.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="89048">6.8 The Shell Architecture</a></i></h3></font><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="89049">6.8.1 Controlling the Target from the Host</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="89050"> </a>Tornado integrates host and target resources so well that it creates the illusion of executing entirely on the target itself. In reality, however, most interactions with any Tornado tool exploit the resources of both host and target. For example, <a href="c-shell8.html#93776">Table 6-17</a> shows how the shell distributes the interpretation and execution of the following simple expression:</p><dl class="margin"><dd><pre class="Code2"><b><a name="89054"></b><tt class="output">-> </tt><b>dir = opendir ("/myDev/myFile") </a></b></pre></dl><dd><p class="Body"><a name="89055"> </a>Parsing the expression is the activity that controls overall execution, and dispatches the other execution activities. This takes place on the host, in the shell's C interpreter, and continues until the entire expression is evaluated and the shell displays its result.</p><dd><p class="Body"><a name="89164"> </a>To avoid repetitive clutter, <a href="c-shell8.html#93776">Table 6-17</a> omits the following important steps, which must be carried out to link the activities in the three contexts (and two systems) shown in each column of the table:</p></dl><dl class="margin"><p class="listspace"><ul class="Dash" type="circle"><li><a name="89165"> </a>After every C-interpreter step, the shell program sends a request to the target server representing the next activity required.</li></ul></p><p class="listspace"><ul class="Dash" type="circle"><li><a name="89166"> </a>The target server receives each such request, and determines whether to execute it in its own context on the host. If not, it passes an equivalent request on to the target agent to execute on the target.<b><p class="table"><h4 class="EntityTitle"><a name="93776"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 6-17: Interpreting: dir = opendir ("/myDev/myFile")</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="93782"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Tornado Shell <br>(on host)</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="93784"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Target Server & Symbol Table <br>(on host)</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="93786"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Agent <br>(on target)</font></b></div></th><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93788"> </a>Parse the string <br><b class="file">"/myDev/myFile"</b>.</div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93790"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93792"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93794"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93796"> </a>Allocate memory for the string; return address <b class="symbol_lc">A</b>.</div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93798"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93800"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93802"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93804"> </a>Write <b class="file">"/myDev/myFile"</b>; return address <b class="symbol_lc">A</b>.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93806"> </a>Parse the name <br><b class="symbol_lc">opendir</b>.</div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93808"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93810"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93812"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93814"> </a>Look up <b class="symbol_lc">opendir</b>; <br>return address <b class="symbol_lc">B</b>.</div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93816"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93818"> </a>Parse the function call <br><b class="symbol_lc">B(A)</b>; wait for the result.</div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93820"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93822"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93824"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93826"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93829"> </a>Spawn a task to run <b class="routine"><i class="routine">opendir</i></b><b>( )</b> and signal result <b class="symbol_lc">C</b> when done.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93831"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93833"> </a>Receive <b class="symbol_lc">C</b> from target agent and pass it to host shell.</div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93835"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93837"> </a>Parse the symbol <b class="symbol_lc">dir</b>. </div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93839"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -