fork

C

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
 
J

Jim Gibson

CwK <[email protected]> said:
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.
 
M

Misha Gale

Jim Gibson said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top