Reference no: EM13320876
Parallel Sort
In this assignment you will be subjected to a 100% completely realistic scenario. Somebody borked our database and now the records are all chopped up and out of order. So now it's YOUR job to clean up this mess and write a program to sort these back into a single file. Oh, and we only have a few nanoseconds to do it, so you'd better do it with pthreads!
As input, you will receive an arbitrary number of ASCII text files with arbitrary file names. These files will all be located in a directory specified on the command line. You are given a set of sample data with which to test your program.
Your program should obtain a list of the files in a given directory and then use that to go about its business.
Each data file will have a number of records that look like the following:
<username>,<password><blood type>,<domain name>,<database index>
You may read these in with any file manipulation function that you see fit (fgets() works quite nicely). You should split these on commas and use atoi() on the database index before sticking them into a struct.
The end result will be an array of these structs to be sorted.
Parallelism
Each file should be handled in parallel. This means that you will list the supplied directory and then spin up a separate thread for each file contained therein.
All file manipulation functions and sorting will take place in the thread allotted for that file.
Sorting
You can write your own sort if you'd like, but since that's not relevant to the assignment, you can go ahead and use the qsort() function in the standard library. You will be sorting by the last field in each record, the database id. The result should be in ascending order.
Note that this function takes a function pointer as an argument. This is a pointer to another function in memory which is used to compare elements in the array. You will learn more about how this works in class.
Makefile
Your makefile should produce an executable which takes one argument (a directory path) and performs a sort on the files located in that directory. Make sure that you are processing this argument in a fashion that finds the directory relative to the current working directory. (e.g., if you execute ./coolsort "./nested/directory/structure", everything in the subdirectory "structure" should be sorted).
Output
The output should be a single ASCII file called sorted.yay containing all of the records from each individual data file in sorted order.
Attachment:- data.rar
What is the ph of a buffer
: What is the ph of a buffer that results when .40 mol nahco2 is mixed with 100 ml of 2.0 m hcl and diluted with water to 250 ml
|
Find the total work done by the gas in one cycle
: Two moles of an ideal monoatomic gas undergo a cyclic process starting from state A at a vol. of 1L and a pressure of 2 atm. Find the total work done by the gas in one cycle
|
What is the position of the block
: A 2.00 kg. frictionless block is attached to an ideal spring with force constant 300 n/m. At t=0 the block has velocity -4.0 m/s, what is the position of the block when its speed is 2.5 m/s
|
What is the difference in water levels between reservoirs
: A wrought iron water line connecting two reservoirs at 20°C has a length of 1500 m, a diameter of 75 cm, two elbows (90º, long-radius, flanged), a fully open gate valve, and a reentrant pipe entrance.
|
Write a program to sort back into a single file
: Write a program to sort these back into a single file. Oh, and we only have a few nanoseconds to do it, so you'd better do it with pthreads!
|
Determine the inductance of a solenoid
: Calculate the inductance of a solenoid with 275 turns if the length of the solenoid is 30 cm and its radius is 2.5 cm
|
Find the total axial deformation-strain of the column
: A 14-in. square concrete post is 6ft tall and reinforced by nine 3/4" diameter steel rods. Assume that the materials are high-strength concrete and ASTM-A36 structural steel.
|
Four primary types of local area networks–contention bus,
: Discuss the advantages and disadvantages of the four primary types of local area networks–contention bus, token bus, token ring, and wireless.
|
Find the velocity and acceleration of a particle of fluid
: A two-dimensional flow field is given by u=2+xy+3t^2, v=2xy^2+t. Find the velocity and acceleration of a particle of fluid at point (2,3) at t=4. Specify units in terms of L and T.
|