[BACK]Return to communication-model.tex CVS log [TXT][DIR] Up to [local] / OpenXM / doc / OpenXM-specs

Annotation of OpenXM/doc/OpenXM-specs/communication-model.tex, Revision 1.3

1.3     ! noro        1: %% $OpenXM: OpenXM/doc/OpenXM-specs/communication-model.tex,v 1.2 2000/01/20 09:22:01 noro Exp $
1.1       noro        2: //&jp \section{ Open XM の通信モデル}
                      3: //&eg \section{ Communication model of Open XM}  (This part has not yet been translated)
                      4:
                      5: /*&jp
                      6: われわれは, 数学プロセスがメッセージを
                      7: 交換しながら計算が進行していくというモデルを想定して設計をすすめている.
                      8: 各プロセスはスタックマシンであり, これを OX スタックマシンとよぶ.
                      9: 数学プロセスの間の通信路の確保の仕方としては以下のように
                     10: いろいろな実現方法を想定している.
                     11: \begin{enumerate}
                     12: \item ファイルを介して通信する.
                     13: \item Library として直接リンクして通信する.
                     14: \item TCP/IP ソケットの利用.
                     15: \item Remote Procedure call の利用.
                     16: \item マルチスレッドの利用.
                     17: \item PVM ライブラリの利用.
                     18: \item MPI ライブラリの利用.
                     19: \end{enumerate}
                     20:
                     21: 通信とはプロセス間のメッセージのやりとりである.
                     22: メッセージは論理的に次のような構造をもつ:
                     23: */
                     24: /*&eg
                     25: In our model of comutation, mathematical processes proceed
                     26: a computation by exchanging messages. Each process is a stack machine,
                     27: which is called an OX stack machine.
1.3     ! noro       28: The following methods are possible to realize communications between
1.1       noro       29: mathematical processes.
                     30: \begin{enumerate}
                     31: \item Communication by files.
                     32: \item Linking as a subroutine library.
                     33: \item TCP/IP streams.
                     34: \item Remote Procedure call.
                     35: \item Muitithread.
                     36: \item PVM library.
                     37: \item MPI library.
                     38: \end{enumerate}
                     39:
                     40: In OpenXM Communication is exechange of messages between processes.
                     41: A message has the following structure:
                     42: */
                     43: /*&C
                     44: \begin{center}
                     45: \begin{tabular}{|c|c|c|}
                     46: \cline{1-2}
                     47: {\tt destination} & {\tt origin} &  \multicolumn{1}{}{}  \\ \hline
                     48: {\tt extension}&{\tt ox message\_tag}&{\tt message\_body} \\
                     49: \hline
                     50: \end{tabular}
                     51: \end{center}
                     52: */
                     53: /*&jp
                     54: このメッセージを, OX Message (Open XM message object) とよぶ.
                     55: OX Message はトップレベルのメッセージ object であり,
                     56: 仕様書では, さまざまなグループに属する object が登場する.
                     57: グループ名は, たとえば, OX Message/TCPIP/Basic0 などと書く.
                     58: {\tt message\_body} の部分の仕様は, OX Message
                     59: の上位に位置する部分であり,  SMobject または CMObject がくる.
                     60: これらの object はタグをもち, そのタグ定数は {\tt SM\_} または
                     61: {\tt CMO\_} ではじまる.
                     62: SMobject は, スタックマシンコマンドメッセージ object であり,
                     63: やはり, グループ分けされている.
                     64: 各グループ名は,
                     65: SMobject/Basic0,  SMobject/Basic1 などと書く.
                     66: SMobject の構造は
                     67: サーバスタックマシンの節で詳しく説明する.
                     68: CMObject についてはすでに Basic0 の CMObject の説明をしたが,
                     69: あとで CMObject レベル 1の説明をする.
                     70: OX Message の
                     71: {\tt ox message\_tag} の定数は {\tt OX\_} で始まる.
                     72: */
                     73: /*&eg
                     74: We call it an OX message (OpenXM message object).
                     75: OX Message is the top level message object.
                     76: The OX messages are classified into three types: DATA, COMMAND,
                     77: and SPECIAL. They are distinguished by {\tt ox message\_tag}.
                     78: The name of an ox message tag begins with  {\tt OX\_}.
1.3     ! noro       79: Typical OX message tags are {\tt OX\_COMMAND} followed by
        !            80: SMobject and {\tt OX\_DATA} followed by CMOobject.
1.1       noro       81: Each message object also has its tag. For SMobject, the name
                     82: of a tag begins with {\tt SM\_}. For CMOobject, the name of
                     83: a tag begins with {\tt CMO\_}.
                     84: An SMobject represents a stack machine command and categorized
                     85: into several groups such as SMobject/Basic0, SMobject/Basic1.
                     86: The details of SMobjects will be explained in Section \ref{sec:stackmachine}.
                     87: We have already explained the Basic0 CMOobjects.
                     88: We will describe the Basic1 CMOobjects later.
                     89: */
                     90: //&jp \subsection{  OX Message の 表現方法 }
                     91: //&eg \subsection{  OX Messages }
                     92:
                     93: /*&jp
                     94: Open XM で各プロセスは
                     95: \begin{center}
                     96: (OXexpression を理解するスタックマシン) $+$ (xxx 言語で動くエンジン)
                     97: \end{center}
                     98: なるハイブリッド構成である.
                     99: このプロセスを, OX スタックマシンと呼ぶ.
                    100: ここでは, OX スタックマシンとやりとりするメッセージである,
                    101: OX Message を表現するための OXexpression, および,
                    102: スタックマシンの operator に対応する, SMobject を表現するための SMexpression
                    103: を定義しよう.
                    104: OX Message を スタックマシンコマンド,
                    105: SMobject を スタックマシンオペレータともよぶ.
                    106: */
                    107:
