Re: Win32::GUI, WMI, and threads

2011-10-27 Thread Jonathan Epstein
I'd try putting all the Win32::OLE stuff into its own (single) thread, 
separate from the GUI thread.  Some creative use of variables (and e.g. 
a Tk Progress bar) can allow you to provide a GUI which indicates how 
long you've been waiting for a WMI call to respond.


HTH,

Jonathan


On 10/27/2011 5:24 PM, Ken Cornetet wrote:


I am writing a Win32::GUI app to monitor a Citrix farm of servers and 
I’ve got things going pretty well. The problem is that I make a lot of 
WMI calls (via Win32::OLE) and they can take anywhere from a second to 
a couple of minutes to complete. This prevents the GUI code from doing 
its normal event loop processing and results in a non-responsive 
windows interface.


I’m thinking that threads are the answer, but any time I’ve mixed 
threads and Win32::OLE, the results have been less than satisfactory. 
Does anyone know how to make Win32::OLE (WMI specifically) and threads 
work together?


Or, is there any way to do async WMI calls?

Ken Cornetet 812.482.8499

To err is human - to moo, bovine.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Win32::GUI, WMI, and threads

2011-10-27 Thread Ken Cornetet
I am writing a Win32::GUI app to monitor a Citrix farm of servers and I've got 
things going pretty well. The problem is that I make a lot of WMI calls (via 
Win32::OLE) and they can take anywhere from a second to a couple of minutes to 
complete. This prevents the GUI code from doing its normal event loop 
processing and results in a non-responsive windows interface.

I'm thinking that threads are the answer, but any time I've mixed threads and 
Win32::OLE, the results have been less than satisfactory. Does anyone know how 
to make Win32::OLE (WMI specifically) and threads work together?

Or, is there any way to do async WMI calls?

Ken Cornetet 812.482.8499
To err is human - to moo, bovine.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Net::SNMP and threads

2007-06-17 Thread Chris Wagner
At 06:26 PM 6/17/2007 -0700, Bill Luebkert wrote:
>I thought you could only start 64 threads on doze ?  What happens with just
>50 threads instead of 100 ?

I've had over 70 running on XP.  The script is actually running on Solaris.
That's why I said I was "just asking". :P




--
REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
"...ne cede malis"

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Net::SNMP and threads

2007-06-17 Thread Chris Wagner
Greetz all, my email was toasted but now I finally got it fixed.

I wanted to ask here if anybody had any experience using Net::SNMP with
threads.  I'm working on a script that uses it to poll device data with 100
concurrent threads.  The memory usage however goes up forever, until it
crashes.  I wrote two test scripts that make a single snmp call, the routing
table, and just let the data expire.  Nothing is saved, just call and let
die. Then I ran that on 1000 devices.  The non threaded version runs fine,
no memory bloat.  The 100 thread version however starts at around 450 MB but
goes to 1.4 GB.  Serious trouble there.

I'm not really trying to get into troubleshooting it here, just wanted to
know if any of u have used it or know of a fix or workaround.  I contacted
the author and he's not sure what's wrong, though he is looking in to it.

Ja.




--
REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
"...ne cede malis"

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


simple perl 5.8 thread pool creation was "perl 5.8 threads and Thread::Pool"

2006-12-09 Thread mailware


Hi all,

Activestate only support v.0.1 of Thread-Pool, while the current module, 0.32 is
not supported.

The one provided in the activeperl repository (0.1) does not support perl 5.8
threads.

How can I implement simple thread-pooling using perl 5.8 threads?
I would need some way of injecting code into the loaded threads, have the
ability to reuse threads, and keep track of thread slots available.

A simple example would be great. I am not an expert when it comes to threads,
just so you are aware.

thanks,

-Jer A

previous message:

Hi all,

Activestate only support v.0.1 of Thread-Pool, while the current module, 0.32 is
not supported.

The one provided in the activeperl repository (0.1) does not support perl 5.8
threads.

How can I implement simple thread-pooling using perl 5.8 threads?
I would need some way of injecting code into the loaded threads, have the
ability to reuse threads, and keep track of thread slots available.

A simple example would be great. I am not an expert when it comes to threads,
just so you are aware.

thanks,

-Jer A 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


perl 5.8 threads and Thread::Pool

2006-12-09 Thread mailware


hi all,

I want to create a pool of perl 5.8 threads, but Thread::Pool was built for the
old Thread implementation, and it does not work!

is there a module for perl 5.8 that creates thread pools?

Thanks in advance for your help.

-Jer A. 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Threads Error

2006-08-19 Thread Chris Wagner
Another thing that will help prevent problems, are u locking all ur shared
variables before accessing them?  {lock $var; pop @array;} etc.

At 01:20 AM 8/19/2006 -0400, Chris O wrote:
>Thanks for the insight. I'm looking into the queing mod now. In the mean
>time, I found that using an array instead of a hash works flawlessly (so
>far) but slowed the script about 50%.




--
REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
"...ne cede malis"

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Threads Error

2006-08-18 Thread Chris Wagner
At 03:10 PM 8/18/2006 -0400, Chris O wrote:
>huge amount of internet content (similar to a search engine). I'm using a
>hash to store and limit concurrent threads to reasonable number; as well as
>sharing hashes between threads (threads::shared); At seemingly random
>intervals the script crashes with an error like "Free to wrong pool 223f98
>not 1d3d210 at D:/Perl/lib/XSLoader.pm line -1.". Anyone have an idea what

That sounds like a classic thread collision.  Something not 100% thread safe
stepping on another thread's toes.  I never fully solved the thread death
problem but I did come up with a way to minimize and mitigate it.  What I
did was to setup a fixed number of worker threads and dispatch work to them
with a message queue from the main thread.  That way u don't have to worry
about too many threads for ur hardware.  We have a dual Sparc Sunfire server
with 2GB memory and it can run my script with 100 worker threads. :)
perlthrtut is a good read.  U can handle thread death by installing a
$SIG{__DIE__} handler.

$queue = new Thread::Queue;

for (1 .. $numthreads) {
threads->create("workfunction");
}
$queue->enqueue(@hoststocheck);

sub workfunction {
$host = $queue->dequeue;
do_something;
}





--
REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
"...ne cede malis"

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Threads Error

2006-08-18 Thread Chris O

All,

I have a script that utilizes www::mechanize to download and categorize a
huge amount of internet content (similar to a search engine). I'm using a
hash to store and limit concurrent threads to reasonable number; as well as
sharing hashes between threads (threads::shared); At seemingly random
intervals the script crashes with an error like "Free to wrong pool 223f98
not 1d3d210 at D:/Perl/lib/XSLoader.pm line -1.". Anyone have an idea what
this error means or why this is happening? Is there a better way to limit
concurrent threads?

ActivePerl-5.8.8.817
WinXP & Win2k Server


- Chris





for my $Host (keys %notvisited){

if (!$threadarray{$Host}) { # No thread already launched
for $Host
while ((scalar keys %threadarray) >= $MaxNbOfThread)
{
sleep 1; # $MaxNbOfThread thread running
reached, so we wait
}

$threadarray{$Host}=1;  # Semaphore to tell
thread for $Host is active
        my $t = threads->create(sub{DoTheThing($Host)});
if (!$t) { error("Failed to create new thread\n"); }

$t->detach();   # We don't need to keep return code
}

}


sub DoTheThing{
my $thehost=shift;
#uses www::mechanize to download $Host
}

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: threads terminate my perl scripts

2006-07-26 Thread Chris Wagner
If perl itself is dieing just from doing use threads I would try
reinstalling it with a fresh download.  If it still does it I would file a
bug report. http://bugs.activestate.com/





--
REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
"...ne cede malis"

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


threads terminate my perl scripts

2006-07-26 Thread Roberto S. G.
hi,
I'm using Activestate perl 5.8.8 build817 in a Windows 2003 SP1 server 
enterprise edition Appliance.
I've been trying to use threads in my scripts, but neither "use threads" 
nor "fork" run... : the script just dies in the threads->create(), no 
info is shown in command line window, and the event viewer shows this info:

The application, C:\Perl\bin\perl.exe, generated an application error 
The error occurred on 07/26/2006 @ 11:52:20.744 The exception generated 
was c005 at address 28088703 (perl58!Perl_stashpv_hvname_match)
Faulting application perl.exe, version 5.8.8.817, faulting module 
perl58.dll, version 5.8.8.817, fault address 0x00088703.

I think I could use "use threads" in a windows 2000 some time ago, so I 
don't know exactly how could I fix this...
Any hint will be appreciated.

achantas
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Win32::OLE & threads

