@comment $OpenXM: OpenXM/src/asir-doc/parts/process.texi,v 1.13 2003/04/19 15:44:56 noro Exp $ \BJP @node 分散計算,,, Top @chapter 分散計算 \E \BEG @node Distributed computation,,, Top @chapter Distributed computation \E @menu * OpenXM:: * Mathcap:: \BJP * スタックマシンコマンド:: * デバッグ:: * 分散計算に関する関数:: \E \BEG * Stackmachine commands:: * Debugging:: * Functions for distributed computation:: \E @end menu \JP @node OpenXM,,, 分散計算 \EG @node OpenXM,,, Distributed computation @section OpenXM \BJP @b{Asir} は, 分散計算における通信プロトコルとして, @b{OpenXM} (Open message eXchange for Mathematics) プロトコルを採用している. @b{OpenXM} プロジェクトについては, @ifhtml @end ifhtml @code{http://www.math.sci.kobe-u.ac.jp/OpenXM/} @ifhtml @end ifhtml を参照してほしい. @b{OpenXM} プロトコルは, 主として数学オブジェクトをプロセス間でやりとりする ための規約である. @b{OpenXM} においては \E \BEG On @b{Asir} distributed computations are done under @b{OpenXM} (Open message eXchange protocol for Mathematics), which is a protocol for exchanging mainly mathematical objects between processes. See @ifhtml @end ifhtml @code{http://www.math.sci.kobe-u.ac.jp/OpenXM/} @ifhtml @end ifhtml for the details of @b{OpenXM}. In @b{OpenXM} a distributed computation is done as follows: \E @enumerate \BJP @item client が server に対して計算実行依頼のメッセージを送る. @item server が計算を実行する. @item client が server に結果送付依頼のメッセージを送る. @item server は結果を返し, client は結果を受け取る \E \BEG @item A client requests something to a server. @item The server does works according to the request. @item The client requests to send data to the server. @item The server sends the data to the client and the client gets the data. \E @end enumerate \BJP という形で分散計算が行われる. server はスタックマシンである. すなわち, client から送られたデータオブジェクトは, 指定がない限り server のスタッ クに積まれ, コマンドが送られた時に, 必要なだけスタックからデータを取り出 して, 関数呼び出しの引数とする. \E \BEG The server is a stack machine. That is data objects sent by the client are pushed to the stack of the server. If the server gets a command, then the data are popped form the stack and they are used as arguments of a function call. \E \BJP @b{OpenXM} において特徴的なことは, 計算結果は単に server のスタックに 積まれるだけで, client からの依頼がない限り, 通信路にデータは流れない という点である. \E \BEG In @b{OpenXM}, the result of a computation done in the server is simply pushed to the stack and the data is not written to the communication stream without requests from the client. \E \BJP プロトコルには, オブジェクトの共通フォーマットを規定 する @b{CMO} (Common Mathematical Object format), プロセスに対する 動作を指定する @b{SM} (Stack Machine command) が含まれる. これらは, データを送る際に, データの種類を指定する ための @b{OX} expression としてラッピングされる. @b{OpenXM} による分散計算を行う場合には, まず, server を立ち上げて, 通信を成立させる必要がある. このために, @code{ox_launch()}, @code{ox_launch_nox()}, @code{ox_launch_generic()} などの関数が用意されている. さらに, 通信の成立した server に対して 以下のような操作が関数として用意されている. \E \BEG @b{OpenXM} protocol consists of two components: @b{CMO} (Common Mathematical Object format) which determines a common format of data representations and @b{SM} (StackMachine command) which specifies actions on servers. These are wrapped as @b{OX} expressions to indicate the sort of data when they are sent. To execute a distributed computation by @b{OpenXM}, one has to invoke @b{OpenXM} servers and to establish communications between the client and the servers. @code{ox_launch()}, @code{ox_launch_nox()}, @code{ox_launch_generic()} are preprared for such purposes. Furthermore the following functions are available. \E @table @code @item @code{ox_push_cmo()} \JP データを server のスタックに積む \EG It requests a server to push an object to the stack of a server. @item @code{ox_pop_cmo()} \JP データを server のスタックから取り出す. \EG It request a server to pop an object from the stack of a server. @item @code{ox_cmo_rpc()} \JP server の関数を呼び出し, 結果をスタックに積む. \BEG It requests to execute a function on a server. The result is pushed to the stack of the server. \E @item @code{ox_execute_string()} \BJP server 固有のユーザ言語 (@b{Asir} なら Asir 言語) で書かれた文字列を server が実行し, 結果をスタックに積む. \E \BEG It requests a server to parse and execute a string by the parser and the evaluater of the server. The result is pushed to the stack of the server. \E @item @code{ox_push_cmd()} \JP @b{SM} コマンドの送信. \EG It requests a server to execute a command. @item @code{ox_get()} \JP 既に通信路にあるデータの取り出し. \EG It gets an object from a data stream. @end table \JP @node Mathcap,,, 分散計算 \EG @node Mathcap,,, Distributed computation @section Mathcap \BJP server, client ともに, @b{OpenXM} で規定されている全ての@b{CMO} フォー マット, @b{SM} コマンドを実装しているとは限らない. 相手の知らないデータ, コマンドを送った場合, 現状では結果は予想できない. このため, @b{OpenXM} では, あらかじめ互いのサポートする @b{CMO}, @b{SM} のリストを交換しあって, 相手の知らないデータを送らないようにする仕組みを提唱している. このための データが Mathcap である. Mathcap は @b{CMO} としてはリストであり, その 要素は 32 bit 整数または文字列である. 現在の規定では, Mathcap は 長さが 3 のリストで, [[version 番号, server 名],@b{SM}taglist,[[@b{OX}tag,@b{CMO}taglist], [@b{OX}tag,@b{CMO}taglist],...]] という形をしている. [@b{OX}tag,@b{CMO}taglist] は, @b{OX}tag で示されるカテゴリのデータに対して, どのような @b{CMO} が使用可 能かを示すものである. この指定を複数許すことにより, 例えば @samp{ox_asir} のように, @b{CMO} データ以外に, @b{Asir} 固有のデータ形式 により, @b{CMO}より多くの種類のデータ送受信を行えることを示せる. データ送信の際に, 相手プロセスの Mathcap が既に登録されている場合, Mathcap によるチェックを行うか否かは, @code{ctrl} コマンドの @code{"ox_check"} スイッチにより決まる. このスイッチの初期値は 1 で, チェックを行うことを意味する. @code{ctrl("ox_check",0)} によりチェックを行わないようにできる. \E \BEG A server or a client does not necessarily implement full specifications of @b{OpenXM}. If a program sends data unknown to its peer, an unrecoverable error may occur. To avoid such a case @b{OpenXM} provides a scheme not to send data unknown to peers. It is realized by exchanging the list of supported @b{CMO} and @b{SM}. The list is called mathcap. Mathcap is also defined as a @b{CMO} and the elements are 32bit integers or strings. The format of mathcap is as follows. [[version number, server name],@b{SM}taglist, [[@b{OX}tag,@b{CMO}taglist],[@b{OX}tag,@b{CMO}taglist],...]] [@b{OX}tag,@b{CMO}taglist] indicates that available object tags for a category of data specified by @b{OX}tag. For example @samp{ox_asir} accepts the local object format used by @b{Asir} and the mathcap from @samp{ox_asir} reflects the fact. If @code{"ox_check"} switch of @code{ctrl} is set to 1, the check by a mathcap is done before data is sent. If @code{"ox_check"} switch of @code{ctrl} is set to 0, the check is not done. By default it is set to 1. \E \BJP @node スタックマシンコマンド,,, 分散計算 @section スタックマシンコマンド \E \BEG @node Stackmachine commands,,, Distributed computation @section Stackmachine commands \E \BJP スタックマシンコマンドは, スタックマシンである server に何らかの操作を行 わせるために用意されている. いくつかのコマンドは, よく用いられる形で, 他 のコマンド, データとともに, @b{Asir} の組み込み関数により送られるが, ユー ザが明示的にあるコマンドを送る必要がしばしば生ずる. スタックマシンコマン ドは 32 bit 以下の整数であり, @code{ox_push_cmd()} コマンドで送信できる. 以下で, 代表的なスタックマシンコマンドについて解説する. @b{SM_xxx=yyy} で, @b{SM_xxx} が mnemonic, @b{yyy} が値である. 以下で, スタックからデータを取り出すとは, スタックの一番上からデータを 取り除くことを言う. \E \BEG The stackmachine commands are provided to request a server to execute various operations. They are automatically sent by built-in functions of @b{Asir}, but one often has to send them manually. They are represented by 32bit integers. One can send them by calling @code{ox_push_cmd()}. Typical stackmachine commands are as follows. @b{SM_xxx=yyy} means that @b{SM_xxx} is a mnemonic and that @b{yyy} is its value. \E @table @b @item SM_popSerializedLocalObject=258 \BJP server が @samp{ox_asir} の場合に, 必ずしも @b{CMO} で定義されていない オブジェクトをスタックから取り出し, 通信路に流す. \E \BEG An object not necessarily defined as @b{CMO} is popped from the stack and is sent to the client. This is available only on @samp{ox_asir}. \E @item SM_popCMO=262 \JP @b{CMO} オブジェクトをスタックから取り出し, 通信路に流す. \EG A @b{CMO} object is popped from the stack and is sent to the client. @item SM_popString=263 \JP スタックからデータを取り出し, 可読形式の文字列に変換して通信路に流す. \EG An object is popped from the stack and is sent to the client as a readable string. @item SM_mathcap=264 \JP server の mathcap をスタックに積む. \EG The server's mathcap is pushed to the stack. @item SM_pops=265 \BJP スタックから取り出したデータを個数として, その個数分スタックから データを取り除く. \E \BEG Objects are removed from the stack. The number of object to be removed is specified by the object at the top of the stack. \E @item SM_setName=266 \BJP スタックからデータを変数名として取り出し, 次に取り出したデータをその 変数に割り当てる. この割り当ては, server 固有の処理として行われる. \E \BEG A variable name is popped form the stack. Then an object is popped and it is assigned to the variable. This assignment is done by the local language of the server. \E @item SM_evalName=267 \JP スタックから取り出したデータを変数名として, その値をスタックに載せる. \BEG A variable name is popped from the stack. Then the value of the variable is pushed to the stack. \E @item SM_executeStringByLocalParser=268 \BJP スタックから取り出したデータを, server 固有の parser, evaluator で 処理し, 結果をスタックに載せる. \E \BEG A string popped from the stack is parsed and evaluated. The result is pushed to the stack. \E @item SM_executeFunction=269 \BJP スタックから, 関数名, 引数の個数, 個数分の引数を取り出し, 関数を呼び出し 結果をスタックに載せる. \E \BEG A function name, the number of arguments and the arguments are popped from the stack. Then the function is executed and the result is pushed to the stack. \E @item SM_beginBlock=270 \JP データブロックのはじまり. \EG It indicates the beginning of a block. @item SM_endBlock=271 \JP データブロックの終り. \EG It indicates the end of a block. @item SM_shutdown=272 \JP server との交信を切断し, server を終了させる. \EG It shuts down communications and terminates servers. @item SM_setMathcap=273 \JP スタックのデータを client の mathcap として, server に登録を要求する. \BEG It requests a server to register the data at the top of the stack as the client's mathcap. \E @item SM_getsp=275 \JP 現在スタックに積まれているデータの数をスタックに載せる. \EG The number of objects in the current stack is pushed to the stack. @item SM_dupErrors=276 \BJP 現在スタックに積まれているオブジェクトの内, エラーオブジェクトのみ をリストにして, スタックに載せる. \E \BEG The list of all the error objects in the current stack is pushed to the stack. \E @item SM_nop=300 \JP なにもしない. \EG Nothing is done. @end table \BJP @node デバッグ,,, 分散計算 @section デバッグ \E \BEG @node Debugging,,, Distributed computation @section Debugging \E \BJP 分散計算においては, 一般にデバッグが困難となる. @samp{ox_asir} に おいては, デバッグのためのいくつかの機能を提供している. \E \BEG In general, it is difficult to debug distributed computations. @samp{ox_asir} provides several functions for debugging. \E @menu \BJP * エラーオブジェクト:: * リセット:: * デバッグ用ポップアップウィンドウ:: \E \BEG * Error object:: * Resetting a server:: * Pop-up command window for debugging:: \E @end menu \BJP @node エラーオブジェクト,,, デバッグ @subsection エラーオブジェクト \E \BEG @node Error object,,, Debugging @subsection Error object \E \BJP @b{OpenXM} server が実行中にエラーを起こした場合, 結果のかわりに @b{CMO} エラーオブジェクトをスタックに積む. エラーオブジェクトは, 対応する @b{SM} コマンドのシリアル番号と, エラーメッセージからなり, それによって どの @b{SM} コマンドがどのようなエラーを起こしたがある程度判明する. \E \BEG When an error has occurred on an @b{OpenXM} server, an error object is pushed to the stack instead of a result of the computation. The error object consists of the serial number of the @b{SM} command which caused the error, and an error message. \E @example [340] ox_launch(); 0 [341] ox_rpc(0,"fctr",1.2*x); 0 [342] ox_pop_cmo(0); error([8,fctrp : invalid argument]) @end example \BJP @node リセット,,, デバッグ @subsection リセット \E \BEG @node Resetting a server,,, Debugging @subsection Resetting a server \E \BJP @code{ox_reset()} は現在実行中の server をリセットして, コマンド受け付け 状態に戻す. この機能は, 通常の @b{Asir} セッションにおけるキーボード割り込み とほぼ同様に, @b{OpenXM} server をリセットできる. また, 何らかの原因で, 通信路のデータが載ったままの状態で @code{ox_rpc()} などを実行すると, @code{ox_pop_cmo()} など, スタックからの取り出しと, 実際に読まれるデータ の対応が不正になる. そのような場合にも有効である. \E \BEG @code{ox_reset()} resets a process whose identifier is @var{number}. After its execution the process is ready for receiving data. This function corresponds to the keyboard interrupt on an usual @b{Asir} session. It often happens that a request of a client does not correspond correctly to the result from a server. It is caused by remaining data on data streams. @code{ox_reset} is effective for such cases. \E \BJP @node デバッグ用ポップアップウィンドウ,,, デバッグ @subsection デバッグ用ポップアップウィンドウ \E \BEG @node Pop-up command window for debugging,,, Debugging @subsection Pop-up command window for debugging \E \BJP server には, client におけるキーボードに相当する入力機能がないため, server 側で動作しているユーザ言語プログラムのデバッグが困難になる. この ため, server 側でのユーザ言語プログラム実行中のエラーおよび, client から の @code{ox_rpc(@var{id},"debug")} 実行により, server にデバッグコマンド を入力するための小さなウィンドウがポップアップする. このウィンドウからの 入力に対する出力は, log 用の @samp{xterm} に表示される. このウィンドウを 閉じるには, @code{quit} を入力すればよい. \E \BEG As a server does not have any standard input device such as a keyboard, it is difficult to debug user programs running on the server. @samp{ox_asir} pops up a small command window to input debug commands when an error has occurred during user a program execution or @code{ox_rpc(@var{id},"debug")} has been executed. The responses to commands are shown in @samp{xterm} to display standard outputs from the server. To close the small window, input @code{quit}. \E \BJP @node 分散計算に関する関数,,, 分散計算 @section 分散計算に関する関数 \E \BEG @node Functions for distributed computation,,, Distributed computation @section Functions for distributed computation \E @menu * ox_launch ox_launch_nox ox_shutdown:: * ox_launch_generic:: * ox_asir:: * ox_rpc ox_cmo_rpc ox_execute_string:: * ox_push_cmo ox_push_local:: * ox_pop_cmo ox_pop_local:: * ox_push_cmd ox_sync:: * ox_get:: * ox_pops:: * ox_reset ox_intr register_handler:: * ox_select:: * ox_flush:: * ox_get_serverinfo:: * generate_port try_bind_listen try_connect try_accept register_server:: * ifplot conplot plot polarplot plotover:: * open_canvas clear_canvas draw_obj draw_string:: @end menu \JP @node ox_launch ox_launch_nox ox_shutdown,,, 分散計算に関する関数 \EG @node ox_launch ox_launch_nox ox_shutdown,,, Functions for distributed computation @subsection @code{ox_launch}, @code{ox_launch_nox}, @code{ox_shutdown} @findex ox_launch @findex ox_launch_nox @findex ox_shutdown @table @t @item ox_launch([@var{host}[,@var{dir}],@var{command}]) @itemx ox_launch_nox([@var{host}[,@var{dir}],@var{command}]) \JP :: 遠隔プロセスの起動および通信を開始する. \EG :: Initialize OpenXM servers. @item ox_shutdown(@var{id}) \JP :: 遠隔プロセスを終了させ, 通信を終了する. \EG :: Terminates OpenXM servers. @end table @table @var @item return \JP 整数 \EG integer @item host \JP 文字列または 0 \EG string or 0 @item dir command \JP 文字列 \EG string @item id \JP 整数 \EG integer @end table @itemize @bullet \BJP @item @code{ox_launch()} は, ホスト @var{host} 上でコマンド @var{command} を起動し, このプロセスと通信を開始する. 引数が 3 つの場合, @var{host} 上で, @var{dir} にある @samp{ox_launch} というサーバ起動用プログラムを立ち上げる. @samp{ox_launch} は @var{command} を起動する. @var{host} が 0 の時, @b{Asir} が動作している マシン上でコマンドを起動する. 無引数の場合, @var{host} は 0, @var{dir} は @code{get_rootdir()} で返されるディレクトリ, @var{command} は同じディレクトリの @samp{ox_asir} を意味する. @item @var{host} が 0, すなわちサーバを local に起動する場合には, @var{dir} を省略できる. この場合, @var{dir} は @code{get_rootdir()} で返される ディレクトリとなる. @item @var{command} が @samp{/} で始まる文字列の場合, 絶対パスと解釈される. それ以外の場合, @var{dir} からの相対パスと解釈される. @item UNIX 版においては, @code{ox_launch()} は, @var{command} の標準出力, 標準 エラー出力を表示するための @samp{xterm} を起動する. @code{ox_launch_nox()} は, @code{X} なしの環境の場合, あるいは @samp{xterm} を起動せずにサーバを立ち上げる場合に用いる. この場合, @var{command} の出力は @samp{/dev/null} に接続される. @code{ox_launch()} の場合でも, 環境変数 @code{DISPLAY} が設定されていない 場合には, @code{ox_launch_nox()} と同じ動作をする. @item 返される整数は通信のための識別子となる. @item @b{Asir} と通信するプロセスは同一のマシン上で動作している必要はない. ま た, 通信におけるバイトオーダは server, client 間での最初の negotiation で決まるため, 相手先のマシンとバイトオーダが異なっていても構わない. @item @var{host} にマシン名を指定する場合, 以下の準備が必要である. ここで, @b{Asir} の動いているホストを @code{A}, 通信相手のプロセス が起動されるホストを @code{B} とする. @enumerate @item ホスト @code{B} の @samp{~/.rhosts} に, ホスト @code{A} のホスト 名を登録する. @item @samp{ox_plot} など, @code{X} とのコネクションも用いられる場合, @code{Xserver} に対し, 必要なホストを authorize させる. @code{xhost} で必要なホスト名を追加すればよい. @item @var{command} によっては, スタックを大量に使用する ものもあるため, @samp{.cshrc} でスタックサイズを大きめ (16MB 程度) に 指定しておくのが安全である. スタックサイズは @code{limit stacksize 16m} などと指定する. @end enumerate @item @var{command} が, X 上にウインドウを開ける場合, @var{display}が指定されればその文字列を, 省略時には環境変数 @code{DISPLAY} の値を用いる. @item 環境変数 @code{ASIR_RSH} がセットされている場合, サーバの立ち上げプログラム として@samp{rsh} の代わりにこの変数の値が用いられる. 例えば, @example % setenv ASIR_RSH "ssh -f -X -A " @end example により, サーバの立ち上げに @samp{ssh} が用いられ, X11 の通信が forwarding される. 詳しくは @samp{ssh} のマニュアルを 参照. @item @code{ox_shutdown()} は識別子 @var{id} に対応する遠隔プロセス を終了させる. @item @b{Asir} が正常した場合には全ての入出力ストリームは自動的に閉じられ, 起動されているプロセスは全て終了するが, 異常終了した場合, 遠隔プロセス が終了しない場合もある. @b{Asir} が異常終了した場合, 遠隔プロセスを 起動したマシン上で @code{ps} などを起動して, もし @b{Asir} から起動 したプロセスが残っている場合, @code{kill} する必要がある. @item log 表示用 @samp{xterm} は @samp{-name ox_term} オプションで起動される. よって, @samp{ox_term} なるリソース名に対して @samp{xterm} のリソース設定 を行えば, log 用 @samp{xterm} の挙動のみを変えることができる. 例えば, @example ox_xterm*iconic:on ox_xterm*scrollBar:on ox_xterm*saveLines:1000 @end example により, icon で起動, scrollbar つき, scrollbar で参照できる行数 が最大 1000 行, という指定ができる. \E \BEG @item Function @code{ox_launch()} invokes a process to execute @var{command} on a host @var{host} and enables @b{Asir} to communicate with that process. If the number of arguments is 3, @samp{ox_launch} in @var{dir} is invoked on @var{host}. Then @samp{ox_launch} invokes @var{command}. If @var{host} is equal to 0, all the commands are invoked on the same machine as the @b{Asir} is running. If no arguments are specified, @var{host}, @var{dir} and @var{command} are regarded as 0, the value of @code{get_rootdir()} and @samp{ox_asir} in the same directory respectively. @item If @var{host} is equal to 0, then @var{dir} can be omitted. In such a case @var{dir} is regarded as the value of @code{get_rootdir()}. @item If @var{command} begins with @samp{/}, it is regarded as an absolute pathname. Otherwise it is regarded as a relative pathname from @var{dir}. @item On UNIX, @code{ox_launch()} invokes @samp{xterm} to display standard outputs from @var{command}. If @code{X11} is not available or one wants to invoke servers without @samp{xterm}, use @code{ox_launch_nox()}, where the outputs of @var{command} are redirected to @samp{/dev/null}. If the environment variable @code{DISPLAY} is not set, @code{ox_launch()} and @code{ox_launch_nox()} behave identically. @item The returned value is used as the identifier for communication. @item The peers communicating with @b{Asir} are not necessarily processes running on the same machine. The communication will be successful even if the byte order is different from those of the peer processes, because the byte order for the communication is determined by a negotiation between a client and a server. @item The following preparations are necessary. Here, Let @code{A} be the host on which @b{Asir} is running, and @code{B} the host on which the peer process will run. @enumerate @item Register the hostname of the host @code{A} to the @samp{~/.rhosts} of the host @code{B}. That is, you should be allowed to access the host @code{B} from @code{A} without supplying a password. @item For cases where connection to @code{X} is also used, let @code{Xserver} authorize the relevant hosts. Adding the hosts can be done by command @code{xhost}. @item If an environment variable @code{ASIR_RSH} is set, the content of this variable is used as a promgram to invoke remote servers instead of @var{rsh}. For example, @example % setenv ASIR_RSH "ssh -f -X -A " @end example implies that remote servers are invoked by @samp{ssh} and that X11 forwarding is enabled. See the manual of @samp{ssh} for the detail. @item Some @var{command}'s consume much stack space. You are recommended to set the stack size to about 16MB large in @samp{.cshrc} for safe. To specify the size, put @code{limit stacksize 16m} for an example. @end enumerate @item When @var{command} opens a window on @code{X}, it uses the string specified for @var{display}; if the specification is omitted, it uses the value set for the environment variable @code{DISPLAY}. @item @code{ox_shutdown()} terminates OpenXM servers whose identifier is @var{id}. @item When @b{Asir} is terminated successfully, all I/O streams are automatically closed, and all the processes invoked are also terminated. However, some remote processes may not terminated when @b{Asir} is terminated abnormally. If ever @b{Asir} is terminated abnormally, you have to kill all the unterminated process invoked by @b{Asir} on every remote host. Check by @code{ps} command on the remote hosts to see if such processed are alive. @item @samp{xterm} for displaying the outputs from @var{command} is invoked with @samp{-name ox_term} option. Thus, by specifying resources for the resource name @samp{ox_term}, only the behaviour of the @samp{xterm} can be customized. @example /* iconify on start */ ox_xterm*iconic:on /* activate the scroll bar */ ox_xterm*scrollBar:on /* 1000 lines can be shown by the scrollbar */ ox_xterm*saveLines:1000 @end example \E @end itemize @example [219] ox_launch(); 0 [220] ox_rpc(0,"fctr",x^10-y^10); 0 [221] ox_pop_local(0); [[1,1],[x^4+y*x^3+y^2*x^2+y^3*x+y^4,1], [x^4-y*x^3+y^2*x^2-y^3*x+y^4,1],[x-y,1],[x+y,1]] [222] ox_shutdown(0); 0 @end example @table @t \JP @item 参照 \EG @item References @fref{ox_rpc ox_cmo_rpc ox_execute_string}, @fref{ox_pop_cmo ox_pop_local}, @fref{ifplot conplot plot polarplot plotover} @end table \JP @node ox_launch_generic,,, 分散計算に関する関数 \EG @node ox_launch_generic,,, Functions for distributed computation @subsection @code{ox_launch_generic} @findex ox_launch_generic @table @t @item ox_launch_generic(@var{host},@var{launch},@var{server},@var{use_unix},@var{use_ssh},@var{use_x},@var{conn_to_serv}) \JP :: 遠隔プロセスの起動および通信を開始する. \EG :: Initialize OpenXM servers. @end table @table @var @item return \JP 整数 \EG integer @item host \JP 文字列または 0 \EG string or 0 @item launcher server \JP 文字列 \EG string @item use_unix use_ssh use_x conn_to_serv \JP 整数 \EG integer @end table @itemize @bullet \BJP @item @code{ox_launch_generic()} は, ホスト @var{host} 上で, コントロールプロセス @var{launch} および サーバプロセス @var{server} を起動する. その他の引数は, 使用する protocol の種類, X の使用/不使用, rsh/ssh によるプロセス起動, connect 方法の指定などを行うスイッチである. @item @var{host} が 0 の場合, @b{Asir} が動作しているマシン上に, @var{launch}, @var{server} を立ち上げる. この場合, @var{use_unix} の値にかかわらず, UNIX internal protocol が用いられる. @item @var{use_unix} が 1 の場合, UNIX internal protocol を用いる. 0 の場合, Internet protocol を用いる. @item @var{use_ssh} が 1 の場合, @samp{ssh} (Secure Shell) によりコントロール, サーバプロセスを立ち上げる. @samp{ssh-agent} などを利用していな場合, パスワードの入力が必要となる. 相手先で @samp{sshd} が動いていない場合, 自動的に @samp{rsh} が用いられるが, パスワードが必要となる場合には, その場で起動に失敗する. @item @var{use_x} が 1 の場合, X 上での動作を仮定し, 設定されている DISPLAY変 数を用いて, log 表示用 @samp{xterm} のもとで @var{server} が起動され る. DISPLAY 変数がセットされていない場合には, 自動的に X なしの設定とな る. DISPLAY が不適切にセットされている場合には, コントロール, サーバがハ ングするので要注意である. @item @var{conn_to_serv} が 1 の場合, @b{Asir} (client) が生成したポートに 対し, client が bind,listen し, 起動されたプロセスが connect する. @var{conn_to_serv} が 0 の場合, 起動されたプロセスが bind, listen し, client が connect する. \E \BEG @item @code{ox_launch_generic()} invokes a control process @var{launch} and a server process @var{server} on @var{host}. The other arguments are switches for protocol family selection, on/off of the X environment, method of process invocation and selection of connection type. @item If @var{host} is equal to 0, processes are invoked on the same machine as the @b{Asir} is running. In this case UNIX internal protocol is always used. @item If @var{use_unix} is equal to 1, UNIX internal protocol is used. If @var{use_unix} is equal to 0, Internet protocol is used. @item If @var{use_ssh} is equal to 1,@samp{ssh} (Secure Shell) is used to invoke processes. If one does not use @samp{ssh-agent}, a password (passphrase) is required. If @samp{sshd} is not running on the target machine, @samp{rsh} is used instead. But it will immediately fail if a password is required. @item If @var{use_x} is equal to 1, it is assumed that X environment is available. In such a case @var{server} is invoked under @samp{xterm} by using the current @code{DISPLAY} variable. If @code{DISPLAY} is not set, it is invoked without X. Note that the processes will hang up if @code{DISPLAY} is incorrectly set. @item If @var{conn_to_serv} is equal to 1, @b{Asir} (client) executes @code{bind} and @code{listen}, and the invoked processes execute @code{connect}. If @var{conn_to_serv} is equal to 0, @b{Asir} (client) the invoked processes execute @code{bind} and @code{listen}, and the client executes @code{connect}. \E @end itemize @example [342] LIB=get_rootdir(); /export/home/noro/ca/Kobe/build/OpenXM/lib/asir [343] ox_launch_generic(0,LIB+"/ox_launch",LIB+"/ox_asir",0,0,0,0); 1 [344] ox_launch_generic(0,LIB+"/ox_launch",LIB+"/ox_asir",1,0,0,0); 2 [345] ox_launch_generic(0,LIB+"/ox_launch",LIB+"/ox_asir",1,1,0,0); 3 [346] ox_launch_generic(0,LIB+"/ox_launch",LIB+"/ox_asir",1,1,1,0); 4 [347] ox_launch_generic(0,LIB+"/ox_launch",LIB+"/ox_asir",1,1,1,1); 5 [348] ox_launch_generic(0,LIB+"/ox_launch",LIB+"/ox_asir",1,1,0,1); 6 @end example @table @t \JP @item 参照 \EG @item References @fref{ox_launch ox_launch_nox ox_shutdown}, @fref{ox_launch_generic} @end table \JP @node generate_port try_bind_listen try_connect try_accept register_server,,, 分散計算に関する関数 \EG @node generate_port try_bind_listen try_connect try_accept register_server,,, Functions for distributed computation @subsection @code{generate_port}, @code{try_bind_listen}, @code{try_connect}, @code{try_accept}, @code{register_server} @findex generate_port @findex try_bind_listen @findex try_connect @findex try_accept @findex register_server @table @t @item generate_port([@var{use_unix}]) \JP :: port の生成 \EG :: Generates a port number. @itemx try_bind_listen(@var{port}) \JP :: port に対して bind, listen \EG :: Binds and listens on a port. @itemx try_connect(@var{host},@var{port}) \JP :: port に対して connect \EG :: Connects to a port. @itemx try_accept(@var{socket},@var{port}) \JP :: connect 要求を accept \EG :: Accepts a connection request. @itemx register_server(@var{control_socket},@var{control_port},@var{server_socket},@var{server_port}) \JP :: connection の成立した control socket, server socket の登録 \EG :: Registers the sockets for which connections are established. @end table @table @var @item return \JP @code{generate_port()} のみ整数または文字列. その他は整数. \EG integer or string for @code{generate_port()}, integer for the others @item use_unix \JP 0 または 1 \EG 0 or 1 @item host \JP 文字列 \EG string @item port control_port server_port \JP 整数または文字列 \EG integer or string @item socket control_socket server_socket \JP 整数 \EG integer @end table @itemize @bullet \BJP @item これらの関数は, 遠隔プロセスと通信を成立させるためのプリミティブである. @item @code{generate_port()} は通信のための port を生成する. 無引数あるいは 引数が 0 の場合, Internet domain の socket のための port 番号, それ 以外の場合には, UNIX domain (host-internal protocol) のための, ファイル名 を生成する. port 番号は random に生成されるが, その port が使用中でない 保証はない. @item @code{try_bind_listen()} は, 与えられた port に対し, その protocol に 対応した socket を生成し, bind, listen する. 成功した場合, socket 識別子を返す. 失敗した場合, -1 が返る. @item @code{try_connect()} は, ホスト @var{host} の port @var{port} に対し connect を試みる. 成功した場合, socket 識別子を返す. 失敗した場合 -1 が返る. @item @code{try_accept()} は, @var{socket} に対する connect 要求を accept し, 新たに生成された socket を返す. 失敗した場合 -1 が返る. いずれの場合にも, @var{socket} は自動的に close される. 引数 @var{port} は, @var{socket} の protocol を判別するために与える. @item @code{register_server()} は, control, server それぞれの socket を 一組にして, server list に登録し, @code{ox_push_cmo()} などで用いる プロセス識別子を返す. @item 遠隔プロセスの起動は, @code{shell()} または手動で行う. \E \BEG @item These functions are primitives to establish communications between a client and servers. @item @code{generate_port()} generates a port name for communication. If the argument is not specified or equal to 0, a port number for Internet domain socket is generated randomly. Otherwise a file name for UNIX domain (host-internal protocol) is generated. Note that it is not assured that the generated port is not in use. @item @code{try_bind_listen()} creates a socket according to the protocol family indicated by the given port and executes @code{bind} and @code{listen}. It returns a socket identifier if it is successful. -1 indicates an error. @item @code{try_connect()} tries to connect to a port @var{port} on a host @var{host}. It returns a socket identifier if it is successful. -1 indicates an error. @item @code{try_accept()} accepts a connection request to a socket @var{socket}. It returns a new socket identifier if it is successful. -1 indicates an error. In any case @var{socket} is automatically closed. @var{port} is specified to distinguish the protocol family of @var{socket}. @item @code{register_server()} registers a pair of a control socket and a server socket. A process identifier indicating the pair is returned. The process identifier is used as an argument of @code{ox} functions such as @code{ox_push_cmo()}. @item Servers are invoked by using @code{shell()}, or manually. \E @end itemize @example [340] CPort=generate_port(); 39896 [341] SPort=generate_port(); 37222 [342] CSocket=try_bind_listen(CPort); 3 [343] SSocket=try_bind_listen(SPort); 5 /* \JP ここで, ox_launch を起動 : \EG ox_launch is invoked here : % ox_launch "127.1" 0 39716 37043 ox_asir "shio:0" */ [344] CSocket=try_accept(CSocket,CPort); 6 [345] SSocket=try_accept(SSocket,SPort); 3 [346] register_server(CSocket,CPort,SSocket,SPort); 0 @end example @table @t \JP @item 参照 \EG @item References @fref{ox_launch ox_launch_nox ox_shutdown}, @fref{ox_launch_generic}, @fref{shell}, @fref{ox_push_cmo ox_push_local} @end table \JP @node ox_asir,,, 分散計算に関する関数 \EG @node ox_asir,,, Functions for distributed computation @subsection @samp{ox_asir} \BJP @samp{ox_asir} は, @b{Asir} のほぼ全ての機能を @b{OpenXM} サーバ として提供する. @samp{ox_asir} は, @code{ox_launch} または @code{ox_launch_nox} で 起動する. 後者は X 環境を用いない場合のために用意されている. \E \BEG @samp{ox_asir} provides almost all the functionalities of @b{Asir} as an @b{OpenXM} server. @samp{ox_asir} is invoked by @code{ox_launch} or @code{ox_launch_nox}. If X environment is not available or is not necessary, one can use @code{ox_launch_nox}. \E @example [5] ox_launch(); 0 @end example @example [5] ox_launch_nox("127.0.0.1","/usr/local/lib/asir","/usr/local/lib/asir/ox_asir"); 0 @end example @example [7] RemoteLibDir = "/usr/local/lib/asir/"$ [8] Machines = ["sumire","rokkaku","genkotsu","shinpuku"]; [sumire,rokkaku,genkotsu,shinpuku] [9] Servers = map(ox_launch,Machines,RemoteLibDir,RemoteLibDir+"ox_asir"); [0,1,2,3] @end example @table @t \JP @item 参照 \EG @item References @fref{ox_launch ox_launch_nox ox_shutdown} @end table \JP @node ox_rpc ox_cmo_rpc ox_execute_string,,, 分散計算に関する関数 \EG @node ox_rpc ox_cmo_rpc ox_execute_string,,, Functions for distributed computation @subsection @code{ox_rpc}, @code{ox_cmo_rpc}, @code{ox_execute_string} @findex ox_rpc @findex ox_cmo_rpc @findex ox_execute_string @table @t @item ox_rpc(@var{number},@code{"@var{func}"},@var{arg0},...) @itemx ox_cmo_rpc(@var{number},@code{"@var{func}"},@var{arg0},...) @itemx ox_execute_string(@var{number},@code{"@var{command}"},...) \JP :: プロセスの函数呼び出し \EG :: Calls a function on an OpenXM server @end table @table @var @item return 0 @item number \JP 数 (プロセス識別子) \EG integer (process identifier) @item func \JP 函数名 \EG function name @item command \JP 文字列 \EG string @item arg0 ... \JP 任意 (引数) \EG arbitrary (arguments) @end table @itemize @bullet \BJP @item 識別子 @var{number} のプロセスの函数を呼び出す. @item 函数の計算終了を待たず, 直ちに 0 を返す. @item @code{ox_rpc()} は, サーバが @samp{ox_asir} の場合のみ用いることができる. それ以外の場合は, @code{ox_cmo_rpc()} を用いる. @item 函数が返す値は @code{ox_pop_local()}, @code{ox_pop_cmo()} により取り出す. @item サーバが @samp{ox_asir} 以外のもの (例えば Kan サーバ @samp{ox_sm1}など) の場合には, @b{Open_XM} プロトコルでサポートされているデータのみを 送ることができる. @item @code{ox_execute_string} は, 送った文字列 @var{command} をサーバが自らの ユーザ言語パーザで解析し, 評価した結果をサーバのスタックに置くように 指示する. \E \BEG @item Calls a function on an @b{OpenXM} server whose identifier is @var{number}. @item It returns 0 immediately. It does not wait the termination of the function call. @item @code{ox_rpc()} can be used when the server is @samp{ox_asir}. Otherwise @code{ox_cmo_rpc()} should be used. @item The result of the function call is put on the stack of the server. It can be received by @code{ox_pop_local()} or @code{ox_pop_cmo()}. @item If the server is not @samp{ox_asir}, only data defined in @b{OpenXM} can be sent. @item @code{ox_execute_string} requests the server to parse and execute @var{command} by the parser and the evaluater of the server. The result is pushed to the stack. \E @end itemize @example [234] ox_cmo_rpc(0,"dp_ht",dp_ptod((x+y)^10,[x,y])); 0 [235] ox_pop_cmo(0); (1)*<<10,0>> [236] ox_execute_string(0,"12345 % 678;"); 0 [237] ox_pop_cmo(0); 141 @end example @table @t \JP @item 参照 \EG @item References @fref{ox_pop_cmo ox_pop_local} @end table \JP @node ox_reset ox_intr register_handler,,, 分散計算に関する関数 \EG @node ox_reset ox_intr register_handler,,, Functions for distributed computation @subsection @code{ox_reset},@code{ox_intr},@code{register_handler} @findex ox_reset @findex register_handler @table @t @item ox_reset(@var{number}) \JP :: プロセスのリセット \EG :: Resets an OpenXM server @item ox_intr(@var{number}) \JP :: プロセスのに @code{SIGINT} 送付 \EG :: Sends @code{SIGINT} to an OpenXM server @item register_handler(@var{func}) \JP :: プロセスのリセットのための関数登録 \EG :: Registers a function callable on a keyboard interrupt. @end table @table @var @item return 1 @item number \JP 数 (プロセス識別子) \EG integer(process identifier) @item func \JP 関数子または 0 \EG functor or 0 @end table @itemize @bullet \BJP @item @code{ox_reset()} は, 識別子 @var{number} のプロセスをリセットし, コマン ド受け付け状態にする. @item そのプロセスが既に書き出した, あるいは現在書き出し中のデータがある場合, それを全部読み出し, 出力バッファを空にした時点で戻る. @item 子プロセスが RUN 状態の場合でも, 割り込みにより強制的に計算を終了させる. @item 分散計算を行う函数の先頭で, 使用するプロセスに対して実行する. あるいは 計算途中での強制中断に用いる. @item @code{ox_intr()} は, 識別子 @var{number} のプロセスをに対して @code{SIGINT} を送付する. @code{SIGINT} に対するプロセスの動作は 規定されていないが, @samp{ox_asir} の場合, ただちに debug mode に 入る. X 上で動作している場合, デバッグコマンド入力用のウィンドウが ポップアップする. @item @code{register_handler()} は, @kbd{C-c} などによる割り込みの際に, @kbd{u} を指定することで, 無引数ユーザ定義関数 @var{func}() が呼び出される ように設定する. この関数に, @code{ox_reset()} を呼び出させることで, 割り込みの際に自動的に @b{OpenXM} server のリセットを行うことができる. @item @var{func} に 0 を指定することで, 設定を解除できる. \E \BEG @item @code{ox_reset()} resets a process whose identifier is @var{number}. After its execution the process is ready for receiving data. @item After executing @code{ox_reset()}, sending/receiving buffers and stream buffers are assured to be empty. @item Even if a process is running, the execution is safely stopped. @item @code{ox_reset()} may be used prior to a distirbuted computation. It can be also used to interrupt a distributed computation. @item @code{ox_intr()} sends @code{SIGINT} to a process whose identifier is @var{number}. The action of a server against @code{SIGINT} is not specified in @b{OpenXM}. @samp{ox_asir} immediately enters the debug mode and pops up an window to input debug commands on X window system. @item @code{register_handler()} registers a function @var{func}(). If @kbd{u} is specified on a keybord interrupt, @var{func}() is executed before returning the toplevel. If @code{ox_reset()} calls are included in @var{func}(), one can automatically reset @b{OpenXM} servers on a keyboard interrupt. @item If @var{func} is equal to 0, the setting is reset. \E @end itemize @example [10] ox_launch(); 0 [11] ox_rpc(0,"fctr",x^100-y^100); 0 \BJP [12] ox_reset(0); /* xterm のウィンドウには */ 1 /* usr1 : return to toplevel by SIGUSR1 が表示される. */ \E \BEG [12] ox_reset(0); /* usr1 : return to toplevel by SIGUSR1 */ 1 /* is displayed on the xterm. */ \E @end example @example [340] Procs=[ox_launch(),ox_launch()]; [0,1] [341] def reset() @{ extern Procs; map(ox_reset,Procs);@} [342] map(ox_rpc,Procs,"fctr",x^100-y^100); [0,0] [343] register_handler(reset); 1 [344] interrupt ?(q/t/c/d/u/w/?) u Abort this computation? (y or n) y Calling the registered exception handler...done. return to toplevel @end example @table @t \JP @item 参照 \EG @item References @fref{ox_rpc ox_cmo_rpc ox_execute_string} @end table \JP @node ox_push_cmo ox_push_local,,, 分散計算に関する関数 \EG @node ox_push_cmo ox_push_local,,, Functions for distributed computation @subsection @code{ox_push_cmo}, @code{ox_push_local} @findex ox_push_cmo @findex ox_push_local @table @t @item ox_push_cmo(@var{number},@var{obj}) @itemx ox_push_local(@var{number},@var{obj}) \JP :: @var{obj} を識別子 @var{number} のプロセスに送信 \EG :: Sends @var{obj} to a process whose identifier is @var{number}. @end table @table @var @item return 0 @item number \JP 数(プロセス識別子) \EG integer(process identifier) @item obj \JP オブジェクト \EG object @end table @itemize @bullet \BJP @item 識別子 @var{number} のプロセスに @var{obj} を送信する. @item @code{ox_push_cmo} は, Asir 以外の @b{Open_XM} サーバに送信 する際に用いる. @item @code{ox_push_local} は, @samp{ox_asir}, @samp{ox_plot} に データを送る場合に用いることができる. @item バッファがいっぱいにならない限り, ただちに復帰する. \E \BEG @item Sends @var{obj} to a process whose identifier is @var{number}. @item @code{ox_push_cmo} is used to send data to an @b{Open_XM} other than @samp{ox_asir} and @samp{ox_plot}. @item @code{ox_push_local} is used to send data to @samp{ox_asir} and @samp{ox_plot}. @item The call immediately returns unless the stream buffer is full. \E @end itemize @table @t \JP @item 参照 \EG @item References @fref{ox_rpc ox_cmo_rpc ox_execute_string}, @fref{ox_pop_cmo ox_pop_local} @end table \JP @node ox_pop_cmo ox_pop_local,,, 分散計算に関する関数 \EG @node ox_pop_cmo ox_pop_local,,, Functions for distributed computation @subsection @code{ox_pop_cmo}, @code{ox_pop_local} @findex ox_pop_local @findex ox_pop_cmo @table @t @item ox_pop_local(@var{number}) \JP :: プロセス識別子 @var{number} からデータを受信する. \EG :: Receives data from a process whose identifier is @var{number}. @end table @table @var @item return \JP 受信データ \EG received data @item number \JP 数 (プロセス識別子) \EG integer(process identifier) @end table @itemize @bullet \BJP @item プロセス識別子 @var{number} のプロセスからデータを受信する. @item @code{ox_pop_cmo} は, Asir 以外の @b{Open_XM} サーバから受信 する際に用いる. @item @code{ox_pop_local} は, @samp{ox_asir}, @samp{ox_plot} から データを受け取る場合に用いることができる. @item サーバが計算中の場合ブロックする. これを避けるためには, @code{ox_push_cmd} で @code{SM_popCMO} (262) または @code{SM_popSerializedLocalObject} (258) を送っておき, @code{ox_select} でプロセスが ready になっていることを確かめてから @code{ox_get} すればよい. \E \BEG @item Receives data from a process whose identifier is @var{number}. @item @code{ox_pop_cmo} can be used to receive data form an @b{OpenXM} server other than @samp{ox_asir} and @samp{ox_plot}. @item @code{ox_pop_local} can be used to receive data from @samp{ox_asir}, @samp{ox_plot}. @item If no data is available, these functions block. To avoid it, send @code{SM_popCMO} (262) or @code{SM_popSerializedLocalObject} (258). Then check the process status by @code{ox_select}. Finally call @code{ox_get} for a ready process. \E @end itemize @example [3] ox_rpc(0,"fctr",x^100-y^100); 0 [4] ox_push_cmd(0,258); 0 [5] ox_select([0]); [0] [6] ox_get(0); [[1,1],[x^2+y^2,1],[x^4-y*x^3+y^2*x^2-y^3*x+y^4,1],...] @end example @table @t \JP @item 参照 \EG @item References @fref{ox_rpc ox_cmo_rpc ox_execute_string}, @fref{ox_push_cmd ox_sync}, @fref{ox_select}, @fref{ox_get} @end table \JP @node ox_push_cmd ox_sync,,, 分散計算に関する関数 \EG @node ox_push_cmd ox_sync,,, Functions for distributed computation @subsection @code{ox_push_cmd}, @code{ox_sync} @findex ox_push_cmd @findex ox_sync @table @t @item ox_push_cmd(@var{number},@var{command}) \JP :: プロセス識別子 @var{number} のプロセスにコマンド @var{command} を送信する. \EG :: Sends a command @var{command} to a process whose identifier is @var{number}. @item ox_sync(@var{number}) \JP :: プロセス識別子 @var{number} のプロセスに @b{OX_SYNC_BALL} を送信する. \EG :: Sends @b{OX_SYNC_BALL} to a process whose identifier is @var{number}. @end table @table @var @item return 0 @item number \JP 数 (プロセス識別子) \EG integer(process identifier) @item command \JP 数 (コマンド識別子) \EG integer(command identifier) @end table @itemize @bullet \BJP @item 識別子 @var{number} のプロセスにコマンドまたは @b{OX_SYNC_BALL} を送信する. @item @b{Open_XM} において送受信データは @b{OX_DATA}, @b{OX_COMMAND}, @b{OX_SYNC_BALL}の 3 種類に分かれる. 通常, コマンドは何らかの操作に 付随して暗黙のうちに送信されるが, これをユーザが個別に送りたい場合に 用いられる. @item @b{OX_SYNC_BALL} は @code{ox_reset} による計算中断, 復帰の際に送受信される が, これを個別に送りたい場合に用いる. なお, 通常状態では @b{OX_SYNC_BALL} は無視される. \E \BEG @item Sends a command or @b{OX_SYNC_BALL} to a process whose identifier is @var{number}. @item Data in @b{OpenXM} are categorized into three types: @b{OX_DATA}, @b{OX_COMMAND}, @b{OX_SYNC_BALL}. Usually @b{OX_COMMAND} and @b{OX_SYNC_BALL} are sent implicitly with high level operations, but these functions are prepared to send these data explicitly. @item @b{OX_SYNC_BALL} is used on the reseting operation by @code{ox_reset}. Usually @b{OX_SYNC_BALL} will be ignored by the peer. \E @end itemize @table @t \JP @item 参照 \EG @item References @fref{ox_rpc ox_cmo_rpc ox_execute_string}, @fref{ox_reset ox_intr register_handler} @end table \JP @node ox_get,,, 分散計算に関する関数 \EG @node ox_get,,, Functions for distributed computation @subsection @code{ox_get} @findex ox_get @table @t @item ox_get(@var{number}) \JP :: プロセス識別子 @var{number} のプロセスからデータを受信する. \EG :: Receives data form a process whose identifer is @var{number}. @end table @table @var @item return \JP 受信データ @item number \JP 数(プロセス識別子) \EG integer(process identifier) @end table @itemize @bullet \BJP @item プロセス識別子 @var{number} のプロセスからデータを受信する. 既に ストリーム上にデータがあることを仮定している. @item @code{ox_push_cmd} と組み合わせて用いる. @item @code{ox_pop_cmo}, @code{ox_pop_local} は, @code{ox_push_cmd} と @code{ox_get} の組み合わせで実現されている. \E \BEG @item Receives data form a process whose identifer is @var{number}. @item One may use this function with @code{ox_push_cmd}. @item @code{ox_pop_cmo} and @code{ox_pop_local} is realized as combinations of @code{ox_push_cmd} and @code{ox_get}. \E @end itemize @example [11] ox_push_cmo(0,123); 0 [12] ox_push_cmd(0,262); /* 262=OX_popCMO */ 0 [13] ox_get(0); 123 @end example @table @t \JP @item 参照 \EG @item References @fref{ox_pop_cmo ox_pop_local}, @fref{ox_push_cmd ox_sync} @end table \JP @node ox_pops,,, 分散計算に関する関数 \EG @node ox_pops,,, Functions for distributed computation @subsection @code{ox_pops} @findex ox_pops @table @t @item ox_pops(@var{number}[,@var{nitem}]) \JP :: プロセス識別子 @var{number} のプロセスのスタックからデータを取り除く. \EG :: Removes data form the stack of a process whose identifier is @var{number}. @end table @table @var @item return 0 @item number \JP 数 (プロセス識別子) \EG integer(process identifier) @item nitem \JP 自然数 \EG non-negative integer @end table @itemize @bullet \BJP @item プロセス識別子 @var{number} のプロセスのスタックからデータを取り除く. @var{nitem} が指定されている場合は @var{nitem} 個, 指定のない場合は 1 個取り除く. \E \BEG @item Removes data form the stack of a process whose identifier is @var{number}. If @var{nitem} is specified, @var{nitem} items are removed. If @var{nitem} is not specified, 1 item is removed. \E @end itemize @example [69] for(I=1;I<=10;I++)ox_push_cmo(0,I); [70] ox_pops(0,4); 0 [71] ox_pop_cmo(0); 6 @end example @table @t \JP @item 参照 \EG @item References @fref{ox_pop_cmo ox_pop_local} @end table \JP @node ox_select,,, 分散計算に関する関数 \EG @node ox_select,,, Functions for distributed computation @subsection @code{ox_select} @findex ox_select @table @t @item ox_select(@var{nlist}[,@var{timeout}]) \JP :: 読み出し可能なプロセスの識別子を返す. \EG :: Returns the list of process identifiers on which data is available. @end table @table @var @item return \JP リスト \EG list @item nlist \JP 数 (子プロセス識別子) のリスト \EG list of integers (process identifier) @item timeout \JP 数 \EG number @end table @itemize @bullet \BJP @item 識別子リスト @var{nlist} のプロセスのうち既に出力を返している プロセスの識別子リストを返す. @item 全てのプロセスが RUN 状態のとき, いずれかのプロセスの終了を待つ. 但し, @var{timeout} が指定されている場合, @var{timeout} 秒だけ待つ. @item @code{ox_push_cmd()} で @code{SM_popCMO} あるいは @code{SM_popSerializedLocalObject} を送っておき, @code{ox_select()} で ready 状態のプロセスを調べて@code{ox_get()} することで, @code{ox_pop_local()}, @code{ox_pop_cmo()}で待ち状態に入るのを防ぐことが できる. \E \BEG @item Returns the list of process identifiers on which data is available. @item If all the processes in @var{nlist} are running, it blocks until one of the processes returns data. If @var{timeout} is specified, it waits for only @var{timeout} seconds. @item By sending @code{SM_popCMO} or @code{SM_popSerializedLocalObject} with @code{ox_push_cmd()} in advance and by examining the process status with @code{ox_select()}, one can avoid a hanging up caused by @code{ox_pop_local()} or @code{ox_pop_cmo()}. In such a case, data can be received by @code{ox_get()}. \E @end itemize @example ox_launch(); 0 [220] ox_launch(); 1 [221] ox_launch(); 2 [222] ox_rpc(2,"fctr",x^500-y^500); 0 [223] ox_rpc(1,"fctr",x^100-y^100); 0 [224] ox_rpc(0,"fctr",x^10-y^10); 0 [225] P=[0,1,2]; [0,1,2] [226] map(ox_push_cmd,P,258); [0,0,0] [227] ox_select(P); [0] [228] ox_get(0); [[1,1],[x^4+y*x^3+y^2*x^2+y^3*x+y^4,1], [x^4-y*x^3+y^2*x^2-y^3*x+y^4,1],[x-y,1],[x+y,1]] @end example @table @t \JP @item 参照 \EG @item References @fref{ox_pop_cmo ox_pop_local}, @fref{ox_push_cmd ox_sync}, @fref{ox_get} @end table \JP @node ox_flush ,,, 分散計算に関する関数 \EG @node ox_flush ,,, Functions for distributed computation @subsection @code{ox_flush} @findex ox_flush @table @t @item ox_flush(@var{id}) \JP :: 送信バッファの強制 flush \EG :: Flushes the sending buffer. @end table @table @var @item return 1 @item id \JP 子プロセス識別子 \EG process identifier @end table @itemize @bullet \BJP @item 通常はバッチモードは off であり, データ, コマンド送信ごとに 送信バッファは flush される. @item バッチモードは @code{"ctrl"} コマンドの @code{"ox_batch"} スイッチ で on/off できる. @item 細かいデータを多数送る場合に, @code{ctrl("ox_batch",1)} でバッチモードを on にすると, バッファがいっぱいになった場合にのみ flush されるため, overhead が小さくなる場合がある. ただしこの場合には, 最後に @code{ox_flush(@var{id})} を実行して, バッファを強制的に flush する必要が ある. @item @code{ox_pop_cmo}, @code{ox_pop_local} のように, コマンド送信後 ただちにデータ待ちに入る関数がハングしないよう, これらの関数の内部では 強制 flush が実行されている. \E \BEG @item By default the batch mode is off and the sending buffer is flushed at every sending operation of data and command. @item The batch mode is set by @code{"ox_batch"} switch of @code{"ctrl"}. @item If one wants to send many pieces of small data, @code{ctrl("ox_batch",1)} may decrease the overhead of flush operations. Of course, one has to call @code{ox_flush(@var{id})} at the end of the sending operations. @item Functions such as @code{ox_pop_cmo} and @code{ox_pop_local} enter a waiting mode immediately after sending a command. These functions always flush the sending buffer. \E @end itemize @example [340] ox_launch_nox(); 0 [341] cputime(1); 0 7e-05sec + gc : 4.8e-05sec(0.000119sec) [342] for(I=0;I<10000;I++)ox_push_cmo(0,I); 0.232sec + gc : 0.006821sec(0.6878sec) [343] ctrl("ox_batch",1); 1 4.5e-05sec(3.302e-05sec) [344] for(I=0;I<10000;I++)ox_push_cmo(0,I); ox_flush(0); 0.08063sec + gc : 0.06388sec(0.4408sec) [345] 1 9.6e-05sec(0.01317sec) @end example @table @t \JP @item 参照 \EG @item References @fref{ox_pop_cmo ox_pop_local}, @fref{ctrl} @end table \JP @node ox_get_serverinfo ,,, 分散計算に関する関数 \EG @node ox_get_serverinfo ,,, Functions for distributed computation @subsection @code{ox_get_serverinfo} @findex ox_get_serverinfo @table @t @item ox_get_serverinfo([@var{id}]) \JP :: server の Mathcap, 動作中のプロセス識別子の取得 \EG :: Gets server's mathcap and proess id. @end table @table @var @item return \JP リスト \EG list @item id \JP 子プロセス識別子 \EG process identifier @end table @itemize @bullet \BJP @item 引数 @var{id} があるとき, プロセス識別子 @var{id} のプロセスの Mathcap をリストとして返す. @item 引数なしのとき, 現在動作中のプロセス識別子およびその Mathcap から なるペアを, リストとして返す. \E \BEG @item If @var{id} is specified, the mathcap of the process whose identifier is @var{id} is returned. @item If @var{id} is not specified, the list of [@var{id},@var{Mathcap}] is returned, where @var{id} is the identifier of a currently active process, and @var{Mathcap} is the mathcap of the process. identifier @var{id} is returned. \E @end itemize @example [343] ox_get_serverinfo(0); [[199909080,Ox_system=ox_sm1.plain,Version=2.991118,HOSTTYPE=FreeBSD], [262,263,264,265,266,268,269,272,273,275,276], [[514],[2130706434,1,2,4,5,17,19,20,22,23,24,25,26,30,31,60,61,27,33,40,16,34]]] [344] ox_get_serverinfo(); [[0,[[199909080,Ox_system=ox_sm1.plain,Version=2.991118,HOSTTYPE=FreeBSD], [262,263,264,265,266,268,269,272,273,275,276], [[514],[2130706434,1,2,4,5,17,19,20,22,23,24,25,26,30,31,60,61,27,33,40,16,34]]]], [1,[[199901160,ox_asir], [276,275,258,262,263,266,267,268,274,269,272,265,264,273,300,270,271], [[514,2144202544], [1,2,3,4,5,2130706433,2130706434,17,19,20,21,22,24,25,26,31,27,33,60],[0,1]]]]] @end example @table @t \JP @item 参照 \EG @item References @fref{Mathcap}. @end table \JP @node ifplot conplot plot polarplot plotover,,, 分散計算に関する関数 \EG @node ifplot conplot plot polarplot plotover,,, Functions for distributed computation @subsection @code{ifplot}, @code{conplot}, @code{plot}, @code{polarplot}, @code{plotover} @findex ifplot @findex conplot @findex polarplot @findex plot @findex plotover @table @t @item ifplot(@var{func} [,@var{geometry}] [,@var{xrange}] [,@var{yrange}] [,@var{id}] [,@var{name}]) \JP :: 2 変数関数の実数上での零点を表示する. \EG :: Displays real zeros of a bi-variate function. @item conplot(@var{func} [,@var{geometry}] [,@var{xrange}] [,@var{yrange}] [,@var{zrange}] [,@var{id}] [,@var{name}]) \JP :: 2 変数関数の実数上での等高線を表示する. \EG :: Displays real contour lines of a bi-variate function. @item plot(@var{func} [,@var{geometry}] [,@var{xrange}] [,@var{id}] [,@var{name}]) \JP :: 1 変数関数のグラフを表示する. \EG :: Displays the graph of a univariate function. @item polarplot(@var{func} [,@var{geometry}] [,@var{thetarange}] [,@var{id}] [,@var{name}]) \JP :: 極形式で与えられた曲線を表示する. \EG :: Displays the graph of a curve given in polar form. @item plotover(@var{func},@var{id},@var{number}) \JP :: すでに存在しているウィンドウへ描画する. \EG Plots on the existing window real zeros of a bivariate function. @end table @table @var @item return \JP 整数 \EG integer @item func \JP 多項式 \EG polynomial @item geometry xrange yrange zrange \JP リスト \EG list @item id number \JP 整数 \EG integer @item name \JP 文字列 \EG string @end table @itemize @bullet \BJP @item @code{ifplot()} は, 2 変数関数 @var{func} の実数上での零点の グラフの表示を行う. @code{conplot()} は, 同様の引数に対し, 等高線の表示を行う. @code{plot()} は 1 変数関数のグラフの表示を行う. @code{polarplot()} は 極形式 @var{r}=@var{f}(@var{theta}) で表された曲線のグラフの表示を行う. @item これらは OpenXM サーバとして実現されている. UNIX 上では @samp{ox_plot} が, Windows 上では @samp{engine} がこれらの機能 を提供しており, これらは @b{Asir} の標準ライブラリディレクトリにある. アクティブな @samp{ox_plot} の id が @var{id} として指定された場合, そのサーバが用いられる. id の指定がない場合には, 起動されて いるサーバのうち, @samp{ox_plot} があればそのサーバが用いられる. @samp{ox_plot} が起動されていない場合には, @code{ox_launch_nox()} が自動的に実行されて, @samp{ox_plot} が 立ち上がり, それが用いられる. @item 引数の内, @var{func} は必須である. その他の引数はオプションである. オプションの形式およびそのデフォルト値 (カッコ内) は次の通り. @table @var @item geometry ウィンドウのサイズをドット単位で [@var{x},@var{y}] で指定する. ([@code{300},@code{300}]. ) @item xrange yrange 変数の範囲の指定で, [@var{v},@var{vmin},@var{vmax}] で指定する. (いずれの変数も [@var{v},@code{-2},@code{2}].) この指定がない場合, @var{func} に含まれる変数の内変数順序の上の変数 が @samp{x}, 下の変数が @samp{y} として扱われる. これを避けるためには @var{xrange}, @var{yrange} を指定する. また, @var{func} が 1 変数の 場合, これらの指定は必須となる. @item zrange @code{conplot()} の場合のみ指定できる. 形式は [@var{v},@var{vmin},@var{vmax} @code{[},@var{step} @code{]}] で, @var{step} が指定され た場合には, 等高線の間隔が (@var{vmax}-@var{vmin})/@var{step} となる. ([@var{z},@code{-2},@code{2},@code{16}].) @item id 遠隔プロセスの番号, すなわち @code{ox_launch()} が返した番号を指定する. (一番最近に作られ, かつアクティブなプロセスに対応する番号.) @item name ウィンドウの名前. (@code{Plot}.) 生成されたウィンドウのタイトルは @var{name:n/m} となる. これは, プロセス番号 @var{n} のプロセスの, @var{m} 番のウィンドウを意味する. この番号は, @code{plotover()} で用いられる. @end table @item 一つのプロセス上で描画できるウィンドウの数は最大 128 個である. @item @code{plotover()} は, 指定したウィンドウ上に, 引数である 2 変数多項式の 零点を上書きする. @item 描画終了後のウィンドウ上で, マウスの左ボタンを押しながらのドラッグ で範囲を指定しボタンを離すと新たなウィンドウが生成され, 指定した 範囲が拡大して表示される. ドラッグは左上から右下へと行う. ドラッグを始めた後キャンセルする場合は, マウスポインタを始点の上か 左に持っていってボタンを離せばよい. 新しいウインドウの形は, 指定 領域と相似で, 最大辺が, 元のウィンドウの最大辺と一致するように 定められる. 以下で説明する @code{precise} が on の場合, 選択した領域が同一 window 上で書き直される. @item ウィンドウ内で右ボタンを押すと, その点の座標がウィンドウの下部に表示される. @item @code{conplot()} で生成したウィンドウにおいて, ウィンドウの右側のマーカを 中ボタンでドラッグすると, 対応する等高線の色が変わり, 右上の ウィンドウに対応するレベルが表示される. @item UNIX 版ではいくつかのボタンにより いくつかの設定変更, 操作ができる. UNIX 版では次のボタンがある. @table @code @item quit window を破壊する. 計算を中断する場合, @code{ox_reset()} を用いる. @item wide (トグル) 現在の表示部分を縦横各 10 倍した領域を表示する. 現在表示されている範囲は この表示において中央部に長方形で示される. この表示で範囲指定を行うと, その範囲が新しいウィンドウに描画される. @item precise (トグル) 選択領域を, 整数演算により, より正確に再描画する. これは, @var{func} が 有理数係数の 2 変数多項式の場合にのみ有効である. このモードでは Sturm 列 と二分法により, 区間内の零点の個数を正確に求めていくもので, デフォルトの 計算法よりも正確な描画が期待できる. ただし, 描画時間は余計にかかる場合が 多い. この説明から明らかなように, この機能は有理数係数の多項式の描画に対 してのみ有効である. ((x^2+y^2-1)^2 の描画で試してみよ.) @item formula 対応する式を表示する. @item noaxis (トグル) 座標軸を消す. @end table @item @samp{ox_plot} が起動されるマシンによっては, スタックを大量に使用する ものもあるため, @samp{.cshrc} でスタックサイズを大きめ (16MB 程度) に 指定しておくのが安全である. スタックサイズは @code{limit stacksize 16m} などと指定する. @item @code{X} では、ウインドウの各部分について resource により 色付けや、ボタンの形を変えることができる。 resource の指定の仕方は以下の通り。(デフォルトを示しておく) @code{plot*form*shapeStyle} は、@t{rectangle, oval, ellipse, roundedRectangle} が、指定できる。 \E \BEG @item Function @code{ifplot()} draws a graph of real zeros of a bi-variate function. Function @code{conplot()} plots the contour lines for a same argument. Function @code{plot()} draws the graph of a uninivariate function. Function @code{polarplot()} draws the graph of a curve given in polar form @var{r}=@var{f}(@var{theta}). @item The plotting functions are realized by an OpenXM server. On UNIX it is @samp{ox_plot} in @b{Asir} root directory. On Windows @samp{engine} acts as @samp{ox_plot}. Of course, it must be activated by @code{ox_launch()} @code{ox_launch_nox()}. If the identifier of an active @samp{ox_plot} is specified as @var{id}, the server is used for drawing pictures. If @var{id} is not specified, an available @samp{ox_plot} server is used if it exists. If no @samp{ox_plot} server is available, then @code{ox_launch_nox()} is automatically executed to invoke @samp{ox_plot}. @item Argument @var{func} is indispensable. Other arguments are optional. The format of optional arguments and their default values (parenthesized) are listed below. @table @var @item geometry Window size is specified by [@var{x},@var{y}] in unit `dot.' [@code{300},@code{300}] for UNIX version; @item xrange yrange Value ranges of the variables are specified by [@var{v},@var{vmin},@var{vmax}]. ([@var{v},@code{-2},@code{2}] for each variable.) If this specification is omitted, the indeterminate having the higher order in @var{func} is taken for @samp{x} and the one with lower order is taken for @samp{y}. To change this selection, specify explicitly by @var{xrange} and/or @var{yrange}. For an uni-variate function, the specification is mandatory. @item zrange This specification applies only to @code{conplot()}. The format is [@var{v},@var{vmin},@var{vmax} @code{[},@var{step} @code{]}]. If @var{step} is specified, the height difference of contours is set to (@var{vmax}-@var{vmin})/@var{step}. ([@var{z},@code{-2},@code{2},@code{16}].) @item id This specifies the number of the remote process by which you wish to draw a graph. (The number for the newest active process.) @item name The name of the window. (@code{Plot}.) The created window is titled @var{name:n/m} which means the @var{m}-th window of the process with process number @var{n}. These numbers are used for @code{plotover()}. @end table @item The maximum number of the windows that can be created on a process is 128. @item Function @code{plotover()} superposes reals zeros of its argument bi-variate function onto the specified window. @item Enlarged plot can be obtained for rectangular area which is specified, on an already existing window with a graph, by dragging cursor with the left button of mouse from the upper-left corner to lower-right corner and then releasing it. Then, a new window is created whose shape is similar to the specified area and whose size is determined so that the largest side of the new window has the same size of the largest side of the original window. If you wish to cancel the action, drag the cursor to any point above or left of the starting point. This facility is effective when @code{precise} button switch is inactive. If @code{precise} is selected and active, the area specified by the cursor dragging will be rewritten on the same window. This will be explained later. @item A click of the right button will display the current coordinates of the cursor at the bottom area of the window. @item Place the cursor at any point in the right marker area on a window created by @code{conplot()}, and drag the cursor with the middle mutton. Then you will find the contour lines changing their colors depending on the movement of the cursor and the corresponding height level displayed on the upper right corner of the window. @item Several operations are available on the window: by button operations for UNIX version, and pull-down menus for Windows version. @table @code @item quit Destroys (kills) the window. While computing, quit the current computation. If one wants to interrupt the computation, use @code{ox_reset()}. @item wide (toggle) Will display, on the same window, a new area enlarged by 10 times as large as the current area for both width-direction and height-direction. The current area will be indicated by a rectangle placed at the center. Area specification by dragging the cursor will create a new window with a plot of the graph in the specified area. @item precise (toggle) When selected and active, @code{ox_plot} redraws the specified area more precisely by integer arithmetic. This mode uses bisection method based on Sturm sequence computation to locate real zeros precisely. More precise plotting can be expected by this technique than by the default plotting technique, at the expense of significant increase of computing time. As you see by above explanation, this function is only effective to polynomials with rational coefficients. (Check how they differ for (x^2+y^2-1)^2.) @item formula Displays the expression for the graph. @item noaxis (toggle) Erase the coordinates. @end table @item Program @samp{ox_plot} may consume much stack space depending on which machine it is running. You are recommended to set the stack size to about 16MB as large in @samp{.cshrc} for safe. To specify the size, put @code{limit stacksize 16m} for an example. @item You can customize various resources of a window on @code{X}, e.g., coloring, shape of buttons etc. The default setting of resources is shown below. For @code{plot*form*shapeStyle} you can select among @t{rectangle}, @t{oval}, @t{ellipse}, and @t{roundedRectangle}. \E @example plot*background:white plot*form*shapeStyle:rectangle plot*form*background:white plot*form*quit*background:white plot*form*wide*background:white plot*form*precise*background:white plot*form*formula*background:white plot*form*noaxis*background:white plot*form*xcoord*background:white plot*form*ycoord*background:white plot*form*level*background:white plot*form*xdone*background:white plot*form*ydone*background:white @end example @end itemize @example @end example @table @t \JP @item 参照 \EG @item References @fref{ox_launch ox_launch_nox ox_shutdown}, @fref{ox_reset ox_intr register_handler} @end table \JP @node open_canvas clear_canvas draw_obj draw_string,,, 分散計算に関する関数 \EG @node open_canvas clear_canvas draw_obj draw_string,,, Functions for distributed computation @subsection @code{open_canvas}, @code{clear_canvas}, @code{draw_obj}, @code{draw_string} @findex open_canvas @findex clear_canvas @findex draw_obj @findex draw_string @table @t @item open_canvas(@var{id}[,@var{geometry}]) \JP :: 描画用ウィンドウ (キャンバス) を生成する. \EG :: Opens a canvas, which is a window for drawing objects. @item clear_canvas(@var{id},@var{index}) \JP :: キャンバスをクリアする. \EG :: Clears a canvas. @item draw_obj(@var{id},@var{index},@var{pointorsegment} [,@var{color}]) \JP :: キャンバス上に点または線分を描画する. \EG :: Draws a point or a line segment on a canvas. @item draw_string(@var{id},@var{index},[@var{x},@var{y}],@var{string} [,@var{color}]) \JP :: キャンバス上に文字列を描画する. \EG :: Draws a character string on a canvas. @end table @table @var @item return 0 @item id index color x y \JP 整数 \EG integer @item pointorsegment \JP リスト \EG list @item string \JP 文字列 \EG character string @end table @itemize @bullet @item \BJP これらは OpenXM サーバ @samp{ox_plot} (Windows 上では @samp{engine}) により提供される. \E \BEG These functions are supplied by the OpenXM server @samp{ox_plot} (@samp{engine} on Windows). \E @item \BJP @code{open_canvas} は, 描画用のウィンドウ(キャンバス)を生成する. @var{geometry} によりウィンドウのサイズを pixel 単位で [@var{x},@var{y}] で指定する. default size は [@code{300},@code{300}]. キャンバスの識別子として, 整数値を OpenXM サーバのスタックに push する. この識別子は @code{draw_obj} の呼び出しに必要であり, @code{ox_pop_cmo} に より取り出して保持する必要がある. \E \BEG @code{open_canvas} opens a canvas, which is a window for drawing objecgts. One can specifies the size of a canvas in pixel by supplying @var{geometry} option [@var{x},@var{y}]. The default size is [@code{300},@code{300}]. This function pushes an integer value onto the stack of the OpenXM server. The value is used to distiguish the opened canvas and one has to pop and maintain the value by @code{ox_pop_cmo} for subsequent calls of @code{draw_obj}. \E @item \BJP @code{clear_canvas} は, サーバ id @var{id}, キャンバス id @var{index} で指定されるキャンバスをクリアする. \E \BEG @code{clear_canvas} clears a canvas specified by a server id @var{id} and a canvas id @var{index}. \E @item \BJP @code{draw_obj} は, サーバ id @var{id}, キャンバス id @var{index} で指定されるキャンバスに点または線分を描画する. @var{pointorsegment} が [@var{x},@var{y}] の場合点の座標, [@var{x},@var{y},@var{u},@var{v}] の場合 [@var{x},@var{y}], [@var{u},@var{v}] を結ぶ線分を表すと見なされる. キャンバスの座標は, 左上隅を原点として横方向に 第一座標, 縦方向に第二座標をとる. 値は pixel 単位で指定する. @var{color} の指定がある場合, @var{color/65536} mod 256, @var{color/256} mod 256, @var{color} mod 256 をそれぞれ Red, Green, Blue の値 (最大 255) とみなす. \E \BEG @code{draw_obj} draws a point or a line segment on a canvas specified by a server id @var{id} and a canvas id @var{index}. If @var{pointorsegment} is [@var{x},@var{y}], it is regarded as a point. If @var{pointorsegment} is [@var{x},@var{y},@var{u},@var{v}], it is regarded as a line segment which connects [@var{x},@var{y}] and [@var{u},@var{v}]. If @var{color} is specified, @var{color/65536} mod 256, @var{color/256} mod 256, @var{color} mod 256 are regarded as the vaules of Red, Green, Blue (Max. 255) respectively. \E @item \BJP @code{draw_string} は, サーバ id @var{id}, キャンバス id @var{index} で指定されるキャンバスに文字列を描画する. 位置は [@var{x},@var{y}] により指定する. \E \BEG @code{draw_string} draws a character string @var{string} on a canvas specified by a server id @var{id} and a canvas id @var{index}. The position of the string is specified by [@var{x},@var{y}]. \E @end itemize @example [182] Id=ox_launch_nox(0,"ox_plot"); 0 [183] open_canvas(Id); 0 [184] Ind=ox_pop_cmo(Id); 0 [185] draw_obj(Id,Ind,[100,100]); 0 [186] draw_obj(Id,Ind,[200,200],0xffff); 0 [187] draw_obj(Id,Ind,[10,10,50,50],0xff00ff); 0 [187] draw_string(Id,Ind,[100,50],"hello",0xffff00); 0 [189] clear_canvas(Id,Ind); 0 @end example @table @t \JP @item 参照 \EG @item References @fref{ox_launch ox_launch_nox ox_shutdown}, @fref{ox_reset ox_intr register_handler}, @fref{ox_pop_cmo ox_pop_local}. @end table