Thanks - however, my attempt to modify the test program by adding the exec as below so it works in 'parallel' with the main program doesn't work, so I must have missed something.<div><div><br></div><div>program Test;</div>
<div>{$mode objfpc}{$H+}</div><div>uses windows,classes, dos,  crt, sysutils,MTProcs;</div><div>var j:longint;</div><div><br></div><div>// a simple parallel procedure</div><div>procedure DoSomethingParallel(Index: PtrInt; Data: Pointer; Item: TMultiThreadP♦</div>
<div>var</div><div>  i: Integer;</div><div>begin</div><div>  writeln(Index);</div><div>  if index=1 then</div><div>  begin</div><div>  //this compression, using arc (but it could be 7z takes 30 secs)</div><div>   exec('c:\windows\system32\cmd','/c c:\utils\arc a -mx tmp c:\live_sol\ans.dat');</div>
<div>   exit;</div><div>  end;</div><div>  for i:=1 to Index*1000000 do ; // do some work</div><div>end;</div><div><br></div><div>begin</div><div>  ProcThreadPool.DoParallel(@DoSomethingParallel,1,5,nil); // address, startind♦</div>
<div> //main prog eg capturing the xml</div><div>  for j:=1 to 10 do</div><div>   begin write(j,' '); sleep(10000); end;</div><div>end.</div></div><div><br></div><div>John</div><div><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> I have a program that captures xml data every 2-6 secs from a power sensor,<br>
> win , xp. Would like to use freearc ebvery minute or so to compress the<br>
> previous data in parallel w/o stopping the capture. Running arc from cmd<br>
> line using exec eg exec('/c arc.exe outfile infile'); The compression may<br>
> take 30 secs or so.<br>
><br>
> Is using mtprocs as in<br>
> <a href="http://wiki.lazarus.freepascal.org/Parallel_procedures#Getting_MTProcs" target="_blank">http://wiki.lazarus.freepascal.org/Parallel_procedures#Getting_MTProcs</a><br>
><br>
> the best way to do this? Or threads. Any other ideas?<br>
<br>
mtprocs uses TThreads.<br>
It creates them on demand and only once and destroys them at the end of<br>
the program. If there is nothing to do the threads are waiting using no<br>
CPU cycles and can wake up very quickly. So they are like light weight<br>
threads.<br>
The nice thing is that mtprocs tries to guess the number of cores and<br>
automatically creates this amount of threads. You can limit the number<br>
of threads or create more if you want. You can free the threads.<br>
I use mtprocs for several xml servers. One server for example<br>
reads files with 12 cores in parallel, scaling nicely.<br>
Another program of mine starts 100 pings in parallel.<br>
mtprocs supports recursion and exceptions.<br>
And it is written entirely in FPC, so it works X-platform.<br>
<br>
Mattias<br>
_______________________________________________<br>
fpc-pascal maillist  -  <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</blockquote></div><br></div>