\begin{figure*}[ht]
  \fvset{firstnumber=1,frame=none,numbers=none,numbersep=3pt,fontfamily=courier,fontsize=\footnotesize}
\begin{minipage}[b]{0.33\linewidth}
 \begin{Verbatim}[baselinestretch=0.95]
int rtl8139_suspend ( ... ) 

/* save PCI config state */
pci_save_state (pdev);

/* disable device */
if (!netif_running (dev))
   return 0;
netif_device_detach (dev);

spin_lock_irqsave
	(&tp->lock, flags);
/* Disable interrupts,
	stop Tx/Rx. */
RTL_W16 (IntrMask, 0);
RTL_W8 (ChipCmd, 0);

/* Copy out device state. */
dev->stats.rx_missed_errors += 
    RTL_R32 (RxMissed);
RTL_W32 (RxMissed, 0);
spin_unlock_irqrestore
       (&tp->lock, flags);

/* Suspend device */
pci_set_power_state (pdev, PCI_D3hot);
\end{Verbatim}
\end{minipage}
\begin{minipage}[b]{0.33\linewidth}
\begin{Verbatim}[baselinestretch=0.95] 
int rtl8139_checkpoint ( ... ) 

spin_lock_irqsave
      (&tp->lock, flags);

/* save PCI config state */
pci_save_state (pdev);

/* Copy out device state. */
dev->stats.rx_missed_errors += 
    RTL_R32 (RxMissed);


spin_unlock_irqrestore 
       (&tp->lock, flags);











\end{Verbatim}
\end{minipage}
\begin{minipage}[b]{0.33\linewidth}
\begin{Verbatim}[baselinestretch=0.95] 
int rtl8139_restore (...) 

spin_lock_irqsave
         (&tp->lock, flags);
		
/* disable device */
netif_device_detach (dev);

/* restore bus state */
pci_restore_state (pdev);

/* restart device */
if (!netif_running (dev))
    return 0;
rtl8139_init_ring (dev);
rtl8139_hw_start (dev);

RTL_W32 (RxMissed, 0);

/* re-enable device */
netif_device_attach (dev);
spin_unlock_irqrestore
         (&tp->lock, flags);



\end{Verbatim}
\end{minipage} 
\vspace{-0.1in}
\caption{\small \bf The above figures show the original suspend routine and refactored 
checkpoint and restore routines in rtl8139 driver. Driver checkpoint a consistent snapshot,
while the heavy work of stopping and starting the device is moved to restore.Drivers may 
also save non-standard registers during suspend which should be done during checkpoint. }
  \label{fig:8139-checkrestore}
  \vspace{-0.1in}
  \end{figure*} 

 

