I am unable to complete this assignment and I have run out of ideas:
There is a given input that looks like this: 92 85 71 25 49 71 95 0.
My program is supposed to create three threads and read the input, the first is supposed to calculate the average of the values the second is supposed to calculate the minimum of the numbers and the third should create the maximum. The 0 at the end is just supposed to show the end of the input
I am supposed to use pipe1 to pass the first number from main to thread1 which will use pipe2 to pass it to thread2 which will sue pipe3 to pass it to thread3.
main should pass along the values to thread1 as it reads them and all threads including main should run parallel. The variables representing the average, minimum and maximum values will be stored locally within each respective thread.
Is there any obvious tool or approach in C that is used for something like this?
With my first tries I ran into the problem that pipes were overwritten before they were read, I wondered wether I should use mutex to lock the code where I read from the pipes but main can just continue writing to the first pipe before the mutex lock is even applied.
I have no fucking idea how to do this, I tried using global variables to have the threads wait for the pipes but
a) I am sure that that this is not intended approach and
b) it does not work anyway