1.2       noro      108: /*&eg
                    109: In Open XM, each process may have a hybrid interface;
                    110: it may accept and execute not only stack machine commands,
                    111: but also its original command sequences.
                    112: We call such a process an OX stack machine.
                    113: Here we introduce OXexpression and SMexpression
                    114: to express OX messages and SM objects respectively.
                    115: */
                    116:
1.1       noro      117: /*&C
                    118: \begin{eqnarray*}
                    119: \mbox{OXexpression}
                    120: &:& \quad
                    121: \mbox{\tt (} \mbox{\tt OX\_tag} \
                    122: [\mbox{ expression}]  \mbox{\tt )}\\
                    123: \mbox{expression}
                    124: &:& \quad  \mbox{SMexpression} \\
                    125: &   &|\   \mbox{CMOexpression} \\
                    126: \mbox{SMexpression}
                    127: &:&  \mbox{\tt (} \mbox{\tt SM\_tag} \
                    128: \{ \mbox{CMOexpression} \} \mbox{\tt )}\\
                    129: \end{eqnarray*}
                    130: */
                    131: /*&jp
                    132: expression の各要素を区切るために {\tt ,} (コンマ) を用いてもよい.
                    133: {\tt OX\_tag} は {\tt OX\_} で始まる定数である.
                    134: {\tt SM\_tag} は {\tt SM\_} で始まるスタックマシンオペレータを識別する定数である.
                    135: 発信元 AAA, 受信先 BBB を書く必要があるときは,
                    136: From AAA, To BBB, を OXexpression の前に書く.
                    137: 必要なければ省略する.
                    138:
                    139: たとえば, あとで説明する, CMO string ``Hello'' を スタックにプッシュする
                    140: 表現は次のように書く:
                    141: */
1.2       noro      142:
                    143: /*&eg
                    144: A comman `{\tt ,}' may be used to separate elements in an expression.
                    145: {\tt OX\_tag} is a constant which denotes an OX message tag.
                    146: {\tt SM\_tag} is a constant which denotes an SM command tag.
                    147: If a sender AAA or a receiver BBB has to be specified,
                    148: 'From AAA' or 'To BBB' is written before the OXexpression.
                    149:
                    150: For example the following expression means a request to
                    151: push a CMO string ``Hello''.
                    152: */
