Question: Description This assignment consists of designing a multithreaded solution that finds the maximum of a set of integers fast. Write your solution using the pthread




![max x 01 for (i 1; i n i++ if (x[i] max)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3d983380dc_96266f3d982d517f.jpg)





Description This assignment consists of designing a multithreaded solution that finds the maximum of a set of integers fast. Write your solution using the pthread library discussed in class. To find the maximum integer in an array X of size n, one might use the following code: max x 01 for (i 1; i n i++ if (x[i] max) xlil max This is based on the fact that we have only one CPU and use (n 1) comparisons to find the maximum, but we can do better if more CPUs are available: Assume that a thread can be used to simulate a CPU. Suppose we have n distinct integers xo, x1, n-1 that we need to find the maximum from. Start with creating a working array, say W, of n entries. Step 1 Initialize W all 1s. This can be done with n threads, each of which writes a 1 into its Wto corresponding entry in the array For example, thread Ti writes 1 into Wii. Since a threads take one step to complete their job, the initialization step only needs one operation in each thread
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
