
\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.} This problem concerns the Pthreads code for counting prime
numbers, in pages 6ff.

\begin{itemize}

\item [(a)] (20) Fill in the blanks:  There is a critical section in lines
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
through
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_.

\item [(b)] (20) Fill in the blanks:  If {\bf n} is 100, then the amount
of work printed out for a thread could range from
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
to
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_.

\end{itemize}

{\bf 2.} (20) Suppose a program that uses the shared-memory paradigm includes
the code (given here in pseudocode)

\begin{Verbatim}[fontsize=\relsize{-2}]
if my_thread_number == 0
   for i = 0 to number_ofthreads
      x[i] = i * i
for i = 0 to number_ofthreads
   z[] = x[i] - y[i]
next_line:
\end{Verbatim}

Fill in the blank with a term from our course:  In the line labeled {\bf
next\_line}, we need a
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_.

{\bf 3.} This problem concerns the MPI code for counting primes. in
pages 11ff.

\begin{itemize}

\item [(a)] (20) When the number 25 is checked for primeness, how many times is it
sent from one node to another?  

\item [(b)] (20) Suppose that instead of the three-node setting here, we
were to rewrite the code for four nodes.  There now would be a function
{\bf Node3()} that would look very similar to the old function {\bf
Node2()}.  Referring to specific line numbers, state the differences
(old line contents versus new ones) between the old {\bf Node2()} and
the new {\bf Node3()}.

\end{itemize}

{\bf Solutions:}

{\bf 1a} 48, 49

{\bf 1b} 0, 3

{\bf 2} barrier

{\bf 3a} 1

{\bf 3b} in line 134, $3 \rightarrow 4$ and in line 141, $7 \rightarrow
11$

\end{document}

