Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q 5 : Compute the run time of the following program Line No Interpretation Program Instructions Number of cycles per instruction 1 Initialization Index =

Q5: Compute the run time of the following program
Line No Interpretation Program Instructions Number of cycles per instruction
1 Initialization Index =01 cycle
2 A Label; not an instruction Label: Start 0 cycle
3 Lines 1-6 are a FOR LOOP If Index <1000,000,000 then 2 cycle
4 Sum = Sum + Index; 1 cycle
5 Index = Index +1; 1 cycle
6 GoTo Label 1 cycle
7 End
a. Find the no of cycles required for the First iteration of the For loop. [10 pts]
Note you have to include the cycle count of Initialization.
No. of cycles for first iteration of FOR loop =1(for initialization)+2(for if condition comparison)+1(for calculating sum)+1(for updating index variable)+1(for going back to label)=6 cycles
b. What is the total number of cycles used by the above program? [10 pts]
Total no. of cycles = no. of cycle for initialization of index variable +(no. of iterations of FOR loop * number of cycles in one iteration FOR loop)=1+(1,000,000,000*5)=5,000,000,001 cycles =5*109 cycles
c. Calculate the time taken by above program in nano seconds for 1 Ghz,2 GHz and 500 MHz CPUs? [30 pts]
(i) Time taken in 1 GHz CPU =(time taken to complete one cycle * total no. of cycles)=1*5,000,000,001=5,000,000,001 nano-seconds =5 seconds (approx.)
(ii) Time taken in 2 GHz CPU =0.5*5,000,000,001=2,500,000,000.5 nano-seconds =2.5 seconds (approx.)
(iii) Time taken in 500 MHz =2*5,000,000,001=10,000,000,002 nano-seconds =10 seconds (approx.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

=+. Alliteration The Magic of Macy's tagline.

Answered: 1 week ago

Question

=+iv. Simple promise No ordinary airline (Virgin Atlantic Airway).

Answered: 1 week ago