109 lines
4.4 KiB
TeX
109 lines
4.4 KiB
TeX
\subsection{The Command Stack}
|
|
This is a helper class to the connection class.
|
|
Each connection to a client has a command stack associated with it. The
|
|
command stack is a stack of command strings as generated by the SICS
|
|
clients. Commands are added to the top of the command queue by the network
|
|
reader. Each time the task associated with a connection runs one command
|
|
is popped from the command stack and executed. During execution the command
|
|
stack must be locked in order to prevent commands being accepted by tasks
|
|
busy waiting for some other process to finish.
|
|
|
|
Correspondingly, the interface to the command stack looks like this:
|
|
|
|
\begin{flushleft} \small
|
|
\begin{minipage}{\linewidth} \label{scrap1}
|
|
$\langle$costaint {\footnotesize ?}$\rangle\equiv$
|
|
\vspace{-1ex}
|
|
\begin{list}{}{} \item
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ typedef struct __costa *pCosta;@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@/*----------------------------- live & death ----------------------------*/@\\
|
|
\mbox{}\verb@ pCosta CreateCommandStack(void);@\\
|
|
\mbox{}\verb@ void DeleteCommandStack(pCosta self);@\\
|
|
\mbox{}\verb@ int SetCommandStackMaxSize(pCosta self, int iNewSize);@\\
|
|
\mbox{}\verb@/*----------------------------------------------------------------------*/@\\
|
|
\mbox{}\verb@ int CostaTop(pCosta self, char *pCommand);@\\
|
|
\mbox{}\verb@ int CostaBottom(pCosta self, char *pCommand);@\\
|
|
\mbox{}\verb@ int CostaPop(pCosta self,char **pPtr);@\\
|
|
\mbox{}\verb@/*----------------------------------------------------------------------*/@\\
|
|
\mbox{}\verb@ void CostaLock(pCosta self);@\\
|
|
\mbox{}\verb@ void CostaUnlock(pCosta self);@\\
|
|
\mbox{}\verb@@$\diamond$
|
|
\end{list}
|
|
\vspace{-1ex}
|
|
\footnotesize\addtolength{\baselineskip}{-1ex}
|
|
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
|
|
\item Macro referenced in scrap ?.
|
|
\end{list}
|
|
\end{minipage}\\[4ex]
|
|
\end{flushleft}
|
|
Internally, two data structure need to be defined, the first for the
|
|
list implementing the command stack, the second for the command stack
|
|
itself.
|
|
|
|
\begin{flushleft} \small
|
|
\begin{minipage}{\linewidth} \label{scrap2}
|
|
$\langle$costadat {\footnotesize ?}$\rangle\equiv$
|
|
\vspace{-1ex}
|
|
\begin{list}{}{} \item
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@/*------------------------------------------------------------------------*/@\\
|
|
\mbox{}\verb@ typedef struct __costa {@\\
|
|
\mbox{}\verb@ int iLock;@\\
|
|
\mbox{}\verb@ int iList;@\\
|
|
\mbox{}\verb@ int iMaxSize;@\\
|
|
\mbox{}\verb@ int iCount;@\\
|
|
\mbox{}\verb@ } Costa;@\\
|
|
\mbox{}\verb@@$\diamond$
|
|
\end{list}
|
|
\vspace{-1ex}
|
|
\footnotesize\addtolength{\baselineskip}{-1ex}
|
|
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
|
|
\item Macro referenced in scrap ?.
|
|
\end{list}
|
|
\end{minipage}\\[4ex]
|
|
\end{flushleft}
|
|
\begin{flushleft} \small
|
|
\begin{minipage}{\linewidth} \label{scrap3}
|
|
\verb@"costa.h"@ {\footnotesize ? }$\equiv$
|
|
\vspace{-1ex}
|
|
\begin{list}{}{} \item
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@/*-------------------------------------------------------------------------@\\
|
|
\mbox{}\verb@ C O S T A@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ A command stack implementation for SICS. To be used by each connection.@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ Mark Koennecke, September 1997@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@ copyright: see implementation file.@\\
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@----------------------------------------------------------------------------*/@\\
|
|
\mbox{}\verb@#ifndef SICSCOSTA@\\
|
|
\mbox{}\verb@#define SICSCOSTA@\\
|
|
\mbox{}\verb@@$\langle$costaint {\footnotesize ?}$\rangle$\verb@@\\
|
|
\mbox{}\verb@#endif@\\
|
|
\mbox{}\verb@@$\diamond$
|
|
\end{list}
|
|
\vspace{-2ex}
|
|
\end{minipage}\\[4ex]
|
|
\end{flushleft}
|
|
\begin{flushleft} \small
|
|
\begin{minipage}{\linewidth} \label{scrap4}
|
|
\verb@"costa.i"@ {\footnotesize ? }$\equiv$
|
|
\vspace{-1ex}
|
|
\begin{list}{}{} \item
|
|
\mbox{}\verb@@\\
|
|
\mbox{}\verb@/*---------------------------------------------------------------------------@\\
|
|
\mbox{}\verb@ C O S T A@\\
|
|
\mbox{}\verb@ Internal data structures for the command stack.@\\
|
|
\mbox{}\verb@--------------------------------------------------------------------------*/@\\
|
|
\mbox{}\verb@@$\langle$costadat {\footnotesize ?}$\rangle$\verb@@\\
|
|
\mbox{}\verb@@$\diamond$
|
|
\end{list}
|
|
\vspace{-2ex}
|
|
\end{minipage}\\[4ex]
|
|
\end{flushleft}
|