Daniel Rychlik <> wrote:
> Thank you for the information...  I have that part working now
> however Ive hit another road block... 
> 
> I have 3 threads that do different things with different files. 
> Those routines are separated in my program.  When I go and grad all
> of the files that need processing, I then spawn the threads to do the
> job of handling the files.  After the spawning process, my processor
> spikes 100% and my memory usage slowly climbs...  Im doing something
> wrong...     
> 
> So here is my loosely based logic of what my program is doing.  I am
> writing this program as an NT service for Windows 2003 server. 
> 
> While (ContinueRun()) {
> 
> Opendir(QUEUE, "directory") or die $!;
> 
> While (defined ( $file = readdir (QUEUE)) ) {
> 
>       If ($file =~ /^local/) {
>               Push (@localData, $file);
>       }
>       If ($file =~ /^remote/) {
>               Push (@remoteData,$file);
>       }
> 
> }
> 
> Closedir(QUEUE);
> 
> $thread1 = threads->create("local_sub",@localData);
> $thread2 = threads->create("remote_sub",@remoteData);
> 
> 
> $thread1->detach();
> $thread2->detach();
> 
> # Sleep 10 seconds and check the que again for any other data.
> Sleep(10);
> 
> }
> 
> Any suggestions of what I should do differently?

Yes. Provide more information. Posting a short self contained example
(SSCE) script that demonstrates the problem would be best. If you are
going to post code, it is better to cut & paste real code. The code
above looks like you just typed it in.

However, I have a couple of observations.

It is probably not a good idea to create new threads every 10 seconds. A
better design might be to use a fixed number of threads and
Thread::Queue objects to pass filenames to them. Don't forget creating
threads is quite expensive. Also, if the thread functions don't exit,
that could well be your problem, or at least part of it. And even if
they do exit it can sometimes take a while before the their resources
are released (I have seen it take up to 2 minutes on Solaris). In any
event, your problem could easily be in your thread functions, which you
don't give any information about, let alone provide code.

You should try to get your program working from the command line before
making it a service. I will be a lot easier to debug. Better still
design it so that it can be run either way. Assuming that you haven't
done so already, that is.

Just to repeat, a SSCE will probably get better results

=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the 
intended addressee(s). Unauthorised reproduction, disclosure, modification, 
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message do not 
necessarily reflect those of Atos Euronext Market Solutions.

L'information contenue dans cet e-mail est confidentielle et uniquement 
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. 
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail 
vous parvient par erreur, nous vous prions de bien vouloir prevenir 
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre 
systeme. Le contenu de ce message electronique ne represente pas necessairement 
la position ou le point de vue d'Atos Euronext Market Solutions.


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to