\documentstyle[alltt]{article}

\setlength{\textwidth}{9.25in}
\setlength{\textheight}{7in}
\setlength{\topmargin}{-0.75in}
\setlength{\oddsidemargin}{-0.25pt}
\setlength{\evensidemargin}{-0.25pt}

\begin{document}

\setcounter{figure}{1}		% 0 for OSDI, 1 for TR, TOCS

\pagestyle{empty}

\begin{figure}
\small
\begin{tabular}{p{4.6in}|p{4in}}
\hline
\multicolumn{2}{c}{\bf a) Traditional caching} \\
\begin{alltt}
ReadCP(file, read parameters, destination address):
    for each file block needed to satisfy request
        compute which disk holds that file block
        if our previous request to that disk is still outstanding,
            wait for response and deposit data into user's buffer
        send new request to that disk's IOP for this (partial) block
    end
    wait for all outstanding requests.
\end{alltt}
&
\begin{alltt}
ReadIOP(file, read parameters):
    look for the requested block in the cache
    if not there
        find or make a free cache buffer
        ask disk to read that block into cache buffer
    reply to CP, including data from cache buffer
    consider prefetching or other optimizations
\end{alltt}
\\ \hline
\multicolumn{2}{c}{\bf b) Two-phase I/O} \\
\begin{alltt}
CollectiveReadCP(file, read parameters, destination address):
    Barrier (CPs using this file), to ensure that all are ready
    decide what portion of the data this processor should read
        (conforming to the file layout)
    for each contiguous chunk of the file this processor should read
        ReadCP(file, one chunk)
    Barrier (CPs using this file), to wait for all I/O to complete
    run permutation algorithm to send data to correct destination
    Barrier (CPs using this file), to wait for permutation to complete
\end{alltt}
&
\begin{alltt}
ReadIOP {\em (as above)}
\end{alltt}
\\\hline
\multicolumn{2}{c}{\bf c) Disk-directed I/O}\\
\begin{alltt}
CollectiveReadCP(file, read parameters, destination address):
    arrange for incoming data to be stored at destination address
    Barrier (CPs using this file), to ensure that all buffers are ready
    any one CP:
        multicast (CollectiveRead, file, read parameters) to all IOPs
        wait for all IOPs to respond that they are finished
    Barrier (CPs using this file), to wait for all I/O to complete
\end{alltt}
&
\begin{alltt}
CollectiveReadIOP(file, read parameters):
    determine the set of file data local to this IOP
    determine the set of disk blocks needed
    sort the disk blocks to optimize disk movement
    using double-buffering for each disk,
        request blocks from the disk
        as each block arrives from disk, 
           send piece(s) to the appropriate CPs
    when complete, send message to original requesting CP
\end{alltt}
\\ \hline
\end{tabular}
\caption{Pseudo-code for collective-read implementations.  
Collective writes are similar.}
\end{figure}

\end{document}
