CMPE322 Project 2 Threading, or not? solved


Category: You will receive a download link of the .ZIP file upon Payment


5/5 - (1 vote)

2 First Part
In this project, we want you to generate N integers from scratch and put them into an
integer list. All integers must be between 1000-10000(both included). The number N will be
passed as a parameter of your main program.
Example execution will be:
./”program name” “number_of_integers”
./myprogram.o 100000
Afterwards, you need to find
• Min,
• Max,
• Range,
• Mode (If there is multiple modes, return first one),
• Median,
• Sum,
• Arithmetic Mean,
• Harmonic Mean,
• Standard Deviation (Where you divide by N-1),
• Interquartile Range,
respectively. You can use max. 5-significant-digit floating point numbers, more digits will not
be checked. It is also needed for you to time your whole operation. Expected output is given
below. First ten lines will be the result of the 10 operations respectively. 11th line is the duration of 10 operations in total (in seconds). For the first part, only a one-process/one-thread
program is expected. You should not realize any process or thread creation (or the implied
versions such as SYSTEM()). The output should be printed to a file named “output1.txt”.
Project 2
Figure 1: Output Example.
This concludes the first part of the project.
3 Second Part
Second part of the project is nearly the same as the first part with some slight differences:
• Every 10 operation must be done in a THREAD, and they must start working at the
same time. For this part, you need to design your code with both:
– 10 threads (One task each)
– 5 threads (Two tasks each). You can group the tasks by two as you wish.
• Example execution will be:
./”program name” “number_of_integers”
./myprogram.o 100000
• The name of the output file will be output2.txt. Output file should be created and written
by the main thread for not mixing the print orders. Note that you also need to time your
whole part. Timing is an important part of your project that you need to explain the
differences or similarities (if any) of time, in a simple pdf report.
4 Permissions and Restrictions
• Only C or C++ is allowed.
• You can use external libraries and functions.
• You can use any mathematical functions or libraries for easiness.
• Only pthreads are allowed for threadding. You must use and create pthreads.
Project 2
5 Submission Details
• Same rules apply as the first project for late submissions and cheating!!!
• Only submit a .zip file. Filename must be (For example:
• Zip file must contain:
– Three c or c++ files. (One for First Part, one with 10 threads, one with 5 threads)
– Makefile (Yes it is a must this time.) (Really important!!!)
– One-page pdf (Maximum) to explain your approach to the both implementations,
and to give your ideas about the differences in duration (if there is any) for all
parts(first part, 10 threads, 5 threads) of the project.
– And nothing else! (No need for output file submission)
– (Optional!!) You can also use a program parameter to obtain the number of threads
to use. Example:
./”program name” “number_of_integers” “number_of_threads”
./myprogram.o 100000 5
This is an optional task for %10 of your note. Please specify the execution format
to the user (with a simple print function) in the beginning of a program, if you will
be implementing this option.