JP2023085797A - Information processing program, information processing device, and information processing method - Google Patents

Information processing program, information processing device, and information processing method Download PDF

Info

Publication number
JP2023085797A
JP2023085797A JP2021200032A JP2021200032A JP2023085797A JP 2023085797 A JP2023085797 A JP 2023085797A JP 2021200032 A JP2021200032 A JP 2021200032A JP 2021200032 A JP2021200032 A JP 2021200032A JP 2023085797 A JP2023085797 A JP 2023085797A
Authority
JP
Japan
Prior art keywords
processing
event
buffer
flag
events
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2021200032A
Other languages
Japanese (ja)
Other versions
JP7061301B1 (en
Inventor
直樹 宮永
Naoki Miyanaga
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Soft Gear Co Ltd
Original Assignee
Soft Gear Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Soft Gear Co Ltd filed Critical Soft Gear Co Ltd
Priority to JP2021200032A priority Critical patent/JP7061301B1/en
Application granted granted Critical
Publication of JP7061301B1 publication Critical patent/JP7061301B1/en
Priority to PCT/JP2022/025042 priority patent/WO2023008008A1/en
Priority to CN202280004572.XA priority patent/CN115917519B/en
Priority to KR1020227044708A priority patent/KR102521873B1/en
Priority to EP22808933.0A priority patent/EP4152168A4/en
Priority to US18/071,627 priority patent/US11762663B2/en
Publication of JP2023085797A publication Critical patent/JP2023085797A/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)
  • Computer And Data Communications (AREA)

Abstract

To provide an information processing program, an information processing device, and an information processing method that speed up communication by performing application processing and data transmission in a non-blocking manner.SOLUTION: A server device 1 has buffering means 106 for accumulating events, socket writing means 102 for processing an event, and flag management means 107 for setting a flag exclusively. The socket writing means 102 includes socket writing request means 102a and callback processing means 102b. The flag management means 107 exclusively sets the flag at timing before the socket writing request means 102a starts processing the event, and cancels the flag at timing after the processing of the callback processing means 102b ends. The socket writing request means 102a accepts a call, and processes the events accumulated by the buffering means 106 when the flag is set.SELECTED DRAWING: Figure 2

Description

本発明は、情報処理プログラム、情報処理装置及び情報処理方法に関する。 The present invention relates to an information processing program, an information processing apparatus, and an information processing method.

従来の技術として、データの大きさに応じて使用するバッファを変更してデータを送信する情報処理装置が提案されている(例えば、特許文献1参照)。 As a conventional technology, an information processing apparatus has been proposed that transmits data by changing the buffer to be used according to the size of the data (see, for example, Japanese Unexamined Patent Application Publication No. 2002-100002).

特許文献1に開示された情報処理装置のCPU(Central Processing Unit)は、アプリケーションバッファエリアを占有するアプリケーションタスクとリングバッファエリアを占有するTCP(Transmission Control Protocol)/IP(Internet Protocol)タスクとを並列的に実行する。アプリケーションタスクは、データ生成処理によってアプリケーションバッファエリアに格納されたデータのサイズが閾値以下であるか否かを判別し、判別結果が肯定的であるときアプリケーションバッファエリア上のデータをリングバッファエリアに複製してデータ送信指示を発行する一方、判別結果が否定的であるときアプリケーションバッファエリアの占有権をTCP/IPタスクに一時的に付与してデータ送信指示を発行する。TCP/IPタスクは、自ら占有するメモリエリア上の送信データをデータ送信指示に応答して送信する。 A CPU (Central Processing Unit) of the information processing apparatus disclosed in Patent Document 1 parallelizes an application task that occupies an application buffer area and a TCP (Transmission Control Protocol)/IP (Internet Protocol) task that occupies a ring buffer area. execute The application task determines whether the size of the data stored in the application buffer area by the data generation process is equal to or less than a threshold value, and copies the data in the application buffer area to the ring buffer area when the determination result is positive. On the other hand, when the determination result is negative, the right to occupy the application buffer area is temporarily given to the TCP/IP task and the data transmission instruction is issued. The TCP/IP task transmits transmission data on the memory area it occupies in response to the data transmission instruction.

特開2010-55214号公報JP 2010-55214 A

しかし、特許文献1の情報処理装置は、送信するデータ量が少ない場合はリングバッファを用いてデータを送信して、アプリケーションタスクを並列して行い、送信するデータ量が多い場合はTCP/IPタスクを専有的に処理することで通信速度の高速化を図るものの、送信するデータ量が多い場合はアプリケーションタスクがブロッキングされて処理されない、という問題がある。 However, when the amount of data to be transmitted is small, the information processing apparatus of Patent Document 1 transmits data using a ring buffer and performs application tasks in parallel. However, if the amount of data to be sent is large, the application task will be blocked and will not be processed.

従って本発明の目的は、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化する情報処理プログラム、情報処理装置及び情報処理方法を提供することにある。 SUMMARY OF THE INVENTION Accordingly, it is an object of the present invention to provide an information processing program, an information processing apparatus, and an information processing method that speed up communication by executing application processing and data transmission in a non-blocking manner.

本発明の一態様は、上記目的を達成するため、以下の情報処理プログラム、情報処理装置及び情報処理方法を提供する。 One aspect of the present invention provides the following information processing program, information processing apparatus, and information processing method in order to achieve the above object.

[1]コンピュータを、
処理対象とするイベントを蓄積するイベント蓄積手段と、
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段として機能させ、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了し
た場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記イベント処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理プログラム。
[2]前記バッファリング手段は、イベントを蓄積する第1のバッファリング手段と、前記第1のバッファリング手段に蓄積された前記イベントを蓄積する第2のバッファリング手段とを有し、
前記処理要求手段は、フラグが立てられた場合に、前記第1のバッファリング手段から前記第2のバッファリング手段に前記イベントを移動して蓄積し、前記第2のバッファリング手段が蓄積している前記イベントの全て又は一部を処理する前記[1]に記載の情報処理プログラム。
[3]前記第1のバッファリング手段と前記第2のバッファリング手段の間、前記第1のバッファリング手段の前段又は前記第2のバッファリング手段の後段に、さらに1以上のバッファリング手段を有する前記[2]に記載の情報処理プログラム。
[4]前記バッファリング手段間の移動において、データブロックのサイズ、個数、タイプ、イベント保持形式の少なくとも1つを変更する前記[2]又は[3]に記載の情報処理プログラム。
[5]前記バッファリング手段間の移動において、移動イベントの数やサイズを予め定めた条件で制限する前記[2]~[4]のいずれかに記載の情報処理プログラム。
[6]前記バッファリング手段は、イベント蓄積手段のイベント蓄積動作と、前記処理手段の処理動作とが、非同期に実行される前記[1]から[5]のいずれかに記載の情報処理プログラム。
[7]前記バッファリング手段は、並列動作する複数のイベント生成元が実行するそれぞれのイベントの蓄積手段が非同期にイベントを蓄積する前記[1]から[6]のいずれかに記載の情報処理プログラム。
[8]前記バッファリング手段は、リングバッファである前記[1]から[7]のいずれかに記載の情報処理プログラム。
[9]前記バッファリング手段は、前記イベントそのものをメモリ領域に順次蓄積するリングバッファである前記[1]に記載の情報処理プログラム。
[10]前記バッファリング手段は、2段リングバッファ構成であり、第1段のリングバッファは並列動作するイベント蓄積手段のイベントを蓄積し、第2段のリングバッファは前記処理手段の処理に応じて定められたサイズに当該イベントを連結および分割するとともに前記処理手段に応じて定められた個数保持する前記[2]、[6]又は[7]に記載の情報処理プログラム。
[11]前記バッファリング手段は、ダイレクトバッファに前記イベントを格納することを特徴とする前記[1]、[2]又は[6]から[10]のいずれかに記載の情報処理プログラム。
[12]前記バッファリング手段は、バッファプールのバッファに前記イベントを蓄積する前記[1]、[2]又は[6]から[10]のいずれかに記載の情報処理プログラム。
[13]前記バッファリング手段は、前記第1段のリングバッファと前記第2段のリングバッファとで、異なるバッファサイズを保持するバッファプールのバッファにイベントを蓄積する前記[10]に記載の情報処理プログラム。
[14]前記処理手段は、蓄積されている前記イベントをすべて処理してからイベント処理を終了する前記[1]から[13]のいずれかに記載の情報処理プログラム。
[15]処理対象とするイベントを蓄積するイベント蓄積手段と、
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段とを有し、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了し
た場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記イベント処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理装置。
[16]コンピュータを、
処理対象とするイベントを蓄積するイベント蓄積ステップと、
前記イベントを蓄積するバッファリングステップと、
前記蓄積したイベントを処理する処理ステップと、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理ステップとを有し、
前記処理ステップは、イベントの処理を要求する処理要求ステップと、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理ステップとを含み、
前記フラグ管理ステップは、前記イベント処理要求ステップにおけるイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理ステップにおける処理の終了後のタイミングでフラグを解除し、
前記処理要求ステップは、前記イベント蓄積ステップにおけるイベント蓄積終了後のタイミング及び前記コールバック処理ステップにおけるイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は蓄積した前記イベントを処理する情報処理方法。
[1] a computer,
event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
act as a flag manager that accepts calls and sets flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means exclusively sets the flag at a timing before the event processing requesting means starts processing the event, and cancels the flag at the timing after the processing of the callback processing means ends,
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. an information processing program for terminating without processing if the flag is not set, and processing the event accumulated by the buffering means if the flag is set.
[2] The buffering means has a first buffering means for accumulating events and a second buffering means for accumulating the events accumulated in the first buffering means,
The processing request means moves and accumulates the event from the first buffering means to the second buffering means when the flag is set, and the second buffering means accumulates the event. The information processing program according to [1], which processes all or part of the event.
[3] One or more buffering means are further provided between the first buffering means and the second buffering means, before the first buffering means, or after the second buffering means. The information processing program according to [2] above.
[4] The information processing program according to [2] or [3], wherein at least one of data block size, number, type, and event holding format is changed in the movement between the buffering means.
[5] The information processing program according to any one of [2] to [4], wherein the number and size of movement events in movement between the buffering means are restricted according to predetermined conditions.
[6] The information processing program according to any one of [1] to [5], wherein the event accumulation operation of the event accumulation means and the processing operation of the processing means are executed asynchronously in the buffering means.
[7] The information processing program according to any one of [1] to [6], wherein the buffering means stores events asynchronously by respective event storage means executed by a plurality of event generators operating in parallel. .
[8] The information processing program according to any one of [1] to [7], wherein the buffering means is a ring buffer.
[9] The information processing program according to [1], wherein the buffering means is a ring buffer that sequentially accumulates the event itself in a memory area.
[10] The buffering means has a two-stage ring buffer structure, the first stage ring buffer stores events of the event storage means operating in parallel, and the second stage ring buffer responds to the processing of the processing means. The information processing program according to the above [2], [6], or [7], which connects and divides the event into a size determined by the above and holds the number of events determined according to the processing means.
[11] The information processing program according to any one of [1], [2], or [6] to [10], wherein the buffering means stores the event in a direct buffer.
[12] The information processing program according to any one of [1], [2], or [6] to [10], wherein the buffering means accumulates the event in a buffer of a buffer pool.
[13] The information according to [10], wherein the buffering means accumulates events in buffers of buffer pools holding different buffer sizes for the first stage ring buffer and the second stage ring buffer. processing program.
[14] The information processing program according to any one of [1] to [13], wherein the processing means finishes event processing after processing all the accumulated events.
[15] event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
a flag management means for accepting calls and setting flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means exclusively sets the flag at a timing before the event processing requesting means starts processing the event, and cancels the flag at the timing after the processing of the callback processing means ends,
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. If the flag is not set, the information processing device ends without processing, and if the flag is set, the event accumulated by the buffering means is processed.
[16] a computer;
an event accumulation step for accumulating events to be processed;
a buffering step of accumulating the events;
a processing step of processing the accumulated events;
a flag management step for accepting and exclusively flagging calls;
The processing step includes a processing request step that requests processing of the event, and a callback processing step that is executed upon receiving a completion notification when processing of the event is completed,
The flag management step exclusively sets the flag at a timing before the start of event processing in the event processing request step, and releases the flag at a timing after the processing in the callback processing step ends,
The process request step accepts a call at the timing after the event accumulation in the event accumulation step ends and the event processing in the callback processing step ends, and if the flag is not set, the process is not performed. an information processing method for processing the accumulated event if set.

請求項1、15、16に係る発明によれば、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化することができる。 According to the inventions according to claims 1, 15, and 16, application processing and data transmission can be executed in a non-blocking manner to speed up communication.

図1は、実施の形態に係る通信管理システムの構成の一例を示す概略図である。FIG. 1 is a schematic diagram showing an example of the configuration of a communication management system according to an embodiment. 図2は、実施の形態に係るサーバ装置の構成例を示すブロック図である。FIG. 2 is a block diagram illustrating a configuration example of a server device according to the embodiment; 図3は、データ送受信の動作の一例を説明するための概略図である。FIG. 3 is a schematic diagram for explaining an example of data transmission/reception operations. 図4は、データ送信動作の一例を説明するための概略図である。FIG. 4 is a schematic diagram for explaining an example of data transmission operation. 図5は、レイヤ構成の変形例を示す概略図である。FIG. 5 is a schematic diagram showing a modification of the layer configuration. 図6は、ソケット書込要求手段の動作例を説明するためのフローチャートである。FIG. 6 is a flow chart for explaining an operation example of the socket write request means. 図7は、コールバック処理手段の動作例を説明するためのフローチャートである。FIG. 7 is a flow chart for explaining an operation example of the callback processing means. 図8は、ソケット書込要求手段の動作例を説明するためのフローチャートである。FIG. 8 is a flow chart for explaining an operation example of the socket write request means. 図9は、データ送受信の動作の別の一例を説明するための概略図である。FIG. 9 is a schematic diagram for explaining another example of the data transmission/reception operation. 図10は、データ送信動作の別の一例を説明するための概略図である。FIG. 10 is a schematic diagram for explaining another example of the data transmission operation. 図11は、ソケット書込要求手段の別の動作例を説明するためのフローチャートである。FIG. 11 is a flow chart for explaining another operation example of the socket write request means. 図12は、コールバック処理手段の別の動作例を説明するためのフローチャートである。FIG. 12 is a flow chart for explaining another operation example of the callback processing means. 図13は、ソケット書込要求手段の別の動作例を説明するためのフローチャートである。FIG. 13 is a flow chart for explaining another operation example of the socket write request means.

[第1の実施の形態]
(通信管理システムの構成)
図1は、実施の形態に係る通信管理システムの構成の一例を示す概略図である。
[First embodiment]
(Configuration of communication management system)
FIG. 1 is a schematic diagram showing an example of the configuration of a communication management system according to an embodiment.

この通信管理システムは、情報処理装置としてのサーバ装置1と、当該サーバ装置1のクライアントとしての端末装置2a、2b、2cとをネットワークによって互いに通信可能に接続することで構成される。通信管理システムに含まれる装置は、パソコン、ゲーム端末、クラウド、仮想マシンであってもよい。ネットワークは、LANやインターネットであってもよいし、仮想ネットワークなどであってもよい。 This communication management system is configured by connecting a server device 1 as an information processing device and terminal devices 2a, 2b, and 2c as clients of the server device 1 so as to be able to communicate with each other via a network. Devices included in the communication management system may be personal computers, game terminals, clouds, and virtual machines. The network may be a LAN, the Internet, or a virtual network.

サーバ装置1は、サーバ型の情報処理装置であり、操作者の操作する端末装置2a、2b、2cの要求に応じて動作するものであって、本体内に情報を処理するための機能を有するCPU(Central Processing Unit)やHDD(Hard Disk Drive)又はフラッシュメモリ、揮発性メモリ、LANボード(無線/有線)等の電子部品を備える。サーバ装置1は、端末装置2a、2b、2cと通信し、データの送受信を行うことで端末装置2a、2b、2c上で扱うデータの同期を行うものであって、例えば、ゲームサーバ等である。サーバ装置1は、同期動作を行う場合は容量の小さいデータを頻繁にやりとりするものであるが、これに限られるものではない。なお、サーバ装置1は、複数のクラスタによって構成してもよく、分散処理を実行するよう構成してもよい。あるいは、クラウド環境において仮想マシンとして構成してもよい。 The server device 1 is a server-type information processing device that operates in response to requests from terminal devices 2a, 2b, and 2c operated by an operator, and has a function for processing information within its main body. It includes electronic components such as a CPU (Central Processing Unit), HDD (Hard Disk Drive), flash memory, volatile memory, and LAN board (wireless/wired). The server device 1 communicates with the terminal devices 2a, 2b, and 2c to transmit and receive data, thereby synchronizing data handled on the terminal devices 2a, 2b, and 2c, and is, for example, a game server. . The server device 1 frequently exchanges small-capacity data when performing a synchronous operation, but is not limited to this. Note that the server apparatus 1 may be configured by a plurality of clusters, and may be configured to execute distributed processing. Alternatively, it may be configured as a virtual machine in a cloud environment.

端末装置2a、2b、2cは、端末型の情報処理装置であり、プログラムに基づいて動作するものであって、本体内に情報を処理するための機能を有するCPUやHDD又はフラッシュメモリ等の電子部品を備える。端末装置2a、2b、2cは、例えば、MMOG(Massively Multiplayer Online Game)等のプログラムに基づいて動作し、動作の結果としてデータをサーバ装置1に対して逐次出力するとともに、サーバ装置1から他の端末の動作の結果としてのデータを受信して各端末装置2a、2b、2c間で高頻度にゲームオブジェクトを同期するものである。なお、端末装置2a、2b、2cは3つの装置で描かれているが単一あるいは2個の装置であってもよいし、4以上の装置で構成してもよく、好ましくは、1000台オーダーの端末装置が接続されるような場合であっても通信可能な構成を提供する。 The terminal devices 2a, 2b, and 2c are terminal-type information processing devices that operate based on programs, and have electronic devices such as CPUs, HDDs, or flash memories that have functions for processing information in their main bodies. Have parts. The terminal devices 2a, 2b, and 2c operate, for example, based on a program such as MMOG (Massively Multiplayer Online Game), sequentially output data to the server device 1 as a result of the operation, and output data from the server device 1 to other devices. It receives data as a result of terminal operations and synchronizes game objects frequently among the terminal devices 2a, 2b, and 2c. Although the terminal devices 2a, 2b, and 2c are depicted as three devices, they may be composed of a single device or two devices, or may be composed of four or more devices, preferably on the order of 1000 units. To provide a configuration capable of communication even when a terminal device is connected.

ネットワーク4は、高速通信が可能な通信ネットワークであり、例えば、イントラネットやLAN(Local Area Network)等の有線又は無線の通信網である。 The network 4 is a communication network capable of high-speed communication, and is, for example, a wired or wireless communication network such as an intranet or a LAN (Local Area Network).

一例として、第1の実施の形態における通信管理システムにおいて、複数の参加者が共通の仮想空間における活動、例えばゲームを行う多人数参加型ゲームが実行される。サーバ装置1及び端末装置2a、2b、2cは、ゲームの進行に伴い各装置内でオブジェクトとして保持している情報(同期対象オブジェクト)を、各装置間で同期するために動作し、特にサーバ装置1は、データ通信を高速化すべくアプリケーションとNIC(Network Interface Card)との間にバッファを設けてアプリケーションとNIC間のデータ授受の動作を制御する。言い換えれば、マルチプロセス、マルチスレッドが、共有リソース(ソケットやNIC)に非同期に書き込む要求が大量に発生する場合、データが混ざらないようにシリアライズするには、排他制御が必要となるため、送信通信路を効率よく使用(特に、送信通路がデータで混雑してからのスループット向上)するために、バッファにバッファリングして、当該バッファへの書込で排他制御(ブロッキング)を行い、当該バッファからの共有リソースへの書込はCAS(Compare and Swap)等でロックフリー(ノンブロッキング)な制御をする。動作の詳細について、実施の形態において具体的に説明する。 As an example, in the communication management system according to the first embodiment, a multiplayer game is executed in which a plurality of participants play an activity, such as a game, in a common virtual space. The server device 1 and the terminal devices 2a, 2b, and 2c operate to synchronize information (synchronized objects) held as objects in each device as the game progresses. 1 provides a buffer between an application and a NIC (Network Interface Card) to speed up data communication, and controls the operation of data transfer between the application and the NIC. In other words, when a large number of requests to asynchronously write to shared resources (sockets and NICs) are generated by multiple processes and multiple threads, exclusive control is required to serialize data so that data is not mixed. In order to efficiently use the path (especially to improve throughput after the transmission path is congested with data), buffering is performed in a buffer, exclusive control (blocking) is performed on writing to the buffer, and data is written from the buffer. Write to the shared resource is controlled in a lock-free (non-blocking) manner by CAS (Compare and Swap) or the like. Details of the operation will be specifically described in an embodiment.

また、第1の実施の形態において使用する「オブジェクト」等の語句は、例えば、Java(登録商標)、C++、C#、Python、JavaScript(登録商標)、Ruby等で用いられる同語句と同義で用いられるが、以降、クラス、及びインスタンス化されたクラス(インスタンス)のことを総称して「オブジェクト」と言う場合がある。 In addition, terms such as “object” used in the first embodiment are synonymous with synonyms used in, for example, Java (registered trademark), C++, C#, Python, JavaScript (registered trademark), Ruby, and the like. Although used, hereinafter, classes and instantiated classes (instances) may be collectively referred to as "objects."

(サーバ装置の構成)
図2は、第1の実施の形態に係るサーバ装置1の構成例を示すブロック図である。以下にサーバ装置1での実装について記述するが、端末装置2a、2b、2cも同様な構成としてもよい。
(Configuration of server device)
FIG. 2 is a block diagram showing a configuration example of the server device 1 according to the first embodiment. Although the implementation in the server device 1 will be described below, the terminal devices 2a, 2b, and 2c may also have the same configuration.

サーバ装置1は、CPU(Central Processing Unit)等から構成され、各部を制御するとともに、各種のプログラムを実行する制御部10と、フラッシュメモリ等の記憶媒体から構成され情報を記憶する記憶部11と、揮発性記録媒体から構成され一時的に情報を記憶するメモリ12と、ネットワークを介して外部と通信する通信部13とを備える。 The server device 1 is composed of a CPU (Central Processing Unit) and the like, and includes a control unit 10 that controls each unit and executes various programs, and a storage unit 11 that is composed of a storage medium such as a flash memory and stores information. , a memory 12 configured from a volatile recording medium for temporarily storing information, and a communication section 13 for communicating with the outside via a network.

制御部10は、OS(Operating System)110を実行することで、OS実行手段100(Javaの場合はJVMも含む)として機能し、アプリケーション112を実行することで、アプリケーション実行手段103、アプリケーション読出手段104、アプリケーション書込手段105として機能し、情報処理プログラムとしての通信管理プログラム111を実行することで、ソケット読出手段101、ソケット書込手段102、バッファリング手段106(受信バッファ106aと送信バッファ106bを含む)、フラグ管理手段107等として機能する。 The control unit 10 functions as an OS execution means 100 (including JVM in the case of Java) by executing an OS (Operating System) 110, and by executing an application 112, an application execution means 103 and an application reading means. 104, functions as application writing means 105, and executes a communication management program 111 as an information processing program to perform socket reading means 101, socket writing means 102, buffering means 106 (receiving buffer 106a and transmitting buffer 106b). ), and functions as flag management means 107 and the like.

OS実行手段100(OSカーネル)は、OS110を実行し、OS110が有する各機能を提供する。OS実行手段100は、特に通信部13(NIC)を制御してネットワークにデータを送信し、ネットワークからデータを受信する。なお、JAVAを利用している場合は、Java VMもOSの一部とみなし、OS実行手段100によって実行されるものとする。 The OS executing means 100 (OS kernel) executes the OS 110 and provides each function of the OS 110 . The OS executing means 100 particularly controls the communication unit 13 (NIC) to transmit data to the network and receive data from the network. Note that when JAVA is used, the Java VM is also regarded as part of the OS and is executed by the OS execution means 100 .

アプリケーション実行手段103は、処理手段としてアプリケーション112を実行し、アプリケーション112が有する各機能を提供するものであり、実行に伴い単一又は複数のスレッドを処理する。典型的には、それぞれのスレッドは、単一又は複数の端末装置とそれぞれ対応する単一又は複数のソケット(端末装置2a、2b、又は、2cの通信対象プログラムのIPアドレス及びポート番号)を介してネットワーク通信(送受信)を行う。 The application execution means 103 executes the application 112 as a processing means, provides each function of the application 112, and processes a single thread or a plurality of threads during execution. Typically, each thread communicates through a single or multiple sockets (IP address and port number of the communication target program of the terminal device 2a, 2b, or 2c) respectively corresponding to single or multiple terminal devices. network communication (send/receive).

アプリケーション読出手段104は、アプリケーション112が有する機能として特に、スレッドの受信処理のために受信対象となるソケット(端末装置2a、2b、又は、2c)に対応する受信バッファ106aのデータを読み出す。 As a function of the application 112, the application reading unit 104 reads data of the receiving buffer 106a corresponding to the receiving socket (terminal device 2a, 2b, or 2c) for receiving processing of the thread.

