CS 3204 – Operating Systems
Dr. Sallie Henry
Project 4 Specification
Project Due at 5:00 April 18, 2000
This is a simple concurrency problem. The problem is to run three processes to sort a list of numbers in decreasing order. A list of numbers will be given from the input file ("input.txt"). The parent process will read the data from the input file, create 2 children processes, each of which will sort half of the data concurrently. After this is done, the parent will merge the two sorted halves to a sorted list of numbers. Then you’ll need to print out the sorted list of numbers to an output file ("output.txt"). The parent will read in the numbers into an array, then fork a child (to sort the first half of the numbers) and fork a second child to sort the second half of the numbers. The parent will then merge the two sorted lists and write out the result.
The name of the input file will be: input.txt.
There will be 2 lines in the input file. The first will specify the number of numbers to be sorted. The next line then contains all the actual numbers. All the numbers will be integers and they will be separated with a blank.
1 2 3 4 5
There will be 5 numbers to be sorted. They are 1, 2, 3, 4, and 5.
Name your output file to be: output.txt.
You need to put your name, SSN and email address as the header of the output file. Then simply print out the numbers in order.
You will have the main process (which will be referred to as the parent process in this document) which spawns two new processes (the children processes) using the UNIX fork() system call.
The synchronization can be achieved by using the UNIX wait() system calls at the appropriate places.
You will need to use the UNIX pipe() system calls to enable inter-process communication.
The source code for this project is to be written in the C/C++ programming language on a UNIX operating system (FreeBSD / Linux), due to the use of the system calls mentioned above.
These are the only UNIX related calls that you will need.
What to hand in:
You need to include a brief description on how to compile your program as the comment in your program and then email it to email@example.com.