A multithreaded parallel grep runner program written in C that divides the workload of searching through all file contents in a directory tree among parallel threads
Consider the list of directories and files in the image below
We have the following:
- walkthrough
- dir1
- dir2
- dir3
- dir4
- dir5
- 5 absent text files with contents that do not contain the string 'cs140'
- 1 present text file with content that do contain the string 'cs140'
Shown in the image below is the content of present.txt
Running the following in the command line:
./multithreaded 3 /media/sf_cs140/cs140221project2-w-coronel/walkthrough/ cs140
Command line arguments:
- argv[0]: ./multithreaded
- argv[1]: 3 (number of workers/threads)
- argv[2]: /media/sf_cs140/cs140221project2-w-coronel/walkthrough/ (path)
- argv[3]: cs140 (string to be searched for)
We get the following output:
As we can see from the screenshot above, the program outputted one PRESENT, five ABSENTs, and six DIRs.
Moreover, we can see the number of workers/threads that did the process of searching