I believe you *are* missing something.  You're going to have to
understand how processes and forking work in Unix.  The fork() call
invokes a new process.  In effect it is a new script on its own.
Stephen's Parallel::ForkManager is just syntactic sugaring around the
same thing.

Semaphores have no meaning unless you have separate tasks running.  A
process is a kind of task.  You do not need the semaphore for your test
as I understand it.  The operating system's scheduler is going to
allocate time slices to each process as it sees fit.

Each forked child process is a real process of its own, and each will
open a connection to the database, independent of the other child
processes.  The time statements are actually executed relative to one
another is essentially random, which is I believe what you want.

I suggest you read the description of fork() in the perlfunc man page
*very* carefully, as it does a lot more than you may have realised the
first time through.  Also you should try reading up on Unix process
semantics.

Again, I recommend simply using fork(), in a loop.

-Will


> -----Original Message-----
> From: Kevin Carothers [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday 23 August 2006 16:48
> To: Stephen Carville
> Cc: [email protected]; joe bayer
> Subject: Re: Help with my perl script
> 
> 
> On 8/23/06, Stephen Carville <[EMAIL PROTECTED]> wrote:
> >
> > joe bayer wrote:
> > > Group,
> > >
> > > I am trying to write a load testing script.
> > >
> > > The script goes like this: 
> ++++++++++++++++++++++++++++++++++ my $j =
> > > 0; while ($j < 300) { $dbh[$j] = DBI->connect (
> > > "dbi:Oracle:$instance[$i]", "$username[$i]", "$passwd[$i]", {
> > > PrintError => 1, RaiseError => 1, AutoCommit => 1 } ) || die
> > > "Database Connection not made $DBI::errstr" ;# Create a 
> Database #do
> > > some random, endless select statement here. $j++; }
> > > ++++++++++++++++++++++++++++++++++++++++++
> > >
> > > What I want is 300 session do the select statement simultaneously.
> > > But this script will do one session after another.
> > >
> > > Do I REALLY have to start 300 perl script in order to 
> this testing,
> > > or  there is some way in perl that one script can start up 300
> > > session and  do their invidual select simultaneously?
> >
> > Check out Parallel::ForkManager.
> >
> > > Thanks for your help.
> > >
> > > Joe
> > >
> > >  --------------------------------- All-new Yahoo! Mail - Fire up a
> > > more powerful email and get things done faster.
> 
> 
> 
> Hi Stephen,
> 
> Unless I'm missing something (I'm no expert in this arena)
> It seems like a script will ecxecute one stmt at a time anyway-
> so how about cranking up 300 separate Perl scripts that 
> synchoronize (ie,
> soak up all available system resources simultaneously) with a named
> semaphore?
> 
> (Win)
>     $sem = Win32::Semaphore->new($initial,$maximum,$name);
> 
> (Unix)
>     $sem = new IPC::Semaphore(IPC_PRIVATE, 10, S_IRWXU | IPC_CREAT);
> 
> I would envision you building a 300-line script to start up 
> each individual
> DB connect, and a single Perl script to "lower the flag" - 
> causing the 300
> perl scripts to pounce.
> 
> It seems like this is a much better test anyway- because I 
> very much doubt
> as *single* perl script will have 300 separate DB 
> connections... but then
> again... I don't know what your environment needs.
> 
> HTH
> 
> KC
> 


     - - - - - Appended by Scientific Atlanta, a Cisco company - - - - - 
This e-mail and any attachments may contain information which is confidential, 
proprietary, privileged or otherwise protected by law. The information is 
solely intended for the named addressee (or a person responsible for delivering 
it to the addressee). If you are not the intended recipient of this message, 
you are not authorized to read, print, retain, copy or disseminate this message 
or any part of it. If you have received this e-mail in error, please notify the 
sender immediately by return e-mail and delete it from your computer.

Reply via email to