Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this project, you are supposed to implement a program which will search words provided by the user in a number of input files and
In this project, you are supposed to implement a program which will search words provided 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 Each input file is a text file; containing a sequence of lines. All of these lines may contain one or more alphanumeric words. A line of 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 inputtxt inputtxt inputtxt output.txt
Implement the program using threads. Instead of creating children processes, create one thread per input file. Each thread will add the matching line information to a shared global linked list. When all threads end, the main thread will process the linked lists and will write the output file in the above format. Take care of any possible synchronization problems use semaphores You need to use POSIX Pthreads library.
Report: Run the following tests and experiments with your program. Use various input files of different sizes egMB For each input and program, measure the runtime of the program. Then generate plots from your results answering following questions: With a fix number of input files, how does the runtime of your program change according to the changing input size? How does the runtime change according to the number of matches? How does the runtime change according to the number of input files. Explain your results and come up with conclusions. Put all of your findings in to a report and submit your report together with your programs.
Submission:
Put your psearch.c Makefile and report into a directory named your surnamename. Then compress the directory zip and upload it to Canvas. The uploaded file will look like yilmazali.zip and it will contain:
psearch.c: Program C file.
Makefile: A makefile to compile your programs. We will just type make and your programs will be compiled and executables psearch will be obtained.
Report.pdf: Your report. Final report should be in PDF form.
Important Note:
Taking the solutions from the Internet or having the project done by somebody else or sharing is NOT ALLOWED and any such action is to be penalized by a disciplinary action. You have to produce your own solution and implementation. This is necessary for you to improve your knowledge and skills, which is the aim of your education.
Do NOT write your programs on Windows OS For compatibility, use a Linux. If you only have Windows on your pc install VirtualBox along with Ubuntu and use that environment. We will NOT try to make your program run, and treat it as it is So correcting any issue that prevents your program from running is your responsibility.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started