Question: use c program This is a multi - threaded implementation of your design about Problem 4 of Homework 3 . Four input files have been

use c program
This is a multi-threaded implementation of your design about Problem 4 of Homework 3. Four input files
have been provided (downloadable at Canvas), each containing several words. You will use four threads.
Each of your threads will read words (via. get_words()) from one of the files (e.g., Thread 1 reads words
from dictionary1.txt). You need to write a get_words() function to retrieve (up to)10 words from a file.
(the last call may get fewer than 10 words). At end of your program, print out number of unique words.
You will write two multi-threaded programs to solve the problem. The first program is a non-optimized
implementation that keeps all of the sequentially search the list to see if there is a match in the critical
section. The second one is an optimized one that keeps most of the time spent on sequentially search the
list to see if there is a match out of critical section for higher performance.
while (num = get_words(word)){
for (i =0; i < num; i++){
/* list is a string array storing all the distinct words that have been encountered so far
You can sequentially search the list to see if there is a match.
*/
if word[i] is not in the list {
increment the count about total number of unique words by one;
add word[i] to list at the end of the list;
}
}
}
Observation: for each program, report the number of words that are searched in the critical section by each
of its four threads (that is, you will report 8 numbers, 4 for each program)

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!