Question: Write a C program where you need to create four child processes. Use for loop to create the child processes. The first child will be
Write a C program where you need to create four child processes. Use for loop to
create the child processes.
The first child will be responsible for copying the content of a source.txt file and
pasting it to the destination.txt file HW: Problem The Parent should not wait
for the first child.
The second child will be responsible for generating a random number between
and write that number to the pipe. Print the random number.
The third child will also be responsible for generating a random number between
and write that number to the same pipe. Print the random number
The fourth child will print the current date using one of the exec family
functions.
The parent process should wait for the second child to complete the task and
then read the number random number from the pipe generated by the second
child and print the random number.
The parent process should also wait for the third child to complete the task and
then read the number random number from the pipe generated by the third child
and print the random number.
The parent process then compares the two random numbers generated by the
second and third child. The child with the larger random number will be printed
as the winner by the parent.
The Parent should also wait for the th child and th child should print the date
after the first child complete their task.
So in total you need to have two c program files. One for implementing the
functionality of childchildc and the remaining oneparentc where you will So in total you need to have two c program files. One for implementing the functionality of childchildc and the remaining oneparentc where you will create the child processes and perform exec Child child and child functionalities should be written in parent.c
You need to pass the source.txt and destination.txt files from the terminal to the programparentc where you will perform the child creation and exec operations.
Form the terminal you need to test your implementation like below:.parent source.txt destination.txt
Zip all the programs and text files and submit it on the blackboard. Follow this format for the naming: yourNamehwzip.
You should have only one folder. Inside that folder you should have the text files and the program files. You need to zip this folder for submission.
Instructions: Follow the instructions properly while writing the code. You should follow the lecture slides to implement the problem rather than copying code from elsewhere.
NB: For further clarification attend the lab discussion.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
