17 Aug 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
… …
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.