Hello All:

I am attempting to do a loadtest on a process which is "suspect"...

Does the following code generate multiple instances....????

for ($i=0; $i <= $iteration; $i++)
{
printf(" Executing Iteration:==> %d\n", $iteration);
system ("master_menu &");
}

As you can see, I run the execution in background. And when I execute the UNIX ps command, it gives me the number of iterations I gave the for-loop to execute.

Now, my Lead says the PERL loop is bogging down the system. I think otherwise.....

Please Help!

Recommended Answers

All 4 Replies

you may try to settting priority of the process
POSIX::nice(12);
POSIX::setsid();

or to optmize executed script somehow.

I'm pretty sure system() waits until the process ends to return to the perl script. So I doubt your loop is running multiple instances of the process, but it could still be bogging down the computer since you run it over and over. How many loops does it run through?

Kevin:

The UNIX Shell Script is a menu-driven interface. So when I initiate it, it just waits for input from STDIN. I have the option to set the loop contro variable to any number, but before I MAX this variable, I just used three(3).

Now, when I look at the UNIX ps command, the output, I believe is telling me that I DO have the number of instances I set the loop control variable at:

200001 A techrx 41750 26900 1 60 20 180b1 204 30f027ec 17:24:53 pts/13 0:00 grep master_menu
40001 A techrx 43512 1 16 68 20 9040 588 17:24:46 pts/19 0:00 sh -c master_menu &
40001 A techrx 52394 1 17 68 20 dfe5 588 17:24:46 pts/19 0:00 sh -c master_menu &
40001 A techrx 54722 1 15 67 20 4fcc 588 17:24:46 pts/19 0:00 sh -c master_menu &
40001 A techrx 60662 1 12 66 20 1f096 588 17:24:46 pts/19 0:00 sh -c master_menu &

Please let me know if I am going down the wrong path here.

Thanks as Always!

Please let me know if I am going down the wrong path here.

Honestly, I don't know. system() does fork off a new process, but the parent waits for the child process. So maybe it can initiate multiple instances of the same process. See the system() function docs for details:

http://perldoc.perl.org/functions/system.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.