<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Timed loop and CPU usage in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/Timed-loop-and-CPU-usage/m-p/436940#M213904</link>
    <description>Platform is WIN_XP Pro and machine is a P4 at 2.5Ghz with 512 Mb ram.&lt;BR /&gt;
&lt;BR /&gt;
LV7.1 + PCI 6229&lt;BR /&gt;
&lt;BR /&gt;
I am using&amp;nbsp; 50ms Timed loop for running a state machine inside it
and also a&amp;nbsp; whole lot of other things like reading / writing
DAQMx&amp;nbsp; functions;&amp;nbsp; file I/O functions and such. As the
project involves a&amp;nbsp; main and sub-panlel set up local variables
could not be elimnated fully and there should be something like 150 of
them. But not all are accessed always - maybe about 15 of them at any
given time depending on the SM staus.&lt;BR /&gt;
&lt;BR /&gt;
Problem :&lt;BR /&gt;
&lt;BR /&gt;
Once started the "Finished late"&amp;nbsp; indication&amp;nbsp; is off and
the&amp;nbsp; actual timing&amp;nbsp; alternates between 49 to 52 ms. The CPU
usage is around 25%.&lt;BR /&gt;
&lt;BR /&gt;
But as time goes by,&amp;nbsp; the system gets unstable : After 15 minutes
or so, the Finished Late indication is always ON and the CPU usage is
gradually tending towards or exceeds 100%.&amp;nbsp; &lt;BR /&gt;
&lt;BR /&gt;
Obviously the machine control timing now gets affected and things slow
down badly. Closing the application ands restarting repeats the above
cycle.&lt;BR /&gt;
&lt;BR /&gt;
I am at a loss&amp;nbsp; to understand what is happening ?&amp;nbsp; WIll
breaking down the single Timed Loop to multiple ones help&amp;nbsp; ? WIll
that be an efficient way of parallel threading ?&lt;BR /&gt;
&lt;BR /&gt;
I can post the code but its quite large and will do it as a last resort.&lt;BR /&gt;
&lt;BR /&gt;
thanks&lt;BR /&gt;
&lt;BR /&gt;
Raghunathan&lt;BR /&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 06 Nov 2006 09:08:19 GMT</pubDate>
    <dc:creator>MogaRaghu</dc:creator>
    <dc:date>2006-11-06T09:08:19Z</dc:date>
    <item>
      <title>Timed loop and CPU usage</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Timed-loop-and-CPU-usage/m-p/436940#M213904</link>
      <description>Platform is WIN_XP Pro and machine is a P4 at 2.5Ghz with 512 Mb ram.&lt;BR /&gt;
&lt;BR /&gt;
LV7.1 + PCI 6229&lt;BR /&gt;
&lt;BR /&gt;
I am using&amp;nbsp; 50ms Timed loop for running a state machine inside it
and also a&amp;nbsp; whole lot of other things like reading / writing
DAQMx&amp;nbsp; functions;&amp;nbsp; file I/O functions and such. As the
project involves a&amp;nbsp; main and sub-panlel set up local variables
could not be elimnated fully and there should be something like 150 of
them. But not all are accessed always - maybe about 15 of them at any
given time depending on the SM staus.&lt;BR /&gt;
&lt;BR /&gt;
Problem :&lt;BR /&gt;
&lt;BR /&gt;
Once started the "Finished late"&amp;nbsp; indication&amp;nbsp; is off and
the&amp;nbsp; actual timing&amp;nbsp; alternates between 49 to 52 ms. The CPU
usage is around 25%.&lt;BR /&gt;
&lt;BR /&gt;
But as time goes by,&amp;nbsp; the system gets unstable : After 15 minutes
or so, the Finished Late indication is always ON and the CPU usage is
gradually tending towards or exceeds 100%.&amp;nbsp; &lt;BR /&gt;
&lt;BR /&gt;
Obviously the machine control timing now gets affected and things slow
down badly. Closing the application ands restarting repeats the above
cycle.&lt;BR /&gt;
&lt;BR /&gt;
I am at a loss&amp;nbsp; to understand what is happening ?&amp;nbsp; WIll
breaking down the single Timed Loop to multiple ones help&amp;nbsp; ? WIll
that be an efficient way of parallel threading ?&lt;BR /&gt;
&lt;BR /&gt;
I can post the code but its quite large and will do it as a last resort.&lt;BR /&gt;
&lt;BR /&gt;
thanks&lt;BR /&gt;
&lt;BR /&gt;
Raghunathan&lt;BR /&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 06 Nov 2006 09:08:19 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Timed-loop-and-CPU-usage/m-p/436940#M213904</guid>
      <dc:creator>MogaRaghu</dc:creator>
      <dc:date>2006-11-06T09:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: Timed loop and CPU usage</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Timed-loop-and-CPU-usage/m-p/437900#M214278</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;It sounds like an interesting problem.&amp;nbsp; It would be worth some experimentation to figure out what's going wrong - attempting to decouple major "pieces" of the code would be helpful.&amp;nbsp; For example, you could try breaking your code into multiple loops if that makes sense in your architecture, but perhaps you could even eliminate all but one of the loops to begin with, and see if you can correlate the problem to the code in just one of your loops.&lt;/P&gt;
&lt;P&gt;Another concern is that&amp;nbsp;you mention using many local variables.&amp;nbsp; Variable read operations cause new buffer allocations, so if you're passing arrays around that way, you could be hitting a problem of forcing your machine to perform many allocations and deallocations of memory.&amp;nbsp; As arrays grow, this can be a bigger and bigger problem.&amp;nbsp; You can use other techniques for passing data around your block diagram, such as dataflow if possible (just simple wires), or queues where dataflow can't dicatate program flow completely.&lt;/P&gt;
&lt;P&gt;Hopefully looking into your code with the above considerations will lead you in the right direction.&amp;nbsp; In your case, removing code so that you can identify which elements are causing the problem should help significantly.&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;JLS&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2006 20:16:59 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Timed-loop-and-CPU-usage/m-p/437900#M214278</guid>
      <dc:creator>JLS</dc:creator>
      <dc:date>2006-11-07T20:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Timed loop and CPU usage</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Timed-loop-and-CPU-usage/m-p/438309#M214401</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;I'll just elaborate slightly on a point that JLS made.&amp;nbsp; To me the most likely culprit sounds like an array that is increasing in size.&amp;nbsp; Many array&amp;nbsp;operations' time to execute is proportional to the size of the array.&amp;nbsp; This also applies to data copies,&amp;nbsp;which can be an issue if lots of local variables are in use.&amp;nbsp; Use of functions like "Build Array", "Insert Into Array", etc, particularly inside the loop where you're concatenating on to an existing array&amp;nbsp;using a shift register would be a big red flag.&lt;/P&gt;
&lt;P&gt;Similar, but&amp;nbsp;easy to overlook are some string operations.&amp;nbsp; String concatenation and then processing of the resulting string is very much like a growing array.&lt;/P&gt;
&lt;P&gt;There may be other good explanations for the behavior that I'm not thinking of, but this is where I'd start.&lt;/P&gt;
&lt;P&gt;Good luck!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2006 14:58:49 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Timed-loop-and-CPU-usage/m-p/438309#M214401</guid>
      <dc:creator>JeffBoettcher</dc:creator>
      <dc:date>2006-11-08T14:58:49Z</dc:date>
    </item>
  </channel>
</rss>

