\documentclass[twocolumn]{article}

\setlength{\oddsidemargin}{-0.5in}
\setlength{\evensidemargin}{-0.5in}
\setlength{\topmargin}{0.0in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\setlength{\textwidth}{7.0in}
\setlength{\textheight}{9.5in}
\setlength{\parindent}{0in}
\setlength{\parskip}{0.05in}
\setlength{\columnseprule}{0.3pt}
\usepackage{fancyvrb}
\usepackage{relsize}
\usepackage{hyperref}

\begin{document}

Name: \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

Directions: {\bf Work only on this sheet} (on both sides, if needed); do not
turn in any supplementary sheets of paper. There is actually plenty of room
for your answers, as long as you organize yourself BEFORE starting writing.

{\bf 1.} Consider the GDB output at the top of p.149.  Answer the
following questions about line 15:

\begin{itemize}

\item [(a)] (10) Which of the four numbers is an address?

\item [(b)] (10) What kind of address is your answer in (a)?  (i) Physical
address. (ii) Virtual address. (iii) Page number.  (iv) Offset.  (v)
Stack position.  (vi) I/O port number.  (vii) None of these.

\end{itemize}

{\bf 2.} (20) Suppose we are running a program on CSIF. It seems slow
to us, and we suspect that this may be due to excessive cache misses or
page faults.  Fill in the blanks:  Using material from our course, we
can determine the number of
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
using the 
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
command, but we cannot determine the number of 
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_.
Of these two numbers the one that causes more slowdown is
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_.

{\bf 3.} (10) Consider the code on p.231.  What is the slot number for
{\bf z}?

{\bf 4.} (25) In the example on p.199, give a numerical expression for the
offset-within-page of {\bf q[0]}.

{\bf 5.} (25) I changed the function {\bf Min()} on p.225 to:

\begin{Verbatim}[fontsize=\relsize{-2}]
public static int gy(int U, int V)
{  int T;
   _______________________________________________________________
   _______________________________________________________________
   _______________________________________________________________
}
\end{Verbatim}

This produced the code

\begin{Verbatim}[fontsize=\relsize{-2}]
public static int gy(int, int);
  Code:
   0:	iload_0
   1:	iconst_3
   2:	iadd
   3:	iload_1
   4:	if_icmpge	14
   7:	iload_0
   8:	iconst_3
   9:	iadd
   10:	istore_2
   11:	goto	18
   14:	iload_1
   15:	iconst_3
   16:	iadd
   17:	istore_2
   18:	iload_2
   19:	ireturn
}
\end{Verbatim}

Fill in the blanks above.

{\bf Solutions:}

{\bf 1a.} Not graded.

{\bf 1b.} (ii)

{\bf 2.} page faults, time, cache misses, page faults

{\bf 3.} 3

{\bf 4.}  0x7bf-4-1999 $\times$ 4

{\bf 5.}

\begin{Verbatim}[fontsize=\relsize{-2}]
if (U+3 < V) T = U+3;
else T = V+3;
return T;
\end{Verbatim}

\end{document}