1.1       noro      153: /*&C
                    154: \begin{center}
                    155: (OX\_DATA, (CMO\_STRING, 5, "Hello"))
                    156: \end{center}
                    157: */
                    158:
                    159:
                    160: /*&jp
1.2       noro      161: The following expression means a request to execute
                    162: a local function ``hoge''.
1.1       noro      163: */
                    164:
                    165: /*&C
                    166: \begin{center}
                    167: (OX\_DATA, (CMO\_STRING, 5, "hoge"))
                    168: \end{center}
                    169: \begin{center}
                    170: (OX\_COMMAND, SM\_executeStringByLocalParser)
                    171: \end{center}
                    172: */
                    173:
                    174: /*&jp
1.2       noro      175: In our standard encoding method, each tag is expressed as
                    176: a 32 bit (4 byte) integer with the network byte order.
1.1       noro      177: */
                    178:
                    179: //&jp \subsection{OXexpression の 標準 encoding と TCP/IP ソケットによる実装法}
1.3     ! noro      180: //&eg \subsection{Standard enconding of OXexpressions and an implementation by TCP/IP sockets}
1.1       noro      181: /*&jp
1.2       noro      182: 通信の実現方法は通信路のとりかたによりかわるが,
                    183: 論理構造は統一的にあつかわないといけない.
                    184: OXexpression はその論理構造を記述している.
                    185:
                    186: ここでは OXexpression の標準 encoding の概略を説明する.
                    187: この encoding 法はTCP/IP ソケット用の encoding 法として
                    188: 現在存在しているサーバに使用されている.
                    189: さらにOX スタックマシンの計算状態を制御するための, コントロールメッセージに
                    190: ついても説明する.
                    191:
                    192:
                    193: {\tt destination}, {\tt origin} の部分は, ソケットによる
                    194: peer to peer の接続なので省略する.
                    195: {\tt extension} フィールドは
                    196: {\tt message\_tag} フィールドの次にくる.
                    197: {\tt extension} フィールドは OX パケットのシリアル番号がはいる.
                    198: シリアル番号は {\tt int32} である.
                    199: この番号は, サーバがエラーを起こした場合, エラーをおこした,
                    200: OX パケットの番号を戻すのに主に利用される.
                    201: 以下 {\tt extension} フィールドは, {\tt message\_tag} の
                    202: に含まれると理解し {\tt extension} フィールドは省略する.
                    203: したがってパケットは
                    204: 次のように記述する
                    205: */
                    206:
                    207: /*&eg
                    208: The logical structure of OX messages are independent of implementations
1.3     ! noro      209: of communication. The OXexpression represents the logical structure.
        !           210: Here we explain an outline of the standard encoding scheme of OXexpression.
        !           211: This encoding scheme is used to implement OpenXM protocols on TCP/IP sockets.
        !           212: In addition, we also explain the control messages to control stack machines.
        !           213:
        !           214: As the socket connection is peer to peer, {\tt destination} and {\tt origin}
        !           215: are omitted.
        !           216: The {\tt extension} field is placed after the {\tt message\_tag} field.
        !           217: The {\tt extension} field consists of the serial number for OX message,
        !           218: which is {\tt int32}.
        !           219: The serial number is used to identify an OX message which caused
        !           220: an error on a server.
        !           221: In the following we regard the {\tt extension} as a component of
        !           222: the {\tt message\_tag} field and omit the {\tt extension} field.
        !           223: Thus OX messages are represented as follows.
1.1       noro      224: */
                    225: /*&C
                    226: \begin{center}
                    227: \begin{tabular}{|c|c|}
                    228: \hline
                    229: {\tt ox message\_tag}&{\tt message\_body} \\
                    230: \hline
                    231: \end{tabular}
                    232: \end{center}
                    233: */
                    234: //&jp が, もっとこまかく見ると,
