version 1.4, 2000/01/07 09:56:08 |
version 1.11, 2000/01/16 06:39:39 |
|
|
% $OpenXM: OpenXM/doc/issac2000/openxm-stackmachines.tex,v 1.3 2000/01/03 04:27:52 takayama Exp $ |
% $OpenXM: OpenXM/doc/issac2000/openxm-stackmachines.tex,v 1.10 2000/01/16 06:02:41 takayama Exp $ |
|
|
\section{OpenXM Stack machines} (Tamura) |
\section{OpenXM Stack machines}\label{sec:ox-stackmachines} |
|
|
In OpenXM specification, all servers are stack machines. |
In OpenXM specification, all servers are stack machines. |
These are called OpenXM stack machines. |
%These are called OpenXM stack machines. |
When a server ox\_xyz gets an OX data message, |
When a server ox\_xyz gets an OX data message, |
it translates the data into its own object and push the object |
it translates the data into a local object of ox\_xyz |
on the stack. |
and pushes the object onto the stack. |
The translation scheme together with definitions of |
According to the OpenMath specification, |
mathematical operations |
the translation scheme |
of the system ox\_xyz is called the {\it phrase dictionary} of |
%% together with definitions of mathematical operations |
ox\_xyz following the OpenMath specification. |
%% of the system ox\_xyz |
|
is called the {\it PhraseBook} of ox\_xyz. |
|
For example, the Asir command {\tt ox\_push\_cmo(P,1)} |
|
(push integer $1$ onto the server $P$) |
|
sends an OX data message |
|
{\tt (OX\_DATA,(CMO\_ZZ,1))} to the server $P$. |
|
Here, |
|
{\tt OX\_DATA} stands for {\tt OX\_DATA} header and |
|
{\tt (CMO\_ZZ,1)} is a body standing for $1$ expressed |
|
by the CMO. |
|
The server tranlates {\tt (CMO\_ZZ, 1)} to its internal object of |
|
the integer $1$ |
|
and pushes the object onto the stack. |
|
|
|
If the server gets an {\it OX command} message, then the server |
|
executes the command. |
Any OX command message starts with the int32 tag OX\_COMMAND. |
Any OX command message starts with the int32 tag OX\_COMMAND. |
The body is OX stack machine operation code expressed by int32. |
The body is a stack machine operation code expressed by int32. |
The codes are listed below. |
The codes are listed below \cite{noro-takayama}. |
\begin{verbatim} |
\begin{verbatim} |
#define SM_popSerializedLocalObject 258 |
#define SM_popSerializedLocalObject 258 |
#define SM_popCMO 262 |
#define SM_popCMO 262 |
Line 32 The codes are listed below. |
|
Line 46 The codes are listed below. |
|
#define SM_executeStringByLocalParserInBatchMode 274 |
#define SM_executeStringByLocalParserInBatchMode 274 |
#define SM_getsp 275 |
#define SM_getsp 275 |
#define SM_dupErrors 276 |
#define SM_dupErrors 276 |
#define SM_DUMMY_sendcmo 280 |
|
#define SM_sync_ball 281 |
|
#define SM_control_kill 1024 |
#define SM_control_kill 1024 |
#define SM_control_to_debug_mode 1025 |
#define SM_control_to_debug_mode 1025 |
#define SM_control_exit_debug_mode 1026 |
#define SM_control_exit_debug_mode 1026 |
Line 41 The codes are listed below. |
|
Line 53 The codes are listed below. |
|
\end{verbatim} |
\end{verbatim} |
|
|
OpenXM does not have a standard for mathematical operation sets |
OpenXM does not have a standard for mathematical operation sets |
while it is a work in progress in \cite{gap}. |
while it is a work in progress in the GAP group \cite{gap}. |
Each OpenXM server has its own mathematical operation set. |
Each OpenXM server has its own set of mathematical operations, |
Mathematical operations are performed as follows. |
which are performed as follows. |
Mathematical operator name, such as fctr (asir factorization command), |
First, arguments for a mathematical operation |
is pushed as a string, |
and the number of the arguments are pushed. |
the stack machine command |
Second, |
SM\_executeFunction (269) pops the operator name, the number of arguments |
the mathematical operator name, |
and arguments, and |
such as {\tt fctr} (the factorization command of Asir), |
the OX stack machine evaluates the operator, and pushes the result on the stack. |
is pushed as a string. |
|
Finally, the stack machine command |
|
{\tt SM\_executeFunction} (269) evaluates the operator and |
|
pushes the result onto the stack |
|
after poping the operator name, the number of arguments |
|
and arguments. |
For example, the following code factorizes $x^{100}-1$ by calling |
For example, the following code factorizes $x^{100}-1$ by calling |
ox\_asir from asir. |
{\tt ox\_asir} from Asir. |
\begin{verbatim} |
\begin{verbatim} |
P = ox_launch(); |
P = ox_launch(); |
ox_push_cmo(P,x^100-1); ox_push_cmo(P,ox_int32(1)); |
ox_push_cmo(P,x^100-1); ox_push_cmo(P,ntoint32(1)); |
ox_push_cmd(P,269); |
ox_push_cmd(P,269); |
Ans = ox_pop_cmo(P); |
Ans = ox_pop_cmo(P); |
\end{verbatim} |
\end{verbatim} |
|
|
When an error has occurred on an OpenXM server, |
When an error has occurred on an OpenXM server, |
an error object is pushed to the stack instead of a result of the computation. |
an error object is pushed onto the stack |
|
instead of a result of the computation. |
The error object consists of the serial number of the OX message |
The error object consists of the serial number of the OX message |
which caused the error, and an error message. |
which caused the error, and an error message. |
\begin{verbatim} |
\begin{verbatim} |
[341] ox_rpc(0,"fctr",1.2*x)$ |
[340] P = ox_launch()$ |
[342] ox_pop_cmo(0); |
[341] ox_rpc(P,"fctr",1.2*x)$ |
|
[342] ox_pop_cmo(P); |
error([8,fctr : invalid argument]) |
error([8,fctr : invalid argument]) |
\end{verbatim} |
\end{verbatim} |
|
|
Errors are not sent to the client except a SM\_pop* command is received. |
OpenXM server won't send error messages to the client |
OX stackmachines works in the asynchronous mode which is similar |
except when it receives a {\tt SM\_pop*} command. |
|
OX stackmachines work in the asynchronous mode which is similar |
to X servers. |
to X servers. |
For servers for graphic applications, it is an advantageous feature. |
For servers of graphic and sound applications, |
It is also easy to emulate RPC and a web server for MCP \cite{iamc} |
it may be an advantageous feature. |
|
It is also possible to emulate RPC and a web server for MCP \cite{iamc} |
on our asynchronous OX stackmachines. |
on our asynchronous OX stackmachines. |
|
|
|
|