Question: You will be writing a program that reads multiple text files in parallel by using threads along with mutex and calculating the student's participation score.

 You will be writing a program that reads multiple text filesin parallel by using threads along with mutex and calculating the student'sparticipation score. See attached: Roster.txt 1.txt (sample file, a number of files

You will be writing a program that reads multiple text files in parallel by using threads along with mutex and calculating the student's participation score. See attached: Roster.txt 1.txt (sample file, a number of files is provided by the user input) Participation class (see skeleton below) The following ADT variable should be made available to all threads through a globally accessible ChatParticipation instance. Thus, all variables are allocated within a class and each thread should access to it by calling appropriate getter and setter functions. Implement required functionality for this ADT skeleton code. class Participation { private: int size; //size of the roster string * names; // a pointer to a dynamic array with the names in the roster file int* participation Points; lla pointer to a dynamic array with the size of the roster. It stores participation points for each student. Example, Anna has 50 chats in all text files, thus participation Points[0]=50. int totalSum;lla variable to store a total number of all student messages in all chat files double * scores; lla variable to store the outcomes, max score is 100. Assign a participation score to each student based on their participation points. Example, calculate an average for class participation points, suppose the class average is 45, and Anna has 50, thus scores [0]=100. Otherwise, the score needs to be adjusted /prorated. public: Participation () { I/TODO: allocate dynamic arrays } I/TODO: getter, setter, destructor methods } ChatParticipation; //global variable. All threads can access it. //This function header needs to stay the same. void *do_work(void *argX /* TODO: This user-defined function is used by each thread accessing the unique data file (example: 1.txt 2.txt and so on). The result from this function is written into the private total sum variable and participation Points. Since the threads will need to modify the shared variables within the class, you are required to use the mutex variable for race condition prevention. */ } The main program will ask for user for input for how many text files are available; then your program needs to populate the dynamic array of student names, listed in the Roster.txt The main program shall also create a dynamic number of threads which preform calculation of participation Points and totalSum by using the same do_work function. The main thread needs to wait for all threads to finish and then calculate scores, and output the values in the following format: Student Name/Participation Points/Score. Roster - Windows Anna, Nguyen, Thomas, Yun, Prateek, Favian, Abhinav, Ameena, Ryan, Parker, Omar, Charlotte, Ronnie, 1 - Windows 20:36:34 From Nguyen : I notice the book and the lecture slides have dinos, what's up with that 20:37:05 From Thomas : Dinosaurs make everything exciting... 20:37:12 From Yun : I like dinosaurs 20:38:23 From Prateek : Are we going to choose are own groups or will they be random? 20:50:18 From Favian : What are the presentations going to be about? 20:50:33 From Nguyen : When will we choose our groups? 20:51:44 From Abhinav : Yes Mam 20:53:08 From Ameena : do well on coding assigments 20:53:14 From Ryan : do well on both midterms 20:53:21 From Parker : Understand the assignments 20:53:47 From Omar : make sure, you and your group make a good presentation 20:54:03 From Charlotte : go to office hours 20:54:04 From Favian : Attend class and participate. Review plenty outside 20:54:22 From Ronnie : Understand the assignments because the will be based on the exams? 20:57:07 From Nguyen : Will the coding assignments be through Linux? You will be writing a program that reads multiple text files in parallel by using threads along with mutex and calculating the student's participation score. See attached: Roster.txt 1.txt (sample file, a number of files is provided by the user input) Participation class (see skeleton below) The following ADT variable should be made available to all threads through a globally accessible ChatParticipation instance. Thus, all variables are allocated within a class and each thread should access to it by calling appropriate getter and setter functions. Implement required functionality for this ADT skeleton code. class Participation { private: int size; //size of the roster string * names; // a pointer to a dynamic array with the names in the roster file int* participation Points; lla pointer to a dynamic array with the size of the roster. It stores participation points for each student. Example, Anna has 50 chats in all text files, thus participation Points[0]=50. int totalSum;lla variable to store a total number of all student messages in all chat files double * scores; lla variable to store the outcomes, max score is 100. Assign a participation score to each student based on their participation points. Example, calculate an average for class participation points, suppose the class average is 45, and Anna has 50, thus scores [0]=100. Otherwise, the score needs to be adjusted /prorated. public: Participation () { I/TODO: allocate dynamic arrays } I/TODO: getter, setter, destructor methods } ChatParticipation; //global variable. All threads can access it. //This function header needs to stay the same. void *do_work(void *argX /* TODO: This user-defined function is used by each thread accessing the unique data file (example: 1.txt 2.txt and so on). The result from this function is written into the private total sum variable and participation Points. Since the threads will need to modify the shared variables within the class, you are required to use the mutex variable for race condition prevention. */ } The main program will ask for user for input for how many text files are available; then your program needs to populate the dynamic array of student names, listed in the Roster.txt The main program shall also create a dynamic number of threads which preform calculation of participation Points and totalSum by using the same do_work function. The main thread needs to wait for all threads to finish and then calculate scores, and output the values in the following format: Student Name/Participation Points/Score. Roster - Windows Anna, Nguyen, Thomas, Yun, Prateek, Favian, Abhinav, Ameena, Ryan, Parker, Omar, Charlotte, Ronnie, 1 - Windows 20:36:34 From Nguyen : I notice the book and the lecture slides have dinos, what's up with that 20:37:05 From Thomas : Dinosaurs make everything exciting... 20:37:12 From Yun : I like dinosaurs 20:38:23 From Prateek : Are we going to choose are own groups or will they be random? 20:50:18 From Favian : What are the presentations going to be about? 20:50:33 From Nguyen : When will we choose our groups? 20:51:44 From Abhinav : Yes Mam 20:53:08 From Ameena : do well on coding assigments 20:53:14 From Ryan : do well on both midterms 20:53:21 From Parker : Understand the assignments 20:53:47 From Omar : make sure, you and your group make a good presentation 20:54:03 From Charlotte : go to office hours 20:54:04 From Favian : Attend class and participate. Review plenty outside 20:54:22 From Ronnie : Understand the assignments because the will be based on the exams? 20:57:07 From Nguyen : Will the coding assignments be through Linux

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!