1.3     ! noro      235: //&eg More precisely it has the following representation.
1.1       noro      236: /*&C
                    237: \begin{center}
                    238: \begin{tabular}{|c|c|}
                    239: \hline
                    240: {\tt ox message\_tag}, \ {\tt packet number}&{\tt message\_body} \\
                    241: \hline
                    242: \end{tabular}
                    243: \end{center}
                    244: */
                    245: /*&jp
                    246: となっている.
                    247:
                    248: グループ OX Message/TCPIP/Basic0 の
                    249: {\tt ox message\_tag} としては次のものが用意されている.
                    250: */
1.3     ! noro      251: //&eg As {\tt ox message\_tag} the following are provided.
1.1       noro      252:
                    253: /*&C
                    254: @plugin/oxMessageTag.h
                    255: \begin{verbatim}
                    256: #define   OX_COMMAND         513
                    257: #define   OX_DATA            514
                    258:
                    259: #define   OX_DATA_WITH_LENGTH  521
                    260: #define   OX_DATA_OPENMATH_XML 523
                    261: #define   OX_DATA_OPENMATH_BINARY 524
                    262: #define   OX_DATA_MP           525
                    263:
                    264: #define   OX_SYNC_BALL       515
                    265: \end{verbatim}
                    266: */
                    267:
                    268: /*&jp
                    269: 通信路は 2 つ用意する.
                    270: 1番目の通信路は
                    271: \verb+  OX_COMMAND +
                    272: および
                    273: \verb+   OX_DATA +
                    274: がながれる.
                    275: 2番目の通信路 ({\tt control}と呼ぶ) には,
                    276: \verb+  OX_COMMAND + およびそれに続くコントロールコマンド
                    277: \verb+  SM_control_* +
                    278: またはコントロール関係のデータ, つまり header
                    279: \verb+   OX_DATA + ではじまりそれに続く CMO データ
                    280: がながれる.
                    281: これらをコントロールメッセージおよびコントロールメッセージの結果
                    282: メッセージと呼ぶ.
                    283: サンプルサーバでは, この 2 つの通信路を, 2 つのポートを用いて
                    284: 実現している.
                    285:
                    286:
1.3     ! noro      287: \verb+ OX_COMMAND + メッセージは次の形のパケットで表現される: \\
        !           288: */
        !           289: /*&eg
        !           290: Two streams are used for communication between a client and a server.
        !           291: One is the stream to exchange data and to send stack machine commands.
        !           292: The other is the stream to control stack machines.
        !           293: Messages on the latter stream are called control messages and
        !           294: results of control messages. The sample server implements
        !           295: the above two streams by using two ports on TCP/IP.
        !           296:
        !           297: The stack machine command message has the following forms: \\
1.1       noro      298: */
                    299: /*&C
                    300: \begin{tabular}{|c|c|}
                    301: \hline
                    302: {\tt OX\_COMMAND} & {\tt int32 function\_id} \\  \hline
                    303: {\it message\_tag} & {\it message\_body}
                    304: \\ \hline
                    305: \end{tabular}, \quad
                    306: ({\tt OX\_COMMAND}, ({\tt SM\_*}))
                    307: \\
                    308: */
                    309:
1.3     ! noro      310: //&jp \verb+ OX_DATA + メッセージは次の形のパケットで表現される: \\
        !           311: //&eg CMO data message has the following form:\\
1.1       noro      312: /*&C
                    313: \begin{tabular}{|c|c|}
                    314: \hline
                    315: {\tt OX\_DATA} &  {\tt CMO data} \\  \hline
                    316: {\it message\_tag} & {\it message\_body}\\ \hline
                    317: \end{tabular}, \quad
                    318: ({\tt OX\_DATA}, {\sl CMObject} data)
                    319: \\
                    320: */
1.3     ! noro      321: //&jp コントロールメッセージは次の形のパケットで表現される: \\
        !           322: //&eg The control message has the following form:\\
