By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,172 Members | 1,751 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,172 IT Pros & Developers. It's quick & easy.

fork

P: n/a
CwK
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
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <bs*********@imsp212.netvigator.com>, CwK <p1*@bigfoot.com>
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.
Jul 19 '05 #2

P: n/a

"Jim Gibson" <jg*****@mail.arc.nasa.gov> wrote in message
news:221220031029144359%jg*****@mail.arc.nasa.gov. ..
In article <bs*********@imsp212.netvigator.com>, CwK <p1*@bigfoot.com>
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.
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.