Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Performing multiple system calls simultaneously and keeping the output

Status
Not open for further replies.

xhonzi

Programmer
Joined
Jul 29, 2003
Messages
196
Location
US
So, I have to make approximate 800 system calls that each retreive a word from a sort of database. I'm trying to convert this over from a csh script that retreives each word in a loop (it's actually 800 words spread over 90 lines, so there's a loop for the 90 lines and a nested loop for each word on the line) and then echoes each word to the screen as it gets it. This takes 12 seconds (or so) since it is executing all 800 calls in serial.

What I would like to do is make all 800 calls at once (or something reasonable like maybe all 90 lines at once, each fetching their own words) and then display all the words in the correct order. Because I'm new at this kind of processing, the only solution I could come up with is to have each forked call write to a file and then concatenate the files after a short time when I can assume they had all finished. There must be a better way.

So, I figure I'm forking some children here, but not sure of the best way to store the info so it's all in order at then end of the day.

Any hints?

Xhonzi
 
why can't this all be dome as one process? Why does it have to be 800 system calls? Why not store the 90 lines in a variable and just do whatever it is you are doing working with the variable?
 
It's a nice idea, but...

I'm retrieving the information from a system over which I have no control. The system allows access to the data to an outside user, but only one word at a time.

And still, I've wondered how to do this in perl for a long time.

Thanks for the reply,

Xhonzi
 
Kirsle,
I think I read that you need to have Perl installed with Thread support to use this module. Do you know if that is correct?

I don't have the ability to reinstall Perl with that option.

Xhonzi
 
I didn't remember any such option when I installed Perl... I think my options were Perl, PPM, documentation, example codes... and PPM3?

So threads installs with the other standard modules that come with Perl. I guess I could also note that I installed Perl 5.8 so that 5.6 might not have it installed.

You can always just open command prompt and type this:
Code:
perl -Mthreads -e exit;

If you get a "Can't find threads.pm in @INC" error, you don't have threads installed.

Also, there's a difference between threads and Thread (with a capital T). Thread is the one for older codes.
 
Thanks, I'll give it a shot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top