[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.10

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

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