In your programming assignment#0, you have successfully implemented the testspecial program to count frequency of each special word in .txt files under a given folder
In your programming assignment#0, you have successfully implemented the testspecial program to count frequency of each special word in .txt files under a given folder. In this assignment, you will have to speed up your program using multithreading.
You will be provided a two.zip which includes the following files:
makefile
count.h
specialcountmulthreads.c
testmulthreads.c
Your assignment is to write/modify code in the following files
count.h
makefile
specialcountmulthreads.c to count the frequency of special words: he, she, they, him, me;
Note: Feel free to do any change of these files (fill the code, create new functions and etc). You also can create new .h and .c files if needed.
The instructor will use the following file to test your code, so please DON’T modify this file:
testmulthreads.c
The following commands to test your code:
make // generate testmulthreads executable file
./testmulthreads 3 // run the testmulthreads program using 3 threads in parallel, the result will be stored in the specialfreq[] array and written in the file result.txt under result folder (Note: the instructor may vary the number of threads to verify your program)
Requirements:
- Multiple threads are expected to run in parallel to share the workload, i.e. suppose 3 threads to process 30 files totally, then each thread should process 10 files;
- When a thread is created, a message should be print out showing which files this thread will process, for example:
Thread id = 274237184 starts processing files with index from 0 to 10!
- When a file is being processed, a message should be print out showing which thread (thread_id = xxx) is processing this file, for example:
Thread id = 265844480 is processing file input_11.txt
- When a thread is done with its workload, a message should be print out showing which files this thread has done with work, for example:
Thread id = 274237184 is done !
- The array long specialfreq[ ] should always be up-to-date, i.e. it always has the result of all the threads counted so far. [You may need to use mutexes to protect this critical region.]
- You should try different strategies and speedup the program to your best.
You should have the screen printing be similar as follows:
Thread id = 274237184 starts processing files with index from 0 to 10!
Thread id = 265844480 starts processing files with index from 11 to 22!
Thread id = 257451776 starts processing files with index from 23 to 31!
Thread id = 265844480 is processing file input_11.txt
Thread id = 257451776 is processing file input_22.txt
Thread id = 274237184 is processing file input_00.txt
… …
Thread id = 274237184 is done !
Thread id = 265844480 is done !
Thread id = 257451776 is done !
The results are counted as follows:
he -> 250932
she -> 181764
… …
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.