Search for question
Question

Implement the program by following the below instructions: • Write a 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 (HW1: Problem 3). The Parent should not wait for the first child. The second child will be responsible for generating a random number between 0- 10 and write that number to the pipe. Print the random number. The third child will also be responsible for generating a random number between 0-10 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 4th child and 4th child should print the date after the first 3 child complete their task. • So, in total you need to have two c program files. One for implementing the functionality of child1(child1.c), and the remaining one(parent.c) where you will create the child processes and perform exec(). Child2, child3, and child4 functionalities should be written in parent.c You need to pass the source.txt, and destination.txt files from the terminal to the program(parent.c) 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: yourName_hw3.zip. 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. N.B: For further clarification attend the lab discussion.