アプリケーション書込手段105は、スレッドの処理の結果生成されたデータを送信対象となるソケット(端末装置2a、2b、又は、2c)に対応する送信処理のために送信バッファに書き込む。書き込まれたデータは通常は書き込まれた順に送信バッファ121bに追加される。例えば、ゲームサーバがゲームオブジェクトの同期処理のため、同期情報のリレー処理を行う場合、アプリケーション書込手段105は、端末装置2aから同期情報のデータ受信し、スレッドで受信データを処理した結果、端末装置2b、及び、2cに同期情報データを送信する。アプリケーション書込手段105は、それぞれの端末装置に対応する2個のソケットに対応する2個の送信バッファ121bにデータを書き込む。アプリケーション書込手段105は、送信バッファ121bにデータを追加した後、ソケット書込要求手段102aを呼び出す。 The application writing unit 105 writes the data generated as a result of the processing of the thread into the transmission buffer for transmission processing corresponding to the socket (terminal device 2a, 2b, or 2c) to be transmitted. The written data are normally added to the transmission buffer 121b in the order in which they were written. For example, when the game server performs relay processing of synchronization information for synchronization processing of game objects, the application writing means 105 receives synchronization information data from the terminal device 2a, processes the received data in a thread, and outputs the data to the terminal device. Synchronization information data is transmitted to the devices 2b and 2c. Application writing means 105 writes data to two transmission buffers 121b corresponding to two sockets corresponding to respective terminal devices. After adding the data to the transmission buffer 121b, the application writing means 105 calls the socket write request means 102a.

ソケット読出手段101は、OS110が有する機能として特に、ネットワークとの通信においてソケットによって受信したデータを後述する受信バッファ106aに読み出す。 As a function of the OS 110, the socket reading means 101 reads data received by a socket in communication with the network into a reception buffer 106a, which will be described later.

処理手段としてのソケット書込手段102は、処理要求手段としてのソケット書込要求手段102aとコールバック処理手段102bとして機能する。 Socket writing means 102 as processing means functions as socket writing request means 102a and callback processing means 102b as processing request means.

図6及び図8は、ソケット書込要求手段102aの動作例を説明するためのフローチャートである。また、図7は、コールバック処理手段102bの動作例を説明するためのフローチャートである。 6 and 8 are flow charts for explaining an operation example of the socket write request means 102a. Also, FIG. 7 is a flow chart for explaining an operation example of the callback processing means 102b.

図6に示すように、ソケット書込要求手段102aは、まず、フラグ管理手段107に依頼して、フラグ管理手段107の管理するフラグの状態を確認し(S10)、フラグが解除されている場合(S11;Yes)、フラグを立てる(S12)。ソケット書込要求手段102aは、アプリケーション書込手段105がイベントをリングバッファ121bに書き込み処理を終了する直前、及びソケット書込要求手段102aの完了後に実行される対応するコールバック処理手段102bの完了直前のいずれかから非同期に呼び出される。呼び出しは通常のメソッドあるいは関数の呼び出しでもよいし、あるいは、OS機能を使い待機しているスレッドへのシグナリングによる起動でもよい。フラグが立てられると、次に、ソケット書込要求手段102aは、ネットワークとの通信により送信するデータを送信バッファ106bからソケットに書き込んで、OS実行手段100にイベントの処理を要求する(S13)。もし、フラグ管理手段107の管理しているフラグがすでに立っている場合は(S11;No)、処理を直ちに終了する。なお、ここでは理解の容易性のため、フラグの検査S10/S11とフラグの変更S12を3個の別ブロックとして説明したが、マルチスレッド環境では、フラグの検査S10とフラグのセットS12の間に別スレッドがスイッチされて割り込むと、複数のスレッドそれぞれがフラグを立てた状態にして(S12)、自分のスレッドがフラグを立てたつもりになってイベント処理(S13)を実行するので、同時時期に、イベント処理(S13)を複数回実行してしまう可能性があり不都合である。この問題を解決するために、本発明では、ブロッキングによってソケット書込手段102a実行を排他制御するかわりに、後述するようなフラグ管理手段107が提供するCAS(Compare and swap)の機能を利用して、フラグの検査(S10/S11)と変更設定(S12)を単一のCPU命令で実行し、S10・S11・S12の処理の間に他のスレッドが実行されない工夫を行っている。 As shown in FIG. 6, the socket write requesting means 102a first requests the flag managing means 107 to check the state of the flag managed by the flag managing means 107 (S10). (S11; Yes), set a flag (S12). The socket write requesting means 102a writes the event to the ring buffer 121b immediately before the application writing means 105 finishes writing the event to the ring buffer 121b, and immediately before the completion of the corresponding callback processing means 102b executed after the completion of the socket write requesting means 102a. Called asynchronously from either The call may be a normal method or function call, or it may be signaled to a waiting thread using an OS facility. When the flag is set, the socket write request means 102a next writes the data to be transmitted by communication with the network from the transmission buffer 106b to the socket, and requests the OS execution means 100 to process the event (S13). If the flag managed by the flag management means 107 is already set (S11; No), the process is terminated immediately. For ease of understanding, the flag checking S10/S11 and the flag changing S12 have been described as three separate blocks. When another thread is switched and interrupted, each of the plurality of threads sets a flag (S12), and the own thread executes event processing (S13) as if the flag was set. , the event processing (S13) may be executed multiple times, which is inconvenient. In order to solve this problem, in the present invention, a CAS (Compare and Swap) function provided by the flag management means 107 as described later is used instead of exclusively controlling the execution of the socket writing means 102a by blocking. , flag inspection (S10/S11) and change setting (S12) are executed by a single CPU command, and other threads are devised so that other threads are not executed between the processing of S10, S11, and S12.

また、図8に示すように、ソケット書込要求手段102aは、ステップS13において送信バッファ106bに送信対象のデータがあるか確認し(S30)、送信対象のデータがある場合(S30;Yes)、OS実行手段100にOS非同期送信要求を行ってイベントの処理を要求する(S31)。また、ソケット書込要求手段102aは、送信対象のデータがない場合(S30;No)、フラグ管理手段107に依頼して、フラグを解除する(S32)。 Further, as shown in FIG. 8, the socket write request means 102a checks whether or not there is data to be transmitted in the transmission buffer 106b in step S13 (S30). An OS asynchronous transmission request is issued to the OS executing means 100 to request event processing (S31). If there is no data to be transmitted (S30; No), socket write request means 102a requests flag management means 107 to clear the flag (S32).

図7に示すように、コールバック処理手段102bは、OS実行手段100がソケット書込要求手段102aにより依頼された書込イベントの処理(図8のS31)を完了した場合に、OS実行手段100から完了通知を受け付けて(非同期に)実行する。OS実行手段100が実行したネットワーク送信結果を受け取る(S20)。送信結果が正常の場合は(S21;Yes)、コールバック処理手段102bは、送信完了分を送信バッファから除外する(S22)。引き続き、コールバック処理手段102bは、フラグ管理手段107に依頼して、フラグを解除する(S23)。引き続き、コールバック処理手段102bは、送信バッファに送信対象データが存在することを確認する(S24)。確認結果が肯定的であれば(送信バッファにデータがあれば)(S24;Yes)、コールバック処理手段102bは、ソケット書込要求手段102aに呼び出しを行う(S25)。確認結果が否定的であれば(S24;No)、コールバック処理手段102bは、処理を終了する。送信結果が異常の場合は(S21;No)、コールバック処理手段102bは、通信断、タイムアウトなどの例外処理(接続の切断など)を行う(S26)。 As shown in FIG. 7, the callback processing means 102b, when the OS execution means 100 completes the processing of the write event requested by the socket write request means 102a (S31 in FIG. 8), the OS execution means 100 Receive a completion notification from (asynchronously) and execute. The network transmission result executed by the OS executing means 100 is received (S20). If the transmission result is normal (S21; Yes), the callback processing means 102b removes the completed transmission from the transmission buffer (S22). Subsequently, the callback processing means 102b requests the flag management means 107 to clear the flag (S23). Subsequently, the callback processing means 102b confirms that there is data to be transmitted in the transmission buffer (S24). If the confirmation result is affirmative (if there is data in the transmission buffer) (S24; Yes), the callback processing means 102b calls the socket write request means 102a (S25). If the confirmation result is negative (S24; No), the callback processing means 102b terminates the process. If the transmission result is abnormal (S21; No), the callback processing means 102b performs exceptional processing (disconnection, etc.) such as disconnection of communication or timeout (S26).

ソケット書込要求手段102a及びコールバック処理手段102bの他の実装としては、以下のように構成してもよい。例えば、コールバック処理手段102bは、OS実行手段100がソケット書込要求手段102aの書込イベントの処理を完了した場合に完了通知を受け付けて(非同期に)実行された送信結果を受け取る。送信結果が異常の場合は、通信断、タイムアウトなどの例外処理(接続の切断など)を行い、終了する。送信結果が正常の場合は、送信完了分を送信バッファから削除する。引き続き、コールバック処理手段102bは、送信バッファに送信対象データが存在することを確認し、確認結果が肯定的であれば、ソケット書込要求手段102aに呼び出しを行う。確認結果が否定的であれば、フラグ管理手段107に依頼して、フラグを解除して処理を終了する。 Another implementation of the socket write request means 102a and the callback processing means 102b may be configured as follows. For example, the callback processing unit 102b receives a completion notification when the OS execution unit 100 completes the processing of the write event of the socket write request unit 102a (asynchronously) and receives the executed transmission result. If the transmission result is abnormal, perform exception processing such as disconnection or timeout (disconnection, etc.), and terminate. If the transmission result is normal, delete the completed transmission from the transmission buffer. Subsequently, the callback processing means 102b confirms that the transmission target data exists in the transmission buffer, and if the confirmation result is affirmative, calls the socket write request means 102a. If the confirmation result is negative, the flag management means 107 is requested to cancel the flag, and the process ends.

バッファリング手段106は、メモリ12に2種類のバッファ領域、受信バッファ106aと送信バッファ106bを用意し、どちらも読み出し及び書き出しの対象を提供するとともに、読み出し及び書き出しをするデータを管理する。バッファを介することでバッファに対する読み出しと書き出しとを非同期に行うことができる。受信バッファ106aは、ソケット読出手段101が書き込み、アプリケーション読出手段104が読み出す。送信バッファ106bは、アプリケーション書込手段105が書き込み、ソケット書込手段102が読み出す。なお、バッファリング手段106(106a及び106b)は、データをノンブロッキングに読み書きする。バッファに必要なメモリを都度実行時に割り当てるのはCPUの効率が悪いので、事前に大きなメモリ領域(1個以上のブロック)を確保して、それを細分化したメモリチャンクをバッファプールに追加してバッファプールを用いた独自のメモリ管理をし、確保済のメモリブロックを再利用して使い回し、実行時の処理効率を向上させるのは一般的である。また、これらのメモリチャンクを組合せて、論理的にリングバッファを構成することも一般的である。ここでは、バッファ領域はバッファプールの一種であるリングバッファ121(受信バッファ106aとして受信リングバッファ121a、及び、送信バッファ106bとして送信リングバッファ121b)を用いた場合について説明するが、必ずしもリングバッファである必要はなく、論理的に無限長のバッファを提供できるバッファであればよく、好ましくはOSカーネルでの処理に好適なダイレクトバッファ等のヒープ領域外のメモリ領域に作成される高速に入出力が可能な一時記憶領域を用いる。 The buffering means 106 prepares two types of buffer areas in the memory 12, a receive buffer 106a and a transmit buffer 106b, both of which provide targets for reading and writing and manage data to be read and written. By using the buffer, reading and writing to the buffer can be performed asynchronously. The receiving buffer 106 a is written by the socket reading means 101 and read by the application reading means 104 . The transmission buffer 106b is written by the application writing means 105 and read by the socket writing means 102. FIG. The buffering means 106 (106a and 106b) reads and writes data in a non-blocking manner. It is inefficient for the CPU to allocate the memory required for the buffer each time it is executed. It is common to manage memory independently using a buffer pool, reuse and reuse allocated memory blocks, and improve processing efficiency during execution. It is also common to logically configure a ring buffer by combining these memory chunks. Here, the case where the ring buffer 121 (a receiving ring buffer 121a as the receiving buffer 106a and a transmitting ring buffer 121b as the transmitting buffer 106b), which is a kind of buffer pool, is used as the buffer area will be described, but the ring buffer is not necessarily used. There is no need, any buffer that can logically provide an infinite length buffer can be used. Preferably, a direct buffer suitable for processing in the OS kernel is created in a memory area outside the heap area, enabling high-speed input/output. temporary storage area.

ダイレクトバッファは、実メモリ空間に存在するため、OSの処理実行においては、ダイレクトバッファ上のデータ処理は、仮想メモリ空間に存在する通常の非ダイレクトバッファ上のデータ処理に比べて、内部的なメモリ操作回数を削減し、処理時間を短くできることが知られている。なお、ダイレクトバッファは、非ダイレクトバッファに比べて、アプリケーションにとっては、メモリの割当・解放にOSの処理時間がかかることが知られている。特にダイレクトバッファの場合は、アプリケーションがメモリの割当・解放を高頻度に実行するのは適切ではなく、後述のバッファプールなどを活用して、事前に確保したメモリを使い回すことが望ましい。また、ダイレクトバッファはOSの処理対象としては好適であるが、一方で、アプリケーションの処理対象において、ダイレクトバッファのメモリアクセス(メモリ読取及びメモリ書込)は非ダイレクトバッファのメモリアクセスに比べて時間がかかるため、通常の処理のためにダイレクトバッファを利用することは不適切であることも知られている。ダイレクトバッファは濫用せずに、OSに処理要求をするデータの格納に特化した使用に限定するのが好適である。また、ダイレクトバッファは、当該アプリケーションだけでなく、当該情報装置で実行する他のアプリケーションも利用する共用のリソースであり、濫用すると当該情報装置の他のアプリケーションの稼働に影響を与える可能性もあり、適切に使用量を節約することが望ましい。以上に第1の実施形態を念頭に好適な利用方法を例として示したが、本発明の利用方法を限定するものではない。 Since the direct buffer exists in the real memory space, data processing on the direct buffer in the execution of the OS process requires less internal memory than data processing on the normal non-direct buffer that exists in the virtual memory space. It is known that the number of operations can be reduced and the processing time can be shortened. It is known that the direct buffer requires more OS processing time to allocate and release memory than the non-direct buffer. Particularly in the case of direct buffers, it is not appropriate for applications to frequently allocate and release memory, and it is desirable to reuse pre-allocated memory by utilizing buffer pools, which will be described later. Direct buffers are suitable for processing by the OS. Therefore, it is also known that the use of direct buffers for normal processing is inappropriate. It is preferable not to overuse the direct buffer, but to limit its use to specialized storage of data for which processing requests are made to the OS. In addition, the direct buffer is a shared resource that is used not only by the application concerned, but also by other applications running on the information device. Appropriate usage savings are desirable. Although the preferred method of use has been shown above as an example with the first embodiment in mind, the method of use of the present invention is not limited.

次に、バッファプールとは、アプリケーションの実行時に素早く動的に必要なメモリ領域を確保するために、アプリケーションの起動時などにメインメモリの空き領域からある程度大きな領域を一括して、複数のメモリブロックとして確保したものとする。バッファプールは、メモリ管理をOSに依頼せず、アプリケーションとして実装し、メモリが必要になったときに、確保されているメモリブロックから適切なサイズのメモリ(メモリチャンク)を借り出し(メモリ割当)、使い終わって不要になったメモリはバッファプールに返却して再利用する(メモリ解放)。バッファプールは様々実装が知られている。通常、メモリブロックはページサイズなど大きなサイズなので、ここでは、アプリケーションで使いやすい1種類あるいは2種類以上の規格化されたサイズのメモリチャンクにあらかじめ分割して、バッファプールに登録する。チャンクサイズは、通常、ページサイズの2の累乗数分の1となるように調整する。2の累乗数分の1とすることで、メモリブロックを無駄なく分割できる。また、規格化されたチャンクサイズのメモリブロックを再利用することで、メモリフラグメンテーションの発生を回避できる。また、メモリをアプリケーションでバッファプールとして管理することは、必要な都度OSにメモリの割当、解放を利用する場合に比べて、個々のメモリ割当・解放に、OS呼出のオーバヘッドなどが発生しないので、メモリ割当・解放の処理が効率化されることが知られている。バッファプールを採用する場合、プールに登録するメモリチャンクのサイズ、種類、数は用途に応じてさまざまな設計方針が考えられる。以上に第1の実施形態を念頭に好適な利用方法を例として示したが、本発明の利用方法を限定するものではない。 Next, a buffer pool is a system that collects a certain amount of free space from the main memory and stores it in multiple memory blocks when an application starts, etc., in order to quickly and dynamically allocate the necessary memory space during application execution. shall be secured as The buffer pool is implemented as an application without relying on the OS for memory management. The memory that is no longer needed after being used is returned to the buffer pool and reused (memory release). Various implementations of the buffer pool are known. Since a memory block is usually a large size such as a page size, here, it is divided in advance into one or more standardized size memory chunks that are easy to use for applications, and registered in the buffer pool. The chunk size is usually adjusted to be one power of two of the page size. A memory block can be divided without waste by setting it to 1/2 by a power of 2. In addition, memory fragmentation can be avoided by reusing memory blocks of standardized chunk size. In addition, managing memory as a buffer pool by an application does not generate overhead such as calling the OS for individual memory allocation and release, compared to the case of using memory allocation and release to the OS each time it is necessary. It is known that memory allocation/release processing is made more efficient. When adopting a buffer pool, various design policies can be considered for the size, type, and number of memory chunks registered in the pool, depending on the application. Although the preferred method of use has been shown above as an example with the first embodiment in mind, the method of use of the present invention is not limited.

さて、第1の実施の形態では、バッファプールを用いる場合、メモリチャンクのサイズとして、OSの処理に適したサイズに規格化されたチャンクサイズ(例えば、ページサイズとしてメモリブロックそのまま、あるいは、その半分など)を利用し、メモリの種類としては、OSの処理に適したダイレクトバッファのメモリを利用する。OSの処理に適した大きなサイズ(例えば、ページサイズ)のメモリチャンクに、イベントデータをぎっしりと詰め込むことにより、非常に小さいサイズのイベントデータをそれぞれ別のチャンクに保持する場合に比べて、OSが提供する非同期送信機能としてAsynchronousSocketChannel.write() の集約書込(gathering write)に指定するメモリチャンクの数を効果的に削減し、また、OSでの処理効率はよくなる。OSは同じバイト数のデータを処理する場合、格納するチャンクの数が少ないほうが、内部的処理が速くなることが知られている。例えば、チャンクサイズは、ページサイズあるいはその半分など、より具体的には1KBや2KBなどの単一のサイズを採用する。また、OSの処理のために確保するメモリブロックの種類としては、ヒープに確保される通常のメモリ(非ダイレクトバッファ)ではなく、OSの処理に適したダイレクトバッファを使うとさらにOSでの処理効率がよい。ダイレクトバッファの採用は、バッファプールと組み合わせても、バッファプールを使わずにその都度メモリ割当・解放を行う場合でも使える技術であるが、バッファプールと組み合わせて使うことで、OSでの処理により適した技術となる。以上に第1の実施形態を念頭に好適な利用方法を例として示したが、本発明の利用方法を限定するものではない。 In the first embodiment, when a buffer pool is used, a chunk size standardized to a size suitable for OS processing is used as the size of the memory chunk (for example, the page size is the memory block as it is or half of it). etc.), and as the type of memory, a direct buffer memory suitable for OS processing is used. By cramming the event data into a large size (e.g., page size) memory chunk that is suitable for OS processing, the OS is able to handle the event data rather than holding each very small size event data in a separate chunk. As an asynchronous transmission function to be provided, AsynchronousSocketChannel. It effectively reduces the number of memory chunks specified for gathering writes of write( ) and improves the processing efficiency in the OS. It is known that when the OS processes the same number of bytes of data, the smaller the number of chunks stored, the faster the internal processing. For example, the chunk size adopts a single size such as the page size or half thereof, more specifically 1 KB or 2 KB. As for the type of memory block to be secured for OS processing, using a direct buffer suitable for OS processing instead of a normal memory (non-direct buffer) secured in the heap will further improve the processing efficiency of the OS. is good. Adopting a direct buffer is a technology that can be used both in combination with a buffer pool and in cases where memory is allocated and released each time without using the buffer pool. technology. Although the preferred method of use has been shown above as an example with the first embodiment in mind, the method of use of the present invention is not limited.

