Assignment 1: Process Creation and File Operations (40 Points) 1 Objectives: Practice with system calls to:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Assignment 1: Process Creation and File Operations (40 Points) 1 Objectives: Practice with system calls to: a) perform file operations; and b) create and use processes. 2 Description: Overview: You will write a program (says wordcount.c) to find out the number of words in multiple text files. Specifically, the program will first determine the number of files to be processed. Then, the program will create multiple processes with each process being responsible for one file to count its words. The typical format to run the program with input parameters is as follows: ./wordcount File_1 File_2 ... File_n Details: First, the program needs to determine the number of files to be processed. This can be done with the argc parameter of the main function; Then, the argv parameter can be used to retrieve the name for each file. After that, fork() system call will be used to create multiple processes (one for each file). For each child process, it can simply invoke a function to count the number of words inside a specific file and print out the result like [note that, no inter-process communication is required as child processes will report (i.e., print out) their results individually]: Child process for File_x: number of words is XXX The main process should wait until all child processes report their results; then, the main process report the end of the program with the print out: All n files have been counted! For word counting, you could simply use the space character as the delimiter. Anything that are not separated by the space will be counted as a single word. For instance, the example "The first program is a Hello-world." will be reported as 6 words (where Hello-world is counted as a single word). You could compare your results using the wc utility that is available on Linux machines. Submission Requirements The assignment needs to be submitted on Blackboard. The submission includes two parts: 1. Source codes [35 points]: This assignment should have only one source file (wordcount.c) and multiple header files (as you like). Your program needs to have proper comments (e.g., explanations for functions and variables etc.). It will be graded based on both functional correctness and clearity of the necessary comments. 2. Report.txt [5 points]: In this text file, you need to report: a) the status of your program (completed or not; partial credit will be given even the program is not completed); b) the design of your program (what and how system calls are utilized etc.); c) what help (if any) you get from TA and/or your classmates; and d) comments and suggestions to improve this assignment; 3. Submission: Please have all the above files zipped into a single file assign1-abc123.zip and upload the file on Blackboard, where abc123 should be your UTSA ID. Assignment 1: Process Creation and File Operations (40 Points) 1 Objectives: Practice with system calls to: a) perform file operations; and b) create and use processes. 2 Description: Overview: You will write a program (says wordcount.c) to find out the number of words in multiple text files. Specifically, the program will first determine the number of files to be processed. Then, the program will create multiple processes with each process being responsible for one file to count its words. The typical format to run the program with input parameters is as follows: ./wordcount File_1 File_2 ... File_n Details: First, the program needs to determine the number of files to be processed. This can be done with the argc parameter of the main function; Then, the argv parameter can be used to retrieve the name for each file. After that, fork() system call will be used to create multiple processes (one for each file). For each child process, it can simply invoke a function to count the number of words inside a specific file and print out the result like [note that, no inter-process communication is required as child processes will report (i.e., print out) their results individually]: Child process for File_x: number of words is XXX The main process should wait until all child processes report their results; then, the main process report the end of the program with the print out: All n files have been counted! For word counting, you could simply use the space character as the delimiter. Anything that are not separated by the space will be counted as a single word. For instance, the example "The first program is a Hello-world." will be reported as 6 words (where Hello-world is counted as a single word). You could compare your results using the wc utility that is available on Linux machines. Submission Requirements The assignment needs to be submitted on Blackboard. The submission includes two parts: 1. Source codes [35 points]: This assignment should have only one source file (wordcount.c) and multiple header files (as you like). Your program needs to have proper comments (e.g., explanations for functions and variables etc.). It will be graded based on both functional correctness and clearity of the necessary comments. 2. Report.txt [5 points]: In this text file, you need to report: a) the status of your program (completed or not; partial credit will be given even the program is not completed); b) the design of your program (what and how system calls are utilized etc.); c) what help (if any) you get from TA and/or your classmates; and d) comments and suggestions to improve this assignment; 3. Submission: Please have all the above files zipped into a single file assign1-abc123.zip and upload the file on Blackboard, where abc123 should be your UTSA ID.
Expert Answer:
Answer rating: 100% (QA)
include include int countwordschar filenameint ppid int mainint argc char argv to store process id o... View the full answer
Related Book For
Business Law and the Legal Environment
ISBN: 978-1285860381
7th edition
Authors: Susan S. Samuelson, Jeffrey F. Beatty
Posted Date:
Students also viewed these accounting questions
-
Question 4 (25%) An ISP is granted a block of IPv4 addresses starting with 49.2.0.0/16. The ISP needs to distribute these addresses to three groups of companies as follows: Group A has 32...
-
Write a program that counts the number of words in PresidentAbraham Lincolns Gettysburg address from http://cs.armstrong.edu/liang/data/ Lincoln.txt.
-
The data from Exercise 16.70 on the number of words of three syllables or more in advertisements from magazines of three different educational levels. In Exercises 16.158-16.166, use the technology...
-
Two companies, Energen and Hastings Corporation, began operations with identical balance sheets. A year later, both required additional manufacturing capacity at a cost of $50,000. Energen obtained a...
-
What can organizations do to prevent and manage workplace stress? How can individuals manage their own stress? What specific c changes can they make?
-
Friendly's Quick Loans, Inc., offers you "three for four or 1 knock on your door." This means you get $3 today and repay $4 when you get your paycheck in one week (or else). What's the effective...
-
Derive the solutions for transient concentration profiles in the two-bulb apparatus (Example 21.5 in the text) for the binary case, and show that the multicomponent case can be derived as an...
-
Full-of-Nature is a vitamin supplement company in New York that makes different herbal pills for gaining muscular strength, losing weight, and living a healthier life. You have been hired to audit...
-
3. Analyze the worst-case time complexity of the algorithm below. Input: n: nonnegative integer 1 Algorithm: LoopMystery 2 sum = 0 3 t = 1 4 d=1 5 k = n 6 while k> 1 do 7 for 1 to k do t=t+d sumsum +...
-
Case: Replacement Decisions Falconville Pump Company, Inc. Brandon Joiner, president and chief executive officer of Falconville Pump Company, Inc., has a potentially serious problem on his hands. The...
-
To claim the exclusion for compensation from exercising a California Qualified Stock Option (CQSO) the taxpayer's earned income must be what amount or less from the corporation granting the CQSO? A....
-
The sole proprietor is free to make any decision she or he wishes concerning Owhom to hire. when to take a vacation. what kind of business to pursue?
-
When you freeze the top row of a worksheet, what part of the worksheet can you scroll?
-
What is the main advantage of an unconditional policy commitment? OA. It provides a significant amount of certainty, which makes it easier for markets and households to make decisions about the...
-
Marisa is 40 years old has several 401(k) plans from moving between employers. She's getting overwhelmed by all the plans, and her friend tells her she can roll them over into an IRA. Marisa decides...
-
Are they the pressures and series of events that led WorldCom executives and managers to "cook the books"? Explain in detail. Explain in detail the setting and all the events that led to the...
-
Consider INSERTION SORT algorithm that takes an array of size n and sorts this array in non-decreasing order as follows. Algorithm: INSERTIONSORT Input: An array A[1..n] of n elements. Output:...
-
You have accepted the engagement of auditing the financial statements of the C. Reis Company, a small manufacturing firm that has been your auditee for several years. Because you were busy writing...
-
a) What is a life interest? b) What evidence does the court rely on in ruling for Baker? c) What argument did the Daves make based on the courtroom testimony? d) Question: Did they rely on anything...
-
a. What is corporation by estoppel? b. Did SGL believe in good faith that Transition Metal existed when it entered into the purchase and sale? c. Why does the court think this point is not relevant?...
-
a. What are the requirements for Rule 506 under Reg D? b. Inter Link sold stock to hundreds of investors. Is that a violation of Rule 506? c. Did Inter Link comply with Rule 506? d. Inter Link did...
-
(a) Among 880 smart phones sold by a retailer, 72 required repairs under the warranty. Estimate the probability that a new phone, which has just been sold, will require repairs under the warranty....
-
A car rental agency has 19 compact cars and 12 intermediate-size cars. If four of the cars are randomly selected for a safety check, what is the probability of getting two of each kind?
-
With reference to Exercise 3.34, suppose that the questionnaire filled in by one of the 150 persons is to be double-checked. If it is chosen in such a way that each questionnaire has a probability of...
Study smarter with the SolutionInn App