Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2 (100%) Your second task is to extend your work in part i to include multi-threaded logic for calculating average and variance of the

image text in transcribed
Part 2 (100%) Your second task is to extend your work in part i to include multi-threaded logic for calculating average and variance of the data read from the tile. The following enhancements have already been made in the process_data module for handling the multithreaded computation: - class definition for ProcessData has been enhanced by including member variables for handling the multithreaded computation. . The constructor definition for Processpata has been enhanced for handling the mulithreaded computation. - The destructor has been enhanced - Overloaded bool operatorfunction has also been enhanced Yourjob is to enhance the operator\" fu '1ction you created in part \"i for multi-threaded computation. Specifically, you include: - Computation of average through mu tithreading: to compute average, you call the function computeAngactor' in different threads with different parts ofthe data items div'ded by partitionindices. a bind total_item5 to the function computaAngactor as the divisor parameter. a create threads by passing the to lowing arguments to the function: address of the first element of each partition as ar'r , number of elements in the partition as size , and an element of the resource variable created to hold averagefactors as avg. :- join the threads. :- add all the averagefactors into he variable to hold total average; this shold be one of the parameters of the operator'[) function. . Computation of variance through letithreading: to compute variance, you call the function computevarFactor in different threads with different parts of the data items div'ded by partitionindices. You follow a procedure similar to the one you followed while computing the average, with following exceptions: :- use the average value computed in the previous step as the 4th parameter. a bind total_item5 and the computed average as divisor and avg , respectively, to the function .before creating the threads. r. the last parameter should be an element of the resource variable created to store variancefactors. :- you add the variance-factors computed by threads to compute the total variance. 0 You open the target data le and write the data [ tata1_items . and data J in the format of the input data file data_int.dat . Your code must be free from memory leak. When binding an argument to a function, consider the following reference: . std::bind[...)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions