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

 Description This assignment consists of designing a multithreaded solution that findsthe maximum of a set of integers fast. Write your solution usingthe pthread library discussed in class. To find the maximum integer inan 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 onlyone CPU and use (n 1) comparisons to find the maximum, butwe can do better if more CPUs are available: Assume that athread can be used to simulate a CPU. Suppose we have ndistinct integers xo, x1, n-1 that we need to find the maximum

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!