/******************************************************************** File: producer_consumer.h Description: Computes the integral of a function in parallel with pthreads. Author: Dana Vrajitoru Organization: IUSB Date: August 2020 *********************************************************************/ #ifndef INTEGRAL_H #define INTEGRAL_H #include // Creates the threads calling the compute_integral function, and to // each of them it passes the value of i converted to a pointer to // serve as id number. void create_threads(pthread_t *threads, int nr_threads); // Joins all of the threads so that the program doesn't end before // they have finished the work. void synchronise(pthread_t *threads, int nr_threads); // Inputs the boundaries of the interval, the number of threads, and // the total number of divisions. It returns the number of threads. int input_data(); // The function computing the integral. To be used to create threads void *compute_integral(void *arg); // A function we can compute the integral for // integral from 1 to x of 1/t dt = ln(x) float F(float x); // Output the computed integral void output_results(); #endif