2006-05-12 Thread Jan Dubois
On Fri, 12 May 2006, ?  wrote:
> I have the latest - 5.8.8.817 - perl installed on my Win2000 SP4.
> Running this script
>
> use threads; use Win32::OLE; threads->new( sub {print "oops, i did it
> again\n"} )->join; __END__
>
> crushes perl interpreter after execution with the following message:
> "Free to wrong pool 1a43338 not 15d2cf0 during global destruction."
>
> There is no issue as soon as 'use Win32::OLE;' is #ed OR no join() or
> detach() is called on a thread.
>
> I'm sure there are folks who ran into this before. Any explanations?

Yes, Win32::OLE is still not compatible with either fork() emulation nor
the threads module.

Cheers,
-Jan


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Win32::OLE & threads

2006-05-12 Thread Артем Аветисян
Hi, all.

I have the latest - 5.8.8.817 - perl installed on my Win2000 SP4.
Running this script 

use threads;
use Win32::OLE;
threads->new( sub {print "oops, i did it again\n"} )->join;
__END__

crushes perl interpreter after execution with the following message:
"Free to wrong pool 1a43338 not 15d2cf0 during global destruction."

There is no issue as soon as 'use Win32::OLE;' is #ed OR no join() or detach() 
is called on a thread.

I'm sure there are folks who ran into this before. Any explanations?

Thanks,
Artem A.Avetisyan.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Win32 Perl Threads SLOW memory leak.

2006-04-13 Thread John Serink
Hi All:

The attached script is a performance test model I use for a production
script I have that uses sockets to connect to various targets once per
minute. It used to leak 2 handles per thread per run but that has been
fixed with perl 5.8.8-817. Now that the handles leak is fixed I have
been observing the test script over the last 4 days and she's leaking
memory...quite badly(as is the production code). I have used perfmon to
log the used memory( private bytes) which is growing at a rate of
1688.5t + 20,000,000 where t is time in units of 15 seconds. For
example, for t=240(1 hour) the memory increases 400Kbytes. Over 24
hours, it increases by ~9.6Mbytesand just keeps going up. I'd like
to make my production code a service but can't until I nail down this
memory leak. Handles are stable.

Any ideas?

Cheers,
John
Code is below:
use strict;
use warnings;
use IO::Select;
use Time::HiRes qw(gettimeofday);
use threads; 
use threads::shared;

my $MODBUSPORT=502;
my $UPDATERATE = 30;
my $CONNECTIONTIMEOUT = 10;
my $SOCKREADTIMEOUT = 5;
my $myfile = ">log.log";
my $i=0;
my $responsesIndex = 0;
my $thistime=gettimeofday();
my $starttime=$thistime;
my %responses: shared ;
my %connstatus: shared ;
my %readstatus: shared ;

while(1){
 my %addresses = (  "one  " => 1,
 "two  " => 2,
 "three" => 3,
 "four " => 4,
 "five " => 5,
 "six  " => 6,
 "seven" => 7,
 "eight" => 8,
 "nine " => 9,
 "ten  " => 10,
 "eleven"=> 11,
 "twelve"=> 12,
 "thirteen" => 13,
 "fourteen" => 14,
 "fifteen" => 15,
 "sixteen" => 16,
 "seventeen" => 17,
 "eightteen" => 18,
 "nineteen" => 19,
 "twenty" => 20);
 my %threadIDs ;
 my %conntimeout ;
 my %readtimeout ;

clearscreen();
 $thistime = gettimeofday();
 my @jim = keys(%addresses);
 for($i=0;$inew(\&goconnect, $addresses{$jim[$i]},
$MODBUSPORT);
  $thrconn -> detach();
  $threadIDs{$jim[$i]} = $thrconn->tid();
  if($i==0){
   $responsesIndex = $threadIDs{$jim[$i]};
   print("Responses Index is $responsesIndex\n");
  }
  $connstatus{$threadIDs{$jim[$i]}} =0;
  $readstatus{$threadIDs{$jim[$i]}} =0;
  $conntimeout{$threadIDs{$jim[$i]}} = gettimeofday();
  $readtimeout{$threadIDs{$jim[$i]}} =0;
  $responses{$threadIDs{$jim[$i]}} =0;  
 }
 my $jim = scalar(keys(%connstatus));
 print("the connstatus hash has $jim elements\n");
 while(scalar(keys(%connstatus))>0){
  my @frank=keys(%connstatus);
  for($i=0;$i$CONNECTIONTIMEOUT){
$responses{$frank[$i]}="Connection Timeout";
my $temp = "";
$temp=returnvalue(\%threadIDs,$frank[$i]);
unless($temp){
 $temp="";
}
$temp = $temp." : ".$responses{$frank[$i]}." ".localtime();
print("$temp\n");
delete($connstatus{$frank[$i]});
   } 
  }
  IO::Select->select(undef,undef,undef,0.5);
}

 my $temptime = gettimeofday()-$thistime;
 print("Preparing to wait, $temptime\n");
 my $steve=hashdestroy(\%connstatus);
 $steve = hashdestroy(\%readstatus);
 $steve = hashdestroy(\%readtimeout);
 $steve = hashdestroy(\%conntimeout);
 $steve = hashdestroy(\%threadIDs);

my $runtime = gettimeofday() - $starttime;
 my $runtimehours = int($runtime/3600);
 my $runtimeminutes = int(($runtime/3600 - $runtimehours)*60);
 my $runtimeseconds = int((($runtime/3600 - $runtimehours)*60 -
$runtimeminutes)*60);
 print("Program run time $runtimehours hours $runtimeminutes minutes
$runtimeseconds seconds\n");
 select(STDOUT);
 $|=1;
do {
 my $displaytime = $UPDATERATE - $temptime;
  $displaytime = sprintf("%05.1f", $displaytime);
  print("Time to next query $displaytime seconds\r");
  select(undef,undef,undef,0.1);
  $temptime = gettimeofday()-$thistime;
 } while($temptime < $UPDATERATE);
}

#  subroutine hashdestroy(\%hash) destroys all the remaining elements  #
#  of the hash pointed to by the reference \$hash. It returns the  #
#  number of elements destroyed.   #
#  #

sub hashdestroy
{
 my $jim = shift();
 my @bob=keys(%$jim);
 my $numdel = 0;
 
 foreach my $bill (@bob){
  delete($$ji

RE: ActivePerl 5.8.8.817 released-Win32 Threads Leaking handles

2006-03-29 Thread John Serink
Hello Jan and Fellow Users:

The Win32 threads leaking handles bug is fixed! Yippie!
OUTSTANDING! Well done development team.

Have tested it on my leaking handles script and my production code,
looks good. The number of handles open jumps when the threads are
launched and as the detached threads die, the handles drop right back
down again as they should.

Cheers,
john

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Jan Dubois
> Sent: Thursday, March 30, 2006 10:50 AM
> To: activeperl@listserv.ActiveState.com; 
> perl-win32-users@listserv.ActiveState.com
> Subject: ActivePerl 5.8.8.817 released
> 
> 
> ActiveState has released ActivePerl 5.8.8.817 today.  It 
> fixes a number of serious issues that have been found in the 
> 816 release:
> 
> * Restored binary compatibility to previous releases.
> * Fixed several bugs on Windows related to GUI applications and
>   signal handling.  These bugs were introduced in build 816.
> * Updated threads and threads::shared modules to fix resource leaks
> 
> As usual, you can download it via the main ActivePerl page:
> 
> http://www.ActiveState.com/ActivePerl
> 
> Note that there is a separate link for downloading the 64 bit 
> Beta versions.
> 
> Please send feedback to
> 
> [EMAIL PROTECTED]
> 
> and report bugs at
> 
> http://bugs.ActiveState.com
> 
> I've appended the relevant section of the CHANGES-58.pod file 
> to show some more detail on other changes from the previous release.
> 
> Cheers,
> -Jan
> 
> Build 817 is based on Perl 5.8.8.
> 
> I
> 
> =over 8
> 
> =item *
> 
> Upgraded the core threads and threads::shared modules with 
> threads-1.12 and threads-shared-0.99 from CPAN. This fixes 
> the handle leakage on Windows and allows setting the stack 
> size for new threads. It also fixes both the '!=' comparison 
> operator for thread objects and the crashes while joining 
> threads that go re-introduced in build 816.
> 
> =item *
> 
> Fixed several bugs in the new implementation of alarm() for 
> Windows. They did manifest themselves by signals not being 
> delivered, or by GUI applications randomly hanging.
> 
> =item *
> 
> Restored binary compatiblity for SvPV_nolen() and similar 
> macros. This incompatibility made it impossible to use 
> perlapp for Unix on Tk based applications.
> 
> =item *
> 
> Reintroduce PL_memory_wrap for binary compatiblity.
> 
> =item *
> 
> The C builtin now ignores directories matching the 
> given name when searching @INC.
> 
> =back
> 
> 
> ___
> Perl-Win32-Users mailing list 
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Threads

2006-02-27 Thread Tom Pollard
On Tue, Feb 28, 2006 at 10:51:39AM +0800, Foo Ji-Haw wrote:
> But don't get too ambitious on Perl's ithreads. They are fun, but not as 
> rich as threads from other languages.

They're also unstable under Unix, and will cause your script to crash
randomly (though not frequently, in my experience.)  This is not a
problem for Win32 Perl, as far as I've been able to tell, but if you
expect your scripts to be cross-platform, don't count on using ithreads
on the Unix side.

TomP
-- 
-
Tom Pollard   [EMAIL PROTECTED]
Schrodinger, Inc.646-366-9555 x102
-

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Threads

2006-02-27 Thread Foo Ji-Haw

Yup. Basically that's it. :)

But don't get too ambitious on Perl's ithreads. They are fun, but not as 
rich as threads from other languages.


Carter Thompson wrote:


Is this really as easy as it seems or am I over looking something?

I have an array with references to tests.  I want to loop through each
element in the array, call a subroutine passing in the test reference
using a thread.   When all tests (threads) have been started I want to
loop through all threads and join so I can retrieve relevant data.

# Start threads.
my @threads = ();
foreach my $ref (@individual_tests) {
    $thr = threads->new(\&run_test, $ref);
push(@threads, $thr);
}

# Retrieve data
foreach my $thr (@threads) {
my $results = $thr->join();
 }

# run_test sub
sub run_test {
my $ref = shift;

# do stuff in here.

}



Thanks for looking this over.

Carter.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Threads

2006-02-27 Thread Carter Thompson


Is this really as easy as it seems or am I over looking something?

I have an array with references to tests.  I want to loop through each
element in the array, call a subroutine passing in the test reference
using a thread.   When all tests (threads) have been started I want to
loop through all threads and join so I can retrieve relevant data.

# Start threads.
my @threads = ();
foreach my $ref (@individual_tests) {
$thr = threads->new(\&run_test, $ref);
    push(@threads, $thr);
}

# Retrieve data
foreach my $thr (@threads) {
my $results = $thr->join();
 }

# run_test sub
sub run_test {
my $ref = shift;

# do stuff in here.

}



Thanks for looking this over.

Carter.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


threads and consoles

2006-01-16 Thread John Serink
Hi All:

Is there a way for a thread to have its own console separate from the
calling process?

Cheers,
john

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


creating sub-threads

2006-01-12 Thread Foo Ji-Haw

Hi all,

Does anyone know if it is possible for a thread to create its own child 
threads? All the threads that are created seem to be tied to the main 
thread, regardless of the thread they were created from.


I've tried:
threads->self->create

But it's no go either. Complete test code is attached.

Any confirmation on this is appreciated. Thanks.
use strict;
use warnings;
use threads;
use threads::shared;

$|=1;

my %command : shared = (1=>'',2=>'');

my $thread = threads->create(\&startThread,1);
my $thread2 = threads->create(\&startThread,2);
sleep(5);

while (1)
{
print "pinging threads\n";
{
lock %command;
$command{1} = 'PING';
$command{2} = 'PING';
}
sleep 5;
lock %command;
foreach my $id (1..2)
{
if ($command{$id} eq 'PING')
{
print "thread $id looks dead\n";
}
else
{
print "thread $id looks alive\n";
    }
}
sleep 5;
}


$thread->join;

sub startThread
{
my $id = shift;

threads->self->create(\&pingThread,$id);
print "Thread $id: started\n";
while (1) 
{ 
die "$id is dead\n" if (int(rand(20)) == 1);
print "$id do stuff\n";
sleep(1);
}
}

sub pingThread
{
my $id = shift;

while (1)
{
{
lock %command;
if ($command{$id} eq 'PING')
{
$command{$id} = 'PONG';
print "$id: I've been pinged!\n";
}
}
sleep (1);
}
}___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Detecting 'dead' threads in Perl

2005-12-20 Thread Foo Ji-Haw

Hi all,

Just wondering if anyone is working with ithreads (not the old threading 
model). If so, how do you discover dead threads? Hope you can share your 
experiences. Thanks.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-29 Thread $Bill Luebkert
Tom Pollard wrote:

> The use of an alarm to timeout an eval{} block definitely works.  I don't
> know why it works, but it does.  I do get the impression that alarms are
> handled in some special way by perl, because this idiom works on all
> platforms we've tried it on (Linux, AIX, IRIX, MacOSX, Windows), even
> though ordinary signal delivery to a threaded app isn't predictable (that
> is, which thread gets the signal?) on some of those platforms.

I just ran a little test using LWP to get a URL and having the CGI script
do a 10 second delay while I did a 5 second alarm eval.  The timer failed
to timeout until after the LWP timeout and then the strangest part was
the result returned from the LWP request came back with the alarm die code
in it:

eval {
$SIG{ALRM} = sub { die "5 second alarm went off" };
alarm 5;
do_url ();  # do an LWP request that takes 10 seconds
alarm 0;
};

Part of the response object dump:

  '_content' => '500 5 second alarm went off
',
  '_msg' => '5 second alarm went off',
  '_rc' => 500,

Very strange indeed.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-26 Thread Tom Pollard
On Thu, 25 Aug 2005, $Bill Luebkert wrote:
> >>win32 doesn't have signals and any that are implemented don't actually
> >>interrupt the receiving process.  I believe they just use simple message
> >>passing to fake it - so your mileage may vary.
> > 
> > My point was precisely that "they" have arranged that this idiom works 
> > under Windows.  Your mileage should not vary; my experience is that 
> > it always works.  
> 
> Which idiom is that ?  SIGALRM ?  or signals in general ?  or your
> eval example specifically ?

The use of an alarm to timeout an eval{} block definitely works.  I don't
know why it works, but it does.  I do get the impression that alarms are
handled in some special way by perl, because this idiom works on all
platforms we've tried it on (Linux, AIX, IRIX, MacOSX, Windows), even
though ordinary signal delivery to a threaded app isn't predictable (that
is, which thread gets the signal?) on some of those platforms.

This didn't work in ActiveState's perl 5.6.1, but as of the 5.8.0 release
it was working.  In any case, we use the technique widely in our
networking code and have found it to work reliably.

TomP

-
Tom Pollard   [EMAIL PROTECTED]
Schrodinger, Inc.646-366-9555 x102
-


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [threads] Forced termination

2005-08-25 Thread John Serink
You sure this works under windows?

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Tom Pollard
> Sent: Friday, August 26, 2005 2:17 AM
> To: ajpeck
> Cc: Perl Win32 mail list
> Subject: Re: [threads] Forced termination
> 
> 
> On Thu, 25 Aug 2005, ajpeck wrote:
> > Is there a way to forcibly terminate a thread after a specified time
> > regardless if the thread is finished executing. 
> 
> The standard eval{}-timeout technique apparently works well 
> for threads. That is, wrap the code that might hang for 5 min 
> in an eval{} block and use an alarm to time it out, e.g.
> 
> eval {
>   local %SIG{ALRM} = { die "TIMEOUT\n"; };
>   alarm 5;
>   <...your code here...>
>   alarm 0;
> }
> giveup() if $@ =~ /^TIMEOUT/;
> 
> ...where giveup() does whatver you need to do to exit from the thread 
> prematurely.  In general, threads and signals are awkward to 
> use together, 
> but this particular idiom has been unproblematic for us in 
> our threaded 
> perl apps.
> 
> TomP
> 
> > I have threads which
> > call certain network functions that have very long hard 
> coded timeouts, 
> > such as 5 mins. A no response of 5 secs is sufficient for 
> me to know 
> > that there is a problem and the nature of it is not needed (device 
> > switched off, network break, etc). These threads only write 
> out a status 
> > result (threads::shared variable) at the very end of the thread 
> > execution, thus terminating the thread early from within the parent 
> > thread and with no result written is good enough for me to 
> know that 
> > there is a problem.
> > 
> > Is there a way to impliment timed thread termination, if so I would
> > appreciate it very much for a very simple example.
> 
> --
> ---
> Tom Pollard   
> [EMAIL PROTECTED]
> Schrodinger, Inc.646-366-9555 x102
> --
> ---
> 
> 
> ___
> Perl-Win32-Users mailing list 
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-25 Thread $Bill Luebkert
Tom Pollard wrote:

> On Thu, 25 Aug 2005, $Bill Luebkert wrote:
> 
>>win32 doesn't have signals and any that are implemented don't actually
>>interrupt the receiving process.  I believe they just use simple message
>>passing to fake it - so your mileage may vary.
> 
> 
> My point was precisely that "they" have arranged that this idiom works 
> under Windows.  Your mileage should not vary; my experience is that 
> it always works.  

Which idiom is that ?  SIGALRM ?  or signals in general ?  or your
eval example specifically ?

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-25 Thread Tom Pollard
On Thu, 25 Aug 2005, $Bill Luebkert wrote:
> win32 doesn't have signals and any that are implemented don't actually
> interrupt the receiving process.  I believe they just use simple message
> passing to fake it - so your mileage may vary.

My point was precisely that "they" have arranged that this idiom works 
under Windows.  Your mileage should not vary; my experience is that 
it always works.  

TomP

-
Tom Pollard   [EMAIL PROTECTED]
Schrodinger, Inc.646-366-9555 x102
-


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-25 Thread $Bill Luebkert
Tom Pollard wrote:

> On Thu, 25 Aug 2005, ajpeck wrote:
> 
>>Is there a way to forcibly terminate a thread after a specified time 
>>regardless if the thread is finished executing. 
> 
> 
> The standard eval{}-timeout technique apparently works well for threads.
> That is, wrap the code that might hang for 5 min in an eval{} block and
> use an alarm to time it out, e.g.
> 
> eval {
>   local %SIG{ALRM} = { die "TIMEOUT\n"; };
>   alarm 5;
>   <...your code here...>
>   alarm 0;
> }
> giveup() if $@ =~ /^TIMEOUT/;
> 
> ...where giveup() does whatver you need to do to exit from the thread 
> prematurely.  In general, threads and signals are awkward to use together, 
> but this particular idiom has been unproblematic for us in our threaded 
> perl apps.

win32 doesn't have signals and any that are implemented don't actually
interrupt the receiving process.  I believe they just use simple message
passing to fake it - so your mileage may vary.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-25 Thread $Bill Luebkert
Foo Ji-Haw wrote:

> I guess Perl's threading is not quite complete as of 5.8.x. But with forking 
> it is possible to kill a child process?

You can certainly do it using Win32::Process, but you may have more
trouble passing info to/from - I've never used the simulated fork on
Win32.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-25 Thread Tom Pollard
On Thu, 25 Aug 2005, ajpeck wrote:
> Is there a way to forcibly terminate a thread after a specified time 
> regardless if the thread is finished executing. 

The standard eval{}-timeout technique apparently works well for threads.
That is, wrap the code that might hang for 5 min in an eval{} block and
use an alarm to time it out, e.g.

eval {
  local %SIG{ALRM} = { die "TIMEOUT\n"; };
  alarm 5;
  <...your code here...>
  alarm 0;
}
giveup() if $@ =~ /^TIMEOUT/;

...where giveup() does whatver you need to do to exit from the thread 
prematurely.  In general, threads and signals are awkward to use together, 
but this particular idiom has been unproblematic for us in our threaded 
perl apps.

TomP

> I have threads which 
> call certain network functions that have very long hard coded timeouts, 
> such as 5 mins. A no response of 5 secs is sufficient for me to know 
> that there is a problem and the nature of it is not needed (device 
> switched off, network break, etc). These threads only write out a status 
> result (threads::shared variable) at the very end of the thread 
> execution, thus terminating the thread early from within the parent 
> thread and with no result written is good enough for me to know that 
> there is a problem.
> 
> Is there a way to impliment timed thread termination, if so I would 
> appreciate it very much for a very simple example.

-
Tom Pollard   [EMAIL PROTECTED]
Schrodinger, Inc.646-366-9555 x102
-


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-25 Thread Foo Ji-Haw
I guess Perl's threading is not quite complete as of 5.8.x. But with forking 
it is possible to kill a child process?


- Original Message - 
From: "$Bill Luebkert" <[EMAIL PROTECTED]>

To: "ajpeck" <[EMAIL PROTECTED]>
Cc: "Perl Win32 mail list" 
Sent: Thursday, August 25, 2005 6:23 PM
Subject: Re: [threads] Forced termination



ajpeck wrote:


Is there a way to forcibly terminate a thread after a specified time
regardless if the thread is finished executing. I have threads which
call certain network functions that have very long hard coded timeouts,
such as 5 mins. A no response of 5 secs is sufficient for me to know
that there is a problem and the nature of it is not needed (device
switched off, network break, etc). These threads only write out a status
result (threads::shared variable) at the very end of the thread
execution, thus terminating the thread early from within the parent
thread and with no result written is good enough for me to know that
there is a problem.

Is there a way to impliment timed thread termination, if so I would
appreciate it very much for a very simple example.


I tried (using Win32::API) to get the current thread ID and store
in a shared vrbl by the sub thread and terminate the sub thread
from the root thread, but I get an error on the TerminateThread :

Bad file descriptor (The handle is invalid)

even though the thread ID looks fine.

So unless that can be resolved, that won't work.

--
 ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
(_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
 / ) /--<  o // //  Castle of Medieval Myth & Magic 
http://www.todbe.com/

-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs 


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-25 Thread $Bill Luebkert
ajpeck wrote:

> I am now trying a process and threads hybrid to get around the problem.
> 
> We can hope that for Perl 6 a function can be added to threads for 
> immediate termination of child threads and freeing resources immediately 
> from the parent thread.

You may not be able to free all of the resources:

TerminateThread is used to cause a thread to exit. When this occurs,
the target thread has no chance to execute any user-mode code and its
initial stack is not deallocated. DLLs attached to the thread are not
notified that the thread is terminating.

TerminateThread is a dangerous function that should only be used in the
most extreme cases. You should call TerminateThread only if you know
exactly what the target thread is doing, and you control all of the
code that the target thread could possibly be running at the time of
the termination. For example, TerminateThread can result in the
following problems:

·   If the target thread owns a critical section, the critical
section will not be released.
·   If the target thread is executing certain kernel32 calls when
it is terminated, the kernel32 state for the thread's process could be
inconsistent.
·   If the target thread is manipulating the global state of a
shared DLL, the state of the DLL could be destroyed, affecting other
users of the DLL.

A thread cannot protect itself against TerminateThread, other than by
controlling access to its handles. The thread handle returned by the
CreateThread and CreateProcess functions has THREAD_TERMINATE access,
so any caller holding one of these handles can terminate your thread.
If the target thread is the last thread of a process when this function
is called, the thread's process is also terminated.

The state of the thread object becomes signaled, releasing any other
threads that had been waiting for the thread to terminate. The thread's
termination status changes from STILL_ACTIVE to the value of the
dwExitCode parameter.

Terminating a thread does not necessarily remove the thread object from
the system. A thread object is deleted when the last thread handle is
closed.



-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-25 Thread ajpeck

I am now trying a process and threads hybrid to get around the problem.

We can hope that for Perl 6 a function can be added to threads for 
immediate termination of child threads and freeing resources immediately 
from the parent thread.


Alun

$Bill Luebkert wrote:


ajpeck wrote:

 

Is there a way to forcibly terminate a thread after a specified time 
regardless if the thread is finished executing. I have threads which 
call certain network functions that have very long hard coded timeouts, 
such as 5 mins. A no response of 5 secs is sufficient for me to know 
that there is a problem and the nature of it is not needed (device 
switched off, network break, etc). These threads only write out a status 
result (threads::shared variable) at the very end of the thread 
execution, thus terminating the thread early from within the parent 
thread and with no result written is good enough for me to know that 
there is a problem.


Is there a way to impliment timed thread termination, if so I would 
appreciate it very much for a very simple example.
   



I tried (using Win32::API) to get the current thread ID and store
in a shared vrbl by the sub thread and terminate the sub thread
from the root thread, but I get an error on the TerminateThread :

Bad file descriptor (The handle is invalid)

even though the thread ID looks fine.

So unless that can be resolved, that won't work.

 



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-25 Thread $Bill Luebkert
ajpeck wrote:

> Is there a way to forcibly terminate a thread after a specified time 
> regardless if the thread is finished executing. I have threads which 
> call certain network functions that have very long hard coded timeouts, 
> such as 5 mins. A no response of 5 secs is sufficient for me to know 
> that there is a problem and the nature of it is not needed (device 
> switched off, network break, etc). These threads only write out a status 
> result (threads::shared variable) at the very end of the thread 
> execution, thus terminating the thread early from within the parent 
> thread and with no result written is good enough for me to know that 
> there is a problem.
> 
> Is there a way to impliment timed thread termination, if so I would 
> appreciate it very much for a very simple example.

I tried (using Win32::API) to get the current thread ID and store
in a shared vrbl by the sub thread and terminate the sub thread
from the root thread, but I get an error on the TerminateThread :

Bad file descriptor (The handle is invalid)

even though the thread ID looks fine.

So unless that can be resolved, that won't work.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [threads] Forced termination

2005-08-25 Thread John Serink
I do this for connecting to ADAM modules which are running MODBUS
servers on port 502.

I use threads as the tcp timeouts in Win32 don't work since I  have to
connect to 27 of these. it takes about about 20 seconds for the thread
to timeout and die if the host I'm trying to connect to isn't
there...and that's fine, works for me.

What are you doing that it takes 5 minutes to timeout?

Cheers,
John

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of ajpeck
> Sent: Thursday, August 25, 2005 3:58 PM
> To: Perl Win32 mail list
> Subject: Re: [threads] Forced termination
> 
> 
> The problem is that I need to reclaim the memory resource of 
> the thread 
> that is not needed no more, so I can start off a new thread. 
> Thus detach 
> is not suitable in this case.
> 
> Alun
> 
> John Serink wrote:
> 
> >Just detach them and forget about them.
> >other than that, I don't think there's a way to terminate them.
> >
> >  
> >
> >>-Original Message-
> >>From: [EMAIL PROTECTED]
> >>[mailto:[EMAIL PROTECTED] On 
> >>Behalf Of ajpeck
> >>Sent: Thursday, August 25, 2005 3:02 PM
> >>To: Perl Win32 mail list
> >>Subject: [threads] Forced termination
> >>
> >>
> >>Is there a way to forcibly terminate a thread after a specified time
> >>regardless if the thread is finished executing. I have 
> threads which 
> >>call certain network functions that have very long hard coded 
> >>timeouts, 
> >>such as 5 mins. A no response of 5 secs is sufficient for 
> me to know 
> >>that there is a problem and the nature of it is not needed (device 
> >>switched off, network break, etc). These threads only write 
> >>out a status 
> >>result (threads::shared variable) at the very end of the thread 
> >>execution, thus terminating the thread early from within the parent 
> >>thread and with no result written is good enough for me to 
> know that 
> >>there is a problem.
> >>
> >>Is there a way to impliment timed thread termination, if so I would
> >>appreciate it very much for a very simple example.
> >>
> >>Thanx
> >>
> >>--
> >>Alun Peck
> >>Section Head: Computers
> >>Department of Mathematical Technology
> >>Faculty of Natural Sciences
> >>Tshwane University of Technology
> >>[EMAIL PROTECTED]
> >>Tel: (012) 318 6389
> >>Fax: (012) 318 6114
> >>
> >>___
> >>Perl-Win32-Users mailing list
> >>Perl-Win32-Users@listserv.ActiveState.com
> >>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> >>
> >>
> >>
> 
> ___
> Perl-Win32-Users mailing list 
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-25 Thread ajpeck
The problem is that I need to reclaim the memory resource of the thread 
that is not needed no more, so I can start off a new thread. Thus detach 
is not suitable in this case.


Alun

John Serink wrote:


Just detach them and forget about them.
other than that, I don't think there's a way to terminate them.

 


-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On 
Behalf Of ajpeck

Sent: Thursday, August 25, 2005 3:02 PM
To: Perl Win32 mail list
Subject: [threads] Forced termination


Is there a way to forcibly terminate a thread after a specified time 
regardless if the thread is finished executing. I have threads which 
call certain network functions that have very long hard coded 
timeouts, 
such as 5 mins. A no response of 5 secs is sufficient for me to know 
that there is a problem and the nature of it is not needed (device 
switched off, network break, etc). These threads only write 
out a status 
result (threads::shared variable) at the very end of the thread 
execution, thus terminating the thread early from within the parent 
thread and with no result written is good enough for me to know that 
there is a problem.


Is there a way to impliment timed thread termination, if so I would 
appreciate it very much for a very simple example.


Thanx

--
Alun Peck
Section Head: Computers
Department of Mathematical Technology
Faculty of Natural Sciences
Tshwane University of Technology
[EMAIL PROTECTED]
Tel: (012) 318 6389
Fax: (012) 318 6114

___
Perl-Win32-Users mailing list 
Perl-Win32-Users@listserv.ActiveState.com

To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

   



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [threads] Forced termination

2005-08-25 Thread John Serink
Just detach them and forget about them.
other than that, I don't think there's a way to terminate them.

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of ajpeck
> Sent: Thursday, August 25, 2005 3:02 PM
> To: Perl Win32 mail list
> Subject: [threads] Forced termination
> 
> 
> Is there a way to forcibly terminate a thread after a specified time 
> regardless if the thread is finished executing. I have threads which 
> call certain network functions that have very long hard coded 
> timeouts, 
> such as 5 mins. A no response of 5 secs is sufficient for me to know 
> that there is a problem and the nature of it is not needed (device 
> switched off, network break, etc). These threads only write 
> out a status 
> result (threads::shared variable) at the very end of the thread 
> execution, thus terminating the thread early from within the parent 
> thread and with no result written is good enough for me to know that 
> there is a problem.
> 
> Is there a way to impliment timed thread termination, if so I would 
> appreciate it very much for a very simple example.
> 
> Thanx
> 
> -- 
> Alun Peck
> Section Head: Computers
> Department of Mathematical Technology
> Faculty of Natural Sciences
> Tshwane University of Technology
> [EMAIL PROTECTED]
> Tel: (012) 318 6389
> Fax: (012) 318 6114
> 
> ___
> Perl-Win32-Users mailing list 
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


[threads] Forced termination

2005-08-25 Thread ajpeck
Is there a way to forcibly terminate a thread after a specified time 
regardless if the thread is finished executing. I have threads which 
call certain network functions that have very long hard coded timeouts, 
such as 5 mins. A no response of 5 secs is sufficient for me to know 
that there is a problem and the nature of it is not needed (device 
switched off, network break, etc). These threads only write out a status 
result (threads::shared variable) at the very end of the thread 
execution, thus terminating the thread early from within the parent 
thread and with no result written is good enough for me to know that 
there is a problem.


Is there a way to impliment timed thread termination, if so I would 
appreciate it very much for a very simple example.


Thanx

--
Alun Peck
Section Head: Computers
Department of Mathematical Technology
Faculty of Natural Sciences
Tshwane University of Technology
[EMAIL PROTECTED]
Tel: (012) 318 6389
Fax: (012) 318 6114

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: references of sub and params in a threads::shared variable

2005-07-25 Thread John Serink
Yup.

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of [EMAIL PROTECTED]
> Sent: Tuesday, July 26, 2005 6:10 AM
> To: Siebe Tolsma
> Cc: perl-win32-users@listserv.ActiveState.com
> Subject: references of sub and params in a threads::shared variable
> 
> 
> how do i use this hash as a shared variable to be used in 
> threads? eg. with threads::shared
> 
> -Jeremy A
> 
> > Why not make it a hash?
> > 
> > my $sub = { ref => \&test, params => [$sockethandle] }; 
> > $sub->{ref}->(@{$sub->{params}});
> > 
> > sub test {
> > my $socket = shift;
> > # ...
> > }
> > 
> > 
> > > hello again,
> > >
> > > > > hello all,
> > > > >
> > > > > here is a ref/deref problem
> > > > >
> > > > > I need to take a socket handle, convert it to a 
> socket ref, then 
> > > > > a
> > scaler
> > > > > string
> > > > >
> > > > > A bit later in the same script, I need to take that scaler 
> > > > > string and
> > turn
> > > > it
> > > > > back to a socket ref, and deref it back to the socket handle.
> > > >
> > > > Maybe instead of asking for the way to implement your solution, 
> > > > you
> > should
> > > > describe the complete problem and see if we can come up with an
> > alternate
> > > > solution that is a little less convoluted.  :)
> > >
> > > let me clarify my problem.
> > >
> > > I have a reference of a subroutine.
> > >
> > > eg.
> > >
> > > $sub = "test";
> > >
> > > ..deref and execute
> > >
> > > &$sub;
> > >
> > > ...
> > >
> > > sub test {
> > > my ($sockethandle,$blah...) = @_;
> > > ..do something
> > > }
> > > 
> > >
> > > in order to pass the paramenters, i decided to do this :
> > >
> > > sub main {
> > >
> > > my $sub = "test|$sockethandle";
> > > ($sub,@_) = split(/\|/,$sub);
> > >
> > > $⊂
> > > }
> > >
> > >
> > > if this is to work correctly, I need to take a socket handle, 
> > > convert it
> > to a
> > > socket ref, then a scaler, so i can pass it as a 
> parameter. in order 
> > > to
> > use the
> > > socket later, i have to take the scaler, convert it to the socket 
> > > ref,
> > then
> > > dereference it.
> > >
> > > Is there an easier way to pass parameters with a subroutine 
> > > reference?
> > >
> > >
> > >
> > >
> > >
> > >
> > > ___
> > > Perl-Win32-Users mailing list 
> > > Perl-Win32-Users@listserv.ActiveState.com
> > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> > >
> > 
> > 
> > ___
> > Perl-Win32-Users mailing list 
> > Perl-Win32-Users@listserv.ActiveState.com
> > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> > 
> 
> 
> 
> 
> ___
> Perl-Win32-Users mailing list 
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


references of sub and params in a threads::shared variable

2005-07-25 Thread mailware
how do i use this hash as a shared variable to be used in threads?
eg. with threads::shared

-Jeremy A

> Why not make it a hash?
> 
> my $sub = { ref => \&test, params => [$sockethandle] };
> $sub->{ref}->(@{$sub->{params}});
> 
> sub test {
> my $socket = shift;
> # ...
> }
> 
> 
> > hello again,
> >
> > > > hello all,
> > > >
> > > > here is a ref/deref problem
> > > >
> > > > I need to take a socket handle, convert it to a socket ref, then a
> scaler
> > > > string
> > > >
> > > > A bit later in the same script, I need to take that scaler string and
> turn
> > > it
> > > > back to a socket ref, and deref it back to the socket handle.
> > >
> > > Maybe instead of asking for the way to implement your solution, you
> should
> > > describe the complete problem and see if we can come up with an
> alternate
> > > solution that is a little less convoluted.  :)
> >
> > let me clarify my problem.
> >
> > I have a reference of a subroutine.
> >
> > eg.
> >
> > $sub = "test";
> >
> > ..deref and execute
> >
> > &$sub;
> >
> > ...
> >
> > sub test {
> > my ($sockethandle,$blah...) = @_;
> > ..do something
> > }
> > 
> >
> > in order to pass the paramenters, i decided to do this :
> >
> > sub main {
> >
> > my $sub = "test|$sockethandle";
> > ($sub,@_) = split(/\|/,$sub);
> >
> > $⊂
> > }
> >
> >
> > if this is to work correctly, I need to take a socket handle, convert it
> to a
> > socket ref, then a scaler, so i can pass it as a parameter. in order to
> use the
> > socket later, i have to take the scaler, convert it to the socket ref,
> then
> > dereference it.
> >
> > Is there an easier way to pass parameters with a subroutine reference?
> >
> >
> >
> >
> >
> >
> > ___
> > Perl-Win32-Users mailing list
> > Perl-Win32-Users@listserv.ActiveState.com
> > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> >
> 
> 
> ___
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: activeperl + mysql + threads = crash

2005-07-25 Thread Paul Sobey
> I thought I can hit a nice milestone today, but it seems that 
> I have hit 
> a strange obstacle instead.
> In my tests, the following code will run, but when it terminates an 
> error message will be shown.
> use strict;
> use warnings;
> use DBI;
> use threads;
> 
> doIt();
> doIt();

[snip]

> Can someone confirm this? Is there anybody who can suggest a 
> workaround? 

The following links imply that DBD::mysql is not threadsafe by default
due to the underlying C library, but can be made so by recompiling. Not
sure whether anyone has any updates on this.

http://aspn.activestate.com/ASPN/Mail/Message/perl-DBI-Dev/2241467
http://search.cpan.org/~jwied/Msql-Mysql-modules-1.2219/mysql/lib/DBD/my
sql.pm#MULTITHREADING

Paul

*
Gloucester Research Limited believes the information 
provided herein is reliable. While every care has been 
taken to ensure accuracy, the information is furnished 
to the recipients with no warranty as to the completeness 
and accuracy of its contents and on condition that any 
errors or omissions shall not be made the basis for any 
claim, demand or cause for action.
*


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: activeperl + mysql + threads = crash

2005-07-25 Thread Reinhard Pagitsch


--- Begin Message ---

Hello,

I made an additional test:
Using the code below Perl v5.8.7 does not crash. In the Task Manager I 
can see that Perl uses 3 threads.

With the original code he uses only one thread.
--- new code --
use strict;
use warnings;
use DBI;
use threads;

print "first\n";
my $thread = threads->new("doIt","argument");
print "scound\n";
my $thread1 = threads->new("doIt","argument");
$thread->join();
$thread1->join();
$thread->detach();
$thread1->detach();


sub doIt
{
   my $Thishost = $ENV{COMPUTERNAME};
   my $addr = (gethostbyname($Thishost))[4];
   $addr = join(".", unpack("C4", $addr));   
   my $dsn = "DBI:mysql:database=resources;host=$addr";
   my $dbh = DBI->connect($dsn,"user", "password") or die "can not 
connect to database \n";

#  my $dbh = DBI->connect('dbi:mysql:database','user','password');
 my $stmt = $dbh->prepare ('select resolution from resources');
 $stmt->execute();
 while (my $record=$stmt->fetchrow_hashref('NAME_lc')) {

 }

 $dbh->disconnect;
}

--- end new code --


Foo Ji-Haw wrote:


Hello Reinhard,

Thanks for confirming my concerns. So you say that on 5.6.x it is ok, 
but not on 5.8.x. But threading + mysql is quite a powerful 
combination to give up!


I wonder if anybody in this mailing list has a workaround/ solution.

Reinhard Pagitsch wrote:


Hello,

I tryed it also with Perl v5.8.7 and had the same prroblem as you, on 
the 2nd doIt Perl crashes.

I also found out that Perl crashes in the DBI.pm sub "disconnect_all".
Removing "use threads;"  it works.

regards,
Reinhard

Foo Ji-Haw wrote:


Hello Reinhard,

I am using 5.8.6 of ActivePerl. Thanks for checking out the codes.

Reinhard Pagitsch wrote:


Hello,


Foo Ji-Haw wrote:


Hi all,

I thought I can hit a nice milestone today, but it seems that I 
have hit a strange obstacle instead.
In my tests, the following code will run, but when it terminates 
an error message will be shown.

use strict;
use warnings;
use DBI;
use threads;

doIt();
doIt();

sub doIt
{
  my $dbh = DBI->connect('dbi:mysql:database','username','password');
  my $stmt = $dbh->prepare ('select id from tablename');
  $stmt->execute();
  while (my $record=$stmt->fetchrow_hashref('NAME_lc')) {}
}

Change the database connection parameters (eg. username, password, 
table name) to your database.


My analysis of the problem is as follows:
1. Using the ODBC driver is ok. I've tested with MSSQL connection 
and it's fine.
2. The problem lies with using threads alongside DBI. If I take 
out 'use threads' all is well.
3. There are 2x doIt() calls because it only fails on the second 
database connection.
4. It seems to be related to fetchrow_hashref(), because if I take 
that out, all is fine.


Can someone confirm this? Is there anybody who can suggest a 
workaround? Thanks.



There is no problem here, Perl v5.6.1. Which Perl version do you use?

regards,
Reinhard











--
QA
ISIS Information Systems
Austria tel: (+43) 2236 27551 150  Fax: 2236 21081
Visit our web site http://www.isis-papyrus.com
---
This e-mail is only intended for the recipient and not legally
binding. Unauthorised use, publication, reproduction or
disclosure of the content of this e-mail is not permitted.
---


--- End Message ---
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: activeperl + mysql + threads = crash

2005-07-25 Thread Foo Ji-Haw

Hello Reinhard,

Thanks for confirming my concerns. So you say that on 5.6.x it is ok, 
but not on 5.8.x. But threading + mysql is quite a powerful combination 
to give up!


I wonder if anybody in this mailing list has a workaround/ solution.

Reinhard Pagitsch wrote:


Hello,

I tryed it also with Perl v5.8.7 and had the same prroblem as you, on 
the 2nd doIt Perl crashes.

I also found out that Perl crashes in the DBI.pm sub "disconnect_all".
Removing "use threads;"  it works.

regards,
Reinhard

Foo Ji-Haw wrote:


Hello Reinhard,

I am using 5.8.6 of ActivePerl. Thanks for checking out the codes.

Reinhard Pagitsch wrote:


Hello,


Foo Ji-Haw wrote:


Hi all,

I thought I can hit a nice milestone today, but it seems that I 
have hit a strange obstacle instead.
In my tests, the following code will run, but when it terminates an 
error message will be shown.

use strict;
use warnings;
use DBI;
use threads;

doIt();
doIt();

sub doIt
{
  my $dbh = DBI->connect('dbi:mysql:database','username','password');
  my $stmt = $dbh->prepare ('select id from tablename');
  $stmt->execute();
  while (my $record=$stmt->fetchrow_hashref('NAME_lc')) {}
}

Change the database connection parameters (eg. username, password, 
table name) to your database.


My analysis of the problem is as follows:
1. Using the ODBC driver is ok. I've tested with MSSQL connection 
and it's fine.
2. The problem lies with using threads alongside DBI. If I take out 
'use threads' all is well.
3. There are 2x doIt() calls because it only fails on the second 
database connection.
4. It seems to be related to fetchrow_hashref(), because if I take 
that out, all is fine.


Can someone confirm this? Is there anybody who can suggest a 
workaround? Thanks.



There is no problem here, Perl v5.6.1. Which Perl version do you use?

regards,
Reinhard







___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: activeperl + mysql + threads = crash

2005-07-25 Thread Reinhard Pagitsch

Hello,

I tryed it also with Perl v5.8.7 and had the same prroblem as you, on 
the 2nd doIt Perl crashes.

I also found out that Perl crashes in the DBI.pm sub "disconnect_all".
Removing "use threads;"  it works.

regards,
Reinhard

Foo Ji-Haw wrote:


Hello Reinhard,

I am using 5.8.6 of ActivePerl. Thanks for checking out the codes.

Reinhard Pagitsch wrote:


Hello,


Foo Ji-Haw wrote:


Hi all,

I thought I can hit a nice milestone today, but it seems that I have 
hit a strange obstacle instead.
In my tests, the following code will run, but when it terminates an 
error message will be shown.

use strict;
use warnings;
use DBI;
use threads;

doIt();
doIt();

sub doIt
{
  my $dbh = DBI->connect('dbi:mysql:database','username','password');
  my $stmt = $dbh->prepare ('select id from tablename');
  $stmt->execute();
  while (my $record=$stmt->fetchrow_hashref('NAME_lc')) {}
}

Change the database connection parameters (eg. username, password, 
table name) to your database.


My analysis of the problem is as follows:
1. Using the ODBC driver is ok. I've tested with MSSQL connection 
and it's fine.
2. The problem lies with using threads alongside DBI. If I take out 
'use threads' all is well.
3. There are 2x doIt() calls because it only fails on the second 
database connection.
4. It seems to be related to fetchrow_hashref(), because if I take 
that out, all is fine.


Can someone confirm this? Is there anybody who can suggest a 
workaround? Thanks.



There is no problem here, Perl v5.6.1. Which Perl version do you use?

regards,
Reinhard






--
QA
ISIS Information Systems
Austria tel: (+43) 2236 27551 150  Fax: 2236 21081
Visit our web site http://www.isis-papyrus.com
---
This e-mail is only intended for the recipient and not legally
binding. Unauthorised use, publication, reproduction or
disclosure of the content of this e-mail is not permitted.
---

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


activeperl + mysql + threads = crash

2005-07-25 Thread Foo Ji-Haw

Hi all,

I thought I can hit a nice milestone today, but it seems that I have hit 
a strange obstacle instead.
In my tests, the following code will run, but when it terminates an 
error message will be shown.

use strict;
use warnings;
use DBI;
use threads;

doIt();
doIt();

sub doIt
{
  my $dbh = DBI->connect('dbi:mysql:database','username','password');
  my $stmt = $dbh->prepare ('select id from tablename');
  $stmt->execute();
  while (my $record=$stmt->fetchrow_hashref('NAME_lc')) {}
}

Change the database connection parameters (eg. username, password, table 
name) to your database.


My analysis of the problem is as follows:
1. Using the ODBC driver is ok. I've tested with MSSQL connection and 
it's fine.
2. The problem lies with using threads alongside DBI. If I take out 'use 
threads' all is well.
3. There are 2x doIt() calls because it only fails on the second 
database connection.
4. It seems to be related to fetchrow_hashref(), because if I take that 
out, all is fine.


Can someone confirm this? Is there anybody who can suggest a workaround? 
Thanks.


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Threads Synchronization

2005-04-13 Thread Paul Sobey
You could try either queues or semaphores:
 
1) Create a new Thread::Queue and have each thread block waiting to pop
something off the queue - create all your threads, then throw as many
1's onto the queue as you need - the threads will all start going within
a few processor quantums of each other.
 
2) Create x Thread::Semaphores, have each thread block, then drop them
all after the threads are created.
 
