1 1 task 1 the first task involves contrasting the performance of prog
1.1 Task 1
The first task involves contrasting the performance of programs with and without caching. In particular,
you will be working with the volatile keyword in Java. The volatile keyword informs the compiler
that the variable should not be cached and accesses should always go to main memory.
You will run two separate loops, one when the loop variable is volatile and one for the loop variable
is not volatile. You will loop <size> number of times for both loops, so if size is 5 your loops will run
Your loop must do something on top of incrementing the loop variable, the loops will maintain a running
total of the addition and subtraction operations using the loop variable. The choice of whether you
perform an addition or subtraction to the runningTotal is based on whether the loop variable is odd or
even for the given iteration. If the loop variable is even (e.g., 10) then you should add the loop variable
to the runningTotal; if the loop variable is odd (e.g., 37) then you should subtract the loop variable
from the runningTotal. To cope with potential overflows/underflows runningTotal should be a long
You will do this <experiments> number of times, then calculate the average time
(totalTime/experiments) that it took to perform operations on runningTotal for both loops. You will
also calculate the average sum for all experiments (totalSum/experiments) for both loops.
You will then output the statistics for each of these loops. You will print out the average time taken to
perform the loop with the regular and volatile variable. Then you will print out the running totals that
each of these loops maintained. These numbers should be the same as both loops run for the number
of times(<size>). Look at the example output below to see more on how these numbers are outputted
to the terminal.
Produce a short report (450-500 words) with graphs and/or tables describing the observed behavior
when using the volatile keyword versus without.
*The amount will be in form of wallet points that you can redeem to pay upto 10% of the price for any assignment. **Use of solution provided by us for unfair practice like cheating will result in action from our end which may include permanent termination of the defaulter’s account.Disclaimer:The website contains certain images which are not owned by the company/ website. Such images are used for indicative purposes only and is a third-party content. All credits go to its rightful owner including its copyright owner. It is also clarified that the use of any photograph on the website including the use of any photograph of any educational institute/ university is not intended to suggest any association, relationship, or sponsorship whatsoever between the company and the said educational institute/ university. Any such use is for representative purposes only and all intellectual property rights belong to the respective owners.