From: "R. Joseph Newton" <[EMAIL PROTECTED]>
> Madhu Reddy wrote:
> 
> > Hi,
> >   I have following sorting program...
> > basically it will split the large files into small
> > file and creates thread..each thread will sort files
> > after that merge back all sorted files...
> >
> > this program works fine on single CPU machine...
> > same program giving problem on 8 CPU machine...
> >
> It could be that the primary thread goes on to:
> 
> $_->join for(@threads);
> my_print("Sorting completed, merging started\n");
> 
> Before the first sort_it thread returns.  Or the first thread moves on
> before the others finish.  I don't know the fine points of Perl
> threads, but I don't see anything explicitly telling the application
> to wait for all threads to complete.

The ->join waits.
$thread->join() means wait for the $thread to complete and reap it.


From: Madhu Reddy <[EMAIL PROTECTED]>
>   I have following sorting program...
> basically it will split the large files into small
> file and creates thread..each thread will sort files 
> after that merge back all sorted files...
> 
> this program works fine on single CPU machine...
> same program giving problem on 8 CPU machine...
> 
> the problem is , after creating the thread....
> one of the thread finishes the job...
> all other threads are still working....
> 
> as soon as one thread finishes the job, i am getting 
> perl application error (pops up small window)
> popup window contains following message...
> 
> ======
> perl.exe application errorr
> 
> The instruction at "0x2808335c" referenced memory at 
> "0x00000004". The memory couldn't be written
> 
> =======

It seems you use a module that was not made thread safe.
Since you see this when a thread finishes I'd think this is caused by 
some object destruction. It seems that some object is DESTROYed and 
it destroys some shared data.

If you create some objects before the thread creation you may want to 
try to bless() them into a different package to prevent the normal 
DESTROY.

You may either do

        @Fake::Object::Class::ISA = qw(Object::Class);
        sub Fake::Object::Class::DESTROY {}
        bless $object, 'Fake::Object::Class';

as soon as possible in each thread or

        bless $object, 'Do not destroy';

before the thread finishes.
It's safer to do the first.

You may also try to pospone loading of some modules AFTER you create 
the threads. So that each thread loads the module separately. 
Sometimes this helps.

Jenda
P.S.: You may want to look at http://Jenda.Krynicky.cz/iThreads.html
It was written in the 5.6.1 times (threads crated by fork()), but it 
stil contains usefull info. IMHO :-)
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to