E.g. (totally untested and not pretty but you get the idea):
 
my $threads = 9;
# Spawn threads
for (1..$threads) {
my $sem   = new Thread::Semaphore(1);
my $thread = new threads (\&bla, $sem);
    push @threads, [$thread, $sem];
}
# Now threads are all waiting, raise sems so they can start
foreach (@threads) {
my $sem = $_->[1];
$sem->up;
}
# All threads running now - next routine will block until they exit
foreach (@threads) {
my $thread = $_->[0];
$thread->join;
}

sub bla {
my $sem = shift;
$sem->down;
# do stuff
}



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Plymouth Rock
Sent: 13 April 2005 05:27
To: perl-win32-users@listserv.ActiveState.com
Subject: Threads Synchronization


 My script uses threads module for creation several threads. Each thread
prints
certain letter for several times via some pause. Kind of letter, number
of times,
length of pause are different for every thread. These threads should be
work in
parallel. Also, I have to synchronize all starts of the threads, that is
all 9
children should be start at the same time, almost 'simultaneously' (at
least for
eyes) , without visual delays between each other. Still I've too large
total
delay between 'a'-letter and 'i'-letter: about 9 secs on Pentium 133.
I've tried:
Thread::Barrier - thread execution barrier/
Win32::IPC - Base class for Win32 synchronization objects/
Proc-SyncExec-1.01 (non-downloadable from CPAN with 'ppm install'),
but nothing could affect to the starts synchronization. Also I'd trying
to use
locks, semaphores, alarms, cond_wait, cond_signal, cond_broadcast...
without a
success. Maybe, Thread::Signal?.. IPC's kill()?..
 This script is CGI, for win32, IE6; it uses buffering $|++, which may
