Commits

Maciej Fijalkowski committed 585c7b3

more stuff

  • Participants
  • Parent commits c9ce8d5

Comments (0)

Files changed (2)

File codeviewer/x.html

+<html>
+<head>
+   <script type="text/javascript" src="jquery.min.js"></script>
+   <script type="text/javascript" src="jquery.scrollTo-1.4.2-min.js"></script>
+   <script type="text/javascript" src="jquery.viewport.mini.js"></script>
+   <script type="text/javascript" src="x.js"></script>
+   <link rel="stylesheet" href="pygments.css">
+   <link rel="stylesheet" href="x.css">
+</head>
+<body>
+  <div class="main-source">
+  <div class="highlight"><pre><div id="w-1" class="wrapper"><span class="line" id="1"><span class="c"># based on a Java version:</span>
+</span></div><div id="w-2" class="wrapper"><span class="line" id="2"><span class="c">#  Based on original version written in BCPL by Dr Martin Richards</span>
+</span></div><div id="w-3" class="wrapper"><span class="line" id="3"><span class="c">#  in 1981 at Cambridge University Computer Laboratory, England</span>
+</span></div><div id="w-4" class="wrapper"><span class="line" id="4"><span class="c">#  and a C++ version derived from a Smalltalk version written by</span>
+</span></div><div id="w-5" class="wrapper"><span class="line" id="5"><span class="c">#  L Peter Deutsch.</span>
+</span></div><div id="w-6" class="wrapper"><span class="line" id="6"><span class="c">#  Java version:  Copyright (C) 1995 Sun Microsystems, Inc.</span>
+</span></div><div id="w-7" class="wrapper"><span class="line" id="7"><span class="c">#  Translation from C++, Mario Wolczko</span>
+</span></div><div id="w-8" class="wrapper"><span class="line" id="8"><span class="c">#  Outer loop added by Alex Jacoby</span>
+</span></div><div id="w-9" class="wrapper"><span class="line" id="9">
+</span></div><div id="w-10" class="wrapper"><span class="line" id="10"><span class="c"># Task IDs</span>
+</span></div><div id="w-11" class="wrapper"><span class="line" id="11"><span class="n">I_IDLE</span> <span class="o">=</span> <span class="mi">1</span>
+</span></div><div id="w-12" class="wrapper"><span class="line" id="12"><span class="n">I_WORK</span> <span class="o">=</span> <span class="mi">2</span>
+</span></div><div id="w-13" class="wrapper"><span class="line" id="13"><span class="n">I_HANDLERA</span> <span class="o">=</span> <span class="mi">3</span>
+</span></div><div id="w-14" class="wrapper"><span class="line" id="14"><span class="n">I_HANDLERB</span> <span class="o">=</span> <span class="mi">4</span>
+</span></div><div id="w-15" class="wrapper"><span class="line" id="15"><span class="n">I_DEVA</span> <span class="o">=</span> <span class="mi">5</span>
+</span></div><div id="w-16" class="wrapper"><span class="line" id="16"><span class="n">I_DEVB</span> <span class="o">=</span> <span class="mi">6</span>
+</span></div><div id="w-17" class="wrapper"><span class="line" id="17">
+</span></div><div id="w-18" class="wrapper"><span class="line" id="18"><span class="c"># Packet types</span>
+</span></div><div id="w-19" class="wrapper"><span class="line" id="19"><span class="n">K_DEV</span> <span class="o">=</span> <span class="mi">1000</span>
+</span></div><div id="w-20" class="wrapper"><span class="line" id="20"><span class="n">K_WORK</span> <span class="o">=</span> <span class="mi">1001</span>
+</span></div><div id="w-21" class="wrapper"><span class="line" id="21">
+</span></div><div id="w-22" class="wrapper"><span class="line" id="22"><span class="c"># Packet</span>
+</span></div><div id="w-23" class="wrapper"><span class="line" id="23">
+</span></div><div id="w-24" class="wrapper"><span class="line" id="24"><span class="n">BUFSIZE</span> <span class="o">=</span> <span class="mi">4</span>
+</span></div><div id="w-25" class="wrapper"><span class="line" id="25">
+</span></div><div id="w-26" class="wrapper"><span class="line" id="26"><span class="n">BUFSIZE_RANGE</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="n">BUFSIZE</span><span class="p">)</span>
+</span></div><div id="w-27" class="wrapper"><span class="line" id="27">
+</span></div><div id="w-28" class="wrapper"><span class="line" id="28"><span class="k">class</span> <span class="nc">Packet</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+</span></div><div id="w-29" class="wrapper"><span class="line" id="29">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">l</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">k</span><span class="p">):</span>
+</span></div><div id="w-30" class="wrapper"><span class="line" id="30">        <span class="bp">self</span><span class="o">.</span><span class="n">link</span> <span class="o">=</span> <span class="n">l</span>
+</span></div><div id="w-31" class="wrapper"><span class="line" id="31">        <span class="bp">self</span><span class="o">.</span><span class="n">ident</span> <span class="o">=</span> <span class="n">i</span>
+</span></div><div id="w-32" class="wrapper"><span class="line" id="32">        <span class="bp">self</span><span class="o">.</span><span class="n">kind</span> <span class="o">=</span> <span class="n">k</span>
+</span></div><div id="w-33" class="wrapper"><span class="line" id="33">        <span class="bp">self</span><span class="o">.</span><span class="n">datum</span> <span class="o">=</span> <span class="mi">0</span>
+</span></div><div id="w-34" class="wrapper"><span class="line" id="34">        <span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">BUFSIZE</span>
+</span></div><div id="w-35" class="wrapper"><span class="line" id="35">
+</span></div><div id="w-36" class="wrapper"><span class="line" id="36">    <span class="k">def</span> <span class="nf">append_to</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">lst</span><span class="p">):</span>
+</span></div><div id="w-37" class="wrapper"><span class="line" id="37">        <span class="bp">self</span><span class="o">.</span><span class="n">link</span> <span class="o">=</span> <span class="bp">None</span>
+</span></div><div id="w-38" class="wrapper"><span class="line" id="38">        <span class="k">if</span> <span class="n">lst</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-39" class="wrapper"><span class="line" id="39">            <span class="k">return</span> <span class="bp">self</span>
+</span></div><div id="w-40" class="wrapper"><span class="line" id="40">        <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-41" class="wrapper"><span class="line" id="41">            <span class="n">p</span> <span class="o">=</span> <span class="n">lst</span>
+</span></div><div id="w-42" class="wrapper"><span class="line" id="42">            <span class="nb">next</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">link</span>
+</span></div><div id="w-43" class="wrapper"><span class="line" id="43">            <span class="k">while</span> <span class="nb">next</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-44" class="wrapper"><span class="line" id="44">                <span class="n">p</span> <span class="o">=</span> <span class="nb">next</span>
+</span></div><div id="w-45" class="wrapper"><span class="line" id="45">                <span class="nb">next</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">link</span>
+</span></div><div id="w-46" class="wrapper"><span class="line" id="46">            <span class="n">p</span><span class="o">.</span><span class="n">link</span> <span class="o">=</span> <span class="bp">self</span>
+</span></div><div id="w-47" class="wrapper"><span class="line" id="47">            <span class="k">return</span> <span class="n">lst</span>
+</span></div><div id="w-48" class="wrapper"><span class="line" id="48">
+</span></div><div id="w-49" class="wrapper"><span class="line" id="49"><span class="c"># Task Records</span>
+</span></div><div id="w-50" class="wrapper"><span class="line" id="50">
+</span></div><div id="w-51" class="wrapper"><span class="line" id="51"><span class="k">class</span> <span class="nc">TaskRec</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+</span></div><div id="w-52" class="wrapper"><span class="line" id="52">    <span class="k">pass</span>
+</span></div><div id="w-53" class="wrapper"><span class="line" id="53">
+</span></div><div id="w-54" class="wrapper"><span class="line" id="54"><span class="k">class</span> <span class="nc">DeviceTaskRec</span><span class="p">(</span><span class="n">TaskRec</span><span class="p">):</span>
+</span></div><div id="w-55" class="wrapper"><span class="line" id="55">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-56" class="wrapper"><span class="line" id="56">        <span class="bp">self</span><span class="o">.</span><span class="n">pending</span> <span class="o">=</span> <span class="bp">None</span>
+</span></div><div id="w-57" class="wrapper"><span class="line" id="57">
+</span></div><div id="w-58" class="wrapper"><span class="line" id="58"><span class="k">class</span> <span class="nc">IdleTaskRec</span><span class="p">(</span><span class="n">TaskRec</span><span class="p">):</span>
+</span></div><div id="w-59" class="wrapper"><span class="line" id="59">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-60" class="wrapper"><span class="line" id="60">        <span class="bp">self</span><span class="o">.</span><span class="n">control</span> <span class="o">=</span> <span class="mi">1</span>
+</span></div><div id="w-61" class="wrapper"><span class="line" id="61">        <span class="bp">self</span><span class="o">.</span><span class="n">count</span> <span class="o">=</span> <span class="mi">10000</span>
+</span></div><div id="w-62" class="wrapper"><span class="line" id="62">
+</span></div><div id="w-63" class="wrapper"><span class="line" id="63"><span class="k">class</span> <span class="nc">HandlerTaskRec</span><span class="p">(</span><span class="n">TaskRec</span><span class="p">):</span>
+</span></div><div id="w-64" class="wrapper"><span class="line" id="64">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-65" class="wrapper"><span class="line" id="65">        <span class="bp">self</span><span class="o">.</span><span class="n">work_in</span> <span class="o">=</span> <span class="bp">None</span>
+</span></div><div id="w-66" class="wrapper"><span class="line" id="66">        <span class="bp">self</span><span class="o">.</span><span class="n">device_in</span> <span class="o">=</span> <span class="bp">None</span>
+</span></div><div id="w-67" class="wrapper"><span class="line" id="67">
+</span></div><div id="w-68" class="wrapper"><span class="line" id="68">    <span class="k">def</span> <span class="nf">workInAdd</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">p</span><span class="p">):</span>
+</span></div><div id="w-69" class="wrapper"><span class="line" id="69">        <span class="bp">self</span><span class="o">.</span><span class="n">work_in</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">append_to</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">work_in</span><span class="p">)</span>
+</span></div><div id="w-70" class="wrapper"><span class="line" id="70">        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">work_in</span>
+</span></div><div id="w-71" class="wrapper"><span class="line" id="71">
+</span></div><div id="w-72" class="wrapper"><span class="line" id="72">    <span class="k">def</span> <span class="nf">deviceInAdd</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">p</span><span class="p">):</span>
+</span></div><div id="w-73" class="wrapper"><span class="line" id="73">        <span class="bp">self</span><span class="o">.</span><span class="n">device_in</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">append_to</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">device_in</span><span class="p">)</span>
+</span></div><div id="w-74" class="wrapper"><span class="line" id="74">        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">device_in</span>
+</span></div><div id="w-75" class="wrapper"><span class="line" id="75">
+</span></div><div id="w-76" class="wrapper"><span class="line" id="76"><span class="k">class</span> <span class="nc">WorkerTaskRec</span><span class="p">(</span><span class="n">TaskRec</span><span class="p">):</span>
+</span></div><div id="w-77" class="wrapper"><span class="line" id="77">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-78" class="wrapper"><span class="line" id="78">        <span class="bp">self</span><span class="o">.</span><span class="n">destination</span> <span class="o">=</span> <span class="n">I_HANDLERA</span>
+</span></div><div id="w-79" class="wrapper"><span class="line" id="79">        <span class="bp">self</span><span class="o">.</span><span class="n">count</span> <span class="o">=</span> <span class="mi">0</span>
+</span></div><div id="w-80" class="wrapper"><span class="line" id="80"><span class="c"># Task</span>
+</span></div><div id="w-81" class="wrapper"><span class="line" id="81">
+</span></div><div id="w-82" class="wrapper"><span class="line" id="82"><span class="k">class</span> <span class="nc">TaskState</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+</span></div><div id="w-83" class="wrapper"><span class="line" id="83">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-84" class="wrapper"><span class="line" id="84">        <span class="bp">self</span><span class="o">.</span><span class="n">packet_pending</span> <span class="o">=</span> <span class="bp">True</span>
+</span></div><div id="w-85" class="wrapper"><span class="line" id="85">        <span class="bp">self</span><span class="o">.</span><span class="n">task_waiting</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-86" class="wrapper"><span class="line" id="86">        <span class="bp">self</span><span class="o">.</span><span class="n">task_holding</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-87" class="wrapper"><span class="line" id="87">
+</span></div><div id="w-88" class="wrapper"><span class="line" id="88">    <span class="k">def</span> <span class="nf">packetPending</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-89" class="wrapper"><span class="line" id="89">        <span class="bp">self</span><span class="o">.</span><span class="n">packet_pending</span> <span class="o">=</span> <span class="bp">True</span>
+</span></div><div id="w-90" class="wrapper"><span class="line" id="90">        <span class="bp">self</span><span class="o">.</span><span class="n">task_waiting</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-91" class="wrapper"><span class="line" id="91">        <span class="bp">self</span><span class="o">.</span><span class="n">task_holding</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-92" class="wrapper"><span class="line" id="92">        <span class="k">return</span> <span class="bp">self</span>
+</span></div><div id="w-93" class="wrapper"><span class="line" id="93">
+</span></div><div id="w-94" class="wrapper"><span class="line" id="94">    <span class="k">def</span> <span class="nf">waiting</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-95" class="wrapper"><span class="line" id="95">        <span class="bp">self</span><span class="o">.</span><span class="n">packet_pending</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-96" class="wrapper"><span class="line" id="96">        <span class="bp">self</span><span class="o">.</span><span class="n">task_waiting</span> <span class="o">=</span> <span class="bp">True</span>
+</span></div><div id="w-97" class="wrapper"><span class="line" id="97">        <span class="bp">self</span><span class="o">.</span><span class="n">task_holding</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-98" class="wrapper"><span class="line" id="98">        <span class="k">return</span> <span class="bp">self</span>
+</span></div><div id="w-99" class="wrapper"><span class="line" id="99">
+</span></div><div id="w-100" class="wrapper"><span class="line" id="100">    <span class="k">def</span> <span class="nf">running</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-101" class="wrapper"><span class="line" id="101">        <span class="bp">self</span><span class="o">.</span><span class="n">packet_pending</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-102" class="wrapper"><span class="line" id="102">        <span class="bp">self</span><span class="o">.</span><span class="n">task_waiting</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-103" class="wrapper"><span class="line" id="103">        <span class="bp">self</span><span class="o">.</span><span class="n">task_holding</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-104" class="wrapper"><span class="line" id="104">        <span class="k">return</span> <span class="bp">self</span>
+</span></div><div id="w-105" class="wrapper"><span class="line" id="105">        
+</span></div><div id="w-106" class="wrapper"><span class="line" id="106">    <span class="k">def</span> <span class="nf">waitingWithPacket</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-107" class="wrapper"><span class="line" id="107">        <span class="bp">self</span><span class="o">.</span><span class="n">packet_pending</span> <span class="o">=</span> <span class="bp">True</span>
+</span></div><div id="w-108" class="wrapper"><span class="line" id="108">        <span class="bp">self</span><span class="o">.</span><span class="n">task_waiting</span> <span class="o">=</span> <span class="bp">True</span>
+</span></div><div id="w-109" class="wrapper"><span class="line" id="109">        <span class="bp">self</span><span class="o">.</span><span class="n">task_holding</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-110" class="wrapper"><span class="line" id="110">        <span class="k">return</span> <span class="bp">self</span>
+</span></div><div id="w-111" class="wrapper"><span class="line" id="111">        
+</span></div><div id="w-112" class="wrapper"><span class="line" id="112">    <span class="k">def</span> <span class="nf">isPacketPending</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-113" class="wrapper"><span class="line" id="113">        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">packet_pending</span>
+</span></div><div id="w-114" class="wrapper"><span class="line" id="114">
+</span></div><div id="w-115" class="wrapper"><span class="line" id="115">    <span class="k">def</span> <span class="nf">isTaskWaiting</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-116" class="wrapper"><span class="line" id="116">        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">task_waiting</span>
+</span></div><div id="w-117" class="wrapper"><span class="line" id="117">
+</span></div><div id="w-118" class="wrapper"><span class="line" id="118">    <span class="k">def</span> <span class="nf">isTaskHolding</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-119" class="wrapper"><span class="line" id="119">        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">task_holding</span>
+</span></div><div id="w-120" class="wrapper"><span class="line" id="120">
+</span></div><div id="w-121" class="wrapper"><span class="line" id="121">    <span class="k">def</span> <span class="nf">isTaskHoldingOrWaiting</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-122" class="wrapper"><span class="line" id="122">        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">task_holding</span> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">packet_pending</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">task_waiting</span><span class="p">)</span>
+</span></div><div id="w-123" class="wrapper"><span class="line" id="123">
+</span></div><div id="w-124" class="wrapper"><span class="line" id="124">    <span class="k">def</span> <span class="nf">isWaitingWithPacket</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-125" class="wrapper"><span class="line" id="125">        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">packet_pending</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">task_waiting</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">task_holding</span>
+</span></div><div id="w-126" class="wrapper"><span class="line" id="126">
+</span></div><div id="w-127" class="wrapper"><span class="line" id="127">
+</span></div><div id="w-128" class="wrapper"><span class="line" id="128">
+</span></div><div id="w-129" class="wrapper"><span class="line" id="129">
+</span></div><div id="w-130" class="wrapper"><span class="line" id="130">
+</span></div><div id="w-131" class="wrapper"><span class="line" id="131"><span class="n">tracing</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-132" class="wrapper"><span class="line" id="132"><span class="n">layout</span> <span class="o">=</span> <span class="mi">0</span>
+</span></div><div id="w-133" class="wrapper"><span class="line" id="133">
+</span></div><div id="w-134" class="wrapper"><span class="line" id="134"><span class="k">def</span> <span class="nf">trace</span><span class="p">(</span><span class="n">a</span><span class="p">):</span>
+</span></div><div id="w-135" class="wrapper"><span class="line" id="135">    <span class="k">global</span> <span class="n">layout</span>
+</span></div><div id="w-136" class="wrapper"><span class="line" id="136">    <span class="n">layout</span> <span class="o">-=</span> <span class="mi">1</span>
+</span></div><div id="w-137" class="wrapper"><span class="line" id="137">    <span class="k">if</span> <span class="n">layout</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
+</span></div><div id="w-138" class="wrapper"><span class="line" id="138">        <span class="k">print</span>
+</span></div><div id="w-139" class="wrapper"><span class="line" id="139">        <span class="n">layout</span> <span class="o">=</span> <span class="mi">50</span>
+</span></div><div id="w-140" class="wrapper"><span class="line" id="140">    <span class="k">print</span> <span class="n">a</span><span class="p">,</span>
+</span></div><div id="w-141" class="wrapper"><span class="line" id="141">
+</span></div><div id="w-142" class="wrapper"><span class="line" id="142">
+</span></div><div id="w-143" class="wrapper"><span class="line" id="143"><span class="n">TASKTABSIZE</span> <span class="o">=</span> <span class="mi">10</span>
+</span></div><div id="w-144" class="wrapper"><span class="line" id="144">
+</span></div><div id="w-145" class="wrapper"><span class="line" id="145"><span class="k">class</span> <span class="nc">TaskWorkArea</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+</span></div><div id="w-146" class="wrapper"><span class="line" id="146">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-147" class="wrapper"><span class="line" id="147">        <span class="bp">self</span><span class="o">.</span><span class="n">taskTab</span> <span class="o">=</span> <span class="p">[</span><span class="bp">None</span><span class="p">]</span> <span class="o">*</span> <span class="n">TASKTABSIZE</span>
+</span></div><div id="w-148" class="wrapper"><span class="line" id="148">
+</span></div><div id="w-149" class="wrapper"><span class="line" id="149">        <span class="bp">self</span><span class="o">.</span><span class="n">taskList</span> <span class="o">=</span> <span class="bp">None</span>
+</span></div><div id="w-150" class="wrapper"><span class="line" id="150">
+</span></div><div id="w-151" class="wrapper"><span class="line" id="151">        <span class="bp">self</span><span class="o">.</span><span class="n">holdCount</span> <span class="o">=</span> <span class="mi">0</span>
+</span></div><div id="w-152" class="wrapper"><span class="line" id="152">        <span class="bp">self</span><span class="o">.</span><span class="n">qpktCount</span> <span class="o">=</span> <span class="mi">0</span>
+</span></div><div id="w-153" class="wrapper"><span class="line" id="153">
+</span></div><div id="w-154" class="wrapper"><span class="line" id="154"><span class="n">taskWorkArea</span> <span class="o">=</span> <span class="n">TaskWorkArea</span><span class="p">()</span>
+</span></div><div id="w-155" class="wrapper"><span class="line" id="155">
+</span></div><div id="w-156" class="wrapper"><span class="line" id="156"><span class="k">class</span> <span class="nc">Task</span><span class="p">(</span><span class="n">TaskState</span><span class="p">):</span>
+</span></div><div id="w-157" class="wrapper"><span class="line" id="157">
+</span></div><div id="w-158" class="wrapper"><span class="line" id="158">
+</span></div><div id="w-159" class="wrapper"><span class="line" id="159">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">p</span><span class="p">,</span><span class="n">w</span><span class="p">,</span><span class="n">initialState</span><span class="p">,</span><span class="n">r</span><span class="p">):</span>
+</span></div><div id="w-160" class="wrapper"><span class="line" id="160">        <span class="bp">self</span><span class="o">.</span><span class="n">link</span> <span class="o">=</span> <span class="n">taskWorkArea</span><span class="o">.</span><span class="n">taskList</span>
+</span></div><div id="w-161" class="wrapper"><span class="line" id="161">        <span class="bp">self</span><span class="o">.</span><span class="n">ident</span> <span class="o">=</span> <span class="n">i</span>
+</span></div><div id="w-162" class="wrapper"><span class="line" id="162">        <span class="bp">self</span><span class="o">.</span><span class="n">priority</span> <span class="o">=</span> <span class="n">p</span>
+</span></div><div id="w-163" class="wrapper"><span class="line" id="163">        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="n">w</span>
+</span></div><div id="w-164" class="wrapper"><span class="line" id="164">
+</span></div><div id="w-165" class="wrapper"><span class="line" id="165">        <span class="bp">self</span><span class="o">.</span><span class="n">packet_pending</span> <span class="o">=</span> <span class="n">initialState</span><span class="o">.</span><span class="n">isPacketPending</span><span class="p">()</span>
+</span></div><div id="w-166" class="wrapper"><span class="line" id="166">        <span class="bp">self</span><span class="o">.</span><span class="n">task_waiting</span> <span class="o">=</span> <span class="n">initialState</span><span class="o">.</span><span class="n">isTaskWaiting</span><span class="p">()</span>
+</span></div><div id="w-167" class="wrapper"><span class="line" id="167">        <span class="bp">self</span><span class="o">.</span><span class="n">task_holding</span> <span class="o">=</span> <span class="n">initialState</span><span class="o">.</span><span class="n">isTaskHolding</span><span class="p">()</span>
+</span></div><div id="w-168" class="wrapper"><span class="line" id="168">
+</span></div><div id="w-169" class="wrapper"><span class="line" id="169">        <span class="bp">self</span><span class="o">.</span><span class="n">handle</span> <span class="o">=</span> <span class="n">r</span>
+</span></div><div id="w-170" class="wrapper"><span class="line" id="170">
+</span></div><div id="w-171" class="wrapper"><span class="line" id="171">        <span class="n">taskWorkArea</span><span class="o">.</span><span class="n">taskList</span> <span class="o">=</span> <span class="bp">self</span>
+</span></div><div id="w-172" class="wrapper"><span class="line" id="172">        <span class="n">taskWorkArea</span><span class="o">.</span><span class="n">taskTab</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span>
+</span></div><div id="w-173" class="wrapper"><span class="line" id="173">
+</span></div><div id="w-174" class="wrapper"><span class="line" id="174">    <span class="k">def</span> <span class="nf">fn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">pkt</span><span class="p">,</span><span class="n">r</span><span class="p">):</span>
+</span></div><div id="w-175" class="wrapper"><span class="line" id="175">        <span class="k">raise</span> <span class="ne">NotImplementedError</span>
+</span></div><div id="w-176" class="wrapper"><span class="line" id="176">
+</span></div><div id="w-177" class="wrapper"><span class="line" id="177">
+</span></div><div id="w-178" class="wrapper"><span class="line" id="178">    <span class="k">def</span> <span class="nf">addPacket</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">p</span><span class="p">,</span><span class="n">old</span><span class="p">):</span>
+</span></div><div id="w-179" class="wrapper"><span class="line" id="179">        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-180" class="wrapper"><span class="line" id="180">            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="n">p</span>
+</span></div><div id="w-181" class="wrapper"><span class="line" id="181">            <span class="bp">self</span><span class="o">.</span><span class="n">packet_pending</span> <span class="o">=</span> <span class="bp">True</span>
+</span></div><div id="w-182" class="wrapper"><span class="line" id="182">            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">priority</span> <span class="o">&gt;</span> <span class="n">old</span><span class="o">.</span><span class="n">priority</span><span class="p">:</span>
+</span></div><div id="w-183" class="wrapper"><span class="line" id="183">                <span class="k">return</span> <span class="bp">self</span>
+</span></div><div id="w-184" class="wrapper"><span class="line" id="184">        <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-185" class="wrapper"><span class="line" id="185">            <span class="n">p</span><span class="o">.</span><span class="n">append_to</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">input</span><span class="p">)</span>
+</span></div><div id="w-186" class="wrapper"><span class="line" id="186">        <span class="k">return</span> <span class="n">old</span>
+</span></div><div id="w-187" class="wrapper"><span class="line" id="187">
+</span></div><div id="w-188" class="wrapper"><span class="line" id="188">
+</span></div><div id="w-189" class="wrapper"><span class="line" id="189">    <span class="k">def</span> <span class="nf">runTask</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-190" class="wrapper"><span class="line" id="190">        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">isWaitingWithPacket</span><span class="p">():</span>
+</span></div><div id="w-191" class="wrapper"><span class="line" id="191">            <span class="n">msg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">input</span>
+</span></div><div id="w-192" class="wrapper"><span class="line" id="192">            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="n">msg</span><span class="o">.</span><span class="n">link</span>
+</span></div><div id="w-193" class="wrapper"><span class="line" id="193">            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-194" class="wrapper"><span class="line" id="194">                <span class="bp">self</span><span class="o">.</span><span class="n">running</span><span class="p">()</span>
+</span></div><div id="w-195" class="wrapper"><span class="line" id="195">            <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-196" class="wrapper"><span class="line" id="196">                <span class="bp">self</span><span class="o">.</span><span class="n">packetPending</span><span class="p">()</span>
+</span></div><div id="w-197" class="wrapper"><span class="line" id="197">        <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-198" class="wrapper"><span class="line" id="198">            <span class="n">msg</span> <span class="o">=</span> <span class="bp">None</span>
+</span></div><div id="w-199" class="wrapper"><span class="line" id="199">
+</span></div><div id="w-200" class="wrapper"><span class="line" id="200">        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">fn</span><span class="p">(</span><span class="n">msg</span><span class="p">,</span><span class="bp">self</span><span class="o">.</span><span class="n">handle</span><span class="p">)</span>
+</span></div><div id="w-201" class="wrapper"><span class="line" id="201">
+</span></div><div id="w-202" class="wrapper"><span class="line" id="202">
+</span></div><div id="w-203" class="wrapper"><span class="line" id="203">    <span class="k">def</span> <span class="nf">waitTask</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-204" class="wrapper"><span class="line" id="204">        <span class="bp">self</span><span class="o">.</span><span class="n">task_waiting</span> <span class="o">=</span> <span class="bp">True</span>
+</span></div><div id="w-205" class="wrapper"><span class="line" id="205">        <span class="k">return</span> <span class="bp">self</span>
+</span></div><div id="w-206" class="wrapper"><span class="line" id="206">
+</span></div><div id="w-207" class="wrapper"><span class="line" id="207">
+</span></div><div id="w-208" class="wrapper"><span class="line" id="208">    <span class="k">def</span> <span class="nf">hold</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+</span></div><div id="w-209" class="wrapper"><span class="line" id="209">        <span class="n">taskWorkArea</span><span class="o">.</span><span class="n">holdCount</span> <span class="o">+=</span> <span class="mi">1</span>
+</span></div><div id="w-210" class="wrapper"><span class="line" id="210">        <span class="bp">self</span><span class="o">.</span><span class="n">task_holding</span> <span class="o">=</span> <span class="bp">True</span>
+</span></div><div id="w-211" class="wrapper"><span class="line" id="211">        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">link</span>
+</span></div><div id="w-212" class="wrapper"><span class="line" id="212">
+</span></div><div id="w-213" class="wrapper"><span class="line" id="213">
+</span></div><div id="w-214" class="wrapper"><span class="line" id="214">    <span class="k">def</span> <span class="nf">release</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">i</span><span class="p">):</span>
+</span></div><div id="w-215" class="wrapper"><span class="line" id="215">        <span class="n">t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">findtcb</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
+</span></div><div id="w-216" class="wrapper"><span class="line" id="216">        <span class="n">t</span><span class="o">.</span><span class="n">task_holding</span> <span class="o">=</span> <span class="bp">False</span>
+</span></div><div id="w-217" class="wrapper"><span class="line" id="217">        <span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">priority</span> <span class="o">&gt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">priority</span><span class="p">:</span>
+</span></div><div id="w-218" class="wrapper"><span class="line" id="218">            <span class="k">return</span> <span class="n">t</span>
+</span></div><div id="w-219" class="wrapper"><span class="line" id="219">        <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-220" class="wrapper"><span class="line" id="220">            <span class="k">return</span> <span class="bp">self</span>
+</span></div><div id="w-221" class="wrapper"><span class="line" id="221">
+</span></div><div id="w-222" class="wrapper"><span class="line" id="222">
+</span></div><div id="w-223" class="wrapper"><span class="line" id="223">    <span class="k">def</span> <span class="nf">qpkt</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">pkt</span><span class="p">):</span>
+</span></div><div id="w-224" class="wrapper"><span class="line" id="224">        <span class="n">t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">findtcb</span><span class="p">(</span><span class="n">pkt</span><span class="o">.</span><span class="n">ident</span><span class="p">)</span>
+</span></div><div id="w-225" class="wrapper"><span class="line" id="225">        <span class="n">taskWorkArea</span><span class="o">.</span><span class="n">qpktCount</span> <span class="o">+=</span> <span class="mi">1</span>
+</span></div><div id="w-226" class="wrapper"><span class="line" id="226">        <span class="n">pkt</span><span class="o">.</span><span class="n">link</span> <span class="o">=</span> <span class="bp">None</span>
+</span></div><div id="w-227" class="wrapper"><span class="line" id="227">        <span class="n">pkt</span><span class="o">.</span><span class="n">ident</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ident</span>
+</span></div><div id="w-228" class="wrapper"><span class="line" id="228">        <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">addPacket</span><span class="p">(</span><span class="n">pkt</span><span class="p">,</span><span class="bp">self</span><span class="p">)</span>
+</span></div><div id="w-229" class="wrapper"><span class="line" id="229">
+</span></div><div id="w-230" class="wrapper"><span class="line" id="230">
+</span></div><div id="w-231" class="wrapper"><span class="line" id="231">    <span class="k">def</span> <span class="nf">findtcb</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="nb">id</span><span class="p">):</span>
+</span></div><div id="w-232" class="wrapper"><span class="line" id="232">        <span class="n">t</span> <span class="o">=</span> <span class="n">taskWorkArea</span><span class="o">.</span><span class="n">taskTab</span><span class="p">[</span><span class="nb">id</span><span class="p">]</span>
+</span></div><div id="w-233" class="wrapper"><span class="line" id="233">        <span class="k">if</span> <span class="n">t</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-234" class="wrapper"><span class="line" id="234">            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s">&quot;Bad task id </span><span class="si">%d</span><span class="s">&quot;</span> <span class="o">%</span> <span class="nb">id</span><span class="p">)</span>
+</span></div><div id="w-235" class="wrapper"><span class="line" id="235">        <span class="k">return</span> <span class="n">t</span>
+</span></div><div id="w-236" class="wrapper"><span class="line" id="236">            
+</span></div><div id="w-237" class="wrapper"><span class="line" id="237">
+</span></div><div id="w-238" class="wrapper"><span class="line" id="238"><span class="c"># DeviceTask</span>
+</span></div><div id="w-239" class="wrapper"><span class="line" id="239">
+</span></div><div id="w-240" class="wrapper"><span class="line" id="240">
+</span></div><div id="w-241" class="wrapper"><span class="line" id="241"><span class="k">class</span> <span class="nc">DeviceTask</span><span class="p">(</span><span class="n">Task</span><span class="p">):</span>
+</span></div><div id="w-242" class="wrapper"><span class="line" id="242">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">p</span><span class="p">,</span><span class="n">w</span><span class="p">,</span><span class="n">s</span><span class="p">,</span><span class="n">r</span><span class="p">):</span>
+</span></div><div id="w-243" class="wrapper"><span class="line" id="243">        <span class="n">Task</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">p</span><span class="p">,</span><span class="n">w</span><span class="p">,</span><span class="n">s</span><span class="p">,</span><span class="n">r</span><span class="p">)</span>
+</span></div><div id="w-244" class="wrapper"><span class="line" id="244">
+</span></div><div id="w-245" class="wrapper"><span class="line" id="245">    <span class="k">def</span> <span class="nf">fn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">pkt</span><span class="p">,</span><span class="n">r</span><span class="p">):</span>
+</span></div><div id="w-246" class="wrapper"><span class="line" id="246">        <span class="n">d</span> <span class="o">=</span> <span class="n">r</span>
+</span></div><div id="w-247" class="wrapper"><span class="line" id="247">        <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="n">DeviceTaskRec</span><span class="p">)</span>
+</span></div><div id="w-248" class="wrapper"><span class="line" id="248">        <span class="k">if</span> <span class="n">pkt</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-249" class="wrapper"><span class="line" id="249">            <span class="n">pkt</span> <span class="o">=</span> <span class="n">d</span><span class="o">.</span><span class="n">pending</span>
+</span></div><div id="w-250" class="wrapper"><span class="line" id="250">            <span class="k">if</span> <span class="n">pkt</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-251" class="wrapper"><span class="line" id="251">                <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">waitTask</span><span class="p">()</span>
+</span></div><div id="w-252" class="wrapper"><span class="line" id="252">            <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-253" class="wrapper"><span class="line" id="253">                <span class="n">d</span><span class="o">.</span><span class="n">pending</span> <span class="o">=</span> <span class="bp">None</span>
+</span></div><div id="w-254" class="wrapper"><span class="line" id="254">                <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">qpkt</span><span class="p">(</span><span class="n">pkt</span><span class="p">)</span>
+</span></div><div id="w-255" class="wrapper"><span class="line" id="255">        <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-256" class="wrapper"><span class="line" id="256">            <span class="n">d</span><span class="o">.</span><span class="n">pending</span> <span class="o">=</span> <span class="n">pkt</span>
+</span></div><div id="w-257" class="wrapper"><span class="line" id="257">            <span class="k">if</span> <span class="n">tracing</span><span class="p">:</span> <span class="n">trace</span><span class="p">(</span><span class="n">pkt</span><span class="o">.</span><span class="n">datum</span><span class="p">)</span>
+</span></div><div id="w-258" class="wrapper"><span class="line" id="258">            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">hold</span><span class="p">()</span>
+</span></div><div id="w-259" class="wrapper"><span class="line" id="259">
+</span></div><div id="w-260" class="wrapper"><span class="line" id="260">
+</span></div><div id="w-261" class="wrapper"><span class="line" id="261">
+</span></div><div id="w-262" class="wrapper"><span class="line" id="262"><span class="k">class</span> <span class="nc">HandlerTask</span><span class="p">(</span><span class="n">Task</span><span class="p">):</span>
+</span></div><div id="w-263" class="wrapper"><span class="line" id="263">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">p</span><span class="p">,</span><span class="n">w</span><span class="p">,</span><span class="n">s</span><span class="p">,</span><span class="n">r</span><span class="p">):</span>
+</span></div><div id="w-264" class="wrapper"><span class="line" id="264">        <span class="n">Task</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">p</span><span class="p">,</span><span class="n">w</span><span class="p">,</span><span class="n">s</span><span class="p">,</span><span class="n">r</span><span class="p">)</span>
+</span></div><div id="w-265" class="wrapper"><span class="line" id="265">
+</span></div><div id="w-266" class="wrapper"><span class="line" id="266">    <span class="k">def</span> <span class="nf">fn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">pkt</span><span class="p">,</span><span class="n">r</span><span class="p">):</span>
+</span></div><div id="w-267" class="wrapper"><span class="line" id="267">        <span class="n">h</span> <span class="o">=</span> <span class="n">r</span>
+</span></div><div id="w-268" class="wrapper"><span class="line" id="268">        <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">HandlerTaskRec</span><span class="p">)</span>
+</span></div><div id="w-269" class="wrapper"><span class="line" id="269">        <span class="k">if</span> <span class="n">pkt</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-270" class="wrapper"><span class="line" id="270">            <span class="k">if</span> <span class="n">pkt</span><span class="o">.</span><span class="n">kind</span> <span class="o">==</span> <span class="n">K_WORK</span><span class="p">:</span>
+</span></div><div id="w-271" class="wrapper"><span class="line" id="271">                <span class="n">h</span><span class="o">.</span><span class="n">workInAdd</span><span class="p">(</span><span class="n">pkt</span><span class="p">)</span>
+</span></div><div id="w-272" class="wrapper"><span class="line" id="272">            <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-273" class="wrapper"><span class="line" id="273">                <span class="n">h</span><span class="o">.</span><span class="n">deviceInAdd</span><span class="p">(</span><span class="n">pkt</span><span class="p">)</span>
+</span></div><div id="w-274" class="wrapper"><span class="line" id="274">        <span class="n">work</span> <span class="o">=</span> <span class="n">h</span><span class="o">.</span><span class="n">work_in</span>
+</span></div><div id="w-275" class="wrapper"><span class="line" id="275">        <span class="k">if</span> <span class="n">work</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-276" class="wrapper"><span class="line" id="276">            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">waitTask</span><span class="p">()</span>
+</span></div><div id="w-277" class="wrapper"><span class="line" id="277">        <span class="n">count</span> <span class="o">=</span> <span class="n">work</span><span class="o">.</span><span class="n">datum</span>
+</span></div><div id="w-278" class="wrapper"><span class="line" id="278">        <span class="k">if</span> <span class="n">count</span> <span class="o">&gt;=</span> <span class="n">BUFSIZE</span><span class="p">:</span>
+</span></div><div id="w-279" class="wrapper"><span class="line" id="279">            <span class="n">h</span><span class="o">.</span><span class="n">work_in</span> <span class="o">=</span> <span class="n">work</span><span class="o">.</span><span class="n">link</span>
+</span></div><div id="w-280" class="wrapper"><span class="line" id="280">            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">qpkt</span><span class="p">(</span><span class="n">work</span><span class="p">)</span>
+</span></div><div id="w-281" class="wrapper"><span class="line" id="281">
+</span></div><div id="w-282" class="wrapper"><span class="line" id="282">        <span class="n">dev</span> <span class="o">=</span> <span class="n">h</span><span class="o">.</span><span class="n">device_in</span>
+</span></div><div id="w-283" class="wrapper"><span class="line" id="283">        <span class="k">if</span> <span class="n">dev</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-284" class="wrapper"><span class="line" id="284">            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">waitTask</span><span class="p">()</span>
+</span></div><div id="w-285" class="wrapper"><span class="line" id="285">
+</span></div><div id="w-286" class="wrapper"><span class="line" id="286">        <span class="n">h</span><span class="o">.</span><span class="n">device_in</span> <span class="o">=</span> <span class="n">dev</span><span class="o">.</span><span class="n">link</span>
+</span></div><div id="w-287" class="wrapper"><span class="line" id="287">        <span class="n">dev</span><span class="o">.</span><span class="n">datum</span> <span class="o">=</span> <span class="n">work</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="n">count</span><span class="p">]</span>
+</span></div><div id="w-288" class="wrapper"><span class="line" id="288">        <span class="n">work</span><span class="o">.</span><span class="n">datum</span> <span class="o">=</span> <span class="n">count</span> <span class="o">+</span> <span class="mi">1</span>
+</span></div><div id="w-289" class="wrapper"><span class="line" id="289">        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">qpkt</span><span class="p">(</span><span class="n">dev</span><span class="p">)</span>
+</span></div><div id="w-290" class="wrapper"><span class="line" id="290">
+</span></div><div id="w-291" class="wrapper"><span class="line" id="291"><span class="c"># IdleTask</span>
+</span></div><div id="w-292" class="wrapper"><span class="line" id="292">
+</span></div><div id="w-293" class="wrapper"><span class="line" id="293">
+</span></div><div id="w-294" class="wrapper"><span class="line" id="294"><span class="k">class</span> <span class="nc">IdleTask</span><span class="p">(</span><span class="n">Task</span><span class="p">):</span>
+</span></div><div id="w-295" class="wrapper"><span class="line" id="295">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">p</span><span class="p">,</span><span class="n">w</span><span class="p">,</span><span class="n">s</span><span class="p">,</span><span class="n">r</span><span class="p">):</span>
+</span></div><div id="w-296" class="wrapper"><span class="line" id="296">        <span class="n">Task</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="bp">None</span><span class="p">,</span><span class="n">s</span><span class="p">,</span><span class="n">r</span><span class="p">)</span>
+</span></div><div id="w-297" class="wrapper"><span class="line" id="297">
+</span></div><div id="w-298" class="wrapper"><span class="line" id="298">    <span class="k">def</span> <span class="nf">fn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">pkt</span><span class="p">,</span><span class="n">r</span><span class="p">):</span>
+</span></div><div id="w-299" class="wrapper"><span class="line" id="299">        <span class="n">i</span> <span class="o">=</span> <span class="n">r</span>
+</span></div><div id="w-300" class="wrapper"><span class="line" id="300">        <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">IdleTaskRec</span><span class="p">)</span>
+</span></div><div id="w-301" class="wrapper"><span class="line" id="301">        <span class="n">i</span><span class="o">.</span><span class="n">count</span> <span class="o">-=</span> <span class="mi">1</span>
+</span></div><div id="w-302" class="wrapper"><span class="line" id="302">        <span class="k">if</span> <span class="n">i</span><span class="o">.</span><span class="n">count</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
+</span></div><div id="w-303" class="wrapper"><span class="line" id="303">            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">hold</span><span class="p">()</span>
+</span></div><div id="w-304" class="wrapper"><span class="line" id="304">        <span class="k">elif</span> <span class="n">i</span><span class="o">.</span><span class="n">control</span> <span class="o">&amp;</span> <span class="mi">1</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
+</span></div><div id="w-305" class="wrapper"><span class="line" id="305">            <span class="n">i</span><span class="o">.</span><span class="n">control</span> <span class="o">/=</span> <span class="mi">2</span>
+</span></div><div id="w-306" class="wrapper"><span class="line" id="306">            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">release</span><span class="p">(</span><span class="n">I_DEVA</span><span class="p">)</span>
+</span></div><div id="w-307" class="wrapper"><span class="line" id="307">        <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-308" class="wrapper"><span class="line" id="308">            <span class="n">i</span><span class="o">.</span><span class="n">control</span> <span class="o">=</span> <span class="n">i</span><span class="o">.</span><span class="n">control</span><span class="o">/</span><span class="mi">2</span> <span class="o">^</span> <span class="mh">0xd008</span>
+</span></div><div id="w-309" class="wrapper"><span class="line" id="309">            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">release</span><span class="p">(</span><span class="n">I_DEVB</span><span class="p">)</span>
+</span></div><div id="w-310" class="wrapper"><span class="line" id="310">            
+</span></div><div id="w-311" class="wrapper"><span class="line" id="311">
+</span></div><div id="w-312" class="wrapper"><span class="line" id="312"><span class="c"># WorkTask</span>
+</span></div><div id="w-313" class="wrapper"><span class="line" id="313">
+</span></div><div id="w-314" class="wrapper"><span class="line" id="314">
+</span></div><div id="w-315" class="wrapper"><span class="line" id="315"><span class="n">A</span> <span class="o">=</span> <span class="nb">ord</span><span class="p">(</span><span class="s">&#39;A&#39;</span><span class="p">)</span>
+</span></div><div id="w-316" class="wrapper"><span class="line" id="316">
+</span></div><div id="w-317" class="wrapper"><span class="line" id="317"><span class="k">class</span> <span class="nc">WorkTask</span><span class="p">(</span><span class="n">Task</span><span class="p">):</span>
+</span></div><div id="w-318" class="wrapper"><span class="line" id="318">    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">p</span><span class="p">,</span><span class="n">w</span><span class="p">,</span><span class="n">s</span><span class="p">,</span><span class="n">r</span><span class="p">):</span>
+</span></div><div id="w-319" class="wrapper"><span class="line" id="319">        <span class="n">Task</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">p</span><span class="p">,</span><span class="n">w</span><span class="p">,</span><span class="n">s</span><span class="p">,</span><span class="n">r</span><span class="p">)</span>
+</span></div><div id="w-320" class="wrapper"><span class="line" id="320">
+</span></div><div id="w-321" class="wrapper"><span class="line" id="321">    <span class="k">def</span> <span class="nf">fn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">pkt</span><span class="p">,</span><span class="n">r</span><span class="p">):</span>
+</span></div><div id="w-322" class="wrapper"><span class="line" id="322">        <span class="n">w</span> <span class="o">=</span> <span class="n">r</span>
+</span></div><div id="w-323" class="wrapper"><span class="line" id="323">        <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">w</span><span class="p">,</span> <span class="n">WorkerTaskRec</span><span class="p">)</span>
+</span></div><div id="w-324" class="wrapper"><span class="line" id="324">        <span class="k">if</span> <span class="n">pkt</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-325" class="wrapper"><span class="line" id="325">            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">waitTask</span><span class="p">()</span>
+</span></div><div id="w-326" class="wrapper"><span class="line" id="326">
+</span></div><div id="w-327" class="wrapper"><span class="line" id="327">        <span class="k">if</span> <span class="n">w</span><span class="o">.</span><span class="n">destination</span> <span class="o">==</span> <span class="n">I_HANDLERA</span><span class="p">:</span>
+</span></div><div id="w-328" class="wrapper"><span class="line" id="328">            <span class="n">dest</span> <span class="o">=</span> <span class="n">I_HANDLERB</span>
+</span></div><div id="w-329" class="wrapper"><span class="line" id="329">        <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-330" class="wrapper"><span class="line" id="330">            <span class="n">dest</span> <span class="o">=</span> <span class="n">I_HANDLERA</span>
+</span></div><div id="w-331" class="wrapper"><span class="line" id="331">
+</span></div><div id="w-332" class="wrapper"><span class="line" id="332">        <span class="n">w</span><span class="o">.</span><span class="n">destination</span> <span class="o">=</span> <span class="n">dest</span>
+</span></div><div id="w-333" class="wrapper"><span class="line" id="333">        <span class="n">pkt</span><span class="o">.</span><span class="n">ident</span> <span class="o">=</span> <span class="n">dest</span>
+</span></div><div id="w-334" class="wrapper"><span class="line" id="334">        <span class="n">pkt</span><span class="o">.</span><span class="n">datum</span> <span class="o">=</span> <span class="mi">0</span>
+</span></div><div id="w-335" class="wrapper"><span class="line" id="335">
+</span></div><div id="w-336" class="wrapper"><span class="line" id="336">        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">BUFSIZE_RANGE</span><span class="p">:</span> <span class="c"># xrange(BUFSIZE)</span>
+</span></div><div id="w-337" class="wrapper"><span class="line" id="337">            <span class="n">w</span><span class="o">.</span><span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
+</span></div><div id="w-338" class="wrapper"><span class="line" id="338">            <span class="k">if</span> <span class="n">w</span><span class="o">.</span><span class="n">count</span> <span class="o">&gt;</span> <span class="mi">26</span><span class="p">:</span>
+</span></div><div id="w-339" class="wrapper"><span class="line" id="339">                <span class="n">w</span><span class="o">.</span><span class="n">count</span> <span class="o">=</span> <span class="mi">1</span>
+</span></div><div id="w-340" class="wrapper"><span class="line" id="340">            <span class="n">pkt</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">A</span> <span class="o">+</span> <span class="n">w</span><span class="o">.</span><span class="n">count</span> <span class="o">-</span> <span class="mi">1</span>
+</span></div><div id="w-341" class="wrapper"><span class="line" id="341">
+</span></div><div id="w-342" class="wrapper"><span class="line" id="342">        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">qpkt</span><span class="p">(</span><span class="n">pkt</span><span class="p">)</span>
+</span></div><div id="w-343" class="wrapper"><span class="line" id="343">
+</span></div><div id="w-344" class="wrapper"><span class="line" id="344"><span class="kn">import</span> <span class="nn">time</span>
+</span></div><div id="w-345" class="wrapper"><span class="line" id="345">
+</span></div><div id="w-346" class="wrapper"><span class="line" id="346"><span class="k">def</span> <span class="nf">schedule</span><span class="p">():</span>
+</span></div><div id="w-347" class="wrapper"><span class="line" id="347">    <span class="n">t</span> <span class="o">=</span> <span class="n">taskWorkArea</span><span class="o">.</span><span class="n">taskList</span>
+</span></div><div id="w-348" class="wrapper"><span class="line" id="348">    <span class="k">while</span> <span class="n">t</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
+</span></div><div id="w-349" class="wrapper"><span class="line" id="349">        <span class="n">pkt</span> <span class="o">=</span> <span class="bp">None</span>
+</span></div><div id="w-350" class="wrapper"><span class="line" id="350">
+</span></div><div id="w-351" class="wrapper"><span class="line" id="351">        <span class="k">if</span> <span class="n">tracing</span><span class="p">:</span>
+</span></div><div id="w-352" class="wrapper"><span class="line" id="352">            <span class="k">print</span> <span class="s">&quot;tcb =&quot;</span><span class="p">,</span><span class="n">t</span><span class="o">.</span><span class="n">ident</span>
+</span></div><div id="w-353" class="wrapper"><span class="line" id="353">
+</span></div><div id="w-354" class="wrapper"><span class="line" id="354">        <span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">isTaskHoldingOrWaiting</span><span class="p">():</span>
+</span></div><div id="w-355" class="wrapper"><span class="line" id="355">            <span class="n">t</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">link</span>
+</span></div><div id="w-356" class="wrapper"><span class="line" id="356">        <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-357" class="wrapper"><span class="line" id="357">            <span class="k">if</span> <span class="n">tracing</span><span class="p">:</span> <span class="n">trace</span><span class="p">(</span><span class="nb">chr</span><span class="p">(</span><span class="nb">ord</span><span class="p">(</span><span class="s">&quot;0&quot;</span><span class="p">)</span><span class="o">+</span><span class="n">t</span><span class="o">.</span><span class="n">ident</span><span class="p">))</span>
+</span></div><div id="w-358" class="wrapper"><span class="line" id="358">            <span class="n">t</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">runTask</span><span class="p">()</span>
+</span></div><div id="w-359" class="wrapper"><span class="line" id="359">
+</span></div><div id="w-360" class="wrapper"><span class="line" id="360"><span class="k">class</span> <span class="nc">Richards</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+</span></div><div id="w-361" class="wrapper"><span class="line" id="361">
+</span></div><div id="w-362" class="wrapper"><span class="line" id="362">    <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">iterations</span><span class="p">):</span>
+</span></div><div id="w-363" class="wrapper"><span class="line" id="363">        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">xrange</span><span class="p">(</span><span class="n">iterations</span><span class="p">):</span>
+</span></div><div id="w-364" class="wrapper"><span class="line" id="364">            <span class="n">taskWorkArea</span><span class="o">.</span><span class="n">holdCount</span> <span class="o">=</span> <span class="mi">0</span>
+</span></div><div id="w-365" class="wrapper"><span class="line" id="365">            <span class="n">taskWorkArea</span><span class="o">.</span><span class="n">qpktCount</span> <span class="o">=</span> <span class="mi">0</span>
+</span></div><div id="w-366" class="wrapper"><span class="line" id="366">
+</span></div><div id="w-367" class="wrapper"><span class="line" id="367">            <span class="n">IdleTask</span><span class="p">(</span><span class="n">I_IDLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">10000</span><span class="p">,</span> <span class="n">TaskState</span><span class="p">()</span><span class="o">.</span><span class="n">running</span><span class="p">(),</span> <span class="n">IdleTaskRec</span><span class="p">())</span>
+</span></div><div id="w-368" class="wrapper"><span class="line" id="368">
+</span></div><div id="w-369" class="wrapper"><span class="line" id="369">            <span class="n">wkq</span> <span class="o">=</span> <span class="n">Packet</span><span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">K_WORK</span><span class="p">)</span>
+</span></div><div id="w-370" class="wrapper"><span class="line" id="370">            <span class="n">wkq</span> <span class="o">=</span> <span class="n">Packet</span><span class="p">(</span><span class="n">wkq</span> <span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">K_WORK</span><span class="p">)</span>
+</span></div><div id="w-371" class="wrapper"><span class="line" id="371">            <span class="n">WorkTask</span><span class="p">(</span><span class="n">I_WORK</span><span class="p">,</span> <span class="mi">1000</span><span class="p">,</span> <span class="n">wkq</span><span class="p">,</span> <span class="n">TaskState</span><span class="p">()</span><span class="o">.</span><span class="n">waitingWithPacket</span><span class="p">(),</span> <span class="n">WorkerTaskRec</span><span class="p">())</span>
+</span></div><div id="w-372" class="wrapper"><span class="line" id="372">
+</span></div><div id="w-373" class="wrapper"><span class="line" id="373">            <span class="n">wkq</span> <span class="o">=</span> <span class="n">Packet</span><span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="n">I_DEVA</span><span class="p">,</span> <span class="n">K_DEV</span><span class="p">)</span>
+</span></div><div id="w-374" class="wrapper"><span class="line" id="374">            <span class="n">wkq</span> <span class="o">=</span> <span class="n">Packet</span><span class="p">(</span><span class="n">wkq</span> <span class="p">,</span> <span class="n">I_DEVA</span><span class="p">,</span> <span class="n">K_DEV</span><span class="p">)</span>
+</span></div><div id="w-375" class="wrapper"><span class="line" id="375">            <span class="n">wkq</span> <span class="o">=</span> <span class="n">Packet</span><span class="p">(</span><span class="n">wkq</span> <span class="p">,</span> <span class="n">I_DEVA</span><span class="p">,</span> <span class="n">K_DEV</span><span class="p">)</span>
+</span></div><div id="w-376" class="wrapper"><span class="line" id="376">            <span class="n">HandlerTask</span><span class="p">(</span><span class="n">I_HANDLERA</span><span class="p">,</span> <span class="mi">2000</span><span class="p">,</span> <span class="n">wkq</span><span class="p">,</span> <span class="n">TaskState</span><span class="p">()</span><span class="o">.</span><span class="n">waitingWithPacket</span><span class="p">(),</span> <span class="n">HandlerTaskRec</span><span class="p">())</span>
+</span></div><div id="w-377" class="wrapper"><span class="line" id="377">
+</span></div><div id="w-378" class="wrapper"><span class="line" id="378">            <span class="n">wkq</span> <span class="o">=</span> <span class="n">Packet</span><span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="n">I_DEVB</span><span class="p">,</span> <span class="n">K_DEV</span><span class="p">)</span>
+</span></div><div id="w-379" class="wrapper"><span class="line" id="379">            <span class="n">wkq</span> <span class="o">=</span> <span class="n">Packet</span><span class="p">(</span><span class="n">wkq</span> <span class="p">,</span> <span class="n">I_DEVB</span><span class="p">,</span> <span class="n">K_DEV</span><span class="p">)</span>
+</span></div><div id="w-380" class="wrapper"><span class="line" id="380">            <span class="n">wkq</span> <span class="o">=</span> <span class="n">Packet</span><span class="p">(</span><span class="n">wkq</span> <span class="p">,</span> <span class="n">I_DEVB</span><span class="p">,</span> <span class="n">K_DEV</span><span class="p">)</span>
+</span></div><div id="w-381" class="wrapper"><span class="line" id="381">            <span class="n">HandlerTask</span><span class="p">(</span><span class="n">I_HANDLERB</span><span class="p">,</span> <span class="mi">3000</span><span class="p">,</span> <span class="n">wkq</span><span class="p">,</span> <span class="n">TaskState</span><span class="p">()</span><span class="o">.</span><span class="n">waitingWithPacket</span><span class="p">(),</span> <span class="n">HandlerTaskRec</span><span class="p">())</span>
+</span></div><div id="w-382" class="wrapper"><span class="line" id="382">
+</span></div><div id="w-383" class="wrapper"><span class="line" id="383">            <span class="n">wkq</span> <span class="o">=</span> <span class="bp">None</span><span class="p">;</span>
+</span></div><div id="w-384" class="wrapper"><span class="line" id="384">            <span class="n">DeviceTask</span><span class="p">(</span><span class="n">I_DEVA</span><span class="p">,</span> <span class="mi">4000</span><span class="p">,</span> <span class="n">wkq</span><span class="p">,</span> <span class="n">TaskState</span><span class="p">()</span><span class="o">.</span><span class="n">waiting</span><span class="p">(),</span> <span class="n">DeviceTaskRec</span><span class="p">());</span>
+</span></div><div id="w-385" class="wrapper"><span class="line" id="385">            <span class="n">DeviceTask</span><span class="p">(</span><span class="n">I_DEVB</span><span class="p">,</span> <span class="mi">5000</span><span class="p">,</span> <span class="n">wkq</span><span class="p">,</span> <span class="n">TaskState</span><span class="p">()</span><span class="o">.</span><span class="n">waiting</span><span class="p">(),</span> <span class="n">DeviceTaskRec</span><span class="p">());</span>
+</span></div><div id="w-386" class="wrapper"><span class="line" id="386">            
+</span></div><div id="w-387" class="wrapper"><span class="line" id="387">            <span class="n">schedule</span><span class="p">()</span>
+</span></div><div id="w-388" class="wrapper"><span class="line" id="388">
+</span></div><div id="w-389" class="wrapper"><span class="line" id="389">            <span class="k">if</span> <span class="n">taskWorkArea</span><span class="o">.</span><span class="n">holdCount</span> <span class="o">==</span> <span class="mi">9297</span> <span class="ow">and</span> <span class="n">taskWorkArea</span><span class="o">.</span><span class="n">qpktCount</span> <span class="o">==</span> <span class="mi">23246</span><span class="p">:</span>
+</span></div><div id="w-390" class="wrapper"><span class="line" id="390">                <span class="k">pass</span>
+</span></div><div id="w-391" class="wrapper"><span class="line" id="391">            <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-392" class="wrapper"><span class="line" id="392">                <span class="k">return</span> <span class="bp">False</span>
+</span></div><div id="w-393" class="wrapper"><span class="line" id="393">
+</span></div><div id="w-394" class="wrapper"><span class="line" id="394">        <span class="k">return</span> <span class="bp">True</span>
+</span></div><div id="w-395" class="wrapper"><span class="line" id="395">
+</span></div><div id="w-396" class="wrapper"><span class="line" id="396"><span class="k">def</span> <span class="nf">entry_point</span><span class="p">(</span><span class="n">iterations</span><span class="p">):</span>
+</span></div><div id="w-397" class="wrapper"><span class="line" id="397">    <span class="n">r</span> <span class="o">=</span> <span class="n">Richards</span><span class="p">()</span>
+</span></div><div id="w-398" class="wrapper"><span class="line" id="398">    <span class="n">startTime</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
+</span></div><div id="w-399" class="wrapper"><span class="line" id="399">    <span class="n">result</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">iterations</span><span class="p">)</span>
+</span></div><div id="w-400" class="wrapper"><span class="line" id="400">    <span class="n">endTime</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
+</span></div><div id="w-401" class="wrapper"><span class="line" id="401">    <span class="k">return</span> <span class="n">result</span><span class="p">,</span> <span class="n">startTime</span><span class="p">,</span> <span class="n">endTime</span>
+</span></div><div id="w-402" class="wrapper"><span class="line" id="402">
+</span></div><div id="w-403" class="wrapper"><span class="line" id="403"><span class="k">def</span> <span class="nf">main</span><span class="p">(</span><span class="n">entry_point</span> <span class="o">=</span> <span class="n">entry_point</span><span class="p">,</span> <span class="n">iterations</span> <span class="o">=</span> <span class="mi">10</span><span class="p">):</span>
+</span></div><div id="w-404" class="wrapper"><span class="line" id="404">    <span class="k">print</span> <span class="s">&quot;Richards benchmark (Python) starting... [</span><span class="si">%r</span><span class="s">]&quot;</span> <span class="o">%</span> <span class="n">entry_point</span>
+</span></div><div id="w-405" class="wrapper"><span class="line" id="405">    <span class="n">result</span><span class="p">,</span> <span class="n">startTime</span><span class="p">,</span> <span class="n">endTime</span> <span class="o">=</span> <span class="n">entry_point</span><span class="p">(</span><span class="n">iterations</span><span class="p">)</span>
+</span></div><div id="w-406" class="wrapper"><span class="line" id="406">    <span class="k">if</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span>
+</span></div><div id="w-407" class="wrapper"><span class="line" id="407">        <span class="k">print</span> <span class="s">&quot;Incorrect results!&quot;</span>
+</span></div><div id="w-408" class="wrapper"><span class="line" id="408">        <span class="k">return</span> <span class="o">-</span><span class="mi">1</span>
+</span></div><div id="w-409" class="wrapper"><span class="line" id="409">    <span class="k">print</span> <span class="s">&quot;finished.&quot;</span>
+</span></div><div id="w-410" class="wrapper"><span class="line" id="410">    <span class="n">total_s</span> <span class="o">=</span> <span class="n">endTime</span> <span class="o">-</span> <span class="n">startTime</span>
+</span></div><div id="w-411" class="wrapper"><span class="line" id="411">    <span class="k">print</span> <span class="s">&quot;Total time for </span><span class="si">%d</span><span class="s"> iterations: </span><span class="si">%.2f</span><span class="s"> secs&quot;</span> <span class="o">%</span><span class="p">(</span><span class="n">iterations</span><span class="p">,</span><span class="n">total_s</span><span class="p">)</span>
+</span></div><div id="w-412" class="wrapper"><span class="line" id="412">    <span class="k">print</span> <span class="s">&quot;Average time per iteration: </span><span class="si">%.2f</span><span class="s"> ms&quot;</span> <span class="o">%</span><span class="p">(</span><span class="n">total_s</span><span class="o">*</span><span class="mi">1000</span><span class="o">/</span><span class="n">iterations</span><span class="p">)</span>
+</span></div><div id="w-413" class="wrapper"><span class="line" id="413">    <span class="k">return</span> <span class="mi">42</span>
+</span></div><div id="w-414" class="wrapper"><span class="line" id="414">
+</span></div><div id="w-415" class="wrapper"><span class="line" id="415"><span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&#39;__main__&#39;</span><span class="p">:</span>
+</span></div><div id="w-416" class="wrapper"><span class="line" id="416">    <span class="kn">import</span> <span class="nn">sys</span>
+</span></div><div id="w-417" class="wrapper"><span class="line" id="417">    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">2</span><span class="p">:</span>
+</span></div><div id="w-418" class="wrapper"><span class="line" id="418">        <span class="n">main</span><span class="p">(</span><span class="n">iterations</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span>
+</span></div><div id="w-419" class="wrapper"><span class="line" id="419">    <span class="k">else</span><span class="p">:</span>
+</span></div><div id="w-420" class="wrapper"><span class="line" id="420">        <span class="n">main</span><span class="p">()</span>
+</span></div></pre></div>
+
+  </div>
+  <div class="rightpan">
+    <div id="container">
+    </div>
+  </div>
+</body>
+</html>

File codeviewer/y.html

+<html>
+  <head>
+   <script type="text/javascript" src="jquery.min.js"></script>
+   <script type="text/javascript" src="jquery.scrollTo-1.4.2-min.js"></script>
+   <script type="text/javascript" src="jquery.viewport.mini.js"></script>
+   <script type="text/javascript" src="y.js"></script>
+   <link rel="stylesheet" href="pygments.css">
+   <link rel="stylesheet" href="x.css">
+  </head>
+  <body>
+    <div id="main-code-browser">
+    
+       <div id="w-1" class="box box-code">
+         Code, 6 lines
+         
+       </div>
+    
+       <div id="w-2" class="box box-code">
+         Code, 2 lines
+         
+       </div>
+    
+       <div id="w-3" class="box box-code">
+         Code, 1 line
+         
+       </div>
+    
+       <div id="w-4" class="box box-code">
+         Code, 1 line
+         
+       </div>
+    
+       <div id="w-5" class="box box-cls">
+         Class Packet
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+            <div class="box box-func">
+              Method append_to
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-6" class="box box-cls">
+         Class TaskRec
+         
+            
+            <div class="box box-code">
+              Code, 1 line
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-7" class="box box-cls">
+         Class DeviceTaskRec
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-8" class="box box-cls">
+         Class IdleTaskRec
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-9" class="box box-cls">
+         Class HandlerTaskRec
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+            <div class="box box-func">
+              Method workInAdd
+            </div>
+            
+            <div class="box box-func">
+              Method deviceInAdd
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-10" class="box box-cls">
+         Class WorkerTaskRec
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-11" class="box box-cls">
+         Class TaskState
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+            <div class="box box-func">
+              Method packetPending
+            </div>
+            
+            <div class="box box-func">
+              Method waiting
+            </div>
+            
+            <div class="box box-func">
+              Method running
+            </div>
+            
+            <div class="box box-func">
+              Method waitingWithPacket
+            </div>
+            
+            <div class="box box-func">
+              Method isPacketPending
+            </div>
+            
+            <div class="box box-func">
+              Method isTaskWaiting
+            </div>
+            
+            <div class="box box-func">
+              Method isTaskHolding
+            </div>
+            
+            <div class="box box-func">
+              Method isTaskHoldingOrWaiting
+            </div>
+            
+            <div class="box box-func">
+              Method isWaitingWithPacket
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-12" class="box box-code">
+         Code, 2 lines
+         
+       </div>
+    
+       <div id="w-13" class="box box-func">
+         Function trace
+         
+       </div>
+    
+       <div id="w-14" class="box box-code">
+         Code, 1 line
+         
+       </div>
+    
+       <div id="w-15" class="box box-cls">
+         Class TaskWorkArea
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-16" class="box box-code">
+         Code, 1 line
+         
+       </div>
+    
+       <div id="w-17" class="box box-cls">
+         Class Task
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+            <div class="box box-func">
+              Method fn
+            </div>
+            
+            <div class="box box-func">
+              Method addPacket
+            </div>
+            
+            <div class="box box-func">
+              Method runTask
+            </div>
+            
+            <div class="box box-func">
+              Method waitTask
+            </div>
+            
+            <div class="box box-func">
+              Method hold
+            </div>
+            
+            <div class="box box-func">
+              Method release
+            </div>
+            
+            <div class="box box-func">
+              Method qpkt
+            </div>
+            
+            <div class="box box-func">
+              Method findtcb
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-18" class="box box-cls">
+         Class DeviceTask
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+            <div class="box box-func">
+              Method fn
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-19" class="box box-cls">
+         Class HandlerTask
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+            <div class="box box-func">
+              Method fn
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-20" class="box box-cls">
+         Class IdleTask
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+            <div class="box box-func">
+              Method fn
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-21" class="box box-code">
+         Code, 1 line
+         
+       </div>
+    
+       <div id="w-22" class="box box-cls">
+         Class WorkTask
+         
+            
+            <div class="box box-func">
+              Method __init__
+            </div>
+            
+            <div class="box box-func">
+              Method fn
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-23" class="box box-code">
+         Code, 1 line
+         
+       </div>
+    
+       <div id="w-24" class="box box-func">
+         Function schedule
+         
+       </div>
+    
+       <div id="w-25" class="box box-cls">
+         Class Richards
+         
+            
+            <div class="box box-func">
+              Method run
+            </div>
+            
+         
+       </div>
+    
+       <div id="w-26" class="box box-func">
+         Function entry_point
+         
+       </div>
+    
+       <div id="w-27" class="box box-func">
+         Function main
+         
+       </div>
+    
+       <div id="w-28" class="box box-code">
+         Code, 1 line
+         
+       </div>
+    
+    </div>
+  </body>
+</html>