Answered step by step
Verified Expert Solution
Link Copied!

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 1. 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 3 input1.txt input2.txt input3.txt 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 (e.g.>100MB). For each input and program, measure the run-time of the program. Then generate plots from your results answering following questions: With a fix number of input files, how does the run-time of your program change according to the changing input size? How does the run-time change according to the number of matches? How does the run-time 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 surname_name. Then compress the directory (.zip) and upload it to Canvas. The uploaded file will look like yilmaz_ali.zip and it will contain:
psearch.c: Program 1 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:
1- 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.
2- 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions

Question

Why is it a good idea to avoid being judgmental? (p. 177)

Answered: 1 week ago