Assignment 6
Assignment 6
Written Assignment 6
This written homework covers code optimization, design & debugging, linking.
Directions
Complete the question(s) on the following pages with single paragraph answers. These questions
are not meant to be particularly long! Once you are done, submit this assignment on Canvas.
Q: Please describe the benefit of 2s-complement signed integers versus other approaches (such
as 1s-complement or signed-magnitude).
Grading
Each assignment will be graded in two parts:
1. Does this work indicate any effort? (e.g. it’s not copied from a homework for another
class or from the book)
2. Three peers will provide short, constructive feedback.
Due Date
This assignment is due on July 12th, 11:59 PM EST. Remember to convert this time to the
timezone you currently reside in.
Question 1
What are the two optimization blockers introduced in class, why is it difficult for the compiler to
optimize them, and what are the possible remedies?
Procedure calls :
within
files ) It is hard for the optimizer to decide whether
.
a
calls
g. cannot automatically
.
e. call outside
of loop move a a
.
remedies :
use inline
functions ( will be substituted at the
place I
mind the code
manually
's
implementation
Memory aliasing :
to the same
reason : there are
possibilities that two
pointers refer
memory other
location .
In this case .
compiler
intermediate
cannot
directly do
load 1 store .
optimizations such as
reducing
remedies :
restricted
keyword
in
arguments to
specify that the
'
use '
procedure aliases
's
arguments are not .
g.
intermediate result .
Question 2
Each of the following subproblems contains two modules. For each problem, identify the
multiply-defined symbols for both modules, explain how the linker would resolve the references
to these multiply-defined symbols. Use the 3 Linker’s Symbol Rules to justify your answer.
Module 1 Module 2
b int x = 1; void x;
int main; void main()
{
int x = 1;
}
d int x; int y;
double y; double x;
double z = 1.0; int z;
the
multiply defined symbols
are main ✗
y
: , .
Other
symbols ( in d and the
global variable ✗ in e) are
weak
symbols .
y references
: will
refer to y in because it's strong symbol a a
initialized
I
global variables y d is weak symbol ,
in a .
Module 2
Hypothesis es :
and
if the dirty bytes in cache and dirty bytes evicted
see -
. -
-
-
bits set
if dirty
to are
watch points see
correctly
2 .
we could use
grind
Val to check
for memory overflows C Which
may
cause
dirty bit over write ) . or set watch
point in
gdb
dirty bit overwritten
is
why
the
to check when and .
Generally ,
steps to
figure
out the
bug using scientific debugging
are as
follows :
Prediction
→ ↳
hypothesis experiment
I sobers ration d
& conclusion