Recent

Author Topic: Multiple TAsyncProcess conundrum  (Read 6731 times)

liewald

  • Full Member
  • ***
  • Posts: 142
Multiple TAsyncProcess conundrum
« on: February 19, 2010, 10:38:24 pm »
I'm writing a prog that has to launch multiple processes and log their output, which is quite verbose. I have no problem launching the processes or polling the running flag to catch when they end for program flow purposes. The [ponewconsole] works perfectly but I just can't figure out how to spool the console output from the multiple sources to multiple log files . The buffers just overflow and the launched processes die.

basically I'm running 14 processes and need them to spool output to 14 log files.

the environment is linux on a 16 processor thread machine (Dual Xeon)

any Ideas anyone?

liewald

  • Full Member
  • ***
  • Posts: 142
Re: Multiple TAsyncProcess conundrum
« Reply #1 on: February 20, 2010, 01:13:11 pm »
I Slept on it and thought I had the brainwave. Create individual threads to poll the outputs and write the files. Seemed like an idea but I'm working in linux and not when I try a simple tthread create it's killing the app.

I've been through the forums, the wiki and the FP dosumentation. Does anyone have a solution to launching threads under linux.

Thanks

Dave


liewald

  • Full Member
  • ***
  • Posts: 142
Re: Multiple TAsyncProcess conundrum
« Reply #2 on: February 24, 2010, 09:27:33 am »
Slowly going NUTS

I'm working my way through this but I'm now getting an error 211 when I'm creating the threads.

I have cthreads first in the uses statement

uses
  cthreads,
  cmem,
  heaptrc,
  Interfaces,
  Forms     


I have {$threading on} set

the thread definition is simple

Type
    TReadThread = class(TThread)
    private
    procedure showstatus;
    protected
      procedure Execute;
    public
      Constructor Create(Createsuspended:boolean);
    end; 


the thread create is minimal

constructor TreadThread.Create(CreateSuspended : boolean);
  begin
    FreeOnTerminate := True;
    inherited Create(CreateSuspended);
  end;   


there is a simple showstatus proc
procedure TreadThread.showstatus;

begin
mainform.threadout.add(timetostr(now));
end;
       


I have simplified the execute to just running showstatus using synchronize

procedure TReadThread.Execute;

 begin
    while (not Terminated)  do
      begin
     synchronize(@showstatus);
      sleep(1000);
   end;
end;     


What am I Missing?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2583
Re: Multiple TAsyncProcess conundrum
« Reply #3 on: February 24, 2010, 10:32:22 am »
IIRC 211 is an invalid pointer operation. I see you use cmem, do you use this as forst in your project file too ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

 

TinyPortal © 2005-2018