フラグ管理手段107は、例えば、CAS(Compare and Swap)等の手段により、フラグをアトミックに管理する。ここでアトミックとは、不可分操作を指し、具体的には、あるメモリ位置の内容と指定された値を比較し、等しければそのメモリ位置に別の指定された値を格納することを1命令で行うCPUの特別な命令を指す。フラグ管理手段107は、ソケット書込要求手段102aの要求によりOS実行手段100がイベント処理を開始するタイミングで排他的にフラグを立て(図6、S12)、イベントの処理の完了のタイミング(コールバック処理手段102bの処理)でフラグを解除する(図7のS23)。ちなみに、図8のS32でもフラグを解除しているがイベント処理を開始するタイミングでフラグをたてたが、イベント処理するデータが全くなかった場合の(例外)処理である。前述のように、図6に示す動作をするので、フラグ管理手段107の機能により、ソケット書込要求手段102a及びコールバック処理手段102bは、ひとつのソケットについては、両手段あわせて高々1個しか同時には実行しないように制御され、ソケットへの書込操作の整合性が保証される。フラグを立てたソケット書込要求手段102a、又は、当該ソケット書込要求手段102aに対応するコールバック処理手段102bが処理中の場合は、2個目以降のソケット書込要求手段102aの呼び出しは、フラグが立っている間は、フラグを自らが立てることができないので、処理を中断し、OS実行手段100への書き込みを行わずに終了(図6のS11;No)する。このため、ソケット書込要求手段102aは必ずしも自らのイベントについてOSに非同期送信呼び出しを実行できるとは限らないが、ノンブロッキングに実行し、イベントが送信できるようになるまで待たずに処理を終了する。ソケット書込要求手段102a自身が非同期送信呼び出しを実行できなかった場合でも、近い将来、実行中のソケット書込手段102(ソケット書込要求手段102aあるいはコールバック処理手段102b)が非同期送信呼び出しを結果的に実行する。すなわち、非同期送信呼び出しが実行されずにソケット書込要求手段102aが処理終了してしまっていたイベントについては、当該イベントが第1のバッファ121bに蓄積されたタイミングに依存して、すでにフラグを立てて排他的に実行中であるソケット書込要求手段102a自身、あるいは当該ソケット書込要求手段102aに対応するコールバック処理手段102bが、後に送信バッファが空でない場合に呼び出すソケット書込要求手段102aにより、非同期送信呼び出しがなされる。なお、前述のように、点線で囲まれたフラグの操作(状態確認や設定のステップS10,S11,S12)はマルチスレッド環境下で他スレッドによる割り込みによる影響がないようにアトミックに実行される必要があり、フラグ管理手段107が提供する(Compare and Swap)の機能を利用する。 The flag management means 107 manages flags atomically by means of, for example, CAS (Compare and Swap). Here, atomic refers to an indivisible operation. Specifically, one instruction compares the contents of a certain memory location with a specified value, and if they are equal, stores another specified value in that memory location. Refers to a special CPU instruction to perform. The flag management unit 107 sets a flag exclusively at the timing when the OS execution unit 100 starts event processing in response to a request from the socket write request unit 102a (FIG. 6, S12), and sets a flag at the timing of completion of event processing (callback The flag is cleared in the process of the processing means 102b (S23 in FIG. 7). Incidentally, even though the flag is cleared in S32 of FIG. 8, the flag is raised at the timing of starting the event processing, but this is (exception) processing when there is no data for the event processing. As described above, since the operation shown in FIG. 6 is performed, the socket write request means 102a and the callback processing means 102b are limited to one socket write request means 102a and one callback processing means 102b by the function of the flag management means 107. Concurrency is controlled to ensure consistency of write operations to sockets. If the flagged socket write request means 102a or the callback processing means 102b corresponding to the socket write request means 102a is in process, calling the second and subsequent socket write request means 102a Since the flag itself cannot be set while the flag is set, the process is interrupted and ends without writing to the OS execution means 100 (S11 in FIG. 6; No). For this reason, the socket write request means 102a cannot necessarily execute an asynchronous transmission call to the OS for its own event, but executes it in a non-blocking manner and ends processing without waiting until the event can be transmitted. Even if the socket write request means 102a itself cannot execute the asynchronous send call, the socket write means 102 (socket write request means 102a or callback processing means 102b) in execution will execute the asynchronous send call in the near future. execute That is, for an event for which processing by the socket write request means 102a has ended without the asynchronous transmission call being executed, the flag has already been set depending on the timing at which the event was accumulated in the first buffer 121b1 . Socket write request means 102a called by the socket write request means 102a itself or the callback processing means 102b corresponding to the socket write request means 102a which is exclusively executing after the socket write request means 102a when the transmission buffer is not empty. makes an asynchronous send call. As described above, the operation of flags enclosed by dotted lines (steps S10, S11, and S12 for status confirmation and setting) must be executed atomically so as not to be affected by interrupts by other threads in a multithread environment. , and the (Compare and Swap) function provided by the flag management means 107 is used.

記憶部11は、制御部10を上述した各手段100-107として動作させるOS110、通信管理プログラム111、アプリケーション112等を記憶する。なお、各手段100~107として機能させるための対象は、OS110、通信管理プログラム111、アプリケーション112を適宜入れ替えて行うものであってもよい。また、記憶部は、リレーショナル・データベースやファイルシステムなどを用いる。なお、高速化のために、Redisなどインメモリデータベースを利用、あるいは、併用してもよい。 The storage unit 11 stores an OS 110, a communication management program 111, an application 112, and the like, which causes the control unit 10 to operate as each of the means 100 to 107 described above. It should be noted that the objects for functioning as the means 100 to 107 may be performed by appropriately replacing the OS 110, the communication management program 111, and the application 112. FIG. Also, a relational database, a file system, or the like is used for the storage unit. For speeding up, an in-memory database such as Redis may be used or used together.

メモリ12は、バッファリング手段106及びその他図示しない手段により制御され、情報を一時的に記憶する。 The memory 12 is controlled by buffering means 106 and other means (not shown) to temporarily store information.

なお、端末装置2a、2b、2cは、サーバ装置1と同様の構成に加え、操作部及び表示部を備える。サーバ装置1と構成が共通する部分については説明を省略する。 The terminal devices 2a, 2b, and 2c have the same configuration as that of the server device 1, but also an operation unit and a display unit. A description of the parts that have the same configuration as the server device 1 will be omitted.

(情報処理装置の動作)
次に、第1の実施形態の作用を、(1)基本動作、(2)データ送信動作に分けて説明する。
(Operation of information processing device)
Next, the operation of the first embodiment will be described separately for (1) basic operation and (2) data transmission operation.

(1)基本動作
一例として、複数のユーザが、複数のゲームオブジェクトを同期させて同一の仮想空間(ルーム)での体験(ゲームプレイ)を共有するために、同じ仮想空間に参加する。ゲームの進行は各端末装置2a、2b、2cで行い、サーバ装置1は、ゲームの進行は行わず、オブジェクトの同期動作のみを行ってもよいし、サーバ装置1がゲームの進行も行ってもよい。
(1) Basic Operation As an example, multiple users participate in the same virtual space in order to synchronize multiple game objects and share the experience (game play) in the same virtual space (room). The game progresses in each of the terminal devices 2a, 2b, and 2c, and the server device 1 does not progress the game and only performs the synchronous operation of the objects, or the server device 1 also progresses the game. good.

サーバ装置1の図示しない参加者管理手段は、ルームへの参加要求を受信すると、参加者に対してユーザID、ユーザ名、ソケットID、参加日時とともに記憶部11の当該ルームIDに関連付けられた参加者管理情報に記録する。 Upon receiving a room participation request, the participant management means (not shown) of the server device 1 sends a participation request associated with the room ID in the storage unit 11 to the participant along with the user ID, user name, socket ID, participation date and time. recorded in the user management information.

端末装置2a、2b、2cは、ゲームのプレイ中は、アプリケーションの実行に伴い複数のオブジェクト(キャラクター、武器、アイテム等)を逐次生成、更新、削除して処理する。サーバ装置1は、ゲームの進行を行う場合、端末装置2a、2b、2cによるオブジェクトの操作要求を受け付けて、処理し、その処理結果を端末装置2a、2b、2cに通知することで、オブジェクトを同期させる。サーバ装置1は、ゲームの進行を行わない場合、端末装置2a、2b、2cにおけるオブジェクトの同期のためのリレー動作を行う。当該リレー動作において、サーバ装置1は、複数のオブジェクトの送受信を行う。いずれの場合でも、サーバ装置は、端末装置2a、2b、2cより、それぞれが操作する複数のオブジェクトの操作に関する情報を受信し、同期対象の端末装置に対応する複数のオブジェクト操作に関する情報を送信する。個々のオブジェクト操作情報のサイズは小さいが、各端末装置2a、2b、2cにおいて、なめらかなオブジェクトの描画を実現するには他頻度なデータ同期(少なくても秒20回から30回程度)が必要となり、洗練されたゲームで同期対象のオブジェクトの数が多い場合、MMOGなど同期対象の端末装置が多い場合、サーバが処理する同期のための送受信パケット数は組み合わせ爆発でストリーミング送受信のように莫大となりうる。近年CPUやメモリの高速化は著しいが、ネットワークの帯域幅、個々の端末とのスループットやレイテンシは、物理的・距離的制約や、モバイルからの利用形態などのトレンドもあり、高速化はよりゆるやかである。そのため、ネットワーク送受信はサーバでの処理において、ボトルネックとなりやすい。本発明では、ネットワーク送信の効率的な利用、NICレベルで常に処理中で空き時間のなるべくないような利用方法、特に、Javaを用いた実装で送信時のソケットの利用率の向上を実現する。以下、サーバ装置1の送受信の動作詳細について説明する。 During game play, the terminal devices 2a, 2b, and 2c sequentially generate, update, and delete a plurality of objects (characters, weapons, items, etc.) as applications are executed. When proceeding with the game, the server device 1 accepts and processes object operation requests from the terminal devices 2a, 2b, and 2c, and notifies the terminal devices 2a, 2b, and 2c of the processing results so that the objects can be processed. Synchronize. When the game is not progressing, the server device 1 performs a relay operation for synchronizing the objects in the terminal devices 2a, 2b, and 2c. In the relay operation, the server device 1 transmits and receives a plurality of objects. In any case, the server device receives from the terminal devices 2a, 2b, and 2c information on the operations of the plurality of objects operated by each of them, and transmits information on the operation of the plurality of objects corresponding to the terminal devices to be synchronized. . Although the size of individual object operation information is small, frequent data synchronization (at least about 20 to 30 times per second) is required to achieve smooth object drawing in each of the terminal devices 2a, 2b, and 2c. If there are many objects to be synchronized in a sophisticated game, or if there are many terminal devices to be synchronized such as MMOG, the number of sending and receiving packets for synchronization processed by the server will be huge like streaming sending and receiving due to combinatorial explosion. sell. In recent years, the speed of CPU and memory has increased significantly, but network bandwidth, throughput and latency with individual terminals have physical and distance restrictions, and there are trends such as mobile usage patterns, so the speed increase is more gradual. is. Therefore, network transmission/reception tends to become a bottleneck in server processing. The present invention realizes efficient use of network transmission, a method of using a NIC level that is always processing and has as little idle time as possible, and an implementation using Java, in particular, that improves socket utilization during transmission. The details of the transmission/reception operation of the server device 1 will be described below.

図3は、データ送受信の動作の一例を説明するための概略図である。 FIG. 3 is a schematic diagram for explaining an example of data transmission/reception operations.

まず、ネットワーク4からサーバ装置1がデータを受信する場合、ネットワーク4のソース131からあるチャネル130を介し、ソケット読出手段101がチャネルに対応するソケット(受信元端末装置に対応するあるIPアドレスのあるポート)によって受信したデータを読み出して受信リングバッファ121aの書込ポインタの位置に書き込む。データは受信リングバッファ121aに追加される。なお、バッファはチャネルあるいはソケットごとに別々に用意する。また、チャネル/ソケットは送受信共用で、対応する端末装置(端末装置の通信相手となる特定のプログラム)ごとに1つ用意する。アプリバッファは、1つで図示しているが、実際は送受信別に管理する。また、リングバッファは、プールとしては、全チャネルで1つとして管理されており、1つで図示しているが、リングバッファ121は、チャネルごと、送受信別々に、それぞれ独立なポインタの管理があり、チャネルごとに、別々の受信リングバッファ121a、送信リングバッファ121bとして区別する。 First, when the server device 1 receives data from the network 4, the socket reading means 101 reads data from the source 131 of the network 4 via the channel 130, and the socket reading means 101 reads the socket corresponding to the channel (with a certain IP address corresponding to the receiving terminal device). port) and writes it to the position of the write pointer in the reception ring buffer 121a. The data is added to receive ring buffer 121a. Separate buffers are prepared for each channel or socket. A channel/socket is used for both transmission and reception, and one channel/socket is prepared for each corresponding terminal device (a specific program that becomes a communication partner of the terminal device). One application buffer is shown in the drawing, but in practice, it is managed separately for transmission and reception. The ring buffer 121 is managed as one pool for all channels, and although one is shown in the figure, the ring buffer 121 manages independent pointers for each channel and for transmission and reception separately. , and separate reception ring buffer 121a and transmission ring buffer 121b for each channel.

次に、アプリケーション読出手段104は、受信元端末装置に対応(チャネルあるいはソケット)した受信リングバッファ121aのデータを読出ポインタの位置から読み出してアプリバッファ120に書き込む。データは受信リングバッファ121aから取り出され、受信リングバッファ121aから除外される。ここでアプリバッファ120はアプリケーションが独自に管理するもので、バッファリング手段106が提供するものではない。アプリバッファは、別のバッファリング手段が提供する。たとえば、OS機能(通常のメモリ割当、メモリ解放)がアプリバッファを提供してもよい。メモリを再利用してメモリ管理を効率化するためには、バッファリング手段106同等の機能が提供するように別のバッファリング手段を構成して、アプリバッファを提供してもよい。 Next, the application reading means 104 reads the data of the reception ring buffer 121 a corresponding to the receiving terminal device (channel or socket) from the position of the read pointer and writes it to the application buffer 120 . Data is retrieved from the receive ring buffer 121a and removed from the receive ring buffer 121a. Here, the application buffer 120 is independently managed by the application and not provided by the buffering means 106 . The app buffer is provided by another buffering means. For example, OS functions (normal memory allocation, memory release) may provide app buffers. In order to reuse the memory and improve the efficiency of memory management, another buffering means may be configured so as to provide a function equivalent to the buffering means 106 to provide an application buffer.

アプリケーション実行手段103は、アプリバッファ120のデータを読み出してスレッドにて処理する。 The application execution unit 103 reads data from the application buffer 120 and processes it in a thread.

また、アプリケーション実行手段103のスレッドで処理されたデータをネットワーク4に送信する場合、アプリケーション実行手段103は、スレッドで処理されたデータをアプリバッファ120に書き込む。 Also, when transmitting data processed by the thread of the application execution unit 103 to the network 4 , the application execution unit 103 writes the data processed by the thread into the application buffer 120 .

次に、アプリケーション書込手段105は、アプリバッファ120のデータを意図する送信先端末装置に応じて、送信先端末装置、より厳密には、チャネルあるいはソケットに対応する送信リングバッファ121bの書込ポインタの位置に書き込む。この結果、データは送信リングバッファ121bに追加される。データを書き込み終わると、書込ポインタを進めて、書込終了位置の次に移動する。次回、アプリケーション書込手段105がデータを書き込む時は、移動後の書込ポインタを使用するので、次回書き込むデータは、今回書き込んだデータの後ろに追加される。一方で、アプリバッファ120のデータは、送信リングバッファ121にコピーされた後は不要なり、アプリケーション実行手段103はこのバッファ領域を再利用できる。なお、送信リングバッファ121bはチャネルあるいはソケットごとに用意する。 Next, the application writing means 105 writes the write pointer of the transmission ring buffer 121b corresponding to the destination terminal device, more precisely, the channel or socket, according to the destination terminal device for which the data in the application buffer 120 is intended. write to the position of As a result, the data is added to the transmission ring buffer 121b. After the data is written, the write pointer is advanced to move to the position next to the write end position. When the application writing means 105 writes data next time, the write pointer after movement is used, so the data to be written next time is added after the data written this time. On the other hand, the data in the application buffer 120 becomes unnecessary after being copied to the transmission ring buffer 121, and the application executing means 103 can reuse this buffer area. The transmission ring buffer 121b is prepared for each channel or socket.

次に、ソケット書込手段102は、送信リングバッファ121bの読出ポインタの位置から書き出しポインタの位置の手前までのデータを読み出し、ソケットによってチャネル130に書き込む。データは、チャネル130を介してソース131に送信される。読出ポインタは、送信に成功したバイト数だけ進めて、送信が完了したデータの次の位置に移動する。この時、データは送信リングバッファ121bから取り出され、送信対象としてOS実行手段100が送信処理をし、送信が完了したデータ(取り出したデータの全部あるいは一部)については、送信リングバッファ121bから除外される。送信が完了しなかったデータについては、引き続き送信リングバッファ121bにとどまる。ここでは、送信リングバッファ121bに蓄積されたデータを全部一度に送信するものとしたが、送信リングバッファ121bに蓄積されているデータが巨大になった場合は、OS送信機能呼出の制限を考慮するなど、全部一度に読み出さず、一部だけを読み出して送信する制御をしてもよい。 Next, the socket writing means 102 reads the data from the position of the read pointer of the transmission ring buffer 121b to the position just before the position of the write pointer, and writes it to the channel 130 by the socket. Data is transmitted to source 131 via channel 130 . The read pointer advances by the number of bytes successfully transmitted and moves to the location next to the data that has been successfully transmitted. At this time, the data is taken out from the transmission ring buffer 121b, and the OS execution means 100 performs transmission processing as a transmission object, and the data that has been transmitted (all or part of the data taken out) is excluded from the transmission ring buffer 121b. be done. Data for which transmission has not been completed continues to remain in the transmission ring buffer 121b. Here, all the data accumulated in the transmission ring buffer 121b is transmitted at once, but if the data accumulated in the transmission ring buffer 121b becomes huge, the limitation of the OS transmission function call is considered. For example, instead of reading all at once, only a part of the data may be read and transmitted.

なお、上記したようにリングバッファ121は、メモリ領域(あるいは、仮想的に連続なメモリ領域)にデータ(イベント)を順次書込み(蓄積)し、読み出しするデータを直接格納するリングバッファであり、格納するデータを順番にメモリ領域に配置・格納(管理するデータを直接的に格納)するものである。このリングバッファ121は、格納したメモリへのポインタをメモリ領域(あるいは、仮想的に連続なメモリ領域)に書込又は読出ポインタとして順番に格納(管理するデータを間接的に格納)するものではない。また、このリングバッファ121は、書込みによりデータ(イベント)の書込単位の境界はなくなるため、データ(イベント)単位で処理する必要がある場合は、境界情報を別途管理しなければならない。第1の実施の形態では、データ処理(イベント処理)は、OSカーネルによるネットワーク送信であるので、データ(イベント)の境界にかかわらずバイトストリームとして送信するので、データ(イベント)の境界は管理しなくてよい。また、第1の実施の形態と同様の効果が得られるようなケースの場合は、他の仮想的なリングバッファの使用を妨げるものではない。 As described above, the ring buffer 121 is a ring buffer that sequentially writes (accumulates) data (events) in a memory area (or a virtually continuous memory area) and directly stores read data. The data to be managed is arranged and stored (directly storing the data to be managed) in the memory area in order. This ring buffer 121 does not store (indirectly store data to be managed) pointers to the stored memory as write or read pointers in a memory area (or virtually continuous memory area). . In addition, since the ring buffer 121 loses the boundaries of the write units of data (events) by writing, if it is necessary to process data (events), boundary information must be managed separately. In the first embodiment, since data processing (event processing) is network transmission by the OS kernel, it is transmitted as a byte stream regardless of data (event) boundaries, so data (event) boundaries are not managed. You don't have to. Also, in cases where the same effect as in the first embodiment can be obtained, the use of other virtual ring buffers is not barred.

以下、アプリケーション実行手段103のスレッドで処理されたデータをOS実行手段100からネットワーク4に送信する場合について詳細に説明する。 A case in which data processed by the thread of the application execution means 103 is transmitted from the OS execution means 100 to the network 4 will be described in detail below.

(2)データ送信動作
図4は、データ送信動作の一例を説明するための概略図である。
(2) Data Transmission Operation FIG. 4 is a schematic diagram for explaining an example of data transmission operation.

アプリケーション実行手段103は、例えば、複数のスレッド1、スレッド2によりデータを処理し、処理結果のデータA、データBを同一の端末装置(より厳密には、同一のソケットあるいはチャネル)に送信するために、アプリケーション書込手段105により送信先端末へ通信するソケットに対応する送信リングバッファ121bに書き込まれる。複数のチャネルへ送信するためには、それぞれのチャネルごとに本発明の各手段が必要となる。スレッド1、スレッド2の処理はマルチスレッドの環境下で非同期に発生するものとする。アプリケーション書込手段105は、データA、データBをチャネル毎に最大1つのデータ書込だけ実行するようブロッキング制御し、アプリケーション書込手段105がスレッド1のデータAを送信リングバッファ121bに書き込んでいる間、スレッド2のデータBの書込処理を待機させる。同様にアプリケーション書込手段105がスレッド2のデータBを送信リングバッファ121bに書き込んでいる間、スレッド1はデータCの書込処理を待機させる。送信リングバッファ121bへの書込は、書込ポインタの位置から開始し、書込終了時には書込ポインタを書込終了位置の次に移動させる。ここでは説明の簡単のために、スレッド間の書込操作が送信リングバッファ121bで混ざらないようにブロッキング制御を行う、送信バッファ106bとして、ノンブロッキングなバッファを採用すれば、さらにアプリケーション書込手段105は効率的に機能する。つまり、送信リングバッファ121bの書込ポインタと読込ポインタは、それぞれがある一時期には高々1個だけがアクティブであるような書込用のスレッド(アプリケーション書込手段105)及び読込用のスレッド(ソケット書込手段102)が排他的に操作するため、ノンブロッキング、かつ非同期に、書込(アプリケーション書込手段105)と読出(ソケット書込手段102)を実行できる。 The application execution means 103, for example, processes data by a plurality of threads 1 and 2, and transmits data A and data B as processing results to the same terminal device (more precisely, the same socket or channel). Then, the application writing means 105 writes to the transmission ring buffer 121b corresponding to the socket for communication to the destination terminal. In order to transmit to multiple channels, each means of the present invention is required for each channel. It is assumed that processing of threads 1 and 2 occurs asynchronously under a multithread environment. Application writing means 105 performs blocking control so that data A and data B are written at maximum one data per channel, and application writing means 105 writes data A of thread 1 to transmission ring buffer 121b. During this time, the write processing of data B of thread 2 is made to wait. Similarly, while the application writing means 105 is writing the data B of the thread 2 to the transmission ring buffer 121b, the thread 1 waits for the data C writing process. Writing to the transmission ring buffer 121b starts from the position of the write pointer, and when writing ends, the write pointer is moved next to the write end position. For the sake of simplicity of explanation, if a non-blocking buffer is adopted as the transmission buffer 106b that performs blocking control so that write operations between threads are not mixed in the transmission ring buffer 121b, then the application writing means 105 work efficiently. In other words, the write pointer and read pointer of the transmission ring buffer 121b are assigned to a thread for writing (application writing means 105) and a thread for reading (socket), of which at most one is active at a given time. Since the writing means 102) operates exclusively, writing (application writing means 105) and reading (socket writing means 102) can be performed non-blocking and asynchronously.

次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていない場合、フラグを立てて、OSシステムコール(例えばJAVAのAsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bに蓄積されているデータ(読出しポインタから呼出時点での書込ポインタの一つ前までのデータ)を送信する。この時点では送信リングバッファ121bにはデータAのみ蓄積されている。ソケット書込要求手段102aは、送信リングバッファ121のデータAをOS実行手段100(OSカーネル)に書き込み要求をして終了する(1)。 Next, the socket write request means 102a refers to the CAS flag of the flag management means 107. If the flag is not set, the socket write request means 102a sets the flag and calls the OS system call (for example, AsynchronousSocketChannel.write() of JAVA). , the data accumulated in the transmission ring buffer 121b (the data from the read pointer to the point immediately before the write pointer at the time of calling) is transmitted. At this point, only data A is stored in the transmission ring buffer 121b. The socket write request means 102a requests the OS execution means 100 (OS kernel) to write the data A in the transmission ring buffer 121, and terminates (1).

次に、OSカーネル100は、データAを適切なサイズ(サイズは、例えば、ネットワーク依存の送信可能な最大パケットサイズMTU(Maximum Transmission Unit、イーサネットならMTUは1500バイト)と各種プロトコルヘッダに応じて決定する。典型的には、イーサネットでTCP/IPであれば、TCPヘッダ20バイトとIPヘッダ20バイトを差し引いたMSS(Maximum Segment Size)1460バイト)に分割してデータA1、A2としてネットワーク4に送信する。OSカーネル100のイベント処理中に、アプリケーション書込手段105から送信リングバッファ121bにデータBを書き込むと送信リングバッファ121bは、OSカーネル100が読取処理をしている最中ではあっても、データBをノンブロッキングに蓄積する。アプリケーション書込手段105は、引き続きソケット書込要求手段102aを呼び出すが、ソケット書込要求手段102aはデータAの処理中でフラグ管理手段107のCASフラグが立っているのでソケット書込要求手段102aはデータBの送信処理をせずに、ノンブロッキングに直ちに終了する(2)。スレッド2は、比較的長時間のネットワーク送信処理(OSカーネル100のイベント処理)の完了を待たずに次の処理を実行できる。この時点で、送信リングバッファ121bには、データBが追加され、データAとデータBが存在する。 Next, the OS kernel 100 determines an appropriate size for the data A (the size is, for example, a network-dependent maximum packet size MTU (Maximum Transmission Unit, MTU is 1500 bytes for Ethernet) and various protocol headers. Typically, in the case of TCP/IP on Ethernet, it is divided into MSS (Maximum Segment Size) 1460 bytes obtained by subtracting 20 bytes of TCP header and 20 bytes of IP header) and transmitted to network 4 as data A1 and A2. do. If data B is written from the application writing means 105 to the transmission ring buffer 121b during the event processing of the OS kernel 100, the transmission ring buffer 121b will not be able to store the data B even while the OS kernel 100 is reading. is accumulated non-blocking. Application writing means 105 continues to call socket write request means 102a, but socket write request means 102a is processing data A and the CAS flag of flag management means 107 is set, so socket write request means 102a The process ends immediately in a non-blocking manner without transmitting data B (2). Thread 2 can execute the next process without waiting for completion of the relatively long network transmission process (event process of OS kernel 100). At this point, data B is added to the transmission ring buffer 121b, and data A and data B are present.

次に、OSカーネル100は、データAの送信を完了するとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、送信完了したバイト数を確認し、この場合はデータA全体が送信完了しているので、送信リングバッファ121bの読出ポインタをデータAの直後へ移動し、データAを送信リングバッファ121bから除外する。次に、コールバック処理手段102bは、フラグ管理手段107のCASフラグを解除する。この時点で、送信リングバッファ121bは、データAが除外され、データBのみが存在する。次に、コールバック処理手段102bは、送信リングバッファ121bにまだ送信すべきデータがあるか(読出ポインタと書込ポインタが一致していれば送信すべきデータはない)を判定する。送信すべきデータがある場合は、ソケット書込要求手段102aを呼び出す。送信すべきデータがない場合は終了する。この場合はすでに、データBが送信リングバッファ121bに存在しているので、ソケット書込要求手段102aを呼び出す(3)。 Next, when the transmission of data A is completed, the OS kernel 100 activates the callback processing means 102b and notifies the transmission completion. The callback processing means 102b confirms the number of bytes that have been transmitted. In this case, the transmission of the entire data A has been completed. Exclude from ring buffer 121b. Next, the callback processing means 102b clears the CAS flag of the flag management means 107. FIG. At this point, the transmission ring buffer 121b has data A removed and only data B exists. Next, callback processing means 102b determines whether there is still data to be transmitted in transmission ring buffer 121b (if the read pointer and write pointer match, there is no data to be transmitted). If there is data to be sent, the socket write request means 102a is called. If there is no data to send, terminate. In this case, since the data B already exists in the transmission ring buffer 121b, the socket write request means 102a is called (3).

次に、ソケット書込要求手段102aは、フラグ管理手段107に依頼して、CASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bに蓄積されているデータ(読出しポインタから呼出時点での書込ポインタの一つ前までのデータ)を送信する。この時点では送信リングバッファ121bにデータBのみ蓄積されている。ソケット書込要求手段102aは、送信リングバッファ121bのデータBをOSカーネル100に書き込み要求をして終了する。 Next, the socket write request means 102a requests the flag management means 107 to refer to the CAS flag. Since the flag is not set, the flag is set and an OS system call (AsynchronousSocketChannel.write()) is called. and transmits the data accumulated in the transmission ring buffer 121b (the data from the read pointer to the point immediately before the write pointer at the time of calling). At this point, only data B is stored in the transmission ring buffer 121b. The socket write request means 102a requests the OS kernel 100 to write the data B in the transmission ring buffer 121b, and terminates.

次に、OSカーネル100は、データBを適切なサイズに分割してデータB1、B2、B3としてネットワーク4に送信する。OSカーネル100のイベント処理中に、アプリケーション書込手段105から送信リングバッファ121bにデータCを書き込むと送信リングバッファ121bはデータCをノンブロッキングに蓄積し、ソケット書込要求手段102aを呼び出すが、ソケット書込手段102は、直前のソケット書込要求手段102aがOSに依頼したデータBの処理中で、フラグ管理手段107のCASフラグが立っているのでソケット書込要求手段102aはデータCの送信処理をOSカーネル100に依頼せずに直ちに終了する(4)。また、同様にして、アプリケーション書込手段105からリングバッファ121にデータDを書き込むとリングバッファ121はデータDをノンブロッキングに蓄積し、ソケット書込要求手段102aを呼び出すが、ソケット書込手段102はデータBの処理中でフラグ管理手段107のCASフラグが立っているのでソケット書込要求手段102aはデータDの送信処理をせずに直ちに終了する(5)。この時点では送信リングバッファ121bにデータB、データC、データDが順番に蓄積されている。 Next, the OS kernel 100 divides the data B into appropriate sizes and transmits them to the network 4 as data B1, B2, and B3. During event processing of the OS kernel 100, when data C is written from the application writing means 105 to the transmission ring buffer 121b, the transmission ring buffer 121b accumulates the data C in a non-blocking manner and calls the socket write request means 102a. The write means 102 is processing the data B requested to the OS by the immediately preceding socket write request means 102a, and since the CAS flag of the flag management means 107 is set, the socket write request means 102a does not send the data C. Terminate immediately without requesting the OS kernel 100 (4). Similarly, when data D is written from the application writing means 105 to the ring buffer 121, the ring buffer 121 accumulates the data D in a non-blocking manner and calls the socket write request means 102a. Since the CAS flag of the flag management means 107 is set during the processing of B, the socket write request means 102a immediately terminates without transmitting the data D (5). At this point, data B, data C, and data D are stored in order in the transmission ring buffer 121b.

次に、OSカーネル100は、データBの送信を完了するとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、まず、送信完了バイト数がデータB全体であることを確認した上で、送信リングバッファ121bの読出ポインタをデータBの次の位置(この場合はデータCの先頭)に移動する。この時点では送信リングバッファ121bは、データBが除外されて、データCとデータDを蓄積している。コールバック処理手段102bは、次に、フラグ管理手段107のCASフラグを解除して、その次に、送信リングバッファ121bは空でない(この場合はデータC及びデータDが蓄積されている)ことを確認して、ソケット書込要求手段102aを呼び出す。 Next, when the transmission of data B is completed, the OS kernel 100 activates the callback processing means 102b and notifies the transmission completion. The callback processing means 102b first confirms that the number of transmission completion bytes is the entire data B, and then sets the read pointer of the transmission ring buffer 121b to the position next to the data B (in this case, the beginning of the data C). Moving. At this time, the transmission ring buffer 121b stores data C and data D with data B excluded. The callback processing means 102b next clears the CAS flag of the flag management means 107, and then confirms that the transmission ring buffer 121b is not empty (in this case, data C and data D are accumulated). After confirmation, the socket write request means 102a is called.

次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bのデータCとデータDをOSカーネル100に書き込む(6)。 Next, the socket write request means 102a refers to the CAS flag of the flag management means 107. Since the flag is not set, the socket write request means 102a sets the flag, calls the OS system call (AsynchronousSocketChannel.write()), and The data C and data D in the buffer 121b are written to the OS kernel 100 (6).

次に、OSカーネル100は、データC及びデータDを適切なサイズに分割してデータC1、C2、C3、…としてネットワーク4に送信する。OSカーネル100のイベント処理中に、アプリケーション書込手段105から送信リングバッファ121bにデータEを書き込むと、送信リングバッファ121bはデータEをノンブロッキングに蓄積するが、ソケット書込要求手段102aの呼出はフラグ管理手段107のCASフラグが立っているのでソケット書込要求手段102aはデータEの送信処理をせずに終了する(7)。また、同様にしてアプリケーション書込手段105から送信リングバッファ121bにデータFを書き込むと、送信リングバッファ121bはデータFをノンブロッキングに蓄積する(8)。この時点で送信リングバッファ121bはデータC、データD、データE、データFを蓄積している。 Next, the OS kernel 100 divides the data C and data D into appropriate sizes and transmits them to the network 4 as data C1, C2, C3, . When data E is written from the application writing means 105 to the transmission ring buffer 121b during event processing of the OS kernel 100, the transmission ring buffer 121b accumulates the data E in a non-blocking manner. Since the CAS flag of the management means 107 is set, the socket write request means 102a terminates without transmitting the data E (7). Similarly, when data F is written from application writing means 105 to transmission ring buffer 121b, transmission ring buffer 121b accumulates data F in a non-blocking manner (8). At this point, the transmission ring buffer 121b has accumulated data C, data D, data E, and data F. FIG.

次に、OSカーネル100は、データCの送信を完了すると、今回はたまたまDの処理を実行せずに、コールバック処理手段102bを起動して、送信完了を通知する。一般にOSシステムコール(AsynchronousSocketChannel.write())は必ずしも要求したデータすべての送信を完了することを保証しない。OSやネットワークの負荷などの理由で要求したデータの一部のみ送信されることがある。したがって、送信完了したバイト数の確認は必須である。また、このシステムコールは、複数のバッファ(メモリチャンク)を指定することで、それらをまとめて1回のシステムコールで送る集約送信(集約書込、gathering write)の機能を提供する。したがって、CとDとは連続した単一のメモリチャンクではなく、2個以上のメモリチャンクであっても1回のシステムコールで送信要求が可能である。この例では、偶然データCの全体の送信終了を通知したが、OSカーネル100にとってはデータCとデータDは集約された連続した送信対象のデータで、別のデータであるかどうかの区別はしていないので、データCを送りきったのは全くの偶然で、データCの送信中、データCの一部を残して送信を終了する場合もある。集約送信では複数のメモリチャンクを指定できるので、CやDはそれぞれが複数のメモリチャンクに分割されて指定されてもよいし、CとDをまとめた一つのメモリチャンクで指定してもよいし、あるいは、部分的にCとDが交じるような複数個のメモリチャンク(例えば、Cの前半、Cの後半とDの前半、Dの後半などの3個)に分割されて指定されてもよい。一方でOSの集約送信は、指定されたチャンクを順に送信しようとするが、OSの都合により、指定されたチャンクすべて送信することもあれば、指定されたチャンクの一部のチャンクのみを送信することもある。ここで一部のチャンクとは、複数チャンクの一部のチャンクの全体であることもあれば、最後のチャンクはチャンクの最初の部分だけで送り残しのある場合があることもある。送信指定したチャンクの含むすべてのバイト数すべてが送信に成功するわけではなく、コールバックルーチンで送信成功したバイト数を確認し、送り残したチャンクあるいはチャンクの一部は、次回の集約送信の対象とする必要がある。(例えば、C1とC2を送信完了して、C3を残す場合とか、C1とC2に加えてC3の前半まで送信完了して、C3の後半を残す場合とかも考えられる。コールバック処理手段102bは、まず、送信完了したバイト数を確認し、この場合は、データCのみが全部送信完了であるので、送信リングバッファ121bの読出ポインタをデータCの次の位置(この場合はデータDの先頭位置)に移動する。この時点で、送信リングバッファ121bは、データCが除外されるが、データC送信処理中にデータEとデータFが追加されているので、送信リングバッファ121bは、データD、データE、データFを蓄積している。コールバック処理手段102bは、次に、フラグ管理手段107のCASフラグを解除する。コールバック処理手段102bは、この場合は、送信リングバッファ121bに送信対象のデータ(この場合は、データD、データE、データF)が存在するので、ソケット書込要求手段102aを呼び出す。 Next, when the transmission of data C is completed, the OS kernel 100 happens to activate the callback processing means 102b without executing the processing of D this time, and notifies the completion of transmission. In general, the OS system call (AsynchronousSocketChannel.write()) does not always guarantee to complete the transmission of all requested data. Only part of the requested data may be sent for reasons such as the OS or network load. Therefore, confirmation of the number of bytes that have been transmitted is essential. In addition, this system call provides a gathering write function for specifying a plurality of buffers (memory chunks) and collectively sending them with one system call. Therefore, even if C and D are not a continuous single memory chunk, but two or more memory chunks, a transmission request can be made with one system call. In this example, the end of transmission of the entire data C was accidentally notified, but for the OS kernel 100, data C and data D are aggregated continuous data to be transmitted, and it is not possible to distinguish whether they are different data. Therefore, it is purely accidental that the data C is completely sent. During the transmission of the data C, there is a case where the transmission is terminated with a part of the data C left. Since multiple memory chunks can be specified in aggregated transmission, C and D may be specified by dividing them into multiple memory chunks, or C and D may be specified in a single memory chunk. Alternatively, it may be divided into a plurality of memory chunks in which C and D partially intersect (for example, three chunks such as the first half of C, the second half of C, the first half of D, and the second half of D). . On the other hand, the aggregate transmission of the OS tries to transmit the specified chunks in order, but depending on the circumstances of the OS, all the specified chunks may be sent, or only some chunks of the specified chunks may be sent. Sometimes. Here, the partial chunk may be the entire partial chunk of a plurality of chunks, or the last chunk may be only the first part of the chunk and may be left unsent. Not all bytes included in the chunk specified for transmission will be successfully transmitted, so the number of bytes successfully transmitted is checked in the callback routine, and the chunks left unsent or part of the chunks will be the target of the next aggregated transmission. should be (For example, transmission of C1 and C2 is completed and C3 is left, or transmission of the first half of C3 in addition to C1 and C2 is completed and the latter half of C3 is left.) First, the number of bytes that have been transmitted is confirmed. In this case, only data C has been completely transmitted. ) At this point, the transmission ring buffer 121b has data C removed, but since data E and data F are added during data C transmission processing, the transmission ring buffer 121b stores data D, It stores data E and data F. Next, the callback processing means 102b clears the CAS flag of the flag management means 107. In this case, the callback processing means 102b sends data to the transmission ring buffer 121b. data (in this case, data D, data E, and data F), the socket write request means 102a is called.

次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bのすべてのデータDEFをOSカーネル100に書き込み要求する(9)。 Next, the socket write request means 102a refers to the CAS flag of the flag management means 107. Since the flag is not set, the socket write request means 102a sets the flag, calls the OS system call (AsynchronousSocketChannel.write()), and A write request is issued to the OS kernel 100 for all the data DEF in the buffer 121b (9).

次に、OSカーネル100は、データDEFを適切なサイズに分割してデータD1、D2、…としてネットワーク4に送信する。 Next, the OS kernel 100 divides the data DEF into appropriate sizes and transmits them to the network 4 as data D1, D2, .

次に、OSカーネル100は、たまたまデータDだけの送信を完了するとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、送信済バイト数を確認すると、偶然データDだけが送信完了となっていたので、送信リングバッファ121bの読出ポインタをデータEの先頭に移動し、フラグ管理手段107のCASフラグを解除して、送信リングバッファが空ではないので、ソケット書込要求手段102aを呼び出す。 Next, when the OS kernel 100 happens to complete the transmission of only the data D, it activates the callback processing means 102b and notifies the transmission completion. When the callback processing means 102b confirms the number of transmitted bytes, it happens that only the data D has been transmitted. Since the flag is cleared and the transmission ring buffer is not empty, the socket write request means 102a is called.

次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、リングバッファ121のデータEFをOSカーネル100に書き込み要求する(10)。 Next, the socket write request means 102a refers to the CAS flag of the flag management means 107. Since the flag is not set, the socket write request means 102a sets the flag, calls the OS system call (AsynchronousSocketChannel.write()), and writes to the ring buffer. The OS kernel 100 is requested to write the data EF of 121 (10).

次に、OSカーネル100は、データEFを適切なサイズに分割してデータE、F1、F2としてネットワーク4に送信する。 Next, the OS kernel 100 divides the data EF into appropriate sizes and transmits them to the network 4 as data E, F1 and F2.

次に、OSカーネル100は、データE、Fの送信をするとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、送信完了バイト数を確認し、送信リングバッファ121bの読出ポインタをデータFの次に移動させ、フラグ管理手段107のCASフラグを解除する。コールバック処理手段102bは、送信リングバッファ121bが空(読出ポインタと書込ポインタが一致)になり、処理を終了する Next, when the OS kernel 100 transmits the data E and F, it activates the callback processing means 102b and notifies the completion of transmission. The callback processing means 102b confirms the number of transmission completed bytes, moves the read pointer of the transmission ring buffer 121b to the position next to the data F, and clears the CAS flag of the flag management means 107. FIG. The callback processing means 102b terminates the processing when the transmission ring buffer 121b becomes empty (the read pointer and the write pointer match).

以上の例では、説明しやすいように、データA-Fはそれぞれが1個以上のネットワークパケットとして送信されるような大きなデータとして図示した。ゲームサーバでオブジェクトの同期情報をストリーミングのように送受信する際には、個々のデータのサイズはネットワークの送信パケットサイズにくらべて非常に小さく、データが蓄積されれば、多数のデータがひとつのネットワーク送信パケットとして送信される。したがって、CASによるノンブロッキングなソケット書込手段は、OSのロック機能を使用する場合に比べて、著しくオーバヘッドが小さくなり、また、複数のデータをまとめて連続なブロックに配置したり、複数のデータをまとめて1回のOS送信要求で送ったりすることにより、送信チャネルを切れ目なく効率よく稼働させることができ、特にストリーミングのような利用形態では有用である。 In the above examples, for ease of explanation, the data A to F are illustrated as large pieces of data each transmitted as one or more network packets. When the game server transmits and receives object synchronization information like streaming, the size of each piece of data is very small compared to the network transmission packet size. Sent as a send packet. Therefore, the non-blocking socket writing means by CAS has a significantly smaller overhead than the case of using the OS lock function, and also puts a plurality of data together in a continuous block, or a plurality of data. By collectively sending the data with one OS transmission request, the transmission channel can be efficiently operated without interruption, which is particularly useful in a mode of use such as streaming.

(第1の実施の形態の効果)
上記した実施の形態によれば、アプリケーション書込手段105とソケット書込手段102の間に送信リングバッファ121bを設け、送信リングバッファ121bはアプリケーション書込手段105の書込データをノンブロッキングに蓄積して、ソケット書込要求手段102aの書込動作をCASフラグに応じて実行し、CASフラグをフラグ管理手段107によって管理し、ソケット書込要求手段102aの書込開始でフラグを立て、OS実行手段100のイベント処理完了の通知を受けたコールバック処理手段102bがフラグを解除するようにしたため、アプリケーション書込手段105の書き込み動作がOS実行手段100の送信イベント処理の動作に直接影響を及ぼさないようになり(アプリケーション書込手段105、OS実行手段100がそれぞれに対応するための待ち時間がなくなり、また、それぞれの呼出回数が削減され)、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化することができる。特に、所要時間の比較的長いネットワークへの送信処理を、ウェイト時間(レイテンシ)短く、なるべく連続処理、かつ、ノンブロッキングに実行することで、ネットワーク送信処理を優先し、送信スループットを上げ、非同期送信(NIO)の処理待ちの間の時間にアプリ処理を実行することができる。
(Effect of the first embodiment)
According to the above embodiment, the transmission ring buffer 121b is provided between the application writing means 105 and the socket writing means 102, and the transmission ring buffer 121b accumulates the data written by the application writing means 105 in a non-blocking manner. , the write operation of the socket write request means 102a is executed according to the CAS flag, the CAS flag is managed by the flag management means 107, the flag is set when the socket write request means 102a starts writing, and the OS execution means 100 The flag is cleared by the callback processing means 102b upon receiving the event processing completion notification, so that the writing operation of the application writing means 105 does not directly affect the transmission event processing operation of the OS execution means 100. (The waiting time for the application writing means 105 and the OS execution means 100 to correspond to each other is eliminated, and the number of calls for each is reduced.), application processing and data transmission are executed in a non-blocking manner for high-speed communication. can be In particular, transmission processing to the network, which takes a relatively long time, is performed with a short wait time (latency), continuous processing as much as possible, and non-blocking, giving priority to network transmission processing, increasing transmission throughput, and asynchronous transmission ( Application processing can be executed during the waiting time for NIO) processing.

また、アプリケーションが消費するOSリソース(総メモリ量、スレッド数、OS機能呼び出し回数)を削減し、処理の高速化を実現できる。また、レンタルサーバやクラウドサービスなどで運用する場合は、よりコンパクトなサーバ仕様で動作させることができ、運用コストが削減される。 In addition, the OS resources (total amount of memory, number of threads, number of OS function calls) consumed by the application can be reduced, and high-speed processing can be realized. Also, when operating with a rental server or cloud service, it can be operated with more compact server specifications, which reduces operating costs.

(第2の実施の形態)
第2の実施の形態は、送信バッファとしての中間バッファが2種類存在する点、アプリケーション書込手段105がマルチスレッド時にノンブロッキングである点で第1の実施の形態と異なる。アプリケーション書込手段105がノンブロッキングで並行処理が可能となり、第1の実施の形態に比べて、アプリケーションの処理効率が改善される。なお、第1の実施の形態と共通の構成、動作については記載を省略する場合がある。まず、第2の実施の形態における通信管理システムの構成、及びサーバ装置の構成については、それぞれ、第1の実施の形態で示した図1及び図2と同じなので記載を省略する。図1及び図2の説明の記載で、第1の実施の形態に特化した動作や機能については、第1の実施の形態とのちがいも含めて、以下に説明する。
(Second embodiment)
The second embodiment differs from the first embodiment in that there are two types of intermediate buffers as transmission buffers and that the application writing means 105 is non-blocking during multithreading. The application writing means 105 can perform non-blocking parallel processing, and application processing efficiency is improved compared to the first embodiment. The description of the configuration and operation common to those of the first embodiment may be omitted. First, the configuration of the communication management system and the configuration of the server device in the second embodiment are the same as those shown in FIGS. 1 and 2 shown in the first embodiment, respectively, so descriptions thereof will be omitted. Operations and functions specific to the first embodiment in the descriptions of FIGS. 1 and 2 will be described below, including differences from the first embodiment.

図9及び図10に示すように、構成において、第1の実施の形態(図3及び図4)と比較して、第2の実施の形態では、リングバッファ121(図3参照。)が中間バッファ121B(図9参照。)に置き換えられる点、バッファリング手段106がメモリ12に送信バッファとして、リングバッファ121b(図4参照。)だけでなく、第1のバッファ121bと第2のバッファ121bを用意する点(図10参照。)で第1の実施の形態と構成が異なる。 As shown in FIGS. 9 and 10, compared with the first embodiment (FIGS. 3 and 4), the ring buffer 121 (see FIG. 3) is intermediate in the second embodiment. In that the buffering means 106 is replaced with the buffer 121B (see FIG. 9), the buffering means 106 stores not only the ring buffer 121b (see FIG. 4) but also the first buffer 121b1 and the second buffer 121b as transmission buffers in the memory 12. 2 (see FIG. 10) is different from the first embodiment.

図10に示すように、第1のバッファ121bは、アプリケーション書込手段105により、スレッド103の処理の結果生成されたイベントの書き込みを受け付け、第2のバッファ121bは、ソケット書込手段102aにより、第1のバッファ121bにスレッド毎に書き込まれたデータの集合の書込を受け付ける。イベントを規格化されたメモリチャンクに保持する場合、第1のバッファ121bでは、一例として、標準的なイベントサイズを考慮し、イベントをチャンクに格納した場合にチャンクの使い残しがあまり発生しないように、既存の各種最適化アルゴリズムなどを用いてチャンクサイズを計算・設計するものとし、ここでは256バイトの規格化されたチャンクにイベントを保持(イベントサイズが256バイトより大きければ複数チャンクに保持)したものを複数保持するものとする。チャンクはバッファプールで管理し、バッファプールを複数のチャネルで共有すると想定して、初期値として4096個用意すると合計1MBである。バッファプールは不足した場合は、追加でメモリチャンクを割り当てて、拡張できる構成が望ましい。また、ここでバッファプールを複数チャネルで共有するとは、異なる送信先ごとに異なるチャネル、異なるソケットを使うため、本発明は単一のチャネルの動作を中心に記述するが、他チャネルでもそれぞれが同様に独立したバッファリング手段106を保持するが、それぞれのバッファリング手段にメモリチャンクを提供するバッファプールは一元的に管理すれば、各チャネルで個別にバッファプールを保持する場合に比べて、バッファプールのメモリ確保の重複を排除して、チャネル間でメモリを融通できるため、バッファプールとして確保する総メモリを節約できる。一方で、第2のバッファ121bはOSでのイベント処理に使用される。第2のバッファ121bは、一例として、OSの好適なデータ処理サイズであるページサイズを考慮し、ここでは2048バイトの規格化されたチャンクをに処理すべき送信データを保持するものとする。チャンクをバッファプールで管理し、バッファプールを複数のチャネルで共有すると想定して、初期値として4096個用意すると合計8MBである。第1のバッファ121bのバッファプールと同様に、バッファプールは不足した場合は、追加でメモリチャンクを割り当てて、拡張できる構成が望ましい。なお、第1のバッファ121bと第2のバッファ121bのそれぞれのチャンク容量及びチャンク数は通信環境やシステムの仕様に合わせて適宜設定するため、例として示した値に限定されるものではない。ただし、バッファプールのメモリチャンクは、あらかじめまとめて取得した大きなメモリを分割して使用するので、メモリチャンクのサイズは、メモリ境界を考慮して、サーバ装置1のページサイズ、又は、ページサイズの2の累乗数分の1から選ぶことがメモリシステムの効率上望ましく、50バイトや100バイトのような任意のバイト数を選択すべきではない。また、第2のバッファは、OSでの処理に適したダイレクトバッファを使用するとOSでの送信処理効率がよくなる。 As shown in FIG. 10, the first buffer 121b_1 accepts writing of an event generated as a result of the processing of the thread 103 by the application writing means 105, and the second buffer 121b_2 accepts the socket writing means 102a. accepts writing of a set of data written for each thread to the first buffer 121b1 . When events are held in standardized memory chunks, the first buffer 121b1 , as an example, considers a standard event size and stores events in chunks so that chunks are not often left unused. In addition, the chunk size is calculated and designed using various existing optimization algorithms, etc. Here, the event is held in a standardized chunk of 256 bytes (if the event size is larger than 256 bytes, it is held in multiple chunks). It is assumed that multiple items are retained. Chunks are managed by a buffer pool, and assuming that the buffer pool is shared by a plurality of channels, if 4096 chunks are prepared as an initial value, the total is 1 MB. If the buffer pool runs short, it is desirable to have a configuration that can be expanded by allocating additional memory chunks. Also, sharing a buffer pool with multiple channels means that different channels and different sockets are used for different destinations, so the present invention will focus on the operation of a single channel, but the same applies to other channels as well. , but if the buffer pools that provide memory chunks to the respective buffering means are centrally managed, compared to the case where each channel individually holds a buffer pool, Since duplication of memory allocation is eliminated and memory can be accommodated between channels, the total memory allocated as a buffer pool can be saved. On the other hand, the second buffer 121b2 is used for event processing in the OS. As an example, the second buffer 121b2 holds transmission data to be processed in normalized chunks of 2048 bytes, considering the page size, which is the preferred data processing size of the OS. Assuming that chunks are managed by a buffer pool and that the buffer pool is shared by a plurality of channels, if 4096 chunks are prepared as an initial value, the total is 8 MB. As with the buffer pool of the first buffer 121b1 , if the buffer pool runs short, it is desirable to have a configuration that can be expanded by allocating additional memory chunks. The chunk capacity and the number of chunks of the first buffer 121b- 1 and the second buffer 121b- 2 are appropriately set according to the communication environment and system specifications, and are not limited to the values shown as examples. . However, since the memory chunks of the buffer pool are used by dividing a large memory that has been collectively obtained in advance, the size of the memory chunks is the page size of the server device 1, or 2 of the page size, considering memory boundaries. It is desirable for memory system efficiency to choose from 1/n powers of , and an arbitrary number of bytes such as 50 bytes or 100 bytes should not be chosen. Also, if a direct buffer suitable for processing in the OS is used as the second buffer, the transmission processing efficiency in the OS will be improved.

また、図11,図12,図13に示すように、第2の実施の形態は、第1の実施の形態(図6、図7、図9)と比べると、フラグ管理手段107の使い方において、処理手段としてのソケット書込手段102、処理要求手段としてのソケット書込要求手段102aとコールバック処理手段102bが第1の実施の形態の同手段と異なる動作をする点で、第1の実施の形態と構成が異なる。ソケット書込要求手段102a及びコールバック処理手段102bの動作について以下説明する。このフラグ管理手段107の変更は、第2の実施形態では、アプリケーション書込手段105がノンブロッキングで並行処理が可能となったため、アプリケーション書込手段105が連続的多頻度に実行されている間に限り、アプリケーション書込手段105がソケット書込要求手段を呼び出さずに、中間バッファ121Bにイベントを書き込むだけの少ない処理で終了するためである。その代わり、アプリケーション書込手段105が連続的多頻度に実行されている間は、すでに実行中のソケット書込手段102のコールバック処理手段は、中間バッファ121Bが保持するイベントがなくなるまで連続してソケット書込手段を呼び出す。このことにより、アプリケーション書込手段105の平均処理速度が短くなり、アプリケーションのスレッド103の並行処理の効率がよくなる。なお、第1の実施例でも第2の実施例で示すアプリケーションの送信スレッドの並列動作効率を重視したフラグ管理手段107の使い方(ソケット書込要求手段102a及びコールバック処理手段102bの動作)を適用することは可能であるし、逆に、第2の実施例でも第1の実施例で示したOSの送信処理効率を重視したフラグ管理手段107の使い方(ソケット書込要求手段102a及びコールバック処理手段102bの動作)を適用することも可能である。また、一方で、フラグ管理方法をこの2種類の手法に限定するものではなく、イベント追加とイベント処理をノンブロッキングかつ非同期に行うための他の手法を用いてもよい。 Also, as shown in FIGS. 11, 12, and 13, the second embodiment differs from the first embodiment (FIGS. 6, 7, and 9) in the usage of the flag management means 107. , socket writing means 102 as processing means, socket writing request means 102a and callback processing means 102b as processing request means operate differently from the same means in the first embodiment. differ in form and composition. The operations of the socket write request means 102a and the callback processing means 102b will be described below. In the second embodiment, since the application writing means 105 is capable of non-blocking parallel processing, this change of the flag management means 107 is limited to the period when the application writing means 105 is continuously and frequently executed. , the application writing means 105 does not call the socket write request means, but writes the event to the intermediate buffer 121B. Instead, while the application writing means 105 is being executed continuously and frequently, the callback processing means of the already executing socket writing means 102 continues until there are no more events held by the intermediate buffer 121B. Call the socket writer. This shortens the average processing speed of the application writing means 105 and improves the efficiency of parallel processing of the threads 103 of the application. The first embodiment also applies the usage of the flag management means 107 (the operation of the socket write request means 102a and the callback processing means 102b) emphasizing the parallel operation efficiency of the transmission threads of the application shown in the second embodiment. Conversely, in the second embodiment as well, the usage of the flag management means 107 emphasizing the transmission processing efficiency of the OS shown in the first embodiment (socket write request means 102a and callback processing action of means 102b) can also be applied. Also, on the other hand, the flag management method is not limited to these two types of methods, and other methods for performing event addition and event processing in a non-blocking and asynchronous manner may be used.

図11及び図13は、ソケット書込要求手段102aの動作例を説明するためのフローチャートである。また、図12は、コールバック処理手段102bの動作例を説明するためのフローチャートである。 11 and 13 are flow charts for explaining an operation example of the socket write request means 102a. Also, FIG. 12 is a flow chart for explaining an operation example of the callback processing means 102b.

まず、図11に示すように、ソケット書込要求手段102aは、呼出元を確認し(S40)、呼出元がアプリケーション書込手段105(第1のバッファにイベント追加後の呼出)の場合(S40;Yes)、フラグ管理手段107に依頼して、フラグ管理手段107の管理するフラグの状態を確認し(S41)、フラグが解除されている場合(S42;Yes)、フラグを立てる(S43)。ソケット書込要求手段102aは、アプリケーション書込手段105がイベントをリングバッファ121bに書き込み処理を終了する直前、及びソケット書込要求手段102aの終了後に実行される対応するコールバック処理手段102bの終了直前のいずれかから非同期に呼出される。呼び出しは通常のメソッドあるいは関数の呼び出しでもよいし、あるいは、OS機能を使い待機しているスレッドへのシグナリングによる起動でもよい。前者の場合のみフラグ管理手段を利用して、OS実行手段にイベント処理を要求できる状態であるかどうかを判断する。後者の場合はすでにフラグを立てて後、1回以上OS実行手段にイベント処理を実行している最中であるので、フラグを再び立てることなく、OS実行手段にイベントの処理を要求しようとする。呼び出し元を通知する一番簡単な方法は、呼び出しパラメータに呼び出し元識別子を含めることであるが、他のどんな方法でもよい。前者の場合でフラグが立てられると、次に、ソケット書込要求手段102aは、OS実行手段100にイベントの処理を要求する(S44)。一方、前者の場合で、もし、フラグ管理手段107の管理しているフラグがすでに立っている場合は(S42;No)、処理を直ちに終了する。また、ソケット書込要求手段102aは、後者の場合、すなわち、呼出元がアプリケーション書込手段105ではなくコールバック処理手段102bの場合(S40;No)、このコールバック処理手段102bの実行に対応する直前のソケット書込要求手段102aの実行時にすでにフラグを立てているので、フラグの状態に関わらずOS実行手段100にイベントの処理を要求する(S44)。なお、前述のように、図6同様に、点線で囲まれたフラグの操作(状態確認や設定S41,S42,S43はマルチスレッド環境下で他スレッドによる割り込みによる影響がないようにアトミックに実行される必要があり、フラグ管理手段107が提供する(Compare and Swap)の機能を利用する。 First, as shown in FIG. 11, the socket write request unit 102a confirms the caller (S40), and if the caller is the application write unit 105 (call after adding the event to the first buffer) (S40 Yes), the flag management means 107 is requested to check the state of the flag managed by the flag management means 107 (S41), and if the flag is cleared (S42; Yes), the flag is set (S43). Socket write request means 102a writes an event immediately before application write means 105 writes an event to ring buffer 121b and immediately before termination of corresponding callback processing means 102b executed after socket write request means 102a ends. is called asynchronously from either The call may be a normal method or function call, or it may be signaled to a waiting thread using an OS facility. Only in the former case, the flag management means is used to determine whether or not it is possible to request event processing to the OS execution means. In the latter case, since the event processing is being executed by the OS execution means one or more times after the flag has already been set, the OS execution means is requested to process the event without setting the flag again. . The simplest way to notify the caller is to include the caller identifier in the call parameters, but any other method is acceptable. If the flag is set in the former case, then the socket write request means 102a requests the OS execution means 100 to process the event (S44). On the other hand, in the former case, if the flag managed by the flag management means 107 is already set (S42; No), the process is terminated immediately. In the latter case, that is, when the calling source is not the application writing unit 105 but the callback processing unit 102b (S40; No), the socket write request unit 102a responds to the execution of the callback processing unit 102b. Since the flag has already been set when the socket write request means 102a was executed immediately before, the OS execution means 100 is requested to process the event regardless of the state of the flag (S44). As described above, similarly to FIG. 6, operations of flags enclosed by dotted lines (status confirmation and setting S41, S42, and S43 are atomically executed so as not to be affected by interrupts by other threads under a multithread environment. Therefore, the (Compare and Swap) function provided by the flag management means 107 is used.

また、図13にOS実行手段100の動作を示す。ソケット書込要求手段102aは、ステップS44(図11)において第1のバッファ121bに送信対象のデータがあるか確認し(S60)、送信対象のデータがある場合(S60;Yes)、第1のバッファ121b上のイベントを第2のバッファ121bに必要に応じて移動する(S61)。単に移動するだけならば、このステップは省略して、第1のバッファのデータを対象として、いきなりOS非同期送信呼出S63を実行すればよく、移動を省く分だけ処理の効率はよくなる。移動するからには、移動操作においてなんらかの性能の向上が期待される操作、例えば、バッファのメモリタイプの変更、バッファのメモリサイズの変更、バッファ内のデータの配置の変更、移動個数(移動イベント数、あるいは、移動バイト数)の制御などを行い、第1のバッファのメモリチャンクに保持されているイベントを、第2のバッファの新たに割り当てたメモリチャンクにコピーし、第1のバッファのコピー終了後の不要なメモリチャンクを解放する。 13 shows the operation of the OS executing means 100. As shown in FIG. In step S44 (FIG. 11), the socket write request means 102a checks whether there is data to be transmitted in the first buffer 121b1 (S60), and if there is data to be transmitted (S60; Yes), the first If necessary, the events on the buffer 121b- 1 in the buffer 121b-1 are moved to the second buffer 121b- 2 (S61). If the data is simply moved, this step can be omitted and the OS asynchronous send call S63 can be executed immediately for the data in the first buffer. Since it is a move operation, some kind of performance improvement is expected in the move operation, such as changing the memory type of the buffer, changing the memory size of the buffer, changing the arrangement of data in the buffer, the number of moves (number of move events, or , the number of bytes moved), etc., and copies the event held in the memory chunk of the first buffer to the newly allocated memory chunk of the second buffer, and after the copy of the first buffer is completed Release unnecessary memory chunks.

なお、バッファが保持するメモリチャンクの割当や解放はバッファプールを用いると効率がよい。以下の各種バリエーションではバッファプールを仮定し、規格化されたサイズのメモリチャンクを用いたバッファを念頭に記述するが、本発明は、それらのすべての操作、あるいは、一部の操作だけと限定せず、通常に都度割当解放するメモリチャンクであっても、また、チャンクのサイズがばらばらであっても、以下の各種バリエーション、及び、その他の有用な操作を除外するものではない。 It is more efficient to allocate and release memory chunks held by buffers using a buffer pool. The various variations below assume a buffer pool and are described with buffers using standardized size memory chunks in mind, but the present invention is not limited to all or only some of these operations. However, even if the memory chunks are normally deallocated each time, and even if the size of the chunks varies, it does not exclude the following variations and other useful operations.

まず、メモリチャンクのタイプは、第2のバッファを後述するようにOSが処理で使用(S63)するので、OSの処理に適したダイレクトバッファを使用するとよい。 First, as for the type of memory chunk, the OS uses the second buffer for processing (S63) as will be described later, so it is preferable to use a direct buffer suitable for the processing of the OS.

次にバッファのサイズやデータの配置を検討する。OSは同じサイズのデータでも、大きなメモリチャンク1個で処理をする方が、小さなチャンクを数多く処理するより効率がよい。そこで、大きなメモリチャンクを用意し、複数のイベントをひとつのメモリチャンクに順番に配置することで、OSが処理するメモリチャンクの個数を削減するとよい。 Next, consider the buffer size and data placement. The OS is more efficient to process the same size data in one large chunk of memory than to process many small chunks. Therefore, it is preferable to reduce the number of memory chunks processed by the OS by preparing a large memory chunk and sequentially arranging a plurality of events in one memory chunk.

次に移動について検討する。移動のタイミングで、ごく単純に、第1のバッファ121bが保持すすべてのイベントを第2のバッファ121bに移動してしまってもよい。しかし、第2のバッファはOS処理に使うダイレクトバッファを使用すること、OS処理要求が一度に処理できるメモリチャンクの数や総バイト数には上限があることを考慮すると、ダイレクトバッファの使用量を抑制するためには、移動するイベントの数は、受け入れる第2のバッファが保持するメモリチャンクが、OS処理要求に適切な分量以下になるように制御するとよい。たとえば、第2のバッファの保持するダイレクトバッファのメモリチャンクの数に対して、例えば32個程度などの上限を設定し、OSの処理が滞るなどの原因で、第2のバッファがすでに相当量のメモリチャンク(この例では32個に近い数のメモリチャンク)を保持している場合、移動を上限の範囲(この例では例えば32個、あるいは33個などの予め定める上限値)で停止する、あるいは、すでに上限を超えていれば移動を行わない(0個の移動を行う)。このように、第2バッファ121bが保持するメモリチャンク数に上限などの制限を設けることで、通信不調などで滞ったイベントは、第1のバッファ121bに蓄積され、サーバ装置1全体で共有するダイレクトバッファリソースを使う第2のバッファ121bを肥大化させることはない。逆に第2のバッファが保持するチャンクがほとんどない健全な状態では、第1のバッファ121bのイベントすべてを移動できる。 Next, consider movement. All the events held in the first buffer 121b- 1 may be simply moved to the second buffer 121b- 2 at the timing of the transfer. However, considering that the second buffer uses the direct buffer used for OS processing, and that there is an upper limit to the number of memory chunks and the total number of bytes that can be processed at once by the OS processing request, the usage of the direct buffer is To do this, the number of moving events should be controlled so that the memory chunks held by the second receiving buffer are less than or equal to the size appropriate for the OS processing requirements. For example, an upper limit such as 32 is set for the number of direct buffer memory chunks held by the second buffer. If you are holding memory chunks (a number close to 32 memory chunks in this example), stop moving at an upper bound (in this example a predetermined upper limit, e.g. 32 or 33), or , if the upper limit is already exceeded, no movement is performed (0 movement is performed). In this way, by setting a limit such as an upper limit on the number of memory chunks held by the second buffer 121b2 , an event delayed due to a communication failure or the like is accumulated in the first buffer 121b1 and shared by the entire server apparatus 1. It does not bloat the second buffer 121b2 , which uses the direct buffer resource to be used. Conversely, in a healthy state where the second buffer holds few chunks, all events in the first buffer 121b1 can be moved.

第1のバッファ121bから第2のバッファ121bへのイベントの移動は、このようなメモリチャンクのタイプの変更やメモリチャンクのサイズの変更やメモリチャンク内のデータ配置の変更や移動個数の制御あるいはその他の性能向上の工夫の全部あるいは一部だけを実施して、後段のOSでのイベント処理効率をよくするために行う。 Movement of events from the first buffer 121b1 to the second buffer 121b2 is performed by changing the type of memory chunk, changing the size of the memory chunk, changing the data arrangement in the memory chunk, and controlling the number of events to be moved. Alternatively, all or part of other measures for improving performance are implemented in order to improve the efficiency of event processing in the subsequent OS.

以上、2個のバッファ(第1のバッファ121b1と第2のバッファ121b2)の例を記載したが、バッファの個数を2個に限定するものではない。メモリチャンクのタイプの変更やメモリチャンクのサイズの変更やメモリチャンク内のデータ配置の変更や移動個数の制御あるいはその他の性能向上の工夫は、2個のバッファ間の1回の移動ですべて実施する必要はなく、3個以上のバッファを用いて、多段に順次実行してもよい。 Although an example of two buffers (first buffer 121b1 and second buffer 121b2) has been described above, the number of buffers is not limited to two. Changing the type of memory chunk, changing the size of the memory chunk, changing the data arrangement in the memory chunk, controlling the number of moves, and other measures to improve performance are all performed in a single move between two buffers. It is not necessary, and may be executed sequentially in multiple stages using three or more buffers.

また、イベント単位の移動の例を記載したが、移動をイベント単位に限定するものではない。ネットワーク送信などOS処理システムが、個々のイベントの境界にとらわれず、蓄積されたバイト単位に処理をする場合、バッファ間のイベントの移動はイベント単位(0個以上の複数個のイベント)に限定されない。あるイベントの一部分だけでもよいし、連続するイベントの部分を結合したもの(例えば、イベントA,イベントB、イベントCが順番に蓄積されていた時に、イベントAの前半が移動した後は、イベントAの後半の一部(イベントAの残りの後半)、イベントB全部、イベントCの前半の一部を連続するイベントの部分を結合したもの)でもよい。 Also, although an example of movement in event units has been described, movement is not limited to event units. When the OS processing system such as network transmission processes in units of accumulated bytes without being constrained by the boundaries of individual events, movement of events between buffers is not limited to units of events (0 or more events). . It may be only a part of a certain event, or a combination of consecutive event parts (for example, when event A, event B, and event C are accumulated in order, after the first half of event A is moved, event A (remaining second half of event A), all of event B, and a part of the first half of event C combined).

また、第1のバッファ121bに送信対象のデータがない場合(S60;No)、ステップS62へと進む。 If there is no data to be transmitted in the first buffer 121b1 (S60; No), the process proceeds to step S62.

なお、第1のバッファ121bへイベントを追加するのは、アプリケーション書込手段105である。アプリケーション書込手段105は、第1のバッファ121bへイベントを追加後(図10)に、ソケット書込要求手段102aを呼び出す。アプリケーション書込手段105は、並行動作する複数スレッド103から非同期に呼出され、ノンブロッキングで第1のバッファ121bにイベントを蓄積する。バッファとしては、たとえば、Javaが提供するキュー(java.util.concurrent.ConcurrentLinkedQueue)を、メモリチャンクへのポインタを管理するFIFOバッファを利用する。バッファプールが管理する、メモリチャンクを再利用することで、効率のよいリングバッファを実現できる。バッファプールのメモリチャンクは典型的なイベントサイズより少し大きめのメモリサイズで規格化するとよい。メモリチャンクにはいりきらない大きなイベントは複数のチャンクに保管する。チャンクサイズは、ページサイズの2の累乗数分の1となるように調整する。第2のバッファ121bも、第1のバッファ121b同様に、イベント情報格納したメモリチャンクへのポインタを保持するFIFOキュー(例えば、java.util.concurrent.ConcurrentLinkedQueue)が使用できる。 It is the application writing means 105 that adds the event to the first buffer 121b1 . After adding the event to the first buffer 121b1 (FIG. 10), the application writing means 105 calls the socket write requesting means 102a. The application writing means 105 is asynchronously called by the threads 103 operating in parallel and accumulates events in the first buffer 121b1 in a non-blocking manner. As the buffer, for example, a queue provided by Java (java.util.concurrent.ConcurrentLinkedQueue) is used, and a FIFO buffer that manages pointers to memory chunks is used. Efficient ring buffers can be implemented by reusing memory chunks managed by the buffer pool. The buffer pool memory chunk should be normalized to a memory size slightly larger than the typical event size. Large events that do not fit in memory chunks are stored in multiple chunks. The chunk size is adjusted to be 1/2 power of the page size. As with the first buffer 121b- 1 , the second buffer 121b- 2 can also use a FIFO queue (for example, java.util.concurrent.ConcurrentLinkedQueue) that holds pointers to memory chunks storing event information.

次に、ソケット書込要求手段102aは、第2のバッファ121bに送信対象のデータがある場合(S62;Yes)、OS実行手段100にOS非同期送信要求を行ってイベントの処理を要求する(S63)。例えば、JavaのAsynchronousSocketChannel.write()の集約書込(gathering write)を呼び出して、複数メモリチャンクを送信対象として、1回の呼び出しで複数のイベントの処理を要求する。また、ソケット書込要求手段102aは、第2のバッファ121bに送信対象のデータがない場合(S62;No)、フラグ管理手段107に依頼して、フラグを解除する(S64)。第1のバッファ121bにデータがないことを確認(S60)後、第2のバッファ121bにもデータがないことを確認(S62)したので、中間バッファ121B(第1のバッファ121b及び第2のバッファ121b)が保持するデータをすべて送信し終わったとみなして、フラグを解除して、場合によってはフラグをたてたまま複数回連続的に行ってきたOS非同期送信呼び出しを終了する。送信し終わったとみなした後、フラグを解除するまでの間に、第1のバッファ121b1にイベントが追加された場合は、次のイベントとともにOS処理が実行される。 Next, when the second buffer 121b2 contains data to be transmitted (S62; Yes), the socket write request means 102a issues an OS asynchronous transmission request to the OS execution means 100 to request event processing ( S63). For example, Java's AsynchronousSocketChannel. Call write( ) gathering write to send multiple memory chunks to request processing of multiple events in one call. If there is no data to be transmitted in the second buffer 121b2 (S62; No), the socket write request means 102a requests the flag management means 107 to clear the flag (S64). After confirming that there is no data in the first buffer 121b1 (S60), it is confirmed that there is no data in the second buffer 121b2 (S62). 2 buffer 121b 2 ) has been completely transmitted, the flag is cleared, and depending on the situation, the OS asynchronous transmission call that has been continuously made multiple times with the flag set is terminated. If an event is added to the first buffer 121b1 before the flag is cleared after it is determined that the transmission has ended, the OS process is executed together with the next event.

図12に示すコールバック処理手段102bは、OS実行手段100がソケット書込要求手段102aの書込イベントの処理を完了した場合に、OS実行手段100から完了通知を受け付けて、対応するソケット書込要求手段102aとは非同期に実行する。コールバック処理手段102bは、OS実行手段100が実行したネットワーク送信結果を受け取る(S50)。送信結果が正常の場合は(S51;Yes)、コールバック処理手段102bは、送信完了分を第2のバッファ121bから削除し(S52)、ソケット書込要求手段102aに呼び出しを行う(S53)。また、送信結果が異常の場合は(S51;No)、コールバック処理手段102bは、通信断、タイムアウトなどの例外処理(接続の切断など)を行う(S54)。 The callback processing means 102b shown in FIG. 12 receives a completion notification from the OS execution means 100 when the OS execution means 100 completes the processing of the write event of the socket write request means 102a, and writes to the corresponding socket. It executes asynchronously with the request means 102a. The callback processing means 102b receives the network transmission result executed by the OS executing means 100 (S50). If the transmission result is normal (S51; Yes), the callback processing means 102b deletes the transmission completion data from the second buffer 121b2 (S52), and calls the socket write request means 102a (S53). . If the transmission result is abnormal (S51; No), the callback processing means 102b performs exceptional processing (disconnection, etc.) such as disconnection of communication or timeout (S54).

(情報処理装置の動作)
第2の実施の形態の作用を、(1)基本動作、(2)データ送信動作に分けて説明する。
(Operation of information processing device)
The operation of the second embodiment will be described separately for (1) basic operation and (2) data transmission operation.

図9は、第2の実施の形態のデータ送受信の動作の一例を説明するための概略図である。 FIG. 9 is a schematic diagram for explaining an example of data transmission/reception operations according to the second embodiment.

(1)基本動作
まず、ネットワーク4からサーバ装置1がデータを受信する場合、ネットワーク4のソース131からあるチャネル130を介し、ソケット読出手段101がチャネルに対応するソケット(受信元端末装置に対応するあるIPアドレスのあるポート)によって受信したデータを読み出して中間バッファ121Bに書き込む。データは中間バッファ121Bに追加される。なお、バッファはチャネルあるいはソケットごとに別々に用意する。また、チャネル/ソケットは送受信共用で、対応する端末装置(端末装置の通信相手となる特定のプログラム)ごとに1つ用意する。アプリバッファは、1つで図示しているが、実際は送受信別に管理する。また、中間バッファ121Bは、バッファプールとしては、全チャネルで1つとして管理されており、1つで図示しているが、チャネルごと、送受信別々に管理され、チャネルごとに、別々の受信中間バッファ、送信中間バッファとして区別する。
(1) Basic operation First, when the server device 1 receives data from the network 4, the socket reading means 101 receives data from the source 131 of the network 4 via the channel 130 and the socket corresponding to the channel (corresponding to the receiving terminal device). A port with a certain IP address) is read and written to the intermediate buffer 121B. Data is added to intermediate buffer 121B. Separate buffers are prepared for each channel or socket. A channel/socket is used for both transmission and reception, and one channel/socket is prepared for each corresponding terminal device (a specific program that becomes a communication partner of the terminal device). One application buffer is shown in the drawing, but in practice, it is managed separately for transmission and reception. In addition, the intermediate buffer 121B is managed as one buffer pool for all channels. , as a transmission intermediate buffer.

以降のアプリバッファ120への書込動作は第1の実施の形態と共通するため省略する。 The subsequent write operation to the application buffer 120 is omitted because it is common to the first embodiment.

次に、アプリケーション実行手段103は、アプリバッファ120のデータを読み出してスレッドにて処理する。 Next, the application execution means 103 reads the data of the application buffer 120 and processes it in the thread.

また、アプリケーション実行手段103のスレッドで処理されたデータをネットワーク4に送信する場合、アプリケーション実行手段103は、スレッドで処理されたデータをアプリバッファ120に書き込む。第2の実施の形態ではアプリケーション書込手段105がマルチスレッドで並行処理される場合をメインに説明する。 Also, when transmitting data processed by the thread of the application execution unit 103 to the network 4 , the application execution unit 103 writes the data processed by the thread into the application buffer 120 . In the second embodiment, the case where the application writing means 105 performs multithread parallel processing will be mainly described.

アプリケーション書込手段105は、アプリバッファ120のデータを意図する送信先端末装置に応じて、送信先端末装置、より厳密には、チャネルあるいはソケットに対応する中間バッファ121B、特に第1のバッファ121bにスレッド毎に書き込む。第1のバッファ121bには、スレッド毎に用意された領域に順次データが書き込まれる。アプリケーション書込手段105の並行処理の効率をよくするために、アプリケーション書込手段105はノンブロキングに中間バッファ121Bにデータ(処理結果のイベント)を書き込む。 Depending on the destination terminal device for which the data in the application buffer 120 is intended, the application writing means 105 writes an intermediate buffer 121B, in particular the first buffer 121b 1 , corresponding to the destination terminal device, more precisely to the channel or socket. per thread. In the first buffer 121b1 , data are sequentially written in areas prepared for each thread. In order to improve the efficiency of parallel processing by the application writing means 105, the application writing means 105 writes data (process result events) to the intermediate buffer 121B in a non-blocking manner.

次に、ソケット書込手段102は、任意のタイミングで第1のバッファ121bから第2のバッファ121bへ順次データを移動する。移動とは、データを保持するメモリチャンクを第1のバッファ121bから第2のバッファ121bへと文字通りバッファ間で移動する場合だけでなく、対象データを第2のバッファへコピーした後に、第1のバッファからは削除する場合を含む。また、移動とは、単なる1対1の移動にとどまらず、移動によりバッファのタイプ、メモリチャンクのサイズ、メモリチャンク内での配置方法を変更したり、移動するイベント個数の調整をしたり、OS実行手段が処理しやすいデータ保持形態に変換したりすることも含む。これらの変換を段階的に実施するためには、第3のバッファ、第4のバッファなどさらにバッファ個数(バッファの段数)を増やしてもよい。また、バッファの利用都度に発生するメモリの割当・解放の負荷を軽減するために、データを保持するメモリチャンクはあらかじめまとめて割り当てたメモリを再利用するバッファプールで管理することができる。第1のバッファ、第2のバッファでバッファプールを共有することもできる。また、複数チャネルでそれぞれのバッファ管理を行う場合でも、単一のバッファプールを共有することもできる。バッファプールでは、多くの場合、規格化されたサイズのメモリチャンクを1種類あるいは複数種類保持する。バッファプールは通信管理プログラム起動時にシステムから確保したメモリを使い回すため、バッファプールのメモリを使ったメモリの割当・解放はシステムコールを伴わず処理が軽い、頻繁で複雑なメモリ利用をしても、システムメモリのフラグメンテーションを引き起こさないなどの効果がある。バッファプールは起動時に適切量を確保するが、実行時に不足が起きてしまった場合は、その時点、あるいは、不足が予測された時点で、OSに負荷を与えてしまうので、可能であればある適当なタイミングを見計らって、OSにリクエストして追加のメモリを確保し、バッファプールを拡張することが望ましい。バッファプールが確保するメモリチャンクのメモリの種類やチャンクのサイズは利用形態で適切にチューニングする。第1のバッファで扱うメモリチャンクとしては、通常のヒープが管理する非ダイレクトバッファから平均的なイベントサイズより少し大きな単一サイズ(例えば256バイト)を選択する。第2のバッファで扱うメモリチャンクとしては、OSが扱いやすいサイズとタイプ、例えばページサイズ、あるいはページサイズの半分(例えば2KB)のダイレクトバッファを選択する。メモリプールのサイズは、OSからまとめて取得したバッファを小分けにして使うので、ページサイズやメモリ境界を意識して、ページサイズ、あるいは、ページサイズの2の累乗数分の1の値を採用し、25バイトや50バイトのような任意の値を採用しない。 Next, the socket writing means 102 sequentially moves data from the first buffer 121b- 1 to the second buffer 121b- 2 at arbitrary timing. Moving refers not only to literally moving a memory chunk holding data between buffers, from the first buffer 121b 1 to the second buffer 121b 2 , but also to copying the target data to the second buffer and then moving it to the second buffer. 1 includes the case of deleting from the buffer. In addition, movement is not limited to simple one-to-one movement, but can be used to change the buffer type, memory chunk size, arrangement method within a memory chunk, adjust the number of events to be moved, or change the number of events to be moved. It also includes conversion into a data retention form that is easy for execution means to process. In order to carry out these conversions step by step, the number of buffers (the number of stages of buffers) such as the third buffer and the fourth buffer may be increased. In addition, in order to reduce the load of memory allocation and release each time a buffer is used, memory chunks that hold data can be managed in a buffer pool that reuses pre-allocated memory. A buffer pool can also be shared by the first buffer and the second buffer. A single buffer pool can also be shared even when multiple channels manage their own buffers. A buffer pool often holds one or more types of standardized size memory chunks. Since the buffer pool uses the memory allocated from the system when the communication management program is started, allocation and freeing of memory using the buffer pool memory does not involve system calls, and the processing is light. , and does not cause system memory fragmentation. The buffer pool secures an appropriate amount at startup, but if there is a shortage during execution, or when the shortage is predicted, the OS will be overloaded, so if possible, It is preferable to make a request to the OS to secure additional memory and expand the buffer pool at an appropriate time. The types of memory chunks secured by the buffer pool and the size of the chunks are appropriately tuned according to the usage pattern. As the memory chunk handled by the first buffer, a single size (for example, 256 bytes) slightly larger than the average event size is selected from the non-direct buffer managed by the normal heap. As the memory chunk handled by the second buffer, a direct buffer of a size and type that is easy for the OS to handle, such as a page size or a half of the page size (eg, 2 KB) is selected. As for the size of the memory pool, the buffers obtained from the OS are used in small portions, so the page size or a value divided by a power of 2 of the page size should be used with the page size and memory boundaries in mind. , do not adopt arbitrary values such as 25 bytes or 50 bytes.

次に第1のバッファから第2のバッファへ移動するタイミングは、予め定めた時間間隔毎であってもよいし、第1のバッファ121b又は第1のバッファ121b内のチャンクに蓄積されたデータ量が予め定めた量になった場合であってもよいし、第1のバッファ121b又は第1のバッファ121b内のチャンク蓄積されたイベントの数が予め定めた数になった場合であってもよい。 The next timing of moving from the first buffer to the second buffer may be every predetermined time interval, or the first buffer 121b- 1 or the chunk stored in the first buffer 121b- 1 . It may be when the amount of data reaches a predetermined amount, or when the number of chunk-accumulated events in the first buffer 121b- 1 or in the first buffer 121b- 1 reaches a predetermined number. There may be.

ソケット書込手段102の起動のトリガ、あるいは、第1のバッファ121bから第2のバッファ121bへのデータの移動のトリガは、ポーリングやタイマなどであってもよいし、すべてあるいは一部のアプリケーション書込手段105の実行直後であってもよい。 A trigger for activating the socket writing means 102 or a trigger for moving data from the first buffer 121b1 to the second buffer 121b2 may be polling or a timer, or all or part of it. It may be immediately after execution of the application writing means 105 .

なお、3段以上のバッファを使用する場合において、格段のバッファ間のデータの移動のタイミング、トリガ、移動方法などは、それぞれの段間で、上記記載の第1バッファと第2バッファについて記述した方法をそれぞれの段で独立に採用することができる。上記の例では移動の際に複数の操作(チャンクのメモリタイプの変更、チャンクサイズの変更、移動量の制限など)を同時に行ったが、操作を分割して、途中結果を追加のバッファとして保持することが考えられる。その場合には、移動のタイミング、トリガはすべての段で同じであってもよい。 When three or more stages of buffers are used, the timing, trigger, movement method, etc. for moving data between stages are described for the above-described first and second buffers. The method can be employed independently at each stage. In the above example, when moving, multiple operations (chunk memory type change, chunk size change, movement amount limit, etc.) were performed at the same time, but the operations were divided and the intermediate results were stored as additional buffers. can be considered. In that case, the movement timing and trigger may be the same for all stages.

次に、ソケット書込手段102は、第2のバッファ121bのデータを読み出し、ソケットによってチャネル130に書き込む。データは、チャネル130を介してソース131に送信される。この時、データは第2のバッファ121bから取り出され、送信対象としてOS実行手段100が送信処理をし、送信が完了したデータ(取り出したデータの全部あるいは一部)については、第2のバッファ121bから削除される。送信が完了しなかったデータについては、引き続き第2のバッファ121bにとどまる。ここでは、第2のバッファ121bに蓄積されたデータを全部一度に送信するものとしたが、第2のバッファ121bに蓄積されているデータが巨大になった場合は、OS送信機能呼出の制限を考慮するなど、全部一度に読み出さず、一部だけを読み出して送信する制御をしてもよい。あるいは、第2のバッファ121bが蓄積するデータが巨大にならないように、第1のバッファ121bから第2のバッファ121bへ移動するイベントの数やバイト数を移動の際にあらかじめ制限してもよい。 Next, the socket writing means 102 reads the data in the second buffer 121b2 and writes it to the channel 130 by means of the socket. Data is transmitted to source 131 via channel 130 . At this time, the data is taken out from the second buffer 121b2 , and the OS executing means 100 performs transmission processing as a transmission target. 121b2 . Data for which transmission has not been completed will continue to remain in the second buffer 121b2 . Here , all the data accumulated in the second buffer 121b2 is transmitted at once. Control may be performed to read and transmit only a portion of the data, instead of reading all at once, for example, in consideration of restrictions. Alternatively, the number of events and the number of bytes transferred from the first buffer 121b-1 to the second buffer 121b- 2 are limited in advance so that the data accumulated in the second buffer 121b-2 does not become huge. good too.

以下、アプリケーション実行手段103のスレッドで処理されたデータをOS実行手段100からネットワーク4に送信する場合について詳細に説明する。 A case in which data processed by the thread of the application execution means 103 is transmitted from the OS execution means 100 to the network 4 will be described in detail below.

(2)データ送信動作
図10は、データ送信動作の一例を説明するための概略図である。スレッド1とスレッド2が、非同期にそれぞれイベントA,C,F,及びイベントB,D,Eを順次生成し、アプリケーション書込手段105、ソケット書込要求手段102aを呼び出し、それぞれのイベントA-Fをネットワーク4に送信する。アプリケーション書込手段105は、スレッド1及びスレッド2が生成したイベント1個を第1のバッファ121bに追加し、ソケット書込手段102aを呼び出す。ソケット書込手段102aは、OSカーネル100がすでにイベント処理を実行中の場合は処理を行わないで終了するが、OSカーネル100がイベント処理を実行中でない場合は、第1のバッファ121bが保持する0個以上のイベントを第2のバッファ121bへ移動し、第2のバッファ121bが保持するイベントについて、OSカーネル100にイベントの処理を依頼する。OSカーネル100がイベントの処理中であるかどうかの状態は、フラグ管理手段107が提供するCASフラグにより管理される。OSカーネル100は要求されたイベントの処理を完了すると、コールバックスレッド(スレッド1のコールバックスレッド)で、コールバック処理手段102bを、スレッド1及びスレッド2とも非同期に実行する。コールバックスレッドは、イベント処理の進捗状況を確認して、第2のバッファ121bを調整後(処理済のイベントを第2のバッファから削除したり、第1のバッファから第2のバッファへイベントを移動したりして)、ソケット書込手段aを再帰的かつ排他的に呼び出し、OSカーネル100が処理中に第1のバッファ121bに蓄積されたイベントについても、イベント処理を行う。コールバックスレッドは、ソケット書込要求手段102a及びコールバック処理手段102bの処理を繰り返して、中間バッファ121B(すなわち、第1のバッファ121b及び第2のバッファ121b)が保持するイベントがなくなるまで稼働する。
(2) Data Transmission Operation FIG. 10 is a schematic diagram for explaining an example of data transmission operation. Thread 1 and thread 2 asynchronously generate events A, C, F and events B, D, E, respectively, and call application writing means 105 and socket write request means 102a, and generate events A to F, respectively. to the network 4. Application writing means 105 adds one event generated by thread 1 and thread 2 to first buffer 121b1 and calls socket writing means 102a. If the OS kernel 100 is already executing event processing, the socket writing means 102a ends without processing. It moves zero or more events to the second buffer 121b2 , and requests the OS kernel 100 to process the events held in the second buffer 121b2 . The state of whether the OS kernel 100 is processing an event is managed by a CAS flag provided by the flag management means 107 . When the OS kernel 100 completes the processing of the requested event, the callback thread (the callback thread of thread 1) executes the callback processing means 102b asynchronously with both thread 1 and thread 2. FIG. The callback thread confirms the progress of event processing and adjusts the second buffer 121b2 (deleting the processed event from the second buffer or transferring the event from the first buffer to the second buffer). ) to recursively and exclusively call the socket writing means a, and process the events accumulated in the first buffer 121b1 during processing by the OS kernel 100 as well. The callback thread repeats the processes of the socket write request means 102a and the callback processing means 102b until there are no more events held by the intermediate buffer 121B (that is, the first buffer 121b 1 and the second buffer 121b 2 ). operate.

アプリケーション実行手段103は、例えば、複数のスレッド1、スレッド2によりデータを処理し、処理結果のイベントA、イベントBを同一の端末装置(より厳密には、同一のソケットあるいはチャネル)に送信するために、当該イベントA、イベントBはアプリケーション書込手段105により送信先端末へ通信するソケットに対応する第1のバッファ121bに書き込まれる。スレッド1、スレッド2の処理は非同期に発生するものとする。第1のバッファ121bは、例えばスレッドセーフでノンブロッキングなリングバッファ(例えば、ノンブロッキングでスレッドセーフなFIFOキュー java.util.ConcurrentLinkedQueue にイベントを格納するメモリチャンクのポインタを登録することで実現可能)である。アプリケーション書込手段105は、イベントA、イベントBをスレッド毎に異なる領域(チャンク)にノンブロッキングにイベントを書き込む(1)(2)。特に、イベントのサイズのメモリチャンクの代わりに、規格化されたサイズのメモリチャンクを用いる場合は、メモリチャンクは、例えば、java.nio.ByteBufferを用いて、保管しているイベントの開始位置と終了位置も管理する。また、規格化されたサイズのメモリチャンクにイベントを保管する場合、チャンクサイズより大きなイベントについては、イベントを複数チャンクにわたるチャンクグループに保管し、チャンクグループへのポインタをリングバッファに追加してもよい。 The application execution means 103, for example, processes data by a plurality of threads 1 and 2, and transmits event A and event B as processing results to the same terminal device (more precisely, the same socket or channel). Then, the event A and event B are written by the application writing means 105 to the first buffer 121b1 corresponding to the socket for communication to the destination terminal. It is assumed that processing of threads 1 and 2 occurs asynchronously. The first buffer 121b 1 is, for example, a thread-safe, non-blocking ring buffer (for example, it can be realized by registering a pointer to a memory chunk storing an event in a non-blocking, thread-safe FIFO queue java.util.ConcurrentLinkedQueue). . The application writing unit 105 writes events A and B in non-blocking areas (chunks) that are different for each thread (1) and (2). In particular, if standardized size memory chunks are used instead of event size memory chunks, the memory chunks can be, for example, java. nio. The ByteBuffer is also used to manage the start and end positions of the stored events. Also, when storing events in memory chunks of a normalized size, for events larger than the chunk size, events may be stored in chunk groups spanning multiple chunks, and a pointer to the chunk group may be added to the ring buffer. .

さて、まず、スレッド1のイベントAについては、アプリケーション書込手段105は第1のバッファ121bのイベントAの処理を要求すべくソケット書込要求手段102aを呼び出す(3)。ソケット書込要求手段102aは、呼出元がアプリケーション書込手段105なので、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて(4)、第1のバッファ121bにイベントが蓄積されているか確認し、イベントがあるので第1のバッファ121bのイベントAを第2のバッファ121bへ移動する(5)。ここで、第2のバッファ121bも、第1のバッファ121b同様に、例えばノンブロッキングなリングバッファ(例えば、ノンブロッキングでスレッドセーフなFIFOキュー java.util.ConcurrentLinkedQueue にイベントを格納するメモリチャンクのポインタを登録することで実現可能)であってもよい。ただし、第2のバッファの操作を行うスレッドは、フラグ管理手段107により、高々1個に制御されているので、スレッドセーフでなくてもよい。また、ソケット書込要求手段102aは、イベントAを第2のバッファ121bへ移動した後、スレッド1に次の処理を進めるよう呼び出しを行い、処理はOSカーネル100にまかせて(6)、OSカーネル100の処理の完了をまたずに終了し、スレッド1の処理に戻る(7)。 First, for event A of thread 1, application writing means 105 calls socket writing request means 102a to request processing of event A of first buffer 121b1 (3). Since the caller is the application writing unit 105, the socket write request unit 102a refers to the CAS flag of the flag management unit 107. Since the flag is not set, the socket write request unit 102a sets the flag (4), and writes the first buffer 121b1. , and since there is an event, event A in the first buffer 121b- 1 is moved to the second buffer 121b- 2 (5). Here, the second buffer 121b 2 , like the first buffer 121b 1 , also stores pointers to memory chunks that store events in, for example, a non-blocking ring buffer (for example, a non-blocking thread-safe FIFO queue java.util.ConcurrentLinkedQueue). can be realized by registering). However, since the number of threads that operate the second buffer is limited to one at most by the flag management means 107, it does not have to be thread-safe. After moving event A to the second buffer 121b2 , the socket write request means 102a calls the thread 1 to proceed with the next process, and leaves the process to the OS kernel 100 (6). The processing ends without waiting for the processing of the kernel 100 to be completed, and the processing of the thread 1 is returned to (7).

一方で、スレッド2のイベントBについては、アプリケーション書込手段105は第1のバッファ121bのイベントBの処理を要求すべくソケット書込要求手段102aを呼び出す(8)。ソケット書込要求手段102aは、呼出元がアプリケーション書込手段105なので、フラグ管理手段107のCASフラグを参照し(9)、この場合は先のイベントAの処理のためにすでにフラグが立っている(4)ため、もはやフラグをたてられない。ソケット書込要求手段102aは、処理ができるようになるまで待たず、ノンブロッキングで処理を終了してスレッド2の処理に戻る(10)。 On the other hand, for event B of thread 2, application writer 105 calls socket write requester 102a to request processing of event B of first buffer 121b1 (8). Since the caller is the application writing means 105, the socket write request means 102a refers to the CAS flag of the flag management means 107 (9). (4) so it is no longer flagged. The socket write request means 102a does not wait until processing becomes possible, ends processing in a non-blocking manner, and returns to the processing of thread 2 (10).

スレッド1については、アプリケーション実行手段103は、引き続きデータを処理し、アプリケーション書込手段105は処理結果のイベントCを第1のバッファ121bに書き込む(11)。第1のバッファ121bは、未処理のイベントBとイベントCを保持している(11)。スレッド1のイベントCについては、アプリケーション書込手段105は第1のバッファ121b1のデータ(追加したデータCだけでなく、すでに追加されているデータBも)の処理を要求すべくソケット書込要求手段102aを呼び出す(50)。ソケット書込要求手段102aは、呼出元がアプリケーション書込手段105なので、フラグ管理手段107のCASフラグを参照し、この場合は先のデータAの処理のためにすでにフラグが立っている(4)ため、もはやフラグをたてられない。ソケット書込要求手段102aは、処理ができるようになるまで待たず、ノンブロッキングでソケット書込要求手段102aの処理を終了してスレッド1の処理に戻る。 For thread 1, the application executing means 103 continues to process data, and the application writing means 105 writes event C as a processing result into the first buffer 121b1 (11). The first buffer 121b1 holds unprocessed events B and C (11). For event C of thread 1, application writing means 105 requests processing of the data in first buffer 121b1 (not only added data C but also already added data B). 102a (50). Since the caller is the application writing means 105, the socket write request means 102a refers to the CAS flag of the flag management means 107. In this case, the flag is already set due to the previous processing of the data A (4). so it can no longer be flagged. The socket write requesting means 102a does not wait until the process becomes ready, but ends the processing of the socket write requesting means 102a in a non-blocking manner and returns to the thread 1 process.

スレッド1のイベントAのネットワーク送信については、具体的には、ソケット書込要求手段102aが、OSカーネル100に処理をまかせる(6)際には、OSシステムコール(例えばJAVAのAsynchronousSocketChannel.write())呼び出しを行い、第2のバッファ121bに存在するイベントA(12)を指定して送信要求する。ソケット書込要求手段102aは、第2のバッファ121bのイベントAをOS実行手段100(OSカーネル)に書き込み要求をして終了し、スレッド1の処理に戻る(7)。 Regarding the network transmission of the event A of the thread 1, specifically, when the socket write request means 102a leaves the processing to the OS kernel 100 (6), an OS system call (for example, AsynchronousSocketChannel.write() of JAVA ) to request transmission of event A(12) existing in the second buffer 121b2 . The socket write request means 102a requests the OS execution means 100 (OS kernel) to write event A in the second buffer 121b2 , ends the process, and returns to the process of thread 1 (7).

スレッド1のイベントAのネットワーク送信については、送信依頼されたOSカーネル100は、第1の実施の形態と同様に、イベントAを適切なサイズに分割してイベントA1、A2を送信する(13)。分割のサイズ、分割の個数、送信間隔はOSやネットワークの負荷などに依存する。 As for network transmission of event A of thread 1, the OS kernel 100 that has received the transmission request divides event A into appropriate sizes and transmits events A1 and A2 (13), as in the first embodiment. . The size of division, the number of divisions, and the transmission interval depend on the OS, network load, and the like.

また、一方で、スレッド2のイベントBについて、OSカーネル100がイベントAの処理中に、アプリケーション書込手段105は、第1のバッファ121bのイベントBを処理すべく、引き続きソケット書込要求手段102aを呼び出す(8)が、ソケット書込要求手段102aは、まだイベントAが処理中(4)でフラグ管理手段107のCASフラグが立っている(9)のでソケット書込要求手段102aは第1のバッファ121bのイベントBを第2のバッファ121bへ移動せず、アプリケーション書込手段105は処理を終了し、スレッド2は次の処理を進める(10)。この時点では、第1のバッファ121bには、イベントB、Cが蓄積されており、まだイベントDは生成されていない(11)。アプリケーション実行手段103は、スレッド2によりデータを処理して、後のタイミングでイベントDを生成する。 On the other hand, regarding event B of thread 2, while OS kernel 100 is processing event A, application writing means 105 continues to process event B of first buffer 121b1 . 102a is called (8), but the socket write request means 102a is still processing event A (4) and the CAS flag of the flag management means 107 is set (9). Without moving the event B in the second buffer 121b-1 to the second buffer 121b- 2 , the application writing means 105 terminates the processing, and the thread 2 proceeds to the next processing (10). At this time, the events B and C are accumulated in the first buffer 121b1 , and the event D has not yet been generated (11). The application executing means 103 processes data by the thread 2 and generates an event D at a later timing.

次に、スレッド1よりイベントAの送信依頼されたOSカーネル100は、イベントAの送信を完了すると、コールバック処理手段102bをスレッド1のコールバックスレッドとして起動して(14)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントA全体が送信完了しているので、第1のバッファ121bからイベントAを削除する(15)。この時点で第1のバッファ121bにはイベントB、Cが存在する(11)。その後、コールバック処理手段102bは、ソケット書込要求手段102aを呼び出す(16)。 Next, when the OS kernel 100 is requested to send the event A by the thread 1, when the transmission of the event A is completed, the callback processing means 102b is started as the callback thread of the thread 1 (14), and the callback processing means 102b confirms the number of bytes that have been transmitted, and in this case the entire event A has been transmitted, so it deletes event A from the first buffer 121b1 (15). At this point, events B and C are present in the first buffer 121b1 (11). After that, the callback processing means 102b calls the socket write request means 102a (16).

引き続き、コールバックスレッドにおいて、ソケット書込要求手段102aは、第1のバッファ121bにイベントが蓄積されているか確認し、イベントがあるので第1のバッファ121bのイベントB、Cを第2のバッファ121bへ移動する(17)。ここでは、第2のバッファ121b2の容量に十分余裕があるので、第1のバッファ121b1のイベントすべてを移動したが、第2のバッファ121b2の容量などを考慮して、第1のバッファ121b1が蓄積するイベントの一部だけ(例えばイベントBだけ)を移動してもよい。たまたま、この後のタイミングで、スレッド2のイベントDについて、アプリケーション書込手段105は処理結果のイベントDを第1のバッファ121bに書き込む(18)。この時点では、第1のバッファ121b1はイベントDだけを保持している。 Subsequently, in the callback thread, the socket write request means 102a checks whether events are accumulated in the first buffer 121b -1 . Move to buffer 121b2 (17). In this case, since the capacity of the second buffer 121b2 is sufficient, all the events in the first buffer 121b1 are moved. You may move only a part of the event (for example, only event B). By chance, at a later timing, the application writing means 105 writes the processing result event D of the thread 2 into the first buffer 121b1 (18). At this point, the first buffer 121b1 holds only event D.

さて、スレッド1のイベントCについては、引き続きソケット書込要求手段102aを呼び出すが、フラグ管理手段107のCASフラグが立っているので、ソケット書込要求手段102aは第1のバッファ121bのイベントB、イベントCを第2のバッファ121bへ移動せず、アプリケーション書込手段105は処理を終了し、スレッド1に戻り処理を進める(19)。アプリケーション実行手段103は、スレッド1によりデータを処理し、後のタイミングでイベントFを生成する(20)。また、この第1バッファ121b1のイベントBとイベントCについては、前述したように、後のタイミングで、コールバックスレッドによりイベント処理が行われることになる。 As for event C of thread 1, the socket write request means 102a is subsequently called. , event C is not moved to the second buffer 121b2 , the application writing means 105 terminates the processing, returns to the thread 1, and advances the processing (19). The application executing means 103 processes data by the thread 1 and generates an event F at a later timing (20). Also, as described above, the callback thread processes the event B and the event C of the first buffer 121b1 at a later timing.

次に、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bの場合なので、引き続きOSシステムコール呼び出しを行い、第2のバッファ121bのイベントBとイベントCを送信要求する(21)。ソケット書込要求手段102aは、第2のバッファ121bのイベントBをOS実行手段100(OSカーネル)に書き込み要求をしてコールバックスレッドを終了する。 Next, in the callback thread, since the call source is the callback processing means 102b, the socket write request means 102a continues to call the OS system call, and transmits event B and event C of the second buffer 121b2 . Request (21). The socket write request means 102a requests the OS execution means 100 (OS kernel) to write event B in the second buffer 121b2 , and terminates the callback thread.

次に、コールバックスレッドよりイベントB、Cの送信依頼をされたOSカーネル100は、イベントB及びイベントCを適切なサイズに分割してネットワークに送信する。まずイベントBを3分割してイベントB1、B2、B3と送信して、終了(OSカーネルは処理を完了)する。イベントBのみ送信してイベントCを送信しない理由、あるいはイベントBの一部でなくイベントB全体を送信した理由は、OSの都合であり、サーバ装置1又はネットワーク4の負荷などの状況による(22)。 Next, the OS kernel 100, which has been requested to transmit events B and C by the callback thread, divides the events B and C into appropriate sizes and transmits them to the network. First, event B is divided into three and transmitted as events B1, B2, and B3, and the processing ends (the OS kernel completes the processing). The reason why only the event B is sent and not the event C, or the reason why the entire event B is sent instead of a part of the event B depends on the circumstances of the OS and the load on the server device 1 or the network 4 (22 ).

また、スレッド2のイベントDについて、スレッド1のコールバックスレッドに依頼されたOSカーネル100のイベント処理中に、アプリケーション書込手段105は、第1のバッファ121bのイベントDを処理すべく、引き続きソケット書込要求手段102aを呼び出す(23)が、ソケット書込要求手段102aはイベントB、Cの処理中(16)でフラグ管理手段107のCASフラグが立っている(24)のでソケット書込要求手段102aは第1のバッファ121bのイベントDを第2のバッファ121bへ移動せず、アプリケーション書込手段105は終了し、スレッド2に戻り次の処理を進める(25)。アプリケーション実行手段103は、引き続きスレッド2によりデータを処理して、後のタイミングでイベントEを生成する(26)。この時点で、第1のバッファ121bには、イベントDが蓄積(18)されており、まだイベントEは生成されていない。 Also, regarding event D of thread 2, during event processing of the OS kernel 100 requested by the callback thread of thread 1, the application writing means 105 continues to process event D of the first buffer 121b1 . The socket write request means 102a is called (23), but since the socket write request means 102a is processing events B and C (16) and the CAS flag of the flag management means 107 is set (24), a socket write request is issued. The means 102a does not move the event D in the first buffer 121b- 1 to the second buffer 121b- 2 , the application writing means 105 terminates and returns to thread 2 to proceed with the next process (25). The application execution means 103 continues to process data by thread 2 and generates event E at a later timing (26). At this time, the event D is accumulated (18) in the first buffer 121b1 , and the event E has not yet been generated.

次に、コールバックスレッドよりイベントB、Cの送信依頼をされたOSカーネル100は、イベントBの送信を完了すると、コールバック処理手段102bを起動して(27)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントB全体が送信完了しているので、第1のバッファ121bからイベントBを削除する。 Next, the OS kernel 100, which is requested to send events B and C from the callback thread, completes the transmission of event B and activates the callback processing means 102b (27), and the callback processing means 102b transmits Check the number of bytes completed, and delete event B from the first buffer 121b1 , since in this case the entire event B has been transmitted.

この時点で、スレッド2は、イベントEを生成し、アプリケーション書込手段105によりイベントEを第1のバッファ121bに書き込む。第1のバッファ121bにはイベントD、Eが存在する(28)。スレッド2において、イベントEを生成(26)したアプリケーション書込手段105は、ソケット書込要求手段102aを呼び出す(30)。ソケット書込要求手段102aは、まだイベントC及びイベントDの処理中(27)でフラグ管理手段107のCASフラグが立っている(31)のでソケット書込要求手段102aは第1のバッファ121bのイベントD及びEを第2のバッファ121bへ移動せず、アプリケーション書込手段105は処理を終了しスレッド2に戻り、スレッド2は次の処理を進める(32)。 At this point, thread 2 generates event E and writes event E to first buffer 121b1 by means of application writing means 105 . Events D and E are present in the first buffer 121b1 (28). In thread 2, application writing means 105 that has generated event E (26) calls socket writing request means 102a (30). The socket write request means 102a is still processing events C and D (27), and the CAS flag of the flag management means 107 is set ( 31 ). Without moving events D and E to the second buffer 121b2 , the application writing means 105 terminates the processing and returns to thread 2, which advances the next processing (32).

スレッド1のコールバックスレッドよりイベントB、Cの送信依頼をされたOSカーネル100が、イベントBの送信を完了後に、再び、スレッド1のコールバックスレッドを起動し、起動したコールバック処理手段102bは、再び、ソケット読み込み要求手段102aを呼び出す(29)。ソケット書込要求手段102aは、第1のバッファ121bにイベントが蓄積されているか確認し、イベントがあるので第1のバッファ121bのイベントD、E(28)を第2のバッファ121bへイベントを移動する(33)。この時点で、第2のバッファ121b2はイベントC、D、Eを保持する。 When the OS kernel 100 is requested to send events B and C by the callback thread of the thread 1, after completing the transmission of the event B, it again activates the callback thread of the thread 1, and the activated callback processing means 102b , again calls the socket read request means 102a (29). The socket write request means 102a checks whether the event is accumulated in the first buffer 121b -1 . Move the event (33). At this point, the second buffer 121b2 holds events C, D and E.

次に、スレッド1のコールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、OSシステムコール呼び出しを行い、第2のバッファ121bのイベントC、D、EをOSに送信要求してコールバックスレッドを終了(34)する。 Next, in the callback thread of thread 1, the socket write request means 102a calls the OS system call because the caller is the callback processing means 102b, and the events C, D, and E of the second buffer 121b2. A transmission request is sent to the OS and the callback thread is terminated (34).

次に、OSカーネル100は、イベントC,D,Eを送信しようとする。まずイベントCを適切なサイズに分割(C1,C2,C3)してイベントC1、C2を送信して終了(OSカーネルは処理を完了)する(35)。イベントCの一部(C1,C2)のみを送信(35)して、残りのイベントC(C3)、イベントD、イベントEを送信しない理由は、前述したようにOSの都合である。この時点で、第1のバッファ121bには、イベントFが蓄積されている。 The OS kernel 100 then attempts to send events C, D, and E. First, the event C is divided into appropriate sizes (C1, C2, C3), the events C1 and C2 are transmitted, and the processing ends (the OS kernel completes the processing) (35). The reason for transmitting (35) only a part of event C (C1, C2) and not transmitting the remaining event C (C3), event D, and event E is the convenience of the OS as described above. At this point, the event F is accumulated in the first buffer 121b1 .

次に、OSカーネル100は、イベントCの一部の送信を完了すると、再び、スレッド1のコールバックスレッドとして、コールバック処理手段102bを起動(36)して、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントCのうちC1、C2が送信完了しているので、第2のバッファ121bからイベントCのうちC1、C2に相当する部分を削除する。Cが単一のチャンクに格納されている場合、C3の送信が完了するまではチャンク全体のメモリ解放はできない。例えば、java.nio.ByteBufferを用いて送信開始位置と送信終了位置を管理する場合、C全体の解放はC3の処理終了後とし、C1,C2の完了は、送信開始位置をC1からC3に移動すればよい。そして再び、ソケット書込要求手段102aを呼び出す(37)。 Next, when the OS kernel 100 completes transmission of part of event C, it activates (36) the callback processing means 102b again as the callback thread of thread 1, and the callback processing means 102b completes the transmission. In this case, since transmission of C1 and C2 of event C has been completed, portions corresponding to C1 and C2 of event C are deleted from the second buffer 121b2 . If C is stored in a single chunk, the entire chunk cannot be freed until the transmission of C3 is complete. For example, java. nio. When the transmission start position and the transmission end position are managed using ByteBuffer, the entire C is released after the processing of C3 is completed, and the transmission start position is moved from C1 to C3 to complete C1 and C2. Then, the socket write request means 102a is called again (37).

次に、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、第1のバッファ121bにイベントが蓄積されているか確認するが、イベントFが蓄積されていたので、イベントFを第2のバッファ121b2へ移動する。イベントFは第1のバッファ121b1から第2のバッファ121b2へ移動し、第1のバッファはイベントがなくなり(38)、第2のバッファはイベントC3、D、E、F(39)を保持する。ソケット書込要求手段102aは、引き続き、OSシステムコール呼び出しを行い、第2のバッファ121bのイベントC3、D、E、F(39)をOS実行手段100(OSカーネル)に書き込み要求をしてコールバックスレッドを終了する(40)。 Next, in the callback thread, the socket write request means 102a checks whether the event is accumulated in the first buffer 121b1 because the caller is the callback processing means 102b. Therefore, event F is moved to the second buffer 121b2. Event F moves from the first buffer 121b1 to the second buffer 121b2, the first buffer being empty (38) and the second buffer holding events C3, D, E, F (39). The socket write request means 102a subsequently makes an OS system call and requests the OS execution means 100 (OS kernel) to write events C3, D, E, and F (39) of the second buffer 121b2. Terminate the callback thread (40).

次に、イベントC3、D、E、Fの送信依頼されたOSカーネル100は、イベントC、Dを適切なサイズに分割してイベントC3、D1、D2を送信する(41)。イベントC3とDのみ送信してイベントE、Fを送信しない理由は、前述したようにOSの都合である。 Next, the OS kernel 100 requested to transmit events C3, D, E, and F divides events C and D into appropriate sizes and transmits events C3, D1, and D2 (41). The reason why only the events C3 and D are transmitted and not the events E and F is the convenience of the OS as described above.

次に、イベントC3、D、E、Fの送信依頼されたOSカーネル100は、イベントC、Dの送信を完了すると、コールバックスレッドとして、コールバック処理手段102bを起動して(42)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントCのうちC3が、イベントDのすべてが送信完了しているので、第2のバッファ121bからイベントC3(あるいはイベントC全体)およびイベントDを削除する。そして再び、ソケット書込要求手段102aを呼び出す(43)。 Next, the OS kernel 100, to which transmission of events C3, D, E, and F has been requested, activates callback processing means 102b as a callback thread (42) after completing the transmission of events C and D, and calls the callback processing means 102b. The back processing means 102b confirms the number of bytes that have been transmitted. ) and event D. Then, the socket write request means 102a is called again (43).

次に、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、まず第1のバッファ121bにイベントが蓄積されているか確認し、イベントがない(38)ので第2のバッファ121bにイベントを移動せず、OSシステムコール呼び出しを行い、第2のバッファ121bのイベントE、F(44)をOS実行手段100(OSカーネル)に書き込み要求をしてコールバックスレッドを終了する(45)。 Next, in the callback thread, the socket write request means 102a first confirms whether an event is accumulated in the first buffer 121b1 because the caller is the callback processing means 102b. An OS system call is made without moving the event to the second buffer 121b2 , and a write request is made to the OS execution means 100 (OS kernel) to write events E and F (44) of the second buffer 121b2. Terminate the back thread (45).

次に、イベントE、Fの送信依頼されたOSカーネル100は、イベントE、Fを適切なサイズに分割してイベントE1、E2、Fを送信する(46)。 Next, the OS kernel 100, which has been requested to transmit events E and F, divides events E and F into appropriate sizes and transmits events E1, E2 and F (46).

次に、イベントE、Fの送信依頼されたOSカーネル100は、イベントE、Fの送信を完了すると、コールバックスレッドとして、コールバック処理手段102bを起動して(47)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントE、Fのすべてが送信完了しているので、第2のバッファ121bからイベントE、Fを削除する。そして再び、ソケット書込要求手段102aを呼び出す(48)。 Next, the OS kernel 100 to which the transmission of the events E and F has been requested activates the callback processing means 102b as a callback thread when the transmission of the events E and F is completed (47). confirms the number of bytes that have been transmitted. In this case, since transmission of all events E and F has been completed, events E and F are deleted from the second buffer 121b2 . Then, the socket write request means 102a is called again (48).

その後、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、第1のバッファ121b及び第2のバッファ121bを順に確認するが、第1のバッファ121b及び第2のバッファ121bのいずれにもイベントがなくなっているので、フラグ管理手段107のCASフラグを解除(49)し、コールバックスレッドを終了する。 After that, in the callback thread, the socket write request means 102a checks the first buffer 121b- 1 and the second buffer 121b- 2 in order because the caller is the callback processing means 102b . and the second buffer 121b2 , the CAS flag of the flag management means 107 is cleared (49) and the callback thread is terminated.

(第2の実施の形態の効果)
上記した第2の実施の形態によれば、アプリケーション書込手段105とソケット書込手段102の間に中間バッファ121Bを設け、中間バッファ121Bの第1のバッファ121bはアプリケーション書込手段105の書込データをスレッド毎にノンブロッキングに蓄積して、ソケット書込要求手段102aの書込動作をCASフラグに応じて実行し、CASフラグをフラグ管理手段107によって管理し、ソケット書込要求手段102aの書込開始でフラグを立て、OS実行手段100のイベント処理完了の通知を受けたコールバック処理手段102bがフラグを解除するとともに、第1のバッファ121bにイベントが存在する場合は第2のバッファ121bにイベントをまとめるなどOS実行手段の処理に適した形式に変換した上で移動してからOS実行手段100により第2のバッファ121bのイベントを処理するようにしたため、アプリケーション書込手段105の書き込み動作がOS実行手段100の送信イベント処理の動作に直接影響を及ぼさないようになり(アプリケーション書込手段105、OS実行手段100がそれぞれに対応するための待ち時間がなくなり、また、イベントごとにOS実行手段100を呼び出す場合に比べてOS実行手段100の呼出回数が削減され)、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化することができる。特に、所要時間の比較的長いネットワークへの送信処理を、ウェイト時間(レイテンシ)短く、なるべく連続処理、かつ、ノンブロッキングに実行することで、ネットワーク送信処理を優先し、送信スループットを上げつつ、非同期送信(NIO)の処理待ちの間の時間にアプリ処理をノンブロッキングに並列実行することができる。
(Effect of Second Embodiment)
According to the above-described second embodiment, the intermediate buffer 121B is provided between the application writing means 105 and the socket writing means 102, and the first buffer 121b1 of the intermediate buffer 121B is used for the writing of the application writing means 105. Write data is accumulated for each thread in a non-blocking manner, the write operation of the socket write request means 102a is executed according to the CAS flag, the CAS flag is managed by the flag management means 107, and the write operation of the socket write request means 102a is executed. A flag is set at the start of loading, and the callback processing means 102b that receives notification of the event processing completion of the OS execution means 100 releases the flag. 2 , the events are converted into a format suitable for the processing of the OS execution means, such as 2, and then the events in the second buffer 121b 2 are processed by the OS execution means 100. The write operation does not directly affect the transmission event processing operation of the OS execution means 100 (there is no waiting time for the application writing means 105 and the OS execution means 100 to respond to each, and each event The number of calls to the OS execution means 100 is reduced compared to calling the OS execution means 100), application processing and data transmission can be executed in a non-blocking manner to speed up communication. In particular, transmission processing to the network, which takes a relatively long time, is performed with a short wait time (latency), continuous processing as much as possible, and non-blocking, giving priority to network transmission processing, increasing transmission throughput, and asynchronous transmission. Application processing can be executed in parallel in a non-blocking manner during the waiting time for (NIO) processing.

(変形例)
上記した第2の実施の形態において、ソケット書込要求手段102aを、アプリケーション書込手段105からの呼び出しにのみ応じてOS実行手段100にイベント処理を要求するソケット書込要求手段102aと、コールバック処理手段102bの呼び出しにのみ応じてOS実行手段100にイベント処理を要求するソケットフラッシュ書込手段102aとに分けてもよい。この場合、図11のステップS40が不要となり、図12のステップS53が「OS実行手段100にイベント処理を要求する」に変わり、図13の動作をソケットフラッシュ書込手段102aが担うこととなる。このように実装した場合についても第2の実施の形態と同様の上記効果を奏する。
(Modification)
In the above-described second embodiment, the socket write request means 102a 1 for requesting event processing to the OS execution means 100 only in response to a call from the application write means 105 and the socket write request means 102a 1 for calling It may be divided into a socket flash writing means 102a2 that requests event processing to the OS execution means 100 only in response to a call from the back processing means 102b. In this case, step S40 of FIG. 11 becomes unnecessary, step S53 of FIG. 12 changes to "request event processing to OS execution means 100", and the operation of FIG. 13 is carried out by socket flash writing means 102a2 . . Even in the case of mounting in this way, the same effects as those of the second embodiment can be obtained.

[他の実施の形態]
なお、本発明は、上記実施の形態に限定されず、本発明の趣旨を逸脱しない範囲で種々な変形や組み合わせが可能である。
(A)CASによるノンブロッキングな排他制御
本発明の基本は、CASによるノンブロッキングなOS実行手段100の呼び出しである。ネットワーク送信処理において、OS実行手段100の呼び出しは、送信要求したデータの一部のみを送信することがあるなど、送信バッファのセットアップ、送信処理、送信完了後の済送信バッファの調整など、同一チャネルへの送信は並行処理することができない。そのためなんらかの排他制御が必要である。そこで、OSの機能を利用して、Synchronizedメソッドなどで実装し、同時に単一のスレッドしか実行できず、他のスレッドは実行中のスレッドの終了を待ち、暫時、ひとつずつ実行が再開されるような、排他制御を行うことが一般的である。ただ、ネットワークゲームでゲームオブジェクトの変化を大量多頻度に中継するようなゲームサーバのような用途では、小さなデータを大量多頻度に送受信することになり、OSの機能を用いた排他制御も多頻度となるため、OS機能呼び出しのオーバヘッドが無視できなくなり、サーバ機能の処理性能を低下させる。そこで本発明は、アトミックなインストラクションで実行されるノンブロッキングなCASを用いて排他制御を行う。イベントをOS機能処理中に、別のイベントのためにOS機能呼び出しを行おうとしてもCASの排他制御によって、実行されることなく、待つこともなく終了してしまう。イベントごとに逐次に処理することはできないので、イベントは一旦、バッファへ蓄積し、OS機能処理実行中のスレッドは、起動時に想定していたイベントだけでなく、起動前に蓄積されていたイベント、あるいは、OS機能処理実行中に蓄積されたイベントも、処理するように工夫している。一般に、OSの機能呼び出しは通常のメモリ処理に比べて、処理時間が長いので、ゲームサーバのような用途では、OS機能呼び出し中に新たなイベントが蓄積される可能性が高い。第1の実施例と第2の実施例で典型的な2種類のCASによるノンブロッキング排他制御方法を示したが、この2個の実施例に限定するものではない。
(B)イベント蓄積の仮想的なリングバッファの形式
OSの機能呼び出しに時間がかかる場合、機能呼び出し実行中に別の処理を非同期に実行できるように、OSは機能呼び出しとコールバックとに分けて処理する仕組みを提供する。そのため、イベント処理後のコールバックは、イベント処理のための機能呼び出しとは非同期に発生する。また、アプリケーションのイベントの生成も非同期である。これらを調停するために、イベントはリングバッファに蓄積し、FIFOでイベント処理できるように、蓄積と処理を完全に非同期に実行できるようにする必要がある。リングバッファにはさまざまなバリエーションがあり、第1の実施例ではイベントデータをバイトシーケンスで蓄積するリングバッファを示し、第2の実施例ではイベントデータを蓄積するメモリチャンクのポインタを蓄積するリングバッファを示したが、開示した2個の方法及びその変形だけに限定するものではない。
(C)イベントの蓄積とOSの機能呼び出しの非同期処理
イベントの蓄積はイベントの発生に同期できる。一方で蓄積しているイベントの処理はイベント処理完了のコールバックから起動すればよい。ただ、イベント処理が全く動作していない、例えば最初の1個目のイベント処理を起動するには別の機構が必要である。第1の実施例及び第2の実施例では、イベント処理が停止している場合に限り、イベント蓄積をトリガとする方式を開示した。しかし、前述しているように、このトリガは、タイマなどで完全に非同期であってもよいし、毎回あるいは数回に一度のイベント蓄積と同期であってもよい。また、トリガとしては、機能呼び出し(メッソッドや関数の呼び出し)であってもよいし、OS機能を用いたシグナリングでもよいし、それ以外の方法でもよい。第2の実施例では、アプリケーションのイベント処理の効率を考慮して、トリガとしてコールバックからのメソッド呼び出しを優先する方式を示した。適用するアプリケーションにより適切な方法を選択するものであり、実施例及びその変形として開示した手法のみに限定するものではない。
(D)メモリの再利用
頻繁にメモリの割当解放を繰り返す場合は、その都度OS機能呼び出しを行うのはオーバヘッドとなるので、事前にまとまったメモリを確保し、メモリの割当解放はOSに依頼するのではなく、確保済のメモリを再利用するバッファプールは一般的である。メモリのフラグメンテーションやそれに伴うガベージコレクションを回避し、メモリの再利用を促進するには、バッファプールは、規格化したメモリチャンクの集合として管理し、アプリケーションが使用するメモリサイズに応じて、必要個数のチャンクを結合して使うのも一般的である。仮想的にリングバッファを実現するには、メモリのバファプールを用いるのがよい。チャンクのサイズや個数、また、使用するメモリの種類(ダイレクトバファであるか非ダイレクトバッファであるか)は適用するアプリケーションにより適切に選択するものであり、実施例及びその変形として開示した手法による選択に限定されるものではない。
[Other embodiments]
The present invention is not limited to the above embodiments, and various modifications and combinations are possible without departing from the scope of the present invention.
(A) Non-blocking exclusive control by CAS The basis of the present invention is non-blocking OS execution means 100 calling by CAS. In network transmission processing, calling the OS execution means 100 may involve transmitting only a part of the data requested to be transmitted, setting up the transmission buffer, transmission processing, adjustment of the transmission buffer after completion of transmission, etc. cannot be sent concurrently. Therefore, some kind of exclusive control is required. Therefore, using the functions of the OS, implement it with a Synchronized method etc., so that only a single thread can be executed at the same time, and the other threads wait for the end of the running thread and resume execution one by one for a while. It is common to perform exclusive control. However, in applications such as a game server that relays changes in game objects in a network game in large quantities and frequently, small data will be sent and received in large quantities frequently, and exclusive control using OS functions will also occur frequently. Therefore, the overhead of calling the OS function cannot be ignored, and the processing performance of the server function is lowered. Therefore, the present invention performs exclusive control using non-blocking CAS executed by atomic instructions. During OS function processing of an event, even if an OS function call is attempted for another event, it will not be executed and will end without waiting due to exclusive control of CAS. Since it is not possible to process each event sequentially, the events are temporarily accumulated in a buffer, and the thread executing the OS function processing not only the events assumed at startup, but also the events accumulated before startup, Alternatively, it is devised to process events accumulated during execution of OS function processing. In general, OS function calls take longer than normal memory processing, so in applications such as game servers, there is a high possibility that new events will be accumulated during OS function calls. Although two typical non-blocking exclusion control methods by CAS have been shown in the first and second embodiments, the present invention is not limited to these two embodiments.
(B) Format of Virtual Ring Buffer for Accumulating Events If an OS function call takes a long time, the OS is divided into function calls and callbacks so that another process can be executed asynchronously while the function call is being executed. Provide a mechanism for processing. Therefore, the callback after event processing occurs asynchronously with the function call for event processing. Application event generation is also asynchronous. In order to arbitrate these, events must be accumulated in a ring buffer so that accumulation and processing can be performed completely asynchronously so that events can be processed in FIFO. There are various variations of ring buffers, the first embodiment shows a ring buffer that stores event data in byte sequences, and the second embodiment shows a ring buffer that stores pointers to memory chunks that store event data. Although shown, it is not intended to be limited to only the two disclosed methods and variations thereof.
(C) Asynchronous Processing of Event Accumulation and OS Function Calling Accumulation of events can be synchronized with the occurrence of events. On the other hand, the accumulated event processing can be started from the event processing completion callback. However, if event processing is not working at all, for example, another mechanism is required to activate the first event processing. In the first embodiment and the second embodiment, a method is disclosed in which event accumulation is used as a trigger only when event processing is stopped. However, as mentioned above, this trigger may be completely asynchronous, such as with a timer, or it may be synchronous with event accumulation once every or several times. The trigger may be a function call (method or function call), signaling using an OS function, or other methods. In the second embodiment, in consideration of the efficiency of event processing of the application, a method of giving priority to method calls from callbacks as triggers has been shown. An appropriate method is selected according to the application to be applied, and the method is not limited only to the methods disclosed as the examples and their modifications.
(D) Reuse of memory When memory allocation and deallocation are repeated frequently, calling the OS function each time becomes an overhead. Buffer pools that reuse allocated memory instead of reusing it are common. To avoid memory fragmentation and associated garbage collection, and to promote memory reuse, the buffer pool should be managed as a set of standardized memory chunks, and depending on the memory size used by the application, the required number of It is also common to combine chunks. To implement a virtual ring buffer, it is better to use a memory buffer pool. The size and number of chunks, and the type of memory to be used (direct buffer or non-direct buffer) are appropriately selected according to the application to be applied, and selection by the method disclosed as the embodiment and its modification is not limited to

図5は、レイヤ構成の変形例を示す概略図である。 FIG. 5 is a schematic diagram showing a modification of the layer configuration.

例えば、本願は、OSI(Open Systems Interconnection)参照モデルの7層のうち、アプリケーション層(アプリケーション112)とプレゼンテーション層及びセッション層(通信管理プログラム111)との間にバッファ(a)を設けた例を説明したが、イ~オの異なる層構成で、異なる位置にバッファ(b)~(e)を設けてもよい。 For example, the present application provides an example in which a buffer (a) is provided between the application layer (application 112) and the presentation layer and session layer (communication management program 111) among the seven layers of the OSI (Open Systems Interconnection) reference model. As described above, the buffers (b) to (e) may be provided at different positions in different layer configurations (a) to (e).

ここで、送信スループットを上げるためには、下位の送信に関するレイヤで待ち、下位のレイヤでレイテンシが発生しないためには、上位のアプリは下位への依頼・呼出はロックフリー(ノンブロッキング)であることが望ましい。上位から下位へはなんらかの集約が発生するので、マルチタスク環境では各スレッドのデータが混ざらないように通常はなんらかの排他制御が必要となる。排他制御にOSの「ロック(Mutex)」を使用すると処理負荷が重くなるため、ロックフリーなアルゴリズムが望ましい。特にゲームサーバのように、同期のためのパケットをストリーミングのように大量に他頻度に送信するような場合は、パケット送信単位でロックがかかるのは望ましくない。ウ~オではOSの排他制御は使えないため、アプリケーションによる排他制御を独自に行う必要がある。 Here, in order to increase the transmission throughput, it is necessary to wait in the layer related to transmission in the lower layer, and in order to prevent latency in the lower layer, requests and calls to the lower layer must be lock-free (non-blocking) for the upper application. is desirable. Since some kind of aggregation occurs from the top to the bottom, in a multitasking environment, some kind of exclusive control is usually required so that the data of each thread is not mixed. A lock-free algorithm is desirable because the use of the OS "lock (mutex)" for exclusive control increases the processing load. In particular, in the case of a game server that transmits a large amount of packets for synchronization at different frequencies, such as streaming, it is not desirable to lock each packet transmission. Since the exclusive control of the OS cannot be used in Woo, it is necessary to independently perform exclusive control by the application.

ア(第1の実施の形態および第2の実施の形態)の場合、Java VM(仮想OS)によって作成されたTCP又はUDP(User Datagram Protocol)チャネルにデータを順次送信する。同一チャネルを複数スレッドで利用する場合には排他制御が必要となる。RUDP(Reliable User Datagram Protocol)の場合は、UDPソケットを使うアプリがACK(肯定応答)や再送などの信頼性保証のレイヤを独自に作成する必要がある。 In the case of a (first embodiment and second embodiment), data is sequentially transmitted to a TCP or UDP (User Datagram Protocol) channel created by a Java VM (virtual OS). Exclusive control is required when multiple threads use the same channel. In the case of RUDP (Reliable User Datagram Protocol), an application that uses UDP sockets must independently create a reliability assurance layer such as ACK (acknowledgement) and retransmission.

イの場合、アとの相違点は仮想OSかNative OSかの違いであるため、アとほぼ同じ構成、動作で実現可能である。 In the case of B, the difference from A is whether it is a virtual OS or a Native OS.

ウの場合、ステートレス(コネクションレス)なUDPで実現可能性がある。OSの内部のレイヤを直接呼び出すことは、通常できないため実現可能性は低いが、直接呼び出す構成があれば可能となる。複数のアプリケーション及びスレッドが、NICを共用する複数の送信先(端末装置)に対する通信全てについて集約が必要となる。 In the case of c, stateless (connectionless) UDP is feasible. It is usually not possible to directly call the layers inside the OS, so the feasibility is low, but it is possible if there is a configuration for direct calling. Multiple applications and threads need to aggregate all communications to multiple destinations (terminal devices) sharing the NIC.

エの場合、OSのプロトコルスタックをバイパスして高速化することができる。プロトコルスタックを独自に制作する必要がある。(例えばDPDK(Data Plane Development Kit)等を用いることができる。https://www.dpdk.org/)。NICドライバは、NDISではなく特殊となり、通常は特定のNICプロダクト依存となる。UDPの場合、データグラムとして、ソケットを介さずに直接送信が可能な場合もある。OSの内部のレイヤを直接呼び出すことは、通常できないため実現可能性は低いが、DPDKのように専用のNICドライバがあれば可能となる。ウ同様に、複数のアプリケーション及びスレッドが、NICを共用する複数の送信先(端末装置)に対する通信全てについて集約が必要となる。 In the case of D, the speed can be increased by bypassing the protocol stack of the OS. You need to create your own protocol stack. (For example, DPDK (Data Plane Development Kit) or the like can be used. https://www.dpdk.org/). NIC drivers are not NDIS, they are specialized and are usually dependent on a particular NIC product. In the case of UDP, it may be possible to send directly as a datagram without going through a socket. It is usually not possible to directly call the internal layer of the OS, so the feasibility is low, but it is possible if there is a dedicated NIC driver like DPDK. C. Similarly, multiple applications and threads need to aggregate all communications to multiple destinations (terminal devices) that share the NIC.

オの場合、アプリケーションが完全にハードウェア依存となるため、組込みシステムなど特殊用途以外で用いられる。ウ同様に、複数のアプリケーション及びスレッドが、NICを共用する複数の送信先(端末装置)に対する通信全てについて集約が必要となる。 In the case of E, since the application is completely hardware-dependent, it is used for non-special purposes such as embedded systems. C. Similarly, multiple applications and threads need to aggregate all communications to multiple destinations (terminal devices) that share the NIC.

次に、各バッファ(a)~(e)について説明する。 Next, each buffer (a) to (e) will be explained.

(a)の場合、一般的用法としてはJAVA限定、OS非依存のものとなり、ソケット単位でのマルチスレッドのアプリパケット(アプリ送信単位)が混ざらないように集約するものとなる。 In the case of (a), as a general usage, it is limited to JAVA and independent of the OS, and is aggregated so as not to mix multithreaded application packets (application transmission units) in units of sockets.

(b)の場合、一般的用法としては言語依存、OSに依存することもあり、(a)と同様となる。(a)経由の場合はそのままパラメータのパススルーで引き渡してもよいし、分散書込の場合は、送信バイトバッファが連続領域にあれば一つの送信バッファにまとめるなどの最適化をしてもよい。ここで、分散書込とは、例えばJavaのAsynchronousSocketChannel.write()の機能で、1つ以上の可変長のデータブロックをグループ化した複数のバッファを指定して送信要求するものを指す。 In the case of (b), the general usage is language-dependent and OS-dependent, and is the same as (a). (a) In the case of via, the parameters may be passed through as they are, and in the case of distributed writing, if the transmission byte buffers are in a continuous area, they may be optimized by combining them into one transmission buffer. Here, distributed writing means, for example, Java's AsynchronousSocketChannel. A function of write( ) that specifies multiple buffers in which one or more variable-length data blocks are grouped and requests transmission.

(c)の場合、通常はOS内部、OSカーネルの作業となり、アプリは横断的に対応してプロトコルごとに集約する。なお、プロトコルヘッダの追加が必要となる。TCPソケットに書かれた時点でコネクションごとのデータストリーム状態、アプリパケットの送信単位の境界は問題としない。適当な大きさに分割して、プロトコルドライバに渡す。その際に、データのコピーや詰替えが発生する可能性がある。UDPソケットの場合は、コネクションレスのため、ソケットに書きまれればバッファリングされずに送信され、まとめて送ることはない。RUDPで複数のデータをまとめて送る場合には、UDPソケットに書き込む前にまとめてから書き込む。 In the case of (c), the work is usually done inside the OS and in the OS kernel, and the application handles it cross-sectionally and aggregates it for each protocol. Note that it is necessary to add a protocol header. When data is written to a TCP socket, the data stream state for each connection and the boundary of the transmission unit of application packets are irrelevant. It is divided into appropriate sizes and passed to the protocol driver. At that time, there is a possibility that data copying or repacking may occur. Since UDP sockets are connectionless, data written to a socket is transmitted without buffering and is not sent all at once. When sending a plurality of data collectively by RUDP, they are collectively written before being written to the UDP socket.

(d)の場合、通常はOS内部、プロトコルドライバの作業となり、アプリは横断的に対応して、各種プロトコルをNICごとに集約する。なお、プロトコルヘッダの追加が必要となる。各パケットの結合、分割、プロトコルヘッダを追加した、全データをNICごとに集約する。 In the case of (d), the task is usually done by the protocol driver inside the OS, and the application handles it cross-sectionally and aggregates various protocols for each NIC. Note that it is necessary to add a protocol header. Aggregate all data for each NIC, combining and splitting each packet and adding protocol headers.

(e)の場合、NIC内部の作業となる。ネットワークタイプに応じた分割、結合、圧縮などの加工、ヘッダなどの追加をして、ビット列に対応する電気信号に変換して、通信回線に送信する。 In the case of (e), it becomes work inside the NIC. Processing such as division, combination, and compression according to the network type, addition of a header, etc., conversion to an electrical signal corresponding to the bit string, and transmission to the communication line.

上記実施の形態では制御部10の各手段100~107の機能をプログラムで実現したが、各手段の全て又は一部をASIC等のハードウェアによって実現してもよい。また、上記実施の形態で用いたプログラムをCD-ROM等の記録媒体に記憶して提供することもできる。また、上記実施の形態で説明した上記ステップの入れ替え、削除、追加等は本発明の要旨を変更しない範囲内で可能である。また、各手段の機能は適宜他の手段に結合してもよいし、複数の手段に分離してもよい。 Although the functions of the means 100 to 107 of the control unit 10 are implemented by programs in the above embodiment, all or part of the means may be implemented by hardware such as ASIC. Also, the program used in the above embodiment can be stored in a recording medium such as a CD-ROM and provided. In addition, replacement, deletion, addition, etc., of the steps described in the above embodiment are possible without changing the gist of the present invention. Also, the function of each means may be appropriately combined with other means, or may be separated into a plurality of means.

上記実施の形態では、主にネットワークの送信イベントの処理について記述したが、本発明は、処理する対象のイベントをネットワーク送信イベントのみに限定するものではない。本発明の各手段のすべて又は一部は、ネットワークの送信以外のイベント処理、特にOS機能に処理操作を依頼する比較的長時間を要する処理(OS機能が非同期処理を可能とするために処理要求手段とコールバック手段とを提供する処理、典型的には各種I/O操作)、より具体的には、ネットワークやディスクなど各種メディアなどに対する出力操作に、対応する要求手段とコールバック手段を差し替えることで、適用できる。また、OS機能を順次複数回呼び出してイベント処理するには、本発明のイベント処理の仕組みを複数段組み合わせることができる。 In the above embodiments, processing of network transmission events has been mainly described, but the present invention does not limit the events to be processed to network transmission events only. All or a part of each means of the present invention can be applied to event processing other than network transmission, especially processing that requires a relatively long time to request processing operations from the OS function (processing request for OS function to enable asynchronous processing). Processing that provides means and callback means, typically various I/O operations), more specifically, output operations to various media such as networks and disks, replaces the corresponding request means and callback means Therefore, it can be applied. Further, in order to process an event by sequentially calling OS functions a plurality of times, it is possible to combine a plurality of event processing schemes of the present invention.

1 :サーバ装置
2a、2b、2c:端末装置
4 :ネットワーク
10 :制御部
11 :記憶部
12 :メモリ
13 :通信部
100 :OS実行手段(OSカーネル)
101 :ソケット読出手段
102 :ソケット書込手段
102a :ソケット書込要求手段
102b :コールバック処理手段
103 :アプリケーション実行手段
104 :アプリケーション読出手段
105 :アプリケーション書込手段
106 :バッファリング手段
107 :フラグ管理手段
111 :通信管理プログラム
112 :アプリケーション
120 :アプリバッファ
121 :リングバッファ
121B :中間バッファ
121b :第1のバッファ
121b :第2のバッファ
130 :チャネル
131 :ソース
Reference Signs List 1: server devices 2a, 2b, 2c: terminal device 4: network 10: control unit 11: storage unit 12: memory 13: communication unit 100: OS execution means (OS kernel)
101: socket reading means 102: socket writing means 102a: socket writing request means 102b: callback processing means 103: application executing means 104: application reading means 105: application writing means 106: buffering means 107: flag management means 111: communication management program 112: application 120: application buffer 121: ring buffer 121B: intermediate buffer 121b1: first buffer 121b2 : second buffer 130: channel 131: source

[1]コンピュータを、
処理対象とするイベントを蓄積するイベント蓄積手段と、
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段として機能させ、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理プログラム。
[2]前記バッファリング手段は、イベントを蓄積する第1のバッファリング手段と、前記第1のバッファリング手段に蓄積された前記イベントを蓄積する第2のバッファリング手段とを有し、
前記処理要求手段は、フラグが立てられた場合に、前記第1のバッファリング手段から前記第2のバッファリング手段に前記イベントを移動して蓄積し、前記第2のバッファリング手段が蓄積している前記イベントの全て又は一部を処理する前記[1]に記載の情報処理プログラム。
[3]前記第1のバッファリング手段と前記第2のバッファリング手段の間、前記第1のバッファリング手段の前段又は前記第2のバッファリング手段の後段に、さらに1以上のバッファリング手段を有する前記[2]に記載の情報処理プログラム。
[4]前記バッファリング手段間の移動において、データブロックのサイズ、個数、タイプ、イベント保持形式の少なくとも1つを変更する前記[2]又は[3]に記載の情報処理プログラム。
[5]前記バッファリング手段間の移動において、移動イベントの数やサイズを予め定めた条件で制限する前記[2]から[4]のいずれか1項に記載の情報処理プログラム。
[6]前記バッファリング手段は、イベント蓄積手段のイベント蓄積動作と、前記処理手段の処理動作とが、非同期に実行される前記[1]から[5]のいずれか1項に記載の情報処理プログラム。
[7]前記バッファリング手段は、並列動作する複数のイベント生成元が実行するそれぞれのイベントの蓄積手段が非同期にイベントを蓄積する前記[1]から[6]のいずれか1項に記載の情報処理プログラム。
[8]前記バッファリング手段は、リングバッファである前記[1]から[7]のいずれか1項に記載の情報処理プログラム。
[9]前記バッファリング手段は、前記イベントそのものをメモリ領域に順次蓄積するリングバッファである前記[1]に記載の情報処理プログラム。
[10]前記バッファリング手段は、2段リングバッファ構成であり、第1段のリングバッファは並列動作するイベント蓄積手段のイベントを蓄積し、第2段のリングバッファは前記処理手段の処理に応じて定められたサイズに当該イベントを連結および分割するとともに前記処理手段に応じて定められた個数保持する前記[2]、[6]又は[7]に記載の情報処理プログラム。
[11]前記バッファリング手段は、ダイレクトバッファに前記イベントを格納することを特徴とする前記[1]、[2]又は[6]から[10]のいずれか1項に記載の情報処理プログラム。
[12]前記バッファリング手段は、バッファプールのバッファに前記イベントを蓄積する前記[1]、[2]又は[6]から[10]のいずれか1項に記載の情報処理プログラム。
[13]前記バッファリング手段は、前記第1段のリングバッファと前記第2段のリングバッファとで、異なるバッファサイズを保持するバッファプールのバッファにイベントを蓄積する前記[10]に記載の情報処理プログラム。
[14]前記処理手段は、蓄積されている前記イベントをすべて処理してからイベント処理を終了する前記[1]から[13]のいずれか1項に記載の情報処理プログラム。
[15]処理対象とするイベントを蓄積するイベント蓄積手段と、
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段とを有し、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理装置。
[16]コンピュータにおいて実行される情報処理方法であって
処理対象とするイベントを蓄積するイベント蓄積ステップと、
前記イベントを蓄積するバッファリングステップと、
前記蓄積したイベントを処理する処理ステップと、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理ステップとを有し、
前記処理ステップは、イベントの処理を要求する処理要求ステップと、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理ステップとを含み、
前記フラグ管理ステップは、前記処理要求ステップにおけるイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理ステップにおける処理の終了後のタイミングでフラグを解除し、
前記処理要求ステップは、前記イベント蓄積ステップにおけるイベント蓄積終了後のタイミング及び前記コールバック処理ステップにおけるイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は蓄積した前記イベントを処理する情報処理方法。
[1] a computer,
event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
act as a flag manager that accepts calls and sets flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means sets the flag exclusively before the process request means starts processing the event, and cancels the flag after the process of the callback processing means ends;
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. an information processing program for terminating without processing if the flag is not set, and processing the event accumulated by the buffering means if the flag is set.
[2] The buffering means has a first buffering means for accumulating events and a second buffering means for accumulating the events accumulated in the first buffering means,
The processing request means moves and accumulates the event from the first buffering means to the second buffering means when the flag is set, and the second buffering means accumulates the event. The information processing program according to [1], which processes all or part of the event.
[3] One or more buffering means are further provided between the first buffering means and the second buffering means, before the first buffering means, or after the second buffering means. The information processing program according to [2] above.
[4] The information processing program according to [2] or [3], wherein at least one of data block size, number, type, and event holding format is changed in the movement between the buffering means.
[5] The information processing program according to any one of [2] to [4], wherein the number and size of movement events are restricted according to predetermined conditions in movement between the buffering means.
[6] The information processing according to any one of [1] to [5], wherein the event accumulation operation of the event accumulation means and the processing operation of the processing means are executed asynchronously in the buffering means. program.
[7] The information according to any one of [1] to [6], wherein the buffering means asynchronously accumulates events by respective event accumulation means executed by a plurality of event generators operating in parallel. processing program.
[8] The information processing program according to any one of [1] to [7], wherein the buffering means is a ring buffer.
[9] The information processing program according to [1], wherein the buffering means is a ring buffer that sequentially accumulates the event itself in a memory area.
[10] The buffering means has a two-stage ring buffer structure, the first stage ring buffer stores events of the event storage means operating in parallel, and the second stage ring buffer responds to the processing of the processing means. The information processing program according to the above [2], [6], or [7], which connects and divides the event into a size determined by the above and holds the number of events determined according to the processing means.
[11] The information processing program according to any one of [1], [2], or [6] to [10], wherein the buffering means stores the event in a direct buffer.
[12] The information processing program according to any one of [1], [2], or [6] to [10], wherein the buffering means accumulates the event in a buffer of a buffer pool.
[13] The information according to [10], wherein the buffering means accumulates events in buffers of buffer pools holding different buffer sizes for the first stage ring buffer and the second stage ring buffer. processing program.
[14] The information processing program according to any one of [1] to [13], wherein the processing means finishes event processing after processing all the accumulated events.
[15] event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
a flag management means for accepting calls and setting flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means sets the flag exclusively before the process request means starts processing the event, and cancels the flag after the process of the callback processing means ends;
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. If the flag is not set, the information processing device ends without processing, and if the flag is set, the event accumulated by the buffering means is processed.
[16] An information processing method executed on a computer, comprising :
an event accumulation step for accumulating events to be processed;
a buffering step of accumulating the events;
a processing step of processing the accumulated events;
a flag management step for accepting and exclusively flagging calls;
The processing step includes a processing request step that requests processing of the event, and a callback processing step that is executed upon receiving a completion notification when processing of the event is completed,
The flag management step exclusively sets the flag at a timing before the start of event processing in the processing request step, and cancels the flag at a timing after the processing in the callback processing step ends,
The process request step accepts a call at the timing after the event accumulation in the event accumulation step ends and the event processing in the callback processing step ends, and if the flag is not set, the process is not performed. an information processing method for processing the accumulated event if set.

Claims (16)

コンピュータを、
処理対象とするイベントを蓄積するイベント蓄積手段と、
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段として機能させ、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了し
た場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記イベント処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理プログラム。
the computer,
event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
act as a flag manager that accepts calls and sets flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means exclusively sets the flag at a timing before the event processing requesting means starts processing the event, and cancels the flag at the timing after the processing of the callback processing means ends,
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. an information processing program for terminating without processing if the flag is not set, and processing the event accumulated by the buffering means if the flag is set.
前記バッファリング手段は、イベントを蓄積する第1のバッファリング手段と、前記第1のバッファリング手段に蓄積された前記イベントを蓄積する第2のバッファリング手段とを有し、
前記処理要求手段は、フラグが立てられた場合に、前記第1のバッファリング手段から前記第2のバッファリング手段に前記イベントを移動して蓄積し、前記第2のバッファリング手段が蓄積している前記イベントの全て又は一部を処理する請求項1に記載の情報処理プログラム。
The buffering means has a first buffering means for accumulating events and a second buffering means for accumulating the events accumulated in the first buffering means,
The processing request means moves and accumulates the event from the first buffering means to the second buffering means when the flag is set, and the second buffering means accumulates the event. 2. The information processing program according to claim 1, which processes all or part of said events that are present.
前記第1のバッファリング手段と前記第2のバッファリング手段の間、前記第1のバッファリング手段の前段又は前記第2のバッファリング手段の後段に、さらに1以上のバッファリング手段を有する請求項2に記載の情報処理プログラム。 1. The method further comprises one or more buffering means between said first buffering means and said second buffering means, before said first buffering means or after said second buffering means. 3. The information processing program according to 2. 前記バッファリング手段間の移動において、データブロックのサイズ、個数、タイプ、イベント保持形式の少なくとも1つを変更する請求項2又は3に記載の情報処理プログラム。 4. The information processing program according to claim 2, wherein at least one of data block size, number, type, and event holding format is changed in the movement between the buffering means. 前記バッファリング手段間の移動において、移動イベントの数やサイズを予め定めた条件で制限する請求項2から4のいずれか1項に記載の情報処理プログラム。 5. The information processing program according to any one of claims 2 to 4, wherein in the movement between said buffering means, the number and size of movement events are restricted according to predetermined conditions. 前記バッファリング手段は、イベント蓄積手段のイベント蓄積動作と、前記処理手段の処理動作とが、非同期に実行される請求項1から5のいずれか1項に記載の情報処理プログラム。 6. The information processing program according to any one of claims 1 to 5, wherein the buffering means executes an event accumulation operation of the event accumulation means and a processing operation of the processing means asynchronously. 前記バッファリング手段は、並列動作する複数のイベント生成元が実行するそれぞれのイベントの蓄積手段が非同期にイベントを蓄積する請求項1から6のいずれか1項に記載の情報処理プログラム。 7. The information processing program according to any one of claims 1 to 6, wherein in the buffering means, event accumulation means executed by a plurality of event generators operating in parallel accumulate events asynchronously. 前記バッファリング手段は、リングバッファである請求項1から7のいずれか1項に記載の情報処理プログラム。 8. The information processing program according to claim 1, wherein said buffering means is a ring buffer. 前記バッファリング手段は、前記イベントそのものをメモリ領域に順次蓄積するリングバッファである請求項1に記載の情報処理プログラム。 2. The information processing program according to claim 1, wherein said buffering means is a ring buffer that sequentially accumulates said events themselves in a memory area. 前記バッファリング手段は、2段リングバッファ構成であり、第1段のリングバッファは並列動作するイベント蓄積手段のイベントを蓄積し、第2段のリングバッファは前記処理手段の処理に応じて定められたサイズに当該イベントを連結および分割するとともに前記処理手段に応じて定められた個数保持する請求項2、6又は7に記載の情報処理プログラム。 The buffering means has a two-stage ring buffer structure, the first stage ring buffer stores events of the event storage means operating in parallel, and the second stage ring buffer is determined according to the processing of the processing means. 8. The information processing program according to claim 2, 6 or 7, wherein the events are linked and divided into the same size and held in a number determined according to the processing means. 前記バッファリング手段は、ダイレクトバッファに前記イベントを格納することを特徴とする請求項1、2又は6から10のいずれか1項に記載の情報処理プログラム。 11. The information processing program according to claim 1, wherein said buffering means stores said event in a direct buffer. 前記バッファリング手段は、バッファプールのバッファに前記イベントを蓄積する請求項1、2又は6から10のいずれか1項に記載の情報処理プログラム。 11. The information processing program according to claim 1, wherein said buffering means accumulates said event in a buffer of a buffer pool. 前記バッファリング手段は、前記第1段のリングバッファと前記第2段のリングバッファとで、異なるバッファサイズを保持するバッファプールのバッファにイベントを蓄積する請求項10に記載の情報処理プログラム。 11. The information processing program according to claim 10, wherein said buffering means accumulates events in buffers of buffer pools holding different buffer sizes in said first stage ring buffer and said second stage ring buffer. 前記処理手段は、蓄積されている前記イベントをすべて処理してからイベント処理を終了する請求項1から請求項13のいずれか1項に記載の情報処理プログラム。 14. The information processing program according to any one of claims 1 to 13, wherein the processing means finishes event processing after processing all the accumulated events. 処理対象とするイベントを蓄積するイベント蓄積手段と、
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段とを有し、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了し
た場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記イベント処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理装置。
event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
a flag management means for accepting calls and setting flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means exclusively sets the flag at a timing before the event processing requesting means starts processing the event, and cancels the flag at the timing after the processing of the callback processing means ends,
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. If the flag is not set, the information processing device ends without processing, and if the flag is set, the event accumulated by the buffering means is processed.
コンピュータを、
処理対象とするイベントを蓄積するイベント蓄積ステップと、
前記イベントを蓄積するバッファリングステップと、
前記蓄積したイベントを処理する処理ステップと、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理ステップとを有し、
前記処理ステップは、イベントの処理を要求する処理要求ステップと、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理ステップとを含み、
前記フラグ管理ステップは、前記イベント処理要求ステップにおけるイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理ステップにおける処理の終了後のタイミングでフラグを解除し、
前記処理要求ステップは、前記イベント蓄積ステップにおけるイベント蓄積終了後のタイミング及び前記コールバック処理ステップにおけるイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は蓄積した前記イベントを処理する情報処理方法。
the computer,
an event accumulation step for accumulating events to be processed;
a buffering step of accumulating the events;
a processing step of processing the accumulated events;
a flag management step for accepting and exclusively flagging calls;
The processing step includes a processing request step that requests processing of the event, and a callback processing step that is executed upon receiving a completion notification when processing of the event is completed,
The flag management step exclusively sets the flag at a timing before the start of event processing in the event processing request step, and releases the flag at a timing after the processing in the callback processing step ends,
The process request step accepts a call at the timing after the event accumulation in the event accumulation step ends and the event processing in the callback processing step ends, and if the flag is not set, the process is not performed. an information processing method for processing the accumulated event if set.
JP2021200032A 2021-07-30 2021-12-09 Information processing program, information processing device and information processing method Active JP7061301B1 (en)

Priority Applications (6)

Application Number Priority Date Filing Date Title
JP2021200032A JP7061301B1 (en) 2021-12-09 2021-12-09 Information processing program, information processing device and information processing method
PCT/JP2022/025042 WO2023008008A1 (en) 2021-07-30 2022-06-23 Information processing program, information processing device, and information processing method
CN202280004572.XA CN115917519B (en) 2021-07-30 2022-06-23 Recording medium storing information processing program, information processing apparatus, and information processing method
KR1020227044708A KR102521873B1 (en) 2021-07-30 2022-06-23 Information processing program, information processing device, and information processing method
EP22808933.0A EP4152168A4 (en) 2021-07-30 2022-06-23 Information processing program, information processing device, and information processing method
US18/071,627 US11762663B2 (en) 2021-07-30 2022-11-30 Information processing program, information processing device, and information processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2021200032A JP7061301B1 (en) 2021-12-09 2021-12-09 Information processing program, information processing device and information processing method

Publications (2)

Publication Number Publication Date
JP7061301B1 JP7061301B1 (en) 2022-04-28
JP2023085797A true JP2023085797A (en) 2023-06-21

Family

ID=81448191

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2021200032A Active JP7061301B1 (en) 2021-07-30 2021-12-09 Information processing program, information processing device and information processing method

Country Status (1)

Country Link
JP (1) JP7061301B1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0962772A (en) * 1995-08-25 1997-03-07 Oki Electric Ind Co Ltd Character recognition device
JP2017062540A (en) * 2015-09-24 2017-03-30 富士ゼロックス株式会社 Uni-directional inter-operating-system communication system, and program
CN112579097A (en) * 2020-12-21 2021-03-30 广州博冠信息科技有限公司 Software project construction method and device, storage medium and electronic equipment
CN112667217A (en) * 2019-10-16 2021-04-16 上汽通用汽车有限公司 Vehicle end development module based on intelligent vehicle networking architecture

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0962772A (en) * 1995-08-25 1997-03-07 Oki Electric Ind Co Ltd Character recognition device
JP2017062540A (en) * 2015-09-24 2017-03-30 富士ゼロックス株式会社 Uni-directional inter-operating-system communication system, and program
CN112667217A (en) * 2019-10-16 2021-04-16 上汽通用汽车有限公司 Vehicle end development module based on intelligent vehicle networking architecture
CN112579097A (en) * 2020-12-21 2021-03-30 广州博冠信息科技有限公司 Software project construction method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
JP7061301B1 (en) 2022-04-28

Similar Documents

Publication Publication Date Title
CN112204513B (en) Group-based data replication in a multi-tenant storage system
US11762581B2 (en) Method, device, and system for controlling data read/write command in NVMe over fabric architecture
US10387202B2 (en) Quality of service implementation in a networked storage system with hierarchical schedulers
US6418478B1 (en) Pipelined high speed data transfer mechanism
EP0891585B1 (en) A method and apparatus for client managed flow control on a limited memory computer system
US11411885B2 (en) Network-accessible data volume modification
CN106874143B (en) Server backup method and backup system thereof
US10037298B2 (en) Network-accessible data volume modification
CN113709131B (en) Network data transmission method, device, computer equipment and readable medium
WO2023008008A1 (en) Information processing program, information processing device, and information processing method
CN110445580B (en) Data transmission method and device, storage medium, and electronic device
US20230281141A1 (en) Method for order-preserving execution of write request and network device
JP2023085797A (en) Information processing program, information processing device, and information processing method
CN108347341A (en) A kind of acceleration capacity method of adjustment and device for adjusting virtual machine acceleration capacity
CN111314249A (en) Method and server for avoiding data packet loss of 5G data forwarding plane
WO2022151766A1 (en) Io request pipeline processing device, method and system, and storage medium
JP6998000B1 (en) Communication management program, information processing device and communication management method
CN111221642A (en) Data processing method and device, storage medium and terminal
CN109478151B (en) Network accessible data volume modification

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20211215

A871 Explanation of circumstances concerning accelerated examination

Free format text: JAPANESE INTERMEDIATE CODE: A871

Effective date: 20211215

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20220308

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20220317

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20220329

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20220401

R150 Certificate of patent or registration of utility model

Ref document number: 7061301

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150