#include #include #include int thread_count, bin_count, data_count, thread_data_count, leftover_data_count; float min_meas, max_meas, bin_size; //setup global histogram with calloc. int* global_histogram; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; void ParseArgs(int argc, char **args); float* GenerateArray(); void * Work(void *pVoid); int main(int argc, char* argv[]) { ///serial functions ParseArgs(argc, argv); float *array = static_cast(calloc(data_count, sizeof(*array))); array = GenerateArray(); global_histogram = static_cast(calloc(bin_count, sizeof(*global_histogram))); pthread_t thread[thread_count]; for(int i = 0; i < thread_count; i++){ //create all the threads pthread_create(&thread[i], nullptr, Work, &array[i*(data_count/thread_count)]); } for(auto i = 0; i 6) throw; bin_size = (max_meas-min_meas)/(float)bin_count; // set the total data for each thread and account for the "extra" thread_data_count = data_count/thread_count; leftover_data_count = data_count % thread_count; } catch (std::exception& e) { std::cerr << "Invalid input data: " << std::endl << "\t"<