It is required to implement the following using the “pthread” library in Linux.
ID: 3628503 • Letter: I
Question
It is required to implement the following using the “pthread” library in Linux. Do notuse Java threads.
(a) The main thread generates n pseudo-random integers, and stores them in an array.
It also reads an integer p, such that n is divisible by p.
(b) The whole array is logically divided into p segments with n/p elements in each.
The main thread spawns p child threads, where the ith thread will sort the ith
segment of the array.
(c) After all the child threads have finished their computation, the main thread will
merge the contents of the sorted array segments, and print the final sorted array.