Question: In this project, you are supposed to implement several programs which will search wordsprovided by the user in a number of input files and will

In this project, you are supposed to implement several programs which will search wordsprovided by the user in a number of input files and will output the matching lines. The programs will be named psearch. They need to take the following command line parameters:an alphanumeric keyword, number of input files (n), input filenames, and an output filename. Number of input files will be greater than or equal to 1. Each input file is a text file; containinga sequence of lines. All of these lines may contain one or more (alphanumeric) words. A lineof an input file matched if the given keyword is found in the line as a separate word. For instance, the keyword “name” appears in “His name is Ali.”, but does not appear in “He is named Ali”. The output file will contain the matched lines along with the name of the input file that the match is found in, and the line number of the match in the format below:
, : . The output must be sorted
according to first and then . An example execution of your
program should be:
psearch name 3 input1.txt input2.txt input3.txt output.txt
Task 1:
a) Implement the program using multiple processes created by the parent main program. Call the program as psearch1a. Create children via the fork() system call. For n input files, n children must be created. Each child will process one input file and will write the result to a temporary output file. When all children end, the parent process will read the temporary output files and will write one final output file in the above format.
In psearch1a, files will be used to pass information from children to the parent process.
b) Repeat a, but this time name your program as psearch1b and use Shared memory with shared anonymous mapping mmap(). Also you need to use unnamed semaphores for synchronization.
c) Repeat a, but this time name your program as psearch1c and use an anonymous (unnamed) pipeline pipe().

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This sounds like a university project or assignment so Im going to help you by providing concept explanations and some pseudocode for each of the task... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!