sometimes
be a cause of certain visual problems in browser. Anyway, you can run it
just in
a shell and look at process of printing. It's most likely, just after
start and
HTML-dumping you won't see: abcdefghi (etc in non-regulated order). It
will be
something like this: ababcbacd (etc in non-regulated order). As I
understand,
such the asynchronous starts do happen due to sequential subN's works
out
without waiting of preparing all future threads to run, every time once
each
subN being called in the code:
my $thrN = threads->new(\&subN);
 So, how to sync all the threads starts (or just all letters printing's
start)?
 

--
Source Code:
--
 
#!C:\Perl\bin\perl -w
 
$|++;
 
print "Content-type: text/html\n\n";
 
use warnings;
 
use Time::HiRes;
use threads;
# use threads::shared;
# use Thread::Barrier;
# use Thread::Semaphore;
 
$doc_top = "\n";
$doc_top .= "\n";
$doc_top .= "\n";
$doc_top .= "function set(id,text) {\n";
$doc_top .= " document.getElementById(id).innerText = text\n";
$doc_top .= "}\n";
$doc_top .= "\n\n";
$doc_top .= "\n";
$doc_top .= "\n\n";
$doc_top .= "\n";
$doc_top .= "\t\n";
$doc_top .= "\t\t\n";
 
$doc_middle ='';
 
$doc_bottom .= "\t\t\n";
$doc_bottom .= "\t\n";
$doc_bottom .= "\n\n";
 
for ($j = 0; $j <= 12; $j++) {
  $doc_middle .= "\t\t\t\n";
  for ($i = 1; $i <= 9; $i++) {
$doc_middle .= "\t\t\t\t \n";
  }
  $doc_middle .= "\t\t\t\n";
}
 
print $doc_top.$doc_middle.$doc_bottom;
print "";
 
sub sub1 {
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 8; $cur_var++) {
print "set('cell1$cur_var', 'a')\n";
Time::HiRes::sleep(0.4);
  }
}
sub sub2 {
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 5; $cur_var++) {
print "set('cell2$cur_var', 'b')\n";
Time::HiRes::sleep(0.2);
  }
}
sub sub3 {
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 11; $cur_var++) {
print "set('cell3$cur_var', 'c')\n";
Time::HiRes::sleep(0.3);
  }
}
sub sub4 {
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 6; $cur_var++) {
print "set('cell4$cur_var', 'd')\n";
Time::HiRes::sleep(1.1);
  }
}
sub sub5 {
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 2; $cur_va

Re: Threads Synchronization

2005-04-13 Thread Сергей Черниенко
Hello Plymouth,

Wednesday, April 13, 2005, 7:26:43 AM, You wrote:

PR>  My script uses threads module for creation several threads. Each thread 
prints
PR> certain letter for several times via some pause. Kind of letter, number of 
times,
PR> length of pause are different for every thread. These threads should be 
work in
PR> parallel. Also, I have to synchronize all starts of the threads, that is 
all 9
PR> children should be start at the same time, almost 'simultaneously' (at 
least for
PR> eyes) , without visual delays between each other. Still I've too large total
PR> delay between 'a'-letter and 'i'-letter: about 9 secs on Pentium 133. I've 
tried:
PR> Thread::Barrier - thread execution barrier/
PR> Win32::IPC - Base class for Win32 synchronization objects/
PR> Proc-SyncExec-1.01 (non-downloadable from CPAN with 'ppm install'),
PR> but nothing could affect to the starts synchronization. Also I'd trying to 
use
PR> locks, semaphores, alarms, cond_wait, cond_signal, cond_broadcast... 
without a
PR> success. Maybe, Thread::Signal?.. IPC's kill()?..
PR>  This script is CGI, for win32, IE6; it uses buffering $|++, which may 
sometimes
PR> be a cause of certain visual problems in browser. Anyway, you can run it 
just in
PR> a shell and look at process of printing. It's most likely, just after start 
and
PR> HTML-dumping you won't see: abcdefghi (etc in non-regulated order). It will 
be
PR> something like this: ababcbacd (etc in non-regulated order). As I 
understand,
PR> such the asynchronous starts do happen due to sequential subN's works out
PR> without waiting of preparing all future threads to run, every time once each
PR> subN being called in the code:
my $thrN = threads->>new(\&subN);
PR>  So, how to sync all the threads starts (or just all letters printing's 
start)?

 As far as I understand You need that FIRST NINE LETTERS were all
 different. Later its order may be pretty arbitrary and depends of
 delays etc. If my suggestion is correct, then after running code
 below about 50 times each time i get needed result

use strict;

$|++;

use warnings;

use Time::HiRes;
use threads;
use threads::shared;

my $count : shared;

sub sub1 {
  $count -= 1;
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 8; $cur_var++) {
redo if $count;
print "set('cell1$cur_var', 'a')\n";
Time::HiRes::sleep(0.4);
  }
}
sub sub2 {
  $count -= 1;
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 5; $cur_var++) {
redo if $count;
print "set('cell2$cur_var', 'b')\n";
Time::HiRes::sleep(0.2);
  }
}
sub sub3 {
  $count -= 1;
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 11; $cur_var++) {
redo if $count;
print "set('cell3$cur_var', 'c')\n";
Time::HiRes::sleep(0.3);
  }
}
sub sub4 {
  $count -= 1;
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 6; $cur_var++) {
redo if $count;
print "set('cell4$cur_var', 'd')\n";
Time::HiRes::sleep(1.1);
  }
}
sub sub5 {
  $count -= 1;
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 2; $cur_var++) {
redo if $count;
print "set('cell5$cur_var', 'e')\n";
Time::HiRes::sleep(0.5);
  }
}
sub sub6 {
  $count -= 1;
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 9; $cur_var++) {
redo if $count;
print "set('cell6$cur_var', 'f')\n";
Time::HiRes::sleep(0.6);
  }
}
sub sub7 {
  $count -= 1;
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 3; $cur_var++) {
redo if $count;
print "set('cell7$cur_var', 'g')\n";
Time::HiRes::sleep(0.7);
  }
}
sub sub8 {
  $count -= 1;
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 5; $cur_var++) {
redo if $count;
print "set('cell8$cur_var', 'h')\n";
Time::HiRes::sleep(0.8);
  }
}
sub sub9 {
  $count -= 1;
  my $cur_var = 0;
  for($cur_var = $cur_var; $cur_var <= 6; $cur_var++) {
redo if $count;
print "set('cell9$cur_var', 'i')\n";
Time::HiRes::sleep(0.9);
  }
}
$count = 9;
my $thr1 = threads->new(\&sub1);
my $thr2 = threads->new(\&sub2);
my $thr3 = threads->new(\&sub3);
my $thr4 = threads->new(\&sub4);
my $thr5 = threads->new(\&sub5);
my $thr6 = threads->new(\&sub6);
my $thr7 = threads->new(\&sub7);
my $thr8 = threads->new(\&sub8);
my $thr9 = threads->new(\&sub9);

$thr1->join;
$thr2->join;
$thr3->join;
$thr4->join;
$thr5->join;
$thr6->join;
$thr7->join;
$thr8->join;
$thr9->join;
 
-- 
Best regards,
 Sergeymailto:[EMAIL PROTECTED]


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Threads Synchronization

2005-04-12 Thread Plymouth Rock



 My script uses threads module for creation 
several threads. Each thread printscertain letter for several times via some 
pause. Kind of letter, number of times,length of pause are different for 
every thread. These threads should be work inparallel. Also, I have to 
synchronize all starts of the threads, that is all 9children should be start 
at the same time, almost 'simultaneously' (at least foreyes) , without 
visual delays between each other. Still I've too large totaldelay between 
'a'-letter and 'i'-letter: about 9 secs on Pentium 133. I've 
tried:Thread::Barrier - thread execution barrier/Win32::IPC - Base class 
for Win32 synchronization objects/Proc-SyncExec-1.01 (non-downloadable from 
CPAN with 'ppm install'),but nothing could affect to the starts 
synchronization. Also I'd trying to uselocks, semaphores, alarms, cond_wait, 
cond_signal, cond_broadcast... without asuccess. Maybe, Thread::Signal?.. 
IPC's kill()?.. This script is CGI, for win32, IE6; it uses buffering 
$|++, which may sometimesbe a cause of certain visual problems in browser. 
Anyway, you can run it just ina shell and look at process of printing. It's 
most likely, just after start andHTML-dumping you won't see: abcdefghi (etc 
in non-regulated order). It will besomething like this: ababcbacd (etc in 
non-regulated order). As I understand,such the asynchronous starts do happen 
due to sequential subN's works outwithout waiting of preparing all future 
threads to run, every time once eachsubN being called in the code:my 
$thrN = threads->new(\&subN); So, how to sync all the threads 
starts (or just all letters printing's start)?
 
--    
Source Code:--
 
#!C:\Perl\bin\perl -w
 
$|++;
 
print "Content-type: text/html\n\n";
 
use warnings;
 
use Time::HiRes;use threads;# use threads::shared;# use 
Thread::Barrier;# use Thread::Semaphore;
 
$doc_top = "\n";$doc_top .= "\n";$doc_top 
.= "\n";<BR>$doc_top .= "function set(id,text) {\n";<BR>$doc_top 
.= " document.getElementById(id).innerText = text\n";<BR>$doc_top .= 
"}\n";<BR>$doc_top .= "\n\n";$doc_top .= 
"\n";$doc_top .= "\n\n";$doc_top .= "\n";$doc_top .= "\t\n";$doc_top .= 
"\t\t\n";
 
$doc_middle ='';
 
$doc_bottom .= "\t\t\n";$doc_bottom .= 
"\t\n";$doc_bottom .= "\n\n";
 
for ($j = 0; $j <= 12; $j++) {  $doc_middle .= 
"\t\t\t\n";  for ($i = 1; $i <= 9; $i++) 
{    $doc_middle .= "\t\t\t\t \n";  }  $doc_middle 
.= "\t\t\t\n";}
 
print $doc_top.$doc_middle.$doc_bottom;print "";
 
sub sub1 {  my $cur_var = 0;  for($cur_var = $cur_var; 
$cur_var <= 8; $cur_var++) {    print 
"set('cell1$cur_var', 
'a')\n";    Time::HiRes::sleep(0.4);  
}}sub sub2 {  my $cur_var = 0;  for($cur_var = 
$cur_var; $cur_var <= 5; $cur_var++) {    print 
"set('cell2$cur_var', 
'b')\n";    Time::HiRes::sleep(0.2);  
}}sub sub3 {  my $cur_var = 0;  for($cur_var = 
$cur_var; $cur_var <= 11; $cur_var++) {    print 
"set('cell3$cur_var', 
'c')\n";    Time::HiRes::sleep(0.3);  
}}sub sub4 {  my $cur_var = 0;  for($cur_var = 
$cur_var; $cur_var <= 6; $cur_var++) {    print 
"set('cell4$cur_var', 
'd')\n";    Time::HiRes::sleep(1.1);  
}}sub sub5 {  my $cur_var = 0;  for($cur_var = 
$cur_var; $cur_var <= 2; $cur_var++) {    print 
"set('cell5$cur_var', 
'e')\n";    Time::HiRes::sleep(0.5);  
}}sub sub6 {  my $cur_var = 0;  for($cur_var = 
$cur_var; $cur_var <= 9; $cur_var++) {    print 
"set('cell6$cur_var', 
'f')\n";    Time::HiRes::sleep(0.6);  
}}sub sub7 {  my $cur_var = 0;  for($cur_var = 
$cur_var; $cur_var <= 3; $cur_var++) {    print 
"set('cell7$cur_var', 
'g')\n";    Time::HiRes::sleep(0.7);  
}}sub sub8 {  my $cur_var = 0;  for($cur_var = 
$cur_var; $cur_var <= 5; $cur_var++) {    print 
"set('cell8$cur_var', 
'h')\n";    Time::HiRes::sleep(0.8);  
}}sub sub9 {  my $cur_var = 0;  for($cur_var = 
$cur_var; $cur_var <= 6; $cur_var++) {    print 
"set('cell9$cur_var', 
'i')\n";    Time::HiRes::sleep(0.9);  
}}
 
