Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > fork

Reply
 
 
CwK
Guest
Posts: n/a
 
      12-22-2003
How to use fork() system function to fork multi child process at the same
time ?

For example:

Run a program to fork 5 child process at the same time and the parent must
wait until all child exit.

The child do some thing like to read different file at the same time.

Thanks


 
Reply With Quote
 
 
 
 
Jim Gibson
Guest
Posts: n/a
 
      12-22-2003
In article <bs76pq$(E-Mail Removed)>, CwK <(E-Mail Removed)>
wrote:

> How to use fork() system function to fork multi child process at the same
> time ?
>
> For example:
>
> Run a program to fork 5 child process at the same time and the parent must
> wait until all child exit.
>
> The child do some thing like to read different file at the same time.
>
> Thanks
>
>


Execute the fork call 5 times. You can't start 5 processes "at the same
time", but you can do it quickly one after another. You will then need
to execute the wait call 5 times in the parent process, one for each
child. No single process can do two or more different things
simultaneously. Two or more processes can execute simultaneously only
if you have more than one processor in your system.

Once you have a Perl program coded, and if it doesn't work, you should
then post it here for additional help.
 
Reply With Quote
 
 
 
 
Misha Gale
Guest
Posts: n/a
 
      01-04-2004

"Jim Gibson" <(E-Mail Removed)> wrote in message
news:221220031029144359%(E-Mail Removed). ..
> In article <bs76pq$(E-Mail Removed)>, CwK <(E-Mail Removed)>
> wrote:
>
> > How to use fork() system function to fork multi child process at the

same
> > time ?
> >
> > For example:
> >
> > Run a program to fork 5 child process at the same time and the parent

must
> > wait until all child exit.
> >
> > The child do some thing like to read different file at the same time.
> >
> > Thanks
> >
> >

>
> Execute the fork call 5 times.


Be sure that only the top-level parent atually executes the forks, otherwise
rather than having five processes you will end up with 2^5=32 processes.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
os.fork and pty.fork Eric Snow Python 0 01-08-2009 06:32 AM
objects and fork command? Doug Nichols Perl 1 08-08-2004 11:07 AM
Noob help request on TCP Server with fork xchris Perl 5 06-22-2004 11:56 AM
Can't fork exec from webpage, problem is not permissions Patrick Perl 1 05-14-2004 12:03 PM
fork in perl 5.8.3 on windows Josh Denny Perl 2 03-02-2004 11:24 PM



Advertisments