Question: For this assignment, your program is to read War and Peace (a text copy is included with this assignment) and it is to count and

 For this assignment, your program is to read War and Peace

(a text copy is included with this assignment) and it is to

For this assignment, your program is to read War and Peace (a text copy is included with this assignment) and it is to count and tally each of the words that are 6 or more characters long. And again, you will only use Linux (not library) file functions, i.e. open, close, read, Iseek. BUT, it is to do this using threads. Each thread will take a chunk of the file and process it, returning it's results to the main which tallies (or if you directly tally to shared memory, that is okay) and then the main will print the ten, 6 or more character, words with the highest tallies, in order highest to lowest, and their associated counts. i.e. The top ten words and the number of times that word appears in the text. Your program should take two parameters on the command line: FileName and Thread Count FileName is the name of the file to read - WarAndPeace.txt ThreadCount is the number of threads you should spawn to evenly divide the work. That is to say - if the parameter is 1, the entire file would be read and processed by one thread. If the parameter is 5, then you would divide the file into 5 equal parts (accounting for rounding on the last part). So thread one would take the first 1/5 of the file, thread 2 the second fifth and so on. But, these threads should all be launched together in a loop. So that they can execute in parallel. #include in your code and in main, include the code below in your main. This will display how much time your program takes. Your submission should include a run with 1 thread, 2 threads, 4 threads, and 8 threads. How do the times compare? struct timespec startTime; struct timespec endTime; clock_gettime (CLOCK_REALTIME, &startTime); clock_gettime(CLOCK_REALTIME, &endTime); time_t sec = endTime.tv_sec - startTime.tv_sec; long n_sec = endTime.tv_nsec - startTime.tv_nsec; if (endTime.tv_nsec

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!