my $thr1 = threads->new(\&sub1);my $thr2 = 
threads->new(\&sub2);my $thr3 = threads->new(\&sub3);my 
$thr4 = threads->new(\&sub4);my $thr5 = 
threads->new(\&sub5);my $thr6 = threads->new(\&sub6);my 
$thr7 = threads->new(\&sub7);my $thr8 = 
threads->new(\&sub8);my $thr9 = threads->

Re[2]:(no subject)Threads

2005-03-04 Thread Сергей Черниенко
Hello John,

Friday, March 04, 2005, 10:01:03 AM, You wrote:

JS> It doesn't cause any problem
JS> But you 'may' want to wait till your threads are done
JS> You can either detach or join to do so.

JS> Cheers,
JS> John

In fact I 'want' to wait for second thread are done. But it is GUI app
and each thread have window. Each window, therefore, has separate
message queue. And when I close main window I want the other window
get WM_CLOSE message and because of that execute callback doing some
work before closing (show messagebox or something like this). Is it
possible to do this without Win32API with ithreads only? The code
below is for Win32Gui, but, as far as I understand, it is question of
threads, not interface type.

use strict;

use threads;
use threads::shared;
use Win32::GUI;
my $thread;
my $auxW;

my $app = new Win32::GUI::Window(-name => "main", -text => "Files",
 -width => 170, -height => 300,
 -onTerminate => \&Terminate_All);
$app->AddListbox(-name => "filelist", -width => 150, -height => 300,
 -vscroll => 1, -onDblClick => \&newthread);
my $path = Win32::GUI::BrowseForFolder(-title => "Choose a folder", -folderonly 
=> 1,
-owner => $app, -root => "c:\\")."\\";
if ($path) {
    $app->filelist->Add(DirList($path));
}

$app->Show();
Win32::GUI::Dialog();


sub newthread {
return 0 if threads->list;
$thread = threads->create("Workhorse", "$path"."$addpath");
return 1;
}
}

sub Terminate_Me {
return -1;
}

sub Workhorse {
my $namebase = shift;
my $grid;
$auxW = new Win32::GUI::Window(-name => "StrW", -text => $namebase,
  -pos => [200, 200],
  -size => [300, 500],
  -autovscroll => 1,
  -onTerminate => \&Terminate_Me);
$auxW->Show;
Win32::GUI::Dialog;
return 1;
}

-- 
Thanks,
 Sergeymailto:[EMAIL PROTECTED]


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Threads + Memory Leak??

2005-02-21 Thread John Serink
Title: Message



1,000,000? No kidding, I always stopped by app in the 100,000 range. I 
didn't think it would survive past 256,000. Your machine must have really be 
crawling along with a million handles open, must have been consuming gobs of 
memory.
 
Hopefully Jena will have time to deal with this one.
 
My work around is to not hold anything in the app's memory, write 
everything to disk and run my app in 6 hour chucks under the watchful eye of 
task scheduler. That way the handles get set back to zero when the app is 
killed, my app gets to ~60,000 handles after 6 hours. You may have to do a tiny 
bit of rewriting to get a work around like that to go.
 
Cheers,
John

  
  -Original Message-From: Paul Sobey 
  [mailto:[EMAIL PROTECTED] Sent: Monday, February 21, 2005 9:10 
  PMTo: John Serink; perl-win32-usersSubject: RE: Threads 
  + Memory Leak??
  Blimey, I stopped counting at 
  1,000,000!
   
  Will check that bug report you 
mailed.
   
  Paul
   
  
  
  From: John Serink 
  [mailto:[EMAIL PROTECTED] Sent: 21 February 2005 
  12:03To: Paul Sobey; perl-win32-usersSubject: RE: 
  Threads + Memory Leak??
  
  Its not memory directly that's leaking, its handles which start to 
  consume memory.
  Have a look at the open handles on your app...maybe use perfmon to 
  monitor is and see if its the number of open handles that's doing 
  it.
   
  Cheers,
  John
  

-Original Message-From: 
[EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
Paul SobeySent: Monday, February 21, 2005 7:51 
PMTo: perl-win32-usersSubject: Threads + Memory 
Leak??
I have a fairly 
large threaded script which maintains a cache of information between threads 
using a shared hash. I'm storing hashrefs in the hash. I've noticed that the 
memory usage of the script gets absolutely huge (over a gig) after about an 
hour of information, despite the fact that I am having the threads prune 
bits of the cache that aren't needed any more.
 
I'd heard that 
there are problems with memory leaks in shared hashes. Can anyone confirm 
that what I am doing should/shouldn't work with ActivePerl 5.8.5 on Win2000? 
I wondered whether storing references was a bad idea and causing garbage 
collection problems, perhaps I should re-write with 
storable?
 
Cheers,
Paul
* 

Gloucester Research Limited 
believes the information 
provided herein is reliable. 
While every care has been 
taken to ensure accuracy, the 
information is furnished 
to the recipients with no 
warranty as to the completeness 
and accuracy of its contents 
and on condition that any 
errors or omissions shall not 
be made the basis for any 
claim, demand or cause for 
action. 
* 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Threads + Memory Leak??

2005-02-21 Thread Paul Sobey
Title: Message



Blimey, I stopped counting at 
1,000,000!
 
Will check that bug report you mailed.
 
Paul
 


From: John Serink 
[mailto:[EMAIL PROTECTED] Sent: 21 February 2005 
12:03To: Paul Sobey; perl-win32-usersSubject: RE: Threads 
+ Memory Leak??

Its not memory directly that's leaking, its handles which start to 
consume memory.
Have a look at the open handles on your app...maybe use perfmon to 
monitor is and see if its the number of open handles that's doing 
it.
 
Cheers,
John

  
  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of 
  Paul SobeySent: Monday, February 21, 2005 7:51 PMTo: 
  perl-win32-usersSubject: Threads + Memory 
  Leak??
  I have a fairly 
  large threaded script which maintains a cache of information between threads 
  using a shared hash. I'm storing hashrefs in the hash. I've noticed that the 
  memory usage of the script gets absolutely huge (over a gig) after about an 
  hour of information, despite the fact that I am having the threads prune bits 
  of the cache that aren't needed any more.
   
  I'd heard that 
  there are problems with memory leaks in shared hashes. Can anyone confirm that 
  what I am doing should/shouldn't work with ActivePerl 5.8.5 on Win2000? I 
  wondered whether storing references was a bad idea and causing garbage 
  collection problems, perhaps I should re-write with 
  storable?
   
  Cheers,
  Paul
  * 
  
  Gloucester Research Limited 
  believes the information 
  provided herein is reliable. 
  While every care has been 
  taken to ensure accuracy, the 
  information is furnished 
  to the recipients with no 
  warranty as to the completeness 
  and accuracy of its contents and 
  on condition that any 
  errors or omissions shall not be 
  made the basis for any 
  claim, demand or cause for 
  action. 
  * 
  
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Suspending threads

2005-02-21 Thread $Bill Luebkert
Goetz Sebastian MTA wrote:

> Hallo everyone,
> 
> First of all I have to mark myself as perl newbie so please be lenient
> towards me.
> 
> Now the facts:
> I am using perl 5.8.0 on a WinXP machine.
> I have increasing needs for some kind of mechanism that supplies me with
> extended thread functionality.
> Especially suspend and resume would be of great advantage.
> Unfortunately I found a CPAN module (Thread::Suspend) only capable for
> Lunix Systems.
> 
> Does anybody have an idea of how to get me out of this mess?

You could try using a shared vrbl to synchronize your threads or
possibly a mutex or semaphore would be easier.  Obviously this would
be a passive solution and your threads would have to be checking the
flags for changes rather than being actively suspended ffrom the
outside.  Take a look at the threads::shared module to see if that's
any help.

You could also try using Win32::API to call API suspend/resume functions.

Here are three functions that you could try playing with:


The GetCurrentThread function returns a pseudohandle for the current thread.
HANDLE GetCurrentThread(VOID)
Parameters
This function has no parameters.
Return Value
The return value is a pseudohandle for the current thread.
Remarks
A pseudohandle is a special constant that is interpreted as the current thread 
handle. The calling thread can use this handle to specify itself whenever a 
thread handle is required. Pseudohandles are not inherited by child processes.
This handle has the maximum possible access to the thread object. For systems 
that support security descriptors, this is the maximum access allowed by the 
security descriptor for the calling process. For systems that do not support 
security descriptors, this is THREAD_ALL_ACCESS.
The function cannot be used by one thread to create a handle that can be used 
by other threads to refer to the first thread. The handle is always interpreted 
as referring to the thread that is using it. A thread can create a "real" 
handle of itself that can be used by other threads, or inherited by other 
processes, by specifying the pseudohandle as the source handle in a call to the 
DuplicateHandle function.
The pseudohandle need not be closed when it is no longer needed. Calling the 
CloseHandle function with this handle has no effect. If the pseudohandle is 
duplicated by DuplicateHandle, the duplicate handle must be closed.
See Also
CloseHandle, DuplicateHandle, GetCurrentProcess, GetCurrentThreadId



The SuspendThread function suspends the specified thread.
DWORD SuspendThread(
  HANDLE  hThread   // handle to the thread
   );   
Parameters
hThread
Identifies the thread. The handle must have THREAD_SUSPEND_RESUME access.
Return Value
If the function succeeds, the return value is the thread's previous suspend 
count; otherwise, it is 0x. To get extended error information, use the 
GetLastError function.
Remarks
If the function succeeds, execution of the specified thread is suspended and 
the thread's suspend count is incremented.
Suspending a thread causes the thread to stop executing user-mode (application) 
code.
Each thread has a suspend count (with a maximum value of 
MAXIMUM_SUSPEND_COUNT). If the suspend count is greater than zero, the thread 
is suspended; otherwise, the thread is not suspended and is eligible for 
execution. Calling SuspendThread causes the target thread's suspend count to be 
incremented. Attempting to increment past the maximum suspend count causes an 
error without incrementing the count.
The ResumeThread function decrements the suspend count of a suspended thread.
See Also
ResumeThread



The ResumeThread function decrements a thread's suspend count. When the suspend 
count is decremented to zero, the execution of the thread is resumed.
DWORD ResumeThread(
HANDLE  hThread // identifies thread to restart
   );   
Parameters
hThread
Specifies a handle for the thread to be restarted. The handle must have 
THREAD_SUSPEND_RESUME access to the thread.
Return Value
If the function succeeds, the return value is the thread's previous suspend 
count.
If the function fails, the return value is 0x. To get extended error 
information, call GetLastError.
Remarks
The ResumeThread function checks the suspend count of the subject thread. If 
the suspend count is 0, the thread is not currently suspended. Otherwise, the 
subject thread's suspend count is decremented. If the resulting value is 0, 
then the execution of the subject thread is resumed.
If the return value is 0, the specified thread was not suspended. If the return 
value is 1, the specified thread was suspended but was restarted. If the return 
value is greater than 1, the specified thread is still suspended.
Note that while reporting debug events, all threads within the reporting 
process are frozen. Debuggers are expected to use the SuspendThread and 
ResumeThread functions to limi

RE: Threads + Memory Leak??

2005-02-21 Thread John Serink
Title: Message



Its not memory directly that's leaking, its handles which start to 
consume memory.
Have a look at the open handles on your app...maybe use perfmon to 
monitor is and see if its the number of open handles that's doing 
it.
 
Cheers,
John

  
  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of 
  Paul SobeySent: Monday, February 21, 2005 7:51 PMTo: 
  perl-win32-usersSubject: Threads + Memory 
  Leak??
  I have a fairly 
  large threaded script which maintains a cache of information between threads 
  using a shared hash. I'm storing hashrefs in the hash. I've noticed that the 
  memory usage of the script gets absolutely huge (over a gig) after about an 
  hour of information, despite the fact that I am having the threads prune bits 
  of the cache that aren't needed any more.
   
  I'd heard that 
  there are problems with memory leaks in shared hashes. Can anyone confirm that 
  what I am doing should/shouldn't work with ActivePerl 5.8.5 on Win2000? I 
  wondered whether storing references was a bad idea and causing garbage 
  collection problems, perhaps I should re-write with 
  storable?
   
  Cheers,
  Paul
  * 
  
  Gloucester Research Limited 
  believes the information 
  provided herein is reliable. 
  While every care has been 
  taken to ensure accuracy, the 
  information is furnished 
  to the recipients with no 
  warranty as to the completeness 
  and accuracy of its contents and 
  on condition that any 
  errors or omissions shall not be 
  made the basis for any 
  claim, demand or cause for 
  action. 
  * 
  
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Threads + Memory Leak??

2005-02-21 Thread Paul Sobey



I have a fairly 
large threaded script which maintains a cache of information between threads 
using a shared hash. I'm storing hashrefs in the hash. I've noticed that the 
memory usage of the script gets absolutely huge (over a gig) after about an hour 
of information, despite the fact that I am having the threads prune bits of the 
cache that aren't needed any more.
 
I'd heard that there 
are problems with memory leaks in shared hashes. Can anyone confirm that what I 
am doing should/shouldn't work with ActivePerl 5.8.5 on Win2000? I wondered 
whether storing references was a bad idea and causing garbage collection 
problems, perhaps I should re-write with storable?
 
Cheers,
Paul
* 

Gloucester Research Limited believes the information  

provided herein is reliable. While every care has been  

taken to ensure accuracy, the information is furnished  

to the recipients with no warranty as to the completeness  

and accuracy of its contents and on condition that any  

errors or omissions shall not be made the basis for any  

claim, demand or cause for action. 

*  
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Suspending threads

2005-02-21 Thread Goetz Sebastian MTA
Title: Suspending threads





Hallo everyone,


First of all I have to mark myself as perl newbie so please be lenient towards me.


Now the facts:
I am using perl 5.8.0 on a WinXP machine.
I have increasing needs for some kind of mechanism that supplies me with extended thread functionality.
Especially suspend and resume would be of great advantage.
Unfortunately I found a CPAN module (Thread::Suspend) only capable for Lunix Systems.


Does anybody have an idea of how to get me out of this mess?


Best regards,


Sebastian



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Array of threads

2005-01-12 Thread knackko
Hello people!
I need some help on threads. I did an array @cle. Foreach entries of 
@cle, i create a thread like this :

*for($i=0;$i<@lacle;$i++) #we create one thread by key
{
   $thread[$i] = threads->new(\&WaitRegEvent,$i,$lacle[$i]);   
}
 

*So i did fantastic stuff in WaitRegEvent.
What i wanted to do is to re create a terminated thread but i don't know 
how to control this in one line, i think it can look like this :

_* my ($n_thread,$keyname) = @thread->join; *_
*$thread[$n_thread] = threads->new(\&WaitRegEvent,$n_thread,$keyname);*
or like this : _* my ($n_thread,$keyname) = $thread[0]->join || 
**$thread[1]->join*_*_ || _
*But the @thread size is not fixed!

thx
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: threads::shared

2004-12-14 Thread Paul Sobey
I wrote this a few months ago because I wanted to make the data from 
XML::Simple available to multiple threads, and it seems to work ok - at least 
all my threads can see the recursed structure! You'll need to use a semaphore 
to control access to the data though, or you'll get into all sorts of 
trouble... 

Anyone else - is this a bad way to handle this? Should I be using storable 
instead?

Paul

My $NiceSharedStructure = ShareRecurse(\%hashref);

sub ShareRecurse {
my $orig = shift;
my $ref = ref($orig);
if ($ref eq "SCALAR") {
my $copy : shared;
$copy = &share($orig);
return \$copy;
} elsif ($ref eq "ARRAY") {
my @copy : shared;
foreach my $value (@{$orig}) {
my $ref = ref($value);
if ($ref eq "SCALAR") {
push @copy, ShareRecurse($value);
} elsif ($ref eq "ARRAY") {
push @copy, ShareRecurse($value);
} elsif ($ref eq "HASH") {
push @copy, ShareRecurse($value);
} else {
push @copy, $value;
}
}
return [EMAIL PROTECTED];
} elsif ($ref eq "HASH") {
my %copy : shared;
foreach my $key (keys %{$orig}) {
my $ref = ref($orig->{$key});
if ($ref eq "SCALAR") {
$copy{$key} = ShareRecurse($orig->{$key});
} elsif ($ref eq "ARRAY") {
$copy{$key} = ShareRecurse($orig->{$key});
} elsif ($ref eq "HASH") {
$copy{$key} = ShareRecurse($orig->{$key});
} else {
$copy{$key} = $orig->{$key};
}
}
return \%copy;
}
}

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris
Sent: 14 December 2004 15:23
To: perl-win32-users
Subject: threads::shared

All,

I'm attempting to set the value of a shared variable from within a thread
and I'm getting a weird error. Can someone tell me what I'm doing wrong
here?

--
use threads;
use threads::shared;

my %final : shared = ();


$final{'foo'}{'bar'}{'test'} = 1; # this is run inside a thread
--

I get the error "thread failed to start: Invalid value for shared scalar at
lookup.pl line 84." The weird part is that I can set a variable in the root
hash like...

$final{'foo'} = 1;


- Chris


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



*
Gloucester Research Limited believes the information 
provided herein is reliable. While every care has been 
taken to ensure accuracy, the information is furnished 
to the recipients with no warranty as to the completeness 
and accuracy of its contents and on condition that any 
errors or omissions shall not be made the basis for any 
claim, demand or cause for action.
*


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


AW: threads::shared

2004-12-14 Thread Dietmar Fiehn, Dr.
> All,
> 
> I'm attempting to set the value of a shared variable from 
> within a thread
> and I'm getting a weird error. Can someone tell me what I'm 
> doing wrong
> here?
> 
> ------
> use threads;
> use threads::shared;
> 
> my %final : shared = ();
> 
> 
> $final{'foo'}{'bar'}{'test'} = 1; # this is run inside a thread
> --

You cannot share more than one level in your hash. So this will not work even 
if this error disappears. Maybe perl warns you about this mistake with this 
message...

If you have more than one level to share you have to write some kind of wrapper 
and use storable to stringify your first level. See the threads::shared manpage 
for further information about limitations.

Dietmar

> I get the error "thread failed to start: Invalid value for 
> shared scalar at
> lookup.pl line 84." The weird part is that I can set a 
> variable in the root
> hash like...
> 
> $final{'foo'} = 1;
> 
> 
> - Chris
> 
> 
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


threads::shared

2004-12-14 Thread Chris
All,

I'm attempting to set the value of a shared variable from within a thread
and I'm getting a weird error. Can someone tell me what I'm doing wrong
here?

------
use threads;
use threads::shared;

my %final : shared = ();


$final{'foo'}{'bar'}{'test'} = 1; # this is run inside a thread
--

I get the error "thread failed to start: Invalid value for shared scalar at
lookup.pl line 84." The weird part is that I can set a variable in the root
hash like...

$final{'foo'} = 1;


- Chris


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Max Number of threads?

2004-11-17 Thread John Serink
Ha, ha!

I knew someone would suggest that.
I'm pretty sure it'll bring my machine to its knees before I get to the
max...assuming the max is above 64 that is.

Has anyone tried this?

Cheers,
John

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of $Bill Luebkert
> Sent: Thursday, November 18, 2004 9:37 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Max Number of threads?
> 
> 
> John Serink wrote:
> 
> > Hi All:
> > 
> > Anyone know what the maximum number of threads a Win32 perl app can
> > spawn?
> 
> Too easy - just write a loop and count them yourself.
> 
> -- 
>   ,-/-  __  _  _ $Bill Luebkert
> Mailto:[EMAIL PROTECTED]
>  (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
>   / ) /--<  o // //  Castle of Medieval Myth & Magic 
> http://www.todbe.com/
> -/-' /___/_<_http://dbecoll.tripod.com/ (My 
> Perl/Lakers stuff)
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Max Number of threads?

2004-11-17 Thread Jan Dubois
On Wed, 17 Nov 2004, John Serink wrote:
> Anyone know what the maximum number of threads a Win32 perl app
> can spawn?

It is somewhere between 60 and 63.  Can't remember the exact number...

Cheers,
-Jan


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Max Number of threads?

2004-11-17 Thread $Bill Luebkert
John Serink wrote:

> Hi All:
> 
> Anyone know what the maximum number of threads a Win32 perl app can
> spawn?

Too easy - just write a loop and count them yourself.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Max Number of threads?

2004-11-17 Thread John Serink
Hi All:

Anyone know what the maximum number of threads a Win32 perl app can
spawn?

Cheers,
John

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: threads::shared

2004-11-12 Thread $Bill Luebkert
Paul Sobey wrote:

> Ended up writing this, which seems to work. Not sure it's perfect but I get 
> copies of the hash that look identical with Data::Dumper...
> 
> Does anyone know a better way of doing this? Seems awfully long winded...

I'm wondering if it will make a difference if you quit using the compile time
syntax :
my $copy : shared;
and switch to using just the run time share calls.

> $TestHash2 = ShareRecurse($TestHash);

This gets the same result (assuming you know what $TestHash is) :

my $TestHash2 = &share({});
$TestHash2 = $TestHash;

> sub ShareRecurse {
>   my $orig = shift;
>   my $ref = ref($orig);
>   if ($ref eq "SCALAR") {
>   my $copy : shared;
>   $copy = &share($orig);
>   return \$copy;
>   } elsif ($ref eq "ARRAY") {
>   my @copy : shared;
>   foreach my $value (@{$orig}) {
>   my $ref = ref($value);
>   if ($ref eq "SCALAR") {
>   push @copy, ShareRecurse($value);
>   } elsif ($ref eq "ARRAY") {
>   push @copy, ShareRecurse($value);
>   } elsif ($ref eq "HASH") {
>   push @copy, ShareRecurse($value);
>   } else {
>   push @copy, $value;
>   }
>   }
>   return [EMAIL PROTECTED];
>   } elsif ($ref eq "HASH") {
>   my %copy : shared;
>   foreach my $key (keys %{$orig}) {
>   my $ref = ref($orig->{$key});
>   if ($ref eq "SCALAR") {
>   $copy{$key} = ShareRecurse($orig->{$key});
>   } elsif ($ref eq "ARRAY") {
>   $copy{$key} = ShareRecurse($orig->{$key});
>   } elsif ($ref eq "HASH") {
>   $copy{$key} = ShareRecurse($orig->{$key});
>   } else {
>   $copy{$key} = $orig->{$key};
>   }
>   }
>   return \%copy;
>   }
> }
> 
>  
> 
> -Original Message-
> From: $Bill Luebkert [mailto:[EMAIL PROTECTED] 
> Sent: 12 November 2004 03:00
> To: Paul Sobey
> Cc: [EMAIL PROTECTED]
> Subject: Re: threads::shared
> 
> Paul Sobey wrote:
> 
> 
>>I'm using XML::Simple to read in two files, and generate two hashrefs. I
>>want to combine these two into a big hashref, like this:
>> 
>>my $combined = { %{$a}, %{$b} };
>> 
>>This works fine, until I want to share the $combined hash to make it
>>visible across several threads.
>> 
>>As an example, consider the following:
>> 
>>use threads;
>>use threads::shared;
>> 
>>
>>my $TestHash = {
>> bla => "bla",
>> wibble => [ "wibble", "wibble" ],
>> blargh => {
>>  I => "Really",
>>  Wish => "This",
>>  Would => "Work"
>> }
>>};
>> 
>>my $TestHash2 : shared;
>> 
>>$TestHash2 = $TestHash;
> 
> 
> I tried reading the docs for shared and they are cryptic at best - try :
> 
>   my $TestHash2 = &share({});
>   $TestHash2 = $TestHash;
> 
> in place of the above two lines.  I don't understand the syntax at all.
> 
> 
>>This fails in my system with the error "Invalid value for shared scalar
>>at D:\scripts\thread2.pl line 17.". I can understand why this should
>>cause problems, since none of the nested references are themselves
>>marked as shared. How can I generate a shared version of the hashes that
>>I can pass around between the threads? I was considering some sort of
>>recursion through the structure, creating new :shared copies of each value?
> 
> 


-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: threads::shared

2004-11-12 Thread Paul Sobey
Ended up writing this, which seems to work. Not sure it's perfect but I get 
copies of the hash that look identical with Data::Dumper...

Does anyone know a better way of doing this? Seems awfully long winded...

P.


$TestHash2 = ShareRecurse($TestHash);

sub ShareRecurse {
my $orig = shift;
my $ref = ref($orig);
if ($ref eq "SCALAR") {
my $copy : shared;
$copy = &share($orig);
return \$copy;
} elsif ($ref eq "ARRAY") {
my @copy : shared;
foreach my $value (@{$orig}) {
my $ref = ref($value);
if ($ref eq "SCALAR") {
push @copy, ShareRecurse($value);
} elsif ($ref eq "ARRAY") {
push @copy, ShareRecurse($value);
} elsif ($ref eq "HASH") {
push @copy, ShareRecurse($value);
} else {
push @copy, $value;
}
}
return [EMAIL PROTECTED];
} elsif ($ref eq "HASH") {
my %copy : shared;
foreach my $key (keys %{$orig}) {
my $ref = ref($orig->{$key});
if ($ref eq "SCALAR") {
$copy{$key} = ShareRecurse($orig->{$key});
} elsif ($ref eq "ARRAY") {
$copy{$key} = ShareRecurse($orig->{$key});
} elsif ($ref eq "HASH") {
$copy{$key} = ShareRecurse($orig->{$key});
} else {
$copy{$key} = $orig->{$key};
}
}
return \%copy;
}
}

 

-Original Message-
From: $Bill Luebkert [mailto:[EMAIL PROTECTED] 
Sent: 12 November 2004 03:00
To: Paul Sobey
Cc: [EMAIL PROTECTED]
Subject: Re: threads::shared

Paul Sobey wrote:

> I'm using XML::Simple to read in two files, and generate two hashrefs. I
> want to combine these two into a big hashref, like this:
>  
> my $combined = { %{$a}, %{$b} };
>  
> This works fine, until I want to share the $combined hash to make it
> visible across several threads.
>  
> As an example, consider the following:
>  
> use threads;
> use threads::shared;
>  
> 
> my $TestHash = {
>  bla => "bla",
>  wibble => [ "wibble", "wibble" ],
>  blargh => {
>   I => "Really",
>   Wish => "This",
>   Would => "Work"
>  }
> };
>  
> my $TestHash2 : shared;
>  
> $TestHash2 = $TestHash;

I tried reading the docs for shared and they are cryptic at best - try :

my $TestHash2 = &share({});
$TestHash2 = $TestHash;

in place of the above two lines.  I don't understand the syntax at all.

> This fails in my system with the error "Invalid value for shared scalar
> at D:\scripts\thread2.pl line 17.". I can understand why this should
> cause problems, since none of the nested references are themselves
> marked as shared. How can I generate a shared version of the hashes that
> I can pass around between the threads? I was considering some sort of
> recursion through the structure, creating new :shared copies of each value?

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)



*
Gloucester Research Limited believes the information 
provided herein is reliable. While every care has been 
taken to ensure accuracy, the information is furnished 
to the recipients with no warranty as to the completeness 
and accuracy of its contents and on condition that any 
errors or omissions shall not be made the basis for any 
claim, demand or cause for action.
*


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: threads::shared

2004-11-11 Thread $Bill Luebkert
Paul Sobey wrote:

> I'm using XML::Simple to read in two files, and generate two hashrefs. I
> want to combine these two into a big hashref, like this:
>  
> my $combined = { %{$a}, %{$b} };
>  
> This works fine, until I want to share the $combined hash to make it
> visible across several threads.
>  
> As an example, consider the following:
>  
> use threads;
> use threads::shared;
>  
> 
> my $TestHash = {
>  bla => "bla",
>  wibble => [ "wibble", "wibble" ],
>  blargh => {
>   I => "Really",
>   Wish => "This",
>   Would => "Work"
>  }
> };
>  
> my $TestHash2 : shared;
>  
> $TestHash2 = $TestHash;

I tried reading the docs for shared and they are cryptic at best - try :

my $TestHash2 = &share({});
$TestHash2 = $TestHash;

in place of the above two lines.  I don't understand the syntax at all.

> This fails in my system with the error "Invalid value for shared scalar
> at D:\scripts\thread2.pl line 17.". I can understand why this should
> cause problems, since none of the nested references are themselves
> marked as shared. How can I generate a shared version of the hashes that
> I can pass around between the threads? I was considering some sort of
> recursion through the structure, creating new :shared copies of each value?

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


threads::shared

2004-11-11 Thread Paul Sobey



I'm using XML::Simple to read in two files, and generate two hashrefs. I want to combine 
these two into a big hashref, like this:
 
my $combined = { 
%{$a}, %{$b} };
 
This works fine, 
until I want to share the $combined hash to make it visible across several threads.
 
As an example, 
consider the following:
 
use threads;use 
threads::shared;
 
my $TestHash = 
{ bla => "bla", wibble => [ "wibble", "wibble" ], blargh => {  I => "Really",  Wish 
=> "This",  Would => "Work" }};
 
my $TestHash2 : shared;
 
$TestHash2 = $TestHash;
 
This fails in my 
system with the error "Invalid value for shared scalar at D:\scripts\thread2.pl 
line 17.". I can understand why this should cause problems, since none of the 
nested references are themselves marked as shared. How can I generate a shared 
version of the hashes that I can pass around between the threads? I was 
considering some sort of recursion through the structure, creating new :shared 
copies of each value?
 
Thanks in advance,
Paul

*
Gloucester Research Limited believes the information 
provided herein is reliable. While every care has been 
taken to ensure accuracy, the information is furnished 
to the recipients with no warranty as to the completeness 
and accuracy of its contents and on condition that any 
errors or omissions shall not be made the basis for any 
claim, demand or cause for action.
*


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perl threads crash perl

2004-07-30 Thread Angelos Karageorgiou


Wl the problem is with the after thread exit clean up code inside
the interpreter. If you do not call the $thread->join to clean up and make
the number of your threads static and not dynamically created you are
fine. Otherwise after a few news and joins things get hairy and the
interpeter crashes


I wrote a multithreaded telnet to odbc server using this approach !!

As for the number of threads that are actually good , it seems to be a
wide ranging magic munber between 2 and 15 dependant on the machine :-(

I just wish fork would work with signals , none of the above would be
necessary



On Fri, 30 Jul 2004, John Deighan wrote:

> Date: Fri, 30 Jul 2004 09:09:05 -0400
> From: John Deighan <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Re: Perl threads crash perl
>
> Seeing as noone else has responded to this, let me simply say that I tried
> to develop an application using Perl threads, and in my opinion, Perl
> threads are seriously broken. We had to re-write the application without
> threads.
>
> The main problem was that threads would die, but I found no reliable way of
> detecting this. Also, some advice I found on the web said that you
> shouldn't create too many threads - they weren't designed for that.
> However, there was no mention of what the limit might be, how to determine
> the limit, or how to discover whether thread creation succeeded or failed.
> All this means that if you want to create a couple of threads, it should
> (?) work, but beyond that, who knows?
>

-- 
Angelos Karageorgiou
Masters of Computer Science
City University of New York
http://www.unix.gr

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Perl threads crash perl

2004-07-30 Thread Michael Jung
There is a compiled in limit of 100 threads in Win32 - I ran into this a
few weeks back.  Please see this thread.

http://www.perlmonks.org/index.pl?node_id=373409

--mikej

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of John Deighan
> Sent: Friday, July 30, 2004 9:09 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Perl threads crash perl
>
>
> Seeing as noone else has responded to this, let me simply say
> that I tried
> to develop an application using Perl threads, and in my opinion, Perl
> threads are seriously broken. We had to re-write the
> application without
> threads.
>
> The main problem was that threads would die, but I found no
> reliable way of
> detecting this. Also, some advice I found on the web said that you
> shouldn't create too many threads - they weren't designed for that.
> However, there was no mention of what the limit might be, how
> to determine
> the limit, or how to discover whether thread creation
> succeeded or failed.
> All this means that if you want to create a couple of
> threads, it should
> (?) work, but beyond that, who knows?
>
> At 04:07 PM 7/29/2004, Nadjaf Kuliev wrote:
> >When i tested my IIS vulnerability checker, it works
> perfecly, but when I
> >added multitasking support, it starts good, bit by bit cpu
> noise increases
> >then perl crases with unknown error. I didnt use fork(). I
> used builtin
> >Threads support with async{}. I dont want to make the code
> public before
> >first release so ill tell some details, if it wont help i
> will email some of
> >you who really wants to help the code. So here it is, the
> main scripts gets
> >all the vulnerability check, ie vulnerable file checks from
> a file and tries
> >them one by one on particular IIS webserver. Ony by one is
> really slow, so I
> >implemented threads. As you may know if it is checking the
> webserver it
> >surely will send HTTP requests for each vulnerable file. I
> use IO::Socket
> >only, not HTTP support modules.
> >
> >As far as i can guess, the reason for crash is most probably
> not in the code
> >  but in the perl, perl threads support particularly and how
> interacts with
> >my OS - windows 98.
> >
> >Any help is greatly appreciated. Thanks in advance.
> >
> >Respect, OkIDaN.
> >___
> >Perl-Win32-Users mailing list
> >[EMAIL PROTECTED]
> >To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perl threads crash perl

2004-07-30 Thread StoneBeat
El Viernes 30 Julio 2004 15:09, John Deighan escribió:
> Seeing as noone else has responded to this, let me simply say that I tried
> to develop an application using Perl threads, and in my opinion, Perl
> threads are seriously broken. We had to re-write the application without
> threads.
>
> The main problem was that threads would die, but I found no reliable way of
> detecting this. Also, some advice I found on the web said that you
> shouldn't create too many threads - they weren't designed for that.
> However, there was no mention of what the limit might be, how to determine
> the limit, or how to discover whether thread creation succeeded or failed.
> All this means that if you want to create a couple of threads, it should
> (?) work, but beyond that, who knows?

--> Use threads::shared

You can define a "control variable" and evaluate, for example i have 
2 threads and one shared "control variable" called "$control" if my thread 
number one finish, first  set these variable to $control="oneDied" and the 
second thread knows it because it do something like: 
if ($control = oneDied) {print "the first thread is dead ...\n"}

I found that "control variables" are very good choice to send "signals" when 
you are using threads. 
For example i use it for know when all the threads are close and the main 
thread can do a clean exit.

PD: Sorry for my  English

>
> At 04:07 PM 7/29/2004, Nadjaf Kuliev wrote:
> >When i tested my IIS vulnerability checker, it works perfecly, but when I
> >added multitasking support, it starts good, bit by bit cpu noise increases
> >then perl crases with unknown error. I didnt use fork(). I used builtin
> >Threads support with async{}. I dont want to make the code public before
> >first release so ill tell some details, if it wont help i will email some
> > of you who really wants to help the code. So here it is, the main scripts
> > gets all the vulnerability check, ie vulnerable file checks from a file
> > and tries them one by one on particular IIS webserver. Ony by one is
> > really slow, so I implemented threads. As you may know if it is checking
> > the webserver it surely will send HTTP requests for each vulnerable file.
> > I use IO::Socket only, not HTTP support modules.
> >
> >As far as i can guess, the reason for crash is most probably not in the
> > code but in the perl, perl threads support particularly and how interacts
> > with my OS - windows 98.
> >
> >Any help is greatly appreciated. Thanks in advance.
> >
> >Respect, OkIDaN.
> >___
> >Perl-Win32-Users mailing list
> >[EMAIL PROTECTED]
> >To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perl threads crash perl

2004-07-30 Thread John Deighan
Seeing as noone else has responded to this, let me simply say that I tried 
to develop an application using Perl threads, and in my opinion, Perl 
threads are seriously broken. We had to re-write the application without 
threads.

The main problem was that threads would die, but I found no reliable way of 
detecting this. Also, some advice I found on the web said that you 
shouldn't create too many threads - they weren't designed for that. 
However, there was no mention of what the limit might be, how to determine 
the limit, or how to discover whether thread creation succeeded or failed. 
All this means that if you want to create a couple of threads, it should 
(?) work, but beyond that, who knows?

At 04:07 PM 7/29/2004, Nadjaf Kuliev wrote:
When i tested my IIS vulnerability checker, it works perfecly, but when I
added multitasking support, it starts good, bit by bit cpu noise increases
then perl crases with unknown error. I didnt use fork(). I used builtin
Threads support with async{}. I dont want to make the code public before
first release so ill tell some details, if it wont help i will email some of
you who really wants to help the code. So here it is, the main scripts gets
all the vulnerability check, ie vulnerable file checks from a file and tries
them one by one on particular IIS webserver. Ony by one is really slow, so I
implemented threads. As you may know if it is checking the webserver it
surely will send HTTP requests for each vulnerable file. I use IO::Socket
only, not HTTP support modules.
As far as i can guess, the reason for crash is most probably not in the code
 but in the perl, perl threads support particularly and how interacts with
my OS - windows 98.
Any help is greatly appreciated. Thanks in advance.
Respect, OkIDaN.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Perl threads crash perl

2004-07-29 Thread Nadjaf Kuliev
When i tested my IIS vulnerability checker, it works perfecly, but when I
added multitasking support, it starts good, bit by bit cpu noise increases
then perl crases with unknown error. I didnt use fork(). I used builtin
Threads support with async{}. I dont want to make the code public before
first release so ill tell some details, if it wont help i will email some of
you who really wants to help the code. So here it is, the main scripts gets
all the vulnerability check, ie vulnerable file checks from a file and tries
them one by one on particular IIS webserver. Ony by one is really slow, so I
implemented threads. As you may know if it is checking the webserver it
surely will send HTTP requests for each vulnerable file. I use IO::Socket
only, not HTTP support modules.

As far as i can guess, the reason for crash is most probably not in the code
 but in the perl, perl threads support particularly and how interacts with
my OS - windows 98.

Any help is greatly appreciated. Thanks in advance.

Respect, OkIDaN.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Gracefully exiting or returning from threads

2004-04-12 Thread Kiran Sowdi



Hello Folks,
 
I am having a problem in exiting or returning from 
perl program.
 
Please let me know which is the function that 
should be called to return from the threads in perl.
 
my program something looks like this:
 
use threads;
.



 
my $thread_id = threads->create("func1", " 
");
...
...
...
 
 
 
 
sub func1()
{





}
 
Thanks in advance.
 
Regards,
Kiran Sowdi
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Threads in Windows.

2004-03-31 Thread Kiran Sowdi



I have used threads to update a list box in 
Tk.
This is working fine on a linux box but the 
following error
pops up when running on a windows box.
 
The problem we are facing when creating a thread in 
Windows,


  Tk::Error: This perl was built for "ithreads", 
  which currently does not support Thread.pm.
  Run "perldoc Thread" for more information at 
  Gui.pl line 2650.
   
  Could you guys please give me some more inputs on how to work with 
  threads on windows.
  I would be greatful to you guys if you can give some pointers, if I have 
  build the new perl package to
  support threads on windows.
   
  Regards,
  Kiran Sowdi
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Threads In Perl?

2003-10-23 Thread Jeff Dietz
Scott,

There is some thread support in Perl. There was a good article or two a 
while back in TPJ, but I don't have a link handy. You can also start 
your investigation at CPAN. There is a Perl threads tutorial at:

http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlthrtut.html

-Jeff

Scott Purcell wrote:

I was wondering if there is any Thread support in Perl? I would like to have my application run, and while the end-user is working in the GUI, I would like to have a background thread, or process keeping track of certain files that may be altered while the user is in the app.

If there is any info on this topic, links would be appreciated.

Thanks,
Scott


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Threads In Perl?

2003-10-23 Thread Peter Eisengrein
Title: RE: Threads In Perl?





I believe 5.8 has thread capability (I'm still on 5.6.x). You could probably do the background work without using threads. Take a look at the _Timer method. You can use that to do things (like your file checking) on a regular basis while still allowing the user to interface with the window.


-Original Message-
From: Scott Purcell [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 23, 2003 4:09 PM
To: [EMAIL PROTECTED]
Subject: Threads In Perl?




I was wondering if there is any Thread support in Perl? I would like to have my application run, and while the end-user is working in the GUI, I would like to have a background thread, or process keeping track of certain files that may be altered while the user is in the app.

If there is any info on this topic, links would be appreciated.


Thanks,
Scott




___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs





Re: Threads In Perl?

2003-10-23 Thread Joe Youngquist
> I was wondering if there is any Thread support in Perl?
Yes, Perl 5.8
> If there is any info on this topic, links would be appreciated.
Try here: http://aspn.activestate.com/ASPN/docs/ActivePerl/lib/threads.html



- Original Message -
From: "Scott Purcell" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 23, 2003 3:09 PM
Subject: Threads In Perl?


>
> I was wondering if there is any Thread support in Perl? I would like to
have my application run, and while the end-user is working in the GUI, I
would like to have a background thread, or process keeping track of certain
files that may be altered while the user is in the app.
>
> If there is any info on this topic, links would be appreciated.
>
> Thanks,
> Scott
>
>
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Threads In Perl?

2003-10-23 Thread Scott Purcell

I was wondering if there is any Thread support in Perl? I would like to have my 
application run, and while the end-user is working in the GUI, I would like to have a 
background thread, or process keeping track of certain files that may be altered while 
the user is in the app.

If there is any info on this topic, links would be appreciated.

Thanks,
Scott



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


modules unavailable / threads

2003-07-04 Thread John Deighan
Does anyone know why the following Perl modules are not available via ppm 
for ActivePerl 5.8?
	XML-DOM
	GD
	GDGraph
	Crype-SSLeay

Also, I'm starting to work with Perl threads. The docs say that I shouldn't 
use modules that are not thread-safe. Does anyone know how to find out if a 
particular Perl module is thread-safe or not? Also, advice on how to ensure 
that Perl modules I develop are thread-safe.

Thanks.
John Deighan
Public Consulting Group
1700 Kraft Dr.
Suite 2250
Blacksburg, VA  24060
[EMAIL PROTECTED]
540-953-2330  x12
FAX: 540-953-2335
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Perl 5.8 threads and sockets problem

2003-02-27 Thread Merrill Cornish
Jer,

FYI:  On Windows, forks and threads take a similar amount of memory since
forks are implemented using the threads mechanism.

Merrill
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: threads question

2003-02-24 Thread Hawley, Eric
want to say thanks for your input, later this evening I will be getting back
to working on this project.  I will definetly look into your suggestions and
once I find the solution I can repost so that everyone can take a look at it
if they so wish to.  Once again thanks for your suggestions.

-Eric

-Original Message-
From: Jonathan Epstein
To: Hawley, Eric; '[EMAIL PROTECTED] '
Sent: 2/24/03 10:28 AM
Subject: Re: threads question

Following up on my own message ... from:

http://search.cpan.org/author/BBIRTH/Win32-SerialPort-0.19/lib/Win32/Ser
ialPort.pm

"Asynchronous (Background) I/O 
The module handles Polling (do if Ready), Synchronous (block until
Ready), and Asynchronous Modes (begin and test if Ready) with the
timeout choices provided by the API. No effort has yet been made to
interact with Windows events. But background I/O has been used
successfully with the Perl Tk modules and callbacks from the event
loop."

So it seems that this approach (using asynchronous I/O with Tk
callbacks) is blessed by the author of Win32::SerialPort.

Jonathan

At 10:12 AM 2/24/2003 -0500, Jonathan Epstein wrote:
>Eric,
>
>Being curious about this question (and a related one a few days ago), I
did some google searches and learned about Tk::after.
>
>See:
>  http://www.mathematik.uni-ulm.de/help/perl5/doc/Tk/after.html
>
>Since apparently Tk itself isn't considered to be thread-safe, I wonder
whether in this case you should forget about threads and just use one of
these 'after' callback routines to perform all your serial port
processing.
>
>Good luck ... let us know if you come up with a solution.
>
>Another (somewhat inconsistent) suggestion: since most of us can't
really run your serial port code, if you're still running into trouble
you might produce some sample code where the temperature and heart rate
are generated pseudo-randomly, rather than getting the data from the
serial port.  Of course then it won't have any Win32 component, so it
will be out of scope for this list ;-)  But you can try reposting it
here as well as on PerlMonks, where there seems to be a lot of knowledge
base on topics like these.
>
>Good luck,
>
>Jonathan
>
>At 05:03 PM 2/22/2003 -0500, Hawley, Eric wrote:
>
>>I have created this gui application which when selecting the Start
button
>>from the menu will continue to run (infinite) until someone stops the
>>processing.  What I have is once the Start button is click it creates
a
>>thread where the while loop will be executed (so that the user can
still
>>interact with the GUI) and information will read in from a serial port
and
>>processed.  Once this information is processed I would like it to
update the
>>GUI display for $temperature and $heart_rate and I can't seem to
figure this
>>out.  If someone can point out my faults I would apperciate it.
>>
>>Code is attached
>>Thanks
>>Eric
>>
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: threads question

2003-02-24 Thread Jonathan Epstein
Following up on my own message ... from:

http://search.cpan.org/author/BBIRTH/Win32-SerialPort-0.19/lib/Win32/SerialPort.pm

"Asynchronous (Background) I/O 
The module handles Polling (do if Ready), Synchronous (block until Ready), and 
Asynchronous Modes (begin and test if Ready) with the timeout choices provided by the 
API. No effort has yet been made to interact with Windows events. But background I/O 
has been used successfully with the Perl Tk modules and callbacks from the event loop."

So it seems that this approach (using asynchronous I/O with Tk callbacks) is blessed 
by the author of Win32::SerialPort.

Jonathan

At 10:12 AM 2/24/2003 -0500, Jonathan Epstein wrote:
>Eric,
>
>Being curious about this question (and a related one a few days ago), I did some 
>google searches and learned about Tk::after.
>
>See:
>  http://www.mathematik.uni-ulm.de/help/perl5/doc/Tk/after.html
>
>Since apparently Tk itself isn't considered to be thread-safe, I wonder whether in 
>this case you should forget about threads and just use one of these 'after' callback 
>routines to perform all your serial port processing.
>
>Good luck ... let us know if you come up with a solution.
>
>Another (somewhat inconsistent) suggestion: since most of us can't really run your 
>serial port code, if you're still running into trouble you might produce some sample 
>code where the temperature and heart rate are generated pseudo-randomly, rather than 
>getting the data from the serial port.  Of course then it won't have any Win32 
>component, so it will be out of scope for this list ;-)  But you can try reposting it 
>here as well as on PerlMonks, where there seems to be a lot of knowledge base on 
>topics like these.
>
>Good luck,
>
>Jonathan
>
>At 05:03 PM 2/22/2003 -0500, Hawley, Eric wrote:
>
>>I have created this gui application which when selecting the Start button
>>from the menu will continue to run (infinite) until someone stops the
>>processing.  What I have is once the Start button is click it creates a
>>thread where the while loop will be executed (so that the user can still
>>interact with the GUI) and information will read in from a serial port and
>>processed.  Once this information is processed I would like it to update the
>>GUI display for $temperature and $heart_rate and I can't seem to figure this
>>out.  If someone can point out my faults I would apperciate it.
>>
>>Code is attached
>>Thanks
>>Eric
>>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: threads question

2003-02-24 Thread Jonathan Epstein
Eric,

Being curious about this question (and a related one a few days ago), I did some 
google searches and learned about Tk::after.

See:
  http://www.mathematik.uni-ulm.de/help/perl5/doc/Tk/after.html

Since apparently Tk itself isn't considered to be thread-safe, I wonder whether in 
this case you should forget about threads and just use one of these 'after' callback 
routines to perform all your serial port processing.

Good luck ... let us know if you come up with a solution.

Another (somewhat inconsistent) suggestion: since most of us can't really run your 
serial port code, if you're still running into trouble you might produce some sample 
code where the temperature and heart rate are generated pseudo-randomly, rather than 
getting the data from the serial port.  Of course then it won't have any Win32 
component, so it will be out of scope for this list ;-)  But you can try reposting it 
here as well as on PerlMonks, where there seems to be a lot of knowledge base on 
topics like these.

Good luck,

Jonathan

At 05:03 PM 2/22/2003 -0500, Hawley, Eric wrote:

>I have created this gui application which when selecting the Start button
>from the menu will continue to run (infinite) until someone stops the
>processing.  What I have is once the Start button is click it creates a
>thread where the while loop will be executed (so that the user can still
>interact with the GUI) and information will read in from a serial port and
>processed.  Once this information is processed I would like it to update the
>GUI display for $temperature and $heart_rate and I can't seem to figure this
>out.  If someone can point out my faults I would apperciate it.
>
>Code is attached
>Thanks
>Eric
>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: following threads via mail headers

2001-12-07 Thread Scot Robnett

Try Mail::Audit by Simon Cozens.

http://search.cpan.org/doc/SIMON/Mail-Audit-1.11/Audit.pm


Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Kuhnibert
Sent: Friday, December 07, 2001 12:35 PM
To: perlwin32
Subject: Re: following threads via mail headers


reposted, apparently there was a list problem ..

>
> hello folks,
>
> both outlook and netscape messanger (and probably many other mail clients)
> have a facility to follow threads, that is, if you send out a mail and
> receive multiple replies on this mail you can see all mails belonging to
> this thread linked to each other. i don't know how this works exacactly,
> there's an item "References:" in the mail-header which appears to be
linked
> to this facility - howevery even when lacking this attribute the client
> still finds mail which are (or better might be) related to each other,
maybe
> by means of the subject! anyway, what i want to do is to fetch mails from
a
> pop3 account vie perl and automagically put mails which belong to each
other
> in a separate folder of their own (i.e. bascially the same analysis the am
> mail clients are performing, just with a different reaction). any perl
> module which dealt with this before?
>
> TIA
> till
>
>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.303 / Virus Database: 164 - Release Date: 11/24/2001

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.303 / Virus Database: 164 - Release Date: 11/24/2001

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: threads, forks and ithreads ??

2001-05-22 Thread Edward G. Orton


- Original Message -
From: "mmollenkopf" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 22, 2001 4:10 PM
Subject: threads, forks and ithreads ??


> Greetings all,
>
> Quick question, Does active perl 5.6.x have any support for threads,
> ithreads or fork built into the binary downloaded from Activestate? . I
have
> the new Perl Programming book which has a couple of examples, some work (I
> think) some dont. Sorry to re-hash this question.  The documentation is a
> bit confusing in this area. like...
I am using Active Perl build 622 on Windows 2000 Server (SP1) and fork works
just fine.

ego
Edward G. Orton, GWN Consultants Inc.
Office: 613-860-3186, Home: 613-764-3186, Fax: 613-764-1721
email: [EMAIL PROTECTED]

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



threads, forks and ithreads ??

2001-05-22 Thread mmollenkopf

Greetings all,

Quick question, Does active perl 5.6.x have any support for threads,
ithreads or fork built into the binary downloaded from Activestate? . I have
the new Perl Programming book which has a couple of examples, some work (I
think) some dont. Sorry to re-hash this question.  The documentation is a
bit confusing in this area. like...
"On some platforms such as Windows where the fork() system call is not
available, Perl can be built to emulate fork() at the interpreter level.
While the emulation is designed to be as compatible as possible with the
real fork() at the level of the Perl program, there are certain important
differences that stem from the fact that all the pseudo child ``processes''
created this way live in the same real process as far as the operating
system is concerned."

Reason is I am trying to go to the next step with my Perl/Tk program (below)
so I can perform other functions without waiting on other functions to
finish.

#!perl.exe
##
# Mollensoft Perl/Tk Ping Commander
##
#
# The Purpose of this Program is to provide a working
# example of the Graphic utiltiy found using Perl and Tk,
# coupled with a commonly used networking function PING.
# Displays Good Examples of menus, Dialog Box, Scrolling,
# List Box, opening files, reading data from files,
# acting on that data, etc.
#  I wrote this program because I could not find any
#  good programming examples perl/tk that show an actual
#  functioning programming using Perl/Tk.
#
#
#   This program is for learning and understanding Perl
#   and is free (Just Like Perl) so do what you want with it!
#
# Creation:  19 May 2001
# Last Edit: 20 May 2001
#
#  courtesy BigAL Mollenkopf-  www.mollensoft.com
#  [EMAIL PROTECTED]
#
##

use Tk;
use Tk::Text;
use Net::Ping;
use Tk::Toplevel;
use Tk::Pane;
use Tk::DialogBox;

my $main = new MainWindow;
$main->title("Perl/Tk Ping Commander");
$menubar = $main->Frame(-relief=>"raised",-borderwidth=>2);
$filebutton = $menubar->Menubutton(-text=>"Ping",-underline => 0);
$filemenu = $filebutton->Menu();
$filebutton->configure(-menu=>$filemenu);
$filemenu->command(-command =>
\&start_ping,-label => "Start Pinging",-underline => 0);
$filemenu->separator;
$filemenu->command(-label => "Exit",-command =>
\&exit_choice,-underline => 1);

$configbutton = $menubar->Menubutton(-text=>"Configure",-underline
=> 0);
$configmenu = $configbutton->Menu();
$configbutton->configure(-menu=>$configmenu);
$configmenu->command(-command => \&cfg_vars,-label =>
"Configure Intervals",-underline => 0);
$configmenu->separator;
$configmenu->command(-command => \&edit_list,-label =>
"Add/Edit Host List",-underline => 0);

$helpbutton = $menubar->Menubutton(-text=>"Help",-underline => 0);
$helpmenu = $helpbutton->Menu();
$helpmenu->command(-command => \&about_choice,-label => "About
Perl/Tk Ping Commander", -underline => 0); # A in About
$helpbutton->configure(-menu=>$helpmenu);
$helpmenu->command(-command => \&show_help,-label =>
"Help", -underline => 0); # A in About

$filebutton->pack(-side=>"left");
$configbutton->pack(-side=>"left");
$helpbutton->pack(-side=>"right");
$menubar->pack(-side=>"top", -fill=>"x");

$status =
$main->Label(-text=>"Ready...",-relief=>sunken,-borderwidth=>2,-anchor=>"w")
;
$status->pack(-side=>"bottom", -fill=>"x");
 $box = $main->Listbox(-relief => 'sunken',-width => 70,-height =>
10)->pack(-side =>'left');
 $scroll = $main->Scrollbar(-command => ['yview', $box]);
 $scroll->pack(-side => 'right', -fill => 'y');
 $box->configure(-yscrollcommand => ['set', $scroll]);
 $box->pack(-side => 'left', -fill => 'both', -expand => 'yes');

 MainLoop;

sub exit_choice {
$dialog=$main->DialogBox(-title => "Really Quit Perl Ping
CMDR?", -buttons => ["OK","Cancel"]);
$result = $dialog->Show;
if ($result eq "OK") {exit;}

Re: Threads

2001-05-06 Thread Jaime Teng

At 01:00 AM 5/6/01 +1000, Rob wrote:
>Howdy all!
>
>I am mostly a java person; I have only been working with perl (and Linux
>too) for a few months.
>
>Threading a is a big issue! :)
>
>I looked up in my ActivePerl docs and there is a Thread package. It says
>this though:
>
>DESCRIPTION
>WARNING: Threading is an experimental feature.  Both the interface
>and implementation are subject to change drastically.  In fact, this
>documentation describes the flavor of threads that was in version
>5.005.  Perl 5.6.0 and later have the beginnings of support for
>interpreter threads, which (when finished) is expected to be
>significantly different from what is described here.  The information
>contained here may therefore soon be obsolete.  Use at your own risk!
>The Thread module provides multithreading support for perl.
>
>So this means we can use threads, right - without having to recompile perl?

ActivePerl (even the latest) built *IS NOT* compiled with thread support.
You have to get the Perl source code and compile it. 

>It also says supported platforms are: Linux, Solaris and Windows.

If you compile it to support thread, then yes.

I have been waiting for THREAD to be truly built-into Perl - at least onto
ActivePerl. But reading the warning and all, i'd say it wont happen in 2 
more years. I have been waiting for thread since early 1999 and have given
up on perl threads when I learned that thread isnt built-into Activeperl
with perl 5.6 or even the latest built 623.

I did not see it happen in the last 2 years, and I dont expect to see
it in the next 2 years. If you want multi-process, go for fork - it IS
there.

dont get me wrong. ActivePerl DOES have thread - you just have to compile
it to support thread. But I dont have a C or C++ compiler nor do i want to
risk writing non-standard perl scripts - that leaves me with no THREAD 
support for perl.

jaime

>
>Rob
>
>___
>Perl-Win32-Users mailing list
>[EMAIL PROTECTED]
>http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Threads

2001-05-05 Thread Rob

Howdy all!

I am mostly a java person; I have only been working with perl (and Linux
too) for a few months.

Threading a is a big issue! :)

I looked up in my ActivePerl docs and there is a Thread package. It says
this though:

DESCRIPTION
WARNING: Threading is an experimental feature.  Both the interface
and implementation are subject to change drastically.  In fact, this
documentation describes the flavor of threads that was in version
5.005.  Perl 5.6.0 and later have the beginnings of support for
interpreter threads, which (when finished) is expected to be
significantly different from what is described here.  The information
contained here may therefore soon be obsolete.  Use at your own risk!
The Thread module provides multithreading support for perl.

So this means we can use threads, right - without having to recompile perl?
It also says supported platforms are: Linux, Solaris and Windows.

Rob

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: how do you get threads to work in activeperl 5.6?

2001-04-18 Thread Jan Dubois

On Tue, 17 Apr 2001 18:12:41 -0700, Jeremy Aiyadurai <[EMAIL PROTECTED]>
wrote:

>I'd like to try working with threads, but whenever i try a script, it says
>"no threads in this perl". I have activeperl 5.6. 
>which supports threads. How do i get threads working? 

ActivePerl 5.6 supports the Perl 5.6 ITHREADS model, not the 5.005
experimental threads.  The only way to access threads from the Perl level
is the fork() emulation.  Check out

perldoc perlfork

for know limitations etc.

-Jan

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Threads in ASPerl build 623

2001-04-04 Thread Jesse Sookne

No problem, I just mean that ActiveState should document this in an obvious
place, because it's confusing and I've seen lots of people asking this.

Maybe someone from AS is monitoring the list and could improve the docs in
this area?

-Jesse


-Original Message-
From: Campbell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 04, 2001 1:49 PM
To: [EMAIL PROTECTED]
Subject: RE: Threads in ASPerl build 623


(sorry..)

On Wed, 4 Apr 2001, Jesse Sookne wrote:

>See message below.  This is definitely a FAQ.
>
>-Jesse
>
>-Original Message-
>From: Jesse Sookne
>Sent: Thursday, March 29, 2001 11:17 AM
>To: 'Kirk Rogers'; Perl-Win32-Users2 (E-mail)
>Subject: RE: Multithreaded Apps on Win32?
>
>
>In perl 5.6, threads are implemented via the fork() emulation.  Read
perldoc
>perlfork for more info.
>
>The Thread module was used in previous versions, and is not compatible with
>5.6.
>
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Threads in ASPerl build 623

2001-04-04 Thread Campbell

(sorry..)

On Wed, 4 Apr 2001, Jesse Sookne wrote:

>See message below.  This is definitely a FAQ.
>
>-Jesse
>
>-Original Message-
>From: Jesse Sookne
>Sent: Thursday, March 29, 2001 11:17 AM
>To: 'Kirk Rogers'; Perl-Win32-Users2 (E-mail)
>Subject: RE: Multithreaded Apps on Win32?
>
>
>In perl 5.6, threads are implemented via the fork() emulation.  Read perldoc
>perlfork for more info.
>
>The Thread module was used in previous versions, and is not compatible with
>5.6.
>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Threads in ASPerl build 623

2001-04-04 Thread Jesse Sookne
Title: RE: Threads in ASPerl build 623





See message below.  This is definitely a FAQ.


-Jesse


-Original Message-
From: Jesse Sookne 
Sent: Thursday, March 29, 2001 11:17 AM
To: 'Kirk Rogers'; Perl-Win32-Users2 (E-mail)
Subject: RE: Multithreaded Apps on Win32?



In perl 5.6, threads are implemented via the fork() emulation.  Read perldoc perlfork for more info.


The Thread module was used in previous versions, and is not compatible with 5.6.





Win32 compile for threads

2001-04-04 Thread Campbell

Once again, hi,

I have recompiled my Perl for Ithreads and Multiplicity, as the
ActivePerl distribution also, was compiled (correct me).  Still I
recieve the error on a simple test:

No threads in this perl at perly.pl line 4.

line 4 is the 'my $thr1 = new Thread \&threadsub;'.

Am I being grossly stupid and unfair to ActivePerl, or is it really not
my fault?

Thanks, again..
campbell

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: How do I use threads

2001-03-05 Thread Jesse Sookne

Oops, non-HTML version follows.

-Jesse

-Original Message-
From: Jesse Sookne 
Sent: Monday, March 05, 2001 11:29 AM
To: 'Peter Guzis'; 'Robert Follis';
'[EMAIL PROTECTED]'
Subject: RE: How do I use threads


Actually, threads are implemented in ActivePerl 5.6, but not with the
Threads module, which as far as I know is only for the 5xx builds of
ActivePerl.

In AP 5.6, you can use threads through the fork() emulation.  Read 'perldoc
perlfork' for more info.

-Jesse

-Original Message-
From: Peter Guzis [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 05, 2001 10:02 AM
To: '[EMAIL PROTECTED]'
Subject: RE: How do I use threads


Threads are disabled in AP 5.6 as of yet.  If you absolutely need this
functionality you'll either need to downgrade to 522, wait for Perl 6, or
hope for a 5.x build supporting threads. 

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
email: [EMAIL PROTECTED]
www.encad.com

-Original Message-
From: Joe Schell [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 04, 2001 3:30 PM
To: Robert Follis
Cc: [EMAIL PROTECTED]
Subject: Re: How do I use threads


Robert Follis wrote:
> 
> I'm using perl 623 and the tutural example of using threads:
> ...
> 
> When I run the script it bombs out and says "No threads in this perl at
> test.pl line 3." Now I'm assuming that when I downloaded the binary and
> installed it that the binary would already include the thread option. Can
> someone help? Please e-mail me back if anyone has any ideas.
> 

And you installed the binary that supports threads right?  Not the other
one?
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: How do I use threads

2001-03-05 Thread Jesse Sookne
Title: RE: How do I use threads





Actually, threads are implemented in ActivePerl 5.6, but not with the Threads module, which as far as I know is only for the 5xx builds of ActivePerl.

In AP 5.6, you can use threads through the fork() emulation.  Read 'perldoc perlfork' for more info.


-Jesse


-Original Message-
From: Peter Guzis [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 05, 2001 10:02 AM
To: '[EMAIL PROTECTED]'
Subject: RE: How do I use threads



Threads are disabled in AP 5.6 as of yet.  If you absolutely need this
functionality you'll either need to downgrade to 522, wait for Perl 6, or
hope for a 5.x build supporting threads. 


Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
email: [EMAIL PROTECTED]
www.encad.com


-Original Message-
From: Joe Schell [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 04, 2001 3:30 PM
To: Robert Follis
Cc: [EMAIL PROTECTED]
Subject: Re: How do I use threads



Robert Follis wrote:
> 
> I'm using perl 623 and the tutural example of using threads:
> ...
> 
> When I run the script it bombs out and says "No threads in this perl at
> test.pl line 3." Now I'm assuming that when I downloaded the binary and
> installed it that the binary would already include the thread option. Can
> someone help? Please e-mail me back if anyone has any ideas.
> 


And you installed the binary that supports threads right?  Not the other
one?
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users





RE: How do I use threads

2001-03-05 Thread Peter Guzis

Threads are disabled in AP 5.6 as of yet.  If you absolutely need this
functionality you'll either need to downgrade to 522, wait for Perl 6, or
hope for a 5.x build supporting threads. 

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
email: [EMAIL PROTECTED]
www.encad.com

-Original Message-
From: Joe Schell [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 04, 2001 3:30 PM
To: Robert Follis
Cc: [EMAIL PROTECTED]
Subject: Re: How do I use threads


Robert Follis wrote:
> 
> I'm using perl 623 and the tutural example of using threads:
> ...
> 
> When I run the script it bombs out and says "No threads in this perl at
> test.pl line 3." Now I'm assuming that when I downloaded the binary and
> installed it that the binary would already include the thread option. Can
> someone help? Please e-mail me back if anyone has any ideas.
> 

And you installed the binary that supports threads right?  Not the other
one?
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Threads and forks

2001-01-29 Thread Flynn, Timothy J

Hi,

I have been trying to get an application of mine to be able to have
some sort of multitasking ability and have been unsuccessful so far.  First
off, I am running on windows 2000 with the latest active perl build.

My first attempt was to use emulated fork.  Using the failsafe
example in the Programming Perl book I can reach 64 forks and then it
croaks.  It appears that it is supposed to wait 5 seconds and then retry the
fork command, but it just waits indefinitely.  I basically took the example
and wrapped it in a for loop to achieve the number of children (64).  Also,
I experimented with $SIG{CHLD} = sub {wait()}; to wait for the children to
end, say at 50 children, so I would not achieve the max value.  I would like
to use fork if I could have a way to wait at the max level, and initiate
forks as the resources permit.  Does anyone have working code they could
show me that could accomplish this on win 2000?


After I had troubles with fork I tried to look for more information
on threads in active perl and discovered this webpage: 

http://velocity.activestate.com/docs/ActivePerl/lib/Pod/perlthrtut.html

It states that perl now supports threads and has a prime numbers example
towards the end.  I tried to execute the example on my machine and I receive
the error message:

No threads in this perl at ###

When I execute perl -V at the command line it states:

Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEXT
PERL_IMPLICIT_SYS


Doesn't USE_ITHREADS give me thread capability? A perl -v also inicates that
this is a win32 multithreaded version.  


I guess what I am looking for is a simple way to simultaneously
execute several processes.  I don't care if I use fork or threads, I just
want it to work :).  Can anyone give me a basic working example or at least
hint at the right direction?

Thanks!

-Tim
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users