469,610 Members | 1,554 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

fork

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
2 3895
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

"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.

Similar topics

4 posts views Thread by Benoit Dejean | last post: by
6 posts views Thread by shellcode | last post: by
27 posts views Thread by steve | last post: by
11 posts views Thread by ramu | last post: by
1 post views Thread by vduber6er | last post: by
3 posts views Thread by thrillseekersforever | last post: by
5 posts views Thread by JoeW | last post: by
3 posts views Thread by CMorgan | last post: by
9 posts views Thread by Gilles Ganault | last post: by
2 posts views Thread by Radz | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.