Question: This assignment is about process Process Creation and File Operations. You will write two programs (say, wordcount.c and multiple_wordcount.c). /wordcount An_Input_File vordcount with process id



This assignment is about process Process Creation and File Operations. You will write two programs (say, wordcount.c and multiple_wordcount.c). /wordcount An_Input_File vordcount with process id of .... counted words in An_Input_File: number of words is ... /multiple_wordcount File_1 File_2 ... File_n vordcount with process id of counted words in File_1: number of words is vordcount with process id of ..... counted words in File_2: number of words is ... vordcount with process id of ..... cannot open File_3 vordcount with process id of .... counted words in File_n: number of words is ... nere is a sample output: parent process pid created .n.. child processes to count words in n. files ..x. files have been counted sucessfully! ..y... files did not exist Click here for a zip file containing templates for wordcount.c, multiple-wordcount.c, makefile, and sample input files. on Linux machines. general structure of multiple-wordcount.c for (i=1; i i++){ cpid = fork() if (cpid ==1){} if (cpid =e 0){ // exec () the wordcount program with argv[i] as a paramenter // if exec() is sucessfull, the child process will be replaced by wordcount // BUT, if exec() fails, the child will continue executing statments here! // So, print an error message here and // otherwise (if you don't exit), what will hapen? // this part is for parent process ! But, DO NOT WAIT FOR A CHILD HERE ! // after the parent creates all children, it comes to this part With the first for-loop, the parent continue to create child processes while each child process simply executes the wordcount program to count/print the number of words in the given file argv[i]. As described above: If the given file exists, the child process counts the words, prints out the count, and returns 0 ; or exit( (0); indicating sucess. If the file does not exist, it prints an error message and returns 1 ; or exit(1); indicating an error happened. Deliverables - You will write a two C programa (e.g., wordcount.c and multiple_wordcount.c) that take the parameters as described above. - When writing your programs, follow the programming style guidelines here. And include comments so we can easily understand and follow your logic. - Produce a single makefile for compiling all of the programs in this assignment. A sample makefile and c template are given in a zip file. - Run your program with different files and copy/paste your output into a textfile (say output1.txt)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
