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
#define _XOPEN_SOURCE 600
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started