=================================================================== RCS file: /home/cvs/OpenXM/doc/issac2000/openxm-stackmachines.tex,v retrieving revision 1.6 retrieving revision 1.13 diff -u -p -r1.6 -r1.13 --- OpenXM/doc/issac2000/openxm-stackmachines.tex 2000/01/13 10:54:33 1.6 +++ OpenXM/doc/issac2000/openxm-stackmachines.tex 2000/01/17 08:06:15 1.13 @@ -1,20 +1,34 @@ -% $OpenXM: OpenXM/doc/issac2000/openxm-stackmachines.tex,v 1.5 2000/01/07 10:22:41 ohara Exp $ +% $OpenXM: OpenXM/doc/issac2000/openxm-stackmachines.tex,v 1.12 2000/01/17 01:23:41 takayama Exp $ -\section{OpenXM Stack machines}\label{sec:ox-stackmachines} (Tamura) +\section{OpenXM Stack machines}\label{sec:ox-stackmachines} 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, -it translates the data into an object of its local mathematical system -and push the object on the stack. -The translation scheme together with definitions of -mathematical operations -of the system ox\_xyz is called the {\it PhraseBook} of -ox\_xyz following the OpenMath specification. +it translates the data into a local object of ox\_xyz +and pushes the object onto the stack. +According to the OpenMath specification, +the translation scheme +%% together with definitions of mathematical operations +%% 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 translates {\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. -The body is OpenXM stack machine operation code expressed by int32. -The codes are listed below. +The body is a stack machine operation code expressed by int32. +The codes are listed below \cite{noro-takayama}. \begin{verbatim} #define SM_popSerializedLocalObject 258 #define SM_popCMO 262 @@ -32,8 +46,6 @@ The codes are listed below. #define SM_executeStringByLocalParserInBatchMode 274 #define SM_getsp 275 #define SM_dupErrors 276 -#define SM_DUMMY_sendcmo 280 -#define SM_sync_ball 281 #define SM_control_kill 1024 #define SM_control_to_debug_mode 1025 #define SM_control_exit_debug_mode 1026 @@ -41,40 +53,49 @@ The codes are listed below. \end{verbatim} OpenXM does not have a standard for mathematical operation sets -while it is a work in progress in \cite{gap}. -Each OpenXM server has its own mathematical operation set. -Mathematical operations are performed as follows. -Mathematical operator name, such as fctr (asir factorization command), -is pushed as a string, -the stack machine command -SM\_executeFunction (269) pops the operator name, the number of arguments -and arguments, and -the OX stack machine evaluates the operator, and pushes the result on the stack. +while it is a work in progress in the GAP group \cite{gap}. +Each OpenXM server has its own set of mathematical operations, +which are performed as follows. +First, arguments for a mathematical operation +and the number of the arguments are pushed. +Second, +the mathematical operator name, +such as {\tt fctr} (the factorization command of Asir), +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 -ox\_asir from asir. +{\tt ox\_asir} from Asir. \begin{verbatim} P = ox_launch(); -ox_push_cmo(P,x^100-1); ox_push_cmo(P,ox_int32(1)); -ox_push_cmd(P,269); +ox_push_cmo(P,x^100-1); ox_push_cmo(P,ntoint32(1)); +ox_push_cmo(P,"fctr"); ox_push_cmd(P,269); Ans = ox_pop_cmo(P); \end{verbatim} 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 which caused the error, and an error message. \begin{verbatim} -[341] ox_rpc(0,"fctr",1.2*x)$ -[342] ox_pop_cmo(0); +[340] P = ox_launch()$ +[341] ox_rpc(P,"fctr",1.2*x)$ +[342] ox_pop_cmo(P); error([8,fctr : invalid argument]) \end{verbatim} -Errors are not sent to the client except a SM\_pop* command is received. -OX stackmachines works in the asynchronous mode which is similar +OpenXM server won't send error messages to the client +except when it receives a {\tt SM\_pop*} command. +OX stack machines work in the asynchronous mode which is similar to X servers. -For servers for graphic applications, it is an advantageous feature. -It is also easy to emulate RPC and a web server for MCP \cite{iamc} -on our asynchronous OX stackmachines. +For servers of graphic and sound applications, +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 stack machines.