1.1       noro      323: /*&C
                    324: \begin{tabular}{|c|c|}
                    325: \hline
                    326: {\tt OX\_COMMAND} & {\tt int32 function\_id}  \\  \hline
                    327: \end{tabular},  \quad
                    328: ({\tt OX\_COMMAND},({\tt SM\_control\_*}))
                    329: \\
                    330: */
                    331: /*&jp
                    332: コントロールメッセージは, 計算を中断したい, debug 用の スレッドを起動する,
                    333: debug モードを抜けたい, などの用途に利用する.
1.3     ! noro      334: */
        !           335: /*&eg
        !           336: The control message is used to interrupt a computation, to invoke
        !           337: debugging threads, or to exit form the debugging mode.
        !           338: */
1.1       noro      339:
1.3     ! noro      340: //&jp コントロールメッセージの結果メッセージは次の形のパケットで表現される: \\
        !           341: //&eg The result of a cotrol message has the following form:\\
1.1       noro      342: /*&C
                    343: \begin{tabular}{|c|c|l|}
                    344: \hline
                    345: {\tt OX\_DATA} & {\tt CMO\_INT32} & {\tt int32 data} \\  \hline
                    346: \end{tabular}, \quad
                    347: ({\tt OX\_DATA}, {\sl Integer32 } n)
                    348: \\
                    349: */
                    350:
                    351:
                    352: /*&jp
                    353: {\tt int32 function\_id}
                    354: の部分に, サーバスタックマシン の operator に対応する番号がはいる.
                    355: グループ SMobject/Basic0 および SMobject/Basic1 に属する
                    356: タグとして以下のものがある.
                    357: */
1.3     ! noro      358: /*&eg
        !           359: {\tt int32 function\_id} is the value of a stack machine command.
        !           360: SM tags in SMobject/Basic0 and SMobject/Basic1 and corresponding
        !           361: values are as follows.
        !           362: */
1.1       noro      363: /*&C
                    364: @plugin/oxFunctionId.h
                    365: \begin{verbatim}
                    366: #define SM_popSerializedLocalObject 258
                    367: #define SM_popCMO 262
                    368: #define SM_popString 263
                    369:
                    370: #define SM_mathcap 264
                    371: #define SM_pops 265
                    372: #define SM_setName 266
                    373: #define SM_evalName 267
                    374: #define SM_executeStringByLocalParser 268
                    375: #define SM_executeFunction 269
                    376: #define SM_beginBlock  270
                    377: #define SM_endBlock    271
                    378: #define SM_shutdown    272
                    379: #define SM_setMathCap  273
                    380: #define SM_executeStringByLocalParserInBatchMode 274
                    381: #define SM_getsp       275
                    382: #define SM_dupErrors   276
                    383:
                    384:
                    385: #define SM_control_kill 1024
                    386: #define SM_control_reset_connection  1030
                    387: \end{verbatim}
                    388: */
                    389:
                    390: //&jp たとえば,
1.3     ! noro      391: //&eg For example
1.1       noro      392: /*C
                    393: \begin{center}
                    394: (OX\_COMMAND, SM\_pops)
                    395: \end{center}
                    396: */
                    397: //&jp は
1.3     ! noro      398: //&eg is encoded as follows.
        !           399: /*&C
1.1       noro      400: \begin{center}
                    401: \begin{tabular}{|c|c|}
                    402: \hline
                    403: {\tt int32} 513  &  {\tt int32} 265 \\
                    404: \hline
                    405: \end{tabular}
                    406: \end{center}
                    407: */
1.3     ! noro      408: //&jp とエンコードされる.
        !           409:
1.1       noro      410: /*&jp
                    411: operator の詳細は次の節で説明する.
                    412: これらの定数の名前はインプリメントのとき短縮形で表現してもよい.
1.3     ! noro      413: */
        !           414: /*&eg
        !           415: The details of the operators are described in Section \ref{sec:stackmanine}.
        !           416: Names of these constants may be represented by abbrebiated forms.
1.1       noro      417: */
                    418:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>