Q- I have a program that takes 2 arguments and computes the sum of all the integ
ID: 3668085 • Letter: Q
Question
Q- I have a program that takes 2 arguments and computes the sum of all the integers form the first one and up to but not including the second. Here are some results I got from running the program that using 4 threads ( by dividing the work among 4 concurrently executing threads- mutithreaded), and doing it using the same computation just in the main- single thread .
Run1 is from 1 to 1,000,000. Run2 is from 1 to 1,000,000,000
Discuss the above results briefly explaining what they mean. Predict what would occur if I went from 1 to 10,000,000,000.
Run Multithreaded 249s 055s SingleThreaded 229s 049 user time.1 systime user time 2 975s 3.601s sys time 2 055s 055sExplanation / Answer
The above results depicts that the multithread programs outperforms the single threaded programs if the number of computations are huge and if the number of computations are less, the single threaded program will be much useful. This can be easily seen from the Run 1 and Run 2. In Run 1 , the single threaded executed faster(user time) than the multithreaded and the system overhead was less compared to the multithreaded program. In the Run2 , the input size increased by 1000 times. Now the multithreaded program executes much faster than the singlethreaded program, The system time reaches a constant for both.
If the computation is further incresed by 10 times say from 1,000,000,000 to 10,000,000,000, i guess the system time will be same for both mutithreaded and single threaded. But the user time will increase by a great factor for the single threaded but the increase in multithread program will be less compared to other. Hence the time difference in execution time for single and multi will increase if the number is incresed from 1,000,000,000 to 10,000,000,000.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.