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 multithreaded implementation of your design about Problem of Homework 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 getwords from one of the files eg Thread reads words
from dictionarytxt You need to write a getwords function to retrieve up to words from a file.
the last call may get fewer than words At end of your program, print out number of unique words.
You will write two multithreaded programs to solve the problem. The first program is a nonoptimized
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 getwordsword
for i ; 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 wordi is not in the list
increment the count about total number of unique words by one;
add wordi 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 numbers, for each program
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
