Question: CODE IN C. 2. Develop a multithreaded program to sort an array of integers. DON'T do this until you've solved problem 1! Your program should

CODE IN C.
 CODE IN C. 2. Develop a multithreaded program to sort an

2. Develop a multithreaded program to sort an array of integers. DON'T do this until you've solved problem 1! Your program should run with 4 threads and use the algorithm discussed in class o Break the array into four equally sized partitions o Sort the partitions separately in different threads o Merge the results back together. This is a 2 step process where two threads merge the four partitions into two partitions and then with one thread merge the two partitions into one o Write a simple routine that checks the final array is in sorted order. If the array is sorted print "Sort complete." Otherwise print an error message .Each of the worker threads should use a bubble sort algorithm (intentionally slow, see the pseudo code below) .Use an array size of 64,000 elements that you randomly initialize using rand ) You may find it interesting to try different sized arrays and vary the number of threads. During development you'll want to use a small array, perhaps start with 2 threads, and printout your array results to confirm the sort and merge worked. The final version of your program should only print out the simple message generated by your simple checker . . Along with your code, turn in a comparison of how much time the multithread program takes versus running the same problem using a 1 threaded bubblesort algorithm. To determine how much time is required, you might use the unix time program (or "timer" from the first programming assignment) Simple bubble routine for (x-0;xarrayly+1]) temp arraylyl arrayly+1]-temp

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!