Question: 1.Create a program that does the following. - Prompts the professor for ten students grades, - Creates ten threads, one for each student. - Create

1.Create a program that does the following. - Prompts the professor for ten students grades, - Creates ten threads, one for each student. - Create a function class_total(grade) which adds the grade to a global variable total_grade using the operator += to increment total_grade - You MUST use mutual exclusion when incrementing total_grade - Print the results of total grade, it should be the correct sum of all ten grades.

2. Create a program that does the following. - Reads in 10 grades from the file grades.txt using one thread with the function called read_grades() - You must use a barrier to wait for grades to be read by the program - Create 10 threads, each uses the function save_bellcurve(grade) which - Adds the grade to a global variable total_grade using the operator += to increment total_grade - Bellcurves the grades by multiplying it by 1.50 and adds the grade to a global variable total_bellcurve - Saves (appends) the bellcurved grade to the file bellcurve.txt - After saving all the bellcurved grades to the file, the main program then prints to the terminal the total grade and the class average before and after the bellcurve. - You will need to use a combination of barriers, mutual exclusion, and thread joining to complete this question. - NOTE: For barriers to work you may need to add the following line to the top of your source file and/or compile it with -std=gnu99

Templates

grades.txt

54 43 47 23 61 44 32 43 56 14

Template #define _XOPEN_SOURCE 600 // required for barriers to work #include #include #include int main(void) { }

#define _XOPEN_SOURCE 600

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!