[go: up one dir, main page]

JPH076043A - Multithreaded server - Google Patents

Multithreaded server

Info

Publication number
JPH076043A
JPH076043A JP6034742A JP3474294A JPH076043A JP H076043 A JPH076043 A JP H076043A JP 6034742 A JP6034742 A JP 6034742A JP 3474294 A JP3474294 A JP 3474294A JP H076043 A JPH076043 A JP H076043A
Authority
JP
Japan
Prior art keywords
thread
processing
priority
sample data
semaphore
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.)
Pending
Application number
JP6034742A
Other languages
Japanese (ja)
Inventor
Ichiro Mizunuma
一郎 水沼
Hiromitsu Shimakawa
博光 島川
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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric Corp
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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP6034742A priority Critical patent/JPH076043A/en
Publication of JPH076043A publication Critical patent/JPH076043A/en
Pending legal-status Critical Current

Links

Landscapes

  • Computer And Data Communications (AREA)

Abstract

(57)【要約】 【目的】 受信したサンプルデータをメモリに格納中で
あっても、要求メッセージに対する処理を可能にして、
要求メッセージに対する処理の高速化を図ることができ
るとともに、要求メッセージの欠損を防止できるマルチ
スレッド・サーバを得ることを目的とする。 【構成】 第2の受信部16・17により保持された要
求メッセージを順次取り出し、その要求メッセージの内
容に応じた処理を第1の受信部11が受信してメモリ1
3・15に格納したサンプルデータに基づいて行うよう
にしたものである。
(57) [Summary] [Purpose] Enables processing of request messages even while storing received sample data in memory.
An object of the present invention is to obtain a multi-threaded server that can speed up the processing for a request message and can prevent the loss of the request message. [Structure] The request messages held by the second receiving units 16 and 17 are sequentially taken out, and the first receiving unit 11 receives the process according to the content of the request message and the memory 1
This is performed based on the sample data stored in 3.15.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】この発明は、外部装置からの要求
メッセージに対し、リアルタイムに応答できるマルチス
レッド・サーバに関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a multithread server which can respond to a request message from an external device in real time.

【0002】[0002]

【従来の技術】図22は従来のマルチスレッド・サーバ
を示す構成図であり、図において、1はプラント、2は
クライアント、3はネットワーク(バックプレーンバス
でもよい)であり、クライアント2及びネットワーク3
から外部装置が構成されている。4はプラント1からサ
ンプルデータを受信するとともに、外部装置から要求メ
ッセージを受信するレシーバ、5はレシーバ4により受
信された要求メッセージの内容に応じてチャイルドスレ
ッド6,7,8のいずれかを起動するとともに、レシー
バ4がサンプルデータを受信した場合にはそのサンプル
データをメモリ9に格納するマザースレッド、6,7,
8は外部装置から送られる要求メッセージに応じた処理
をメモリ9に格納されたサンプルデータに基づいて行う
チャイルドスレッドであり、チャイルドスレッド6,
7,8は起動時にマザースレッド5によって生成され
る。9はサンプルデータを格納するメモリ、10はチャ
イルドスレッド6,7,8の処理結果を一時的に保持す
るFIFOキュー、20はFIFOキュー10に保持さ
れた処理結果を、保持された順に取り出して外部装置へ
送信するトランスミッタである。
2. Description of the Related Art FIG. 22 is a block diagram showing a conventional multithreaded server. In the figure, 1 is a plant, 2 is a client, 3 is a network (may be a backplane bus), and a client 2 and a network 3 are shown.
External device. A receiver 4 receives the sample data from the plant 1 and a request message from an external device, and a receiver 5 activates one of the child threads 6, 7 and 8 depending on the content of the request message received by the receiver 4. At the same time, when the receiver 4 receives the sample data, the mother thread for storing the sample data in the memory 9, 6, 7,
Reference numeral 8 denotes a child thread that performs processing according to a request message sent from an external device based on the sample data stored in the memory 9.
7, 8 are generated by the mother thread 5 at the time of startup. Reference numeral 9 is a memory for storing sample data, 10 is a FIFO queue for temporarily holding the processing results of the child threads 6, 7, 8 and 20 is a processing queue for holding the processing results held in the FIFO queue 10 It is a transmitter that transmits to the device.

【0003】次に動作について説明する。まず、レシー
バ4は、プラント1からサンプルデータまたは外部装置
から要求メッセージを受信する。そして、マザースレッ
ド5は、レシーバ4がプラント1からサンプルデータを
受信した場合には、そのサンプルデータをメモリ9に格
納し、レシーバ4が外部装置から要求メッセージを受信
した場合には、その要求メッセージの内容に応じてチャ
イルドスレッド6,7,8のいずれかを生成して起動す
る。
Next, the operation will be described. First, the receiver 4 receives sample data from the plant 1 or a request message from an external device. Then, the mother thread 5 stores the sample data in the memory 9 when the receiver 4 receives the sample data from the plant 1, and the request message when the receiver 4 receives the request message from the external device. Either one of the child threads 6, 7, or 8 is generated and activated in accordance with the content of.

【0004】例えば、マザースレッド5によりチャイル
ドスレッド6が起動された場合には、チャイルドスレッ
ド6は、要求メッセージに応じた処理をメモリ9に格納
されたサンプルデータに基づいて行う。そして、チャイ
ルドスレッド6の処理結果がFIFOキュー10に送信
され、一時的に保持される。そして、トランスミッタ2
0はFIFOキュー10に保持された処理結果を、保持
された順に取り出して外部装置へ送信する。即ち、図2
3に示すように、FIFOキュー10に先に保持された
処理結果が、後に保持された処理結果より優先度が低い
場合でも、優先度の低い先に保持された処理結果から送
信される。なお、チャイルドスレッド6,7,8はそれ
ぞれ並列的に処理を行うことができるが、メモリ9に対
するアクセスは同時に行うことができない。
For example, when the mother thread 5 activates the child thread 6, the child thread 6 performs processing according to the request message based on the sample data stored in the memory 9. Then, the processing result of the child thread 6 is transmitted to the FIFO queue 10 and is temporarily retained. And transmitter 2
0 fetches the processing results held in the FIFO queue 10 in the order in which they are held and sends them to the external device. That is, FIG.
As shown in FIG. 3, even if the processing result held first in the FIFO queue 10 has a lower priority than the processing result held later, the processing result held first has a lower priority. The child threads 6, 7, and 8 can perform processing in parallel, but cannot access the memory 9 at the same time.

【0005】[0005]

【発明が解決しようとする課題】従来のマルチスレッド
・サーバは以上のように構成されているので、プラント
1等からのサンプルデータも外部装置からの要求メッセ
ージもレシーバ4が受信してマザースレッド5がその後
の処理を決定しなければならず、従って、例えば、受信
した要求メッセージに応答する処理を行っている途中
で、サンプルデータを受信した場合、その処理が終了す
るまでそのサンプルデータをメモリ9に格納することが
できず、その結果、そのサンプルデータの格納が次のサ
ンプルデータの到着までに終了しないと、サンプルデー
タの欠測が起こる事態が発生する問題点があった。
Since the conventional multi-thread server is configured as described above, the receiver 4 receives the sample data from the plant 1 and the like and the request message from the external device, and the mother thread 5 receives the sample data. Must determine the subsequent processing. Therefore, for example, when the sample data is received during the process of responding to the received request message, the sample data is stored in the memory 9 until the process is completed. However, if the storage of the sample data is not completed by the arrival of the next sample data, the sample data may be missed.

【0006】また、レシーバ4は、複数の要求信号等を
保持する機能がないので、マザースレッド5が、レシー
バ4により受信された要求メッセージ等(便宜上、旧要
求メッセージという)を取り込む前に、他の要求メッセ
ージ等を外部装置から送られてしまうと、旧要求メッセ
ージが欠損してしまう問題点があった。
Further, since the receiver 4 does not have a function of holding a plurality of request signals and the like, before the mother thread 5 fetches the request message and the like (for convenience, referred to as old request message) received by the receiver 4, If the request message or the like is sent from the external device, the old request message is lost.

【0007】また、トランスミッタ20は、FIFOキ
ュー10に保持された順に取り出して送信するので、先
に保持された処理結果より後から保持された処理結果の
方が高速性を要求されていても、先に保持された処理結
果を送信するまで後に保持された処理結果は待たされて
しまい、外部装置の要求を十分満足することができない
問題点があった。
Further, since the transmitter 20 takes out and transmits in the order held in the FIFO queue 10, even if the processing result held later is required to be faster than the processing result held first, There is a problem that the processing result held later is kept waiting until the processing result held earlier is transmitted, and the request of the external device cannot be sufficiently satisfied.

【0008】また、トランスミッタ20は、送信以外の
他の処理を行うスレッド(図3参照)の存在を確認せず
に処理結果を送信してしまうので、トランスミッタ20
の送信処理より当該スレッドの処理の方が高速性を要求
されていても、トランスミッタ20の送信処理が終わる
まで当該スレッドの処理が待たされてしまう問題点があ
った。
Further, since the transmitter 20 sends the processing result without confirming the existence of a thread (see FIG. 3) that performs processing other than the transmission, the transmitter 20
Even if the processing of the thread is required to have higher speed than the transmission processing of No. 2, there is a problem that the processing of the thread is kept waiting until the transmission processing of the transmitter 20 is completed.

【0009】また、マザースレッド5は、要求メッセー
ジに応答する処理を実行する際に、チャイルドスレッド
6,7,8を生成する毎にチャイルドスレッド6,7,
8の処理に必要なメモリ領域を確保しなければならず、
従って、徐々にメモリ空間上に不要となったメモリ領域
が増えていくためガベージコレクションを行う必要が生
じ、その間要求メッセージに対する応答ができなくなる
問題点があった。
Further, the mother thread 5 generates the child threads 6, 7, and 8 each time it executes the processing in response to the request message.
The memory area necessary for the processing of 8 must be secured,
Therefore, since the unnecessary memory area gradually increases in the memory space, it becomes necessary to perform the garbage collection, and there is a problem that the response to the request message becomes impossible during that period.

【0010】また、マザースレッド5は、要求メッセー
ジに応答する処理を実行する際に、その都度チャイルド
スレッド6,7,8を生成する必要があるが、スタック
領域が不足しているような場合には生成することができ
ず、スタック領域が解放されるまで処理を待機しなけれ
ばならない問題点があった。
Further, the mother thread 5 needs to generate the child threads 6, 7, and 8 each time when executing the processing responding to the request message, but when the stack area is insufficient, Could not be created, and there was a problem that the process had to wait until the stack area was released.

【0011】さらに、チャイルドスレッド6,7,8は
それぞれ並列的に処理を行うことができるが、メモリ9
に対するアクセスは同時に行うことができないので、並
列処理の効率が低下し、高速処理ができないなどの問題
点もあった。
Further, the child threads 6, 7, and 8 can perform processing in parallel, but the memory 9
Since it is not possible to access the two simultaneously, there is a problem that the efficiency of parallel processing is reduced and high speed processing cannot be performed.

【0012】請求項1の発明は上記のような問題点を解
消するためになされたもので、受信したサンプルデータ
をメモリに格納中であっても、要求メッセージに対する
処理を可能にして、要求メッセージに対する処理の高速
化を図ることができるとともに、要求メッセージの欠損
を防止できるマルチスレッド・サーバを得ることを目的
とする。
The invention of claim 1 has been made to solve the above problems, and enables the processing of the request message even when the received sample data is stored in the memory, and the request message is processed. It is an object of the present invention to obtain a multi-threaded server that can speed up the processing of the request message and can prevent the loss of the request message.

【0013】請求項2の発明は、上記目的に加え、高速
性の要求される処理結果から順次送信できるようにし
て、外部装置の要求を十分満足できるマルチスレッド・
サーバを得ることを目的とする。
In addition to the above object, the invention of claim 2 is a multi-threaded system capable of sufficiently satisfying the request of an external device by enabling sequential transmission from the processing result requiring high speed.
Aim to get the server.

【0014】請求項3の発明は、処理結果を外部装置へ
送信する処理よりも、高速性の要求される処理がある場
合には、その高速性の要求される処理を優先して処理が
できるマルチスレッド・サーバを得ることを目的とす
る。
According to the third aspect of the invention, when there is a process requiring high speed processing, the process requiring high speed processing can be prioritized over the process of transmitting the processing result to the external device. Aim to get a multithreaded server.

【0015】請求項4の発明は、要求メッセージの欠損
を防止できるとともに、高速性の要求される要求メッセ
ージに対する処理から行うことができるマルチスレッド
・サーバを得ることを目的とする。
It is an object of the present invention to obtain a multithreaded server which can prevent loss of a request message and can perform processing from the request message requiring high speed.

【0016】請求項5の発明は、ガベージコレクション
を行う必要をなくし、要求メッセージに対する応答を妨
げられることのないマルチスレッド・サーバを得ること
を目的とする。
It is an object of the invention of claim 5 to obtain a multi-threaded server that does not need to perform garbage collection and that does not prevent a response to a request message.

【0017】請求項6の発明は、スタック領域の不足を
理由に、要求メッセージに対する処理が遅延するのを防
止できるマルチスレッド・サーバを得ることを目的とす
る。
It is an object of the present invention to provide a multithreaded server capable of preventing a delay in processing a request message due to lack of a stack area.

【0018】請求項7の発明は、並列処理の効率を向上
させ、高速に処理を行うことができるマルチスレッド・
サーバを得ることを目的とする。
The invention of claim 7 improves the efficiency of parallel processing and enables multi-thread processing capable of high-speed processing.
Aim to get the server.

【0019】請求項8の発明は、周期的に処理を行う周
期起動型スレッドのリアルタイム性を確保できるマルチ
スレッド・サーバを得ることを目的とする。
It is an object of the invention of claim 8 to obtain a multi-thread server capable of ensuring the real-time property of a cyclically-starting thread that performs processing periodically.

【0020】請求項9及び請求項10の発明は、タイマ
スレッドの待ち時間をできるだけ短くできるマルチスレ
ッド・サーバを得ることを目的とする。
It is an object of the inventions of claims 9 and 10 to obtain a multi-thread server capable of minimizing the waiting time of a timer thread.

【0021】[0021]

【課題を解決するための手段】請求項1の発明に係るマ
ルチスレッド・サーバは、第2の受信部により保持され
た要求メッセージを順次取り出し、その要求メッセージ
の内容に応じた処理を第1の受信部が受信してメモリに
格納したサンプルデータに基づいて行うようにしたもの
である。
A multithreaded server according to a first aspect of the present invention sequentially takes out request messages held by a second receiving section, and performs a process according to the contents of the request message in a first way. This is performed based on the sample data received by the receiving unit and stored in the memory.

【0022】請求項2の発明に係るマルチスレッド・サ
ーバは、処理実行部の処理結果を一時的に保持するとと
もに、複数の処理結果を保持した場合には優先度の高い
処理結果から順次外部装置に対して送信するようにした
ものである。
The multithreaded server according to the second aspect of the present invention temporarily holds the processing results of the processing execution unit, and when a plurality of processing results are held, the external devices are sequentially processed in descending order of priority. Is to be sent to.

【0023】請求項3の発明に係るマルチスレッド・サ
ーバは、処理実行部の処理結果を外部装置に対して送信
する処理を行う際に、他の処理と競合する場合、該他の
処理より優先度が高いときのみ処理を行うようにしたも
のである。
In the multithreaded server according to the invention of claim 3, when the processing result of the processing execution unit is transmitted to the external device, if there is competition with other processing, the multithread server has priority over the other processing. The processing is performed only when the frequency is high.

【0024】請求項4の発明に係るマルチスレッド・サ
ーバは、第2の受信部が複数の要求メッセージを保持し
ている場合、優先度の高い要求メッセージから順次取り
出すようにしたものである。
In the multithreaded server according to the fourth aspect of the present invention, when the second receiving unit holds a plurality of request messages, request messages with higher priority are sequentially extracted.

【0025】請求項5の発明に係るマルチスレッド・サ
ーバは、各スレッドが処理を実行する際に必要となるメ
モリ領域を各スレッド毎に予め確保しておき、各スレッ
ドに処理を実行させる際に対応するメモリ領域を割り当
てるようにしたものである。
In the multithreaded server according to the invention of claim 5, a memory area required when each thread executes a process is secured in advance for each thread, and when the thread executes the process. The corresponding memory area is allocated.

【0026】請求項6の発明に係るマルチスレッド・サ
ーバは、処理に必要となるスレッドを予め生成し、待機
状態にしておくようにしたものである。
A multithreaded server according to a sixth aspect of the present invention is configured such that threads required for processing are generated in advance and are put in a standby state.

【0027】請求項7の発明に係るマルチスレッド・サ
ーバは、第1の受信部により受信されたサンプルデータ
をメモリに格納中に、処理実行部から所定のアドレスに
格納されているサンプルデータの読み込み要求があった
場合、その読み込み要求に係るアドレスが、現在サンプ
ルデータを格納しているアドレスと一致するときのみそ
の読み込み要求を却下するようにしたものである。
According to a seventh aspect of the present invention, the multithread server reads the sample data stored at the predetermined address from the processing execution unit while storing the sample data received by the first receiving unit in the memory. When there is a request, the read request is rejected only when the address related to the read request matches the address currently storing the sample data.

【0028】請求項8の発明に係るマルチスレッド・サ
ーバは、所定の起動周期毎に周期起動型スレッドを起動
させるとともに、その周期起動型スレッドが起動後所定
時刻経過しても処理を終了しない場合には、その処理を
中断させて獲得している資源を解放させるタイマスレッ
ドを設けたものである。
The multithread server according to the invention of claim 8 activates the periodic activation type thread at every prescribed activation period, and when the periodic activation type thread does not terminate the processing even after a prescribed time has elapsed after the activation. Is provided with a timer thread for interrupting the processing and releasing the acquired resource.

【0029】請求項9の発明に係るマルチスレッド・サ
ーバは、タイマスレッドより優先度の低いスレッドがセ
マフォを獲得しているためにそのタイマスレッドが待ち
状態になっている場合、一時的にその優先度の低いスレ
ッドの優先度をそのタイマスレッドの優先度と同一にす
る優先度継承機能をそのセマフォに持たせたものであ
る。
In the multithreaded server according to the invention of claim 9, when a timer thread is waiting because a thread having a lower priority than the timer thread has acquired the semaphore, the priority is temporarily given to the timer thread. The semaphore has a priority inheritance function that makes the priority of a thread with a low frequency equal to the priority of the timer thread.

【0030】請求項10の発明に係るマルチスレッド・
サーバは、共有資源を使用しているか否かを示すフラグ
及びそのフラグを読み書きするためのセマフォを各スレ
ッド毎に設けるとともに、タイマスレッドより優先度の
低いスレッドが当該セマフォを獲得しているためにその
タイマスレッドが待ち状態になっている場合、一時的に
その優先度の低いスレッドの優先度をそのタイマスレッ
ドの優先度と同一にする優先度継承機能をそのセマフォ
に持たせたものである。
The multi-thread according to the invention of claim 10
The server provides a flag indicating whether or not the shared resource is used and a semaphore for reading and writing the flag for each thread, and the thread having a lower priority than the timer thread acquires the semaphore. When the timer thread is in a waiting state, the semaphore has a priority inheritance function that temporarily sets the priority of the thread having the low priority to the priority of the timer thread.

【0031】[0031]

【作用】請求項1の発明におけるマルチスレッド・サー
バは、要求メッセージを保持する第2の受信部を設けた
ことにより、要求メッセージの欠損が防止され、また、
第2の受信部により保持された要求メッセージを順次取
り出し、その要求メッセージの内容に応じた処理を第1
の受信部が受信してメモリに格納したサンプルデータに
基づいて行う処理実行部を設けたことにより、第2の受
信部から要求メッセージを受信中でも、第1の受信部か
らサンプルデータを受信してメモリに格納することがで
きる。
The multithreaded server according to the first aspect of the present invention is provided with the second receiving unit for holding the request message, so that the loss of the request message is prevented, and
The request messages held by the second receiving unit are sequentially taken out, and the processing according to the content of the request message is performed first.
Since the processing execution unit that performs the processing based on the sample data received by the receiving unit of the first embodiment and stored in the memory is provided, the sample data is received from the first receiving unit even when the request message is received from the second receiving unit. Can be stored in memory.

【0032】請求項2の発明におけるマルチスレッド・
サーバは、処理実行部の処理結果を一時的に保持すると
ともに、複数の処理結果を保持した場合には優先度の高
い処理結果から順次外部装置に対して送信する送信部を
設けたことにより、高速性の要求される処理結果から順
次送信できるようになる。
The multithread according to the invention of claim 2
The server temporarily holds the processing result of the processing execution unit, and when a plurality of processing results are held, by providing a transmitting unit that sequentially transmits to the external device from the processing result with high priority, It becomes possible to transmit sequentially from the processing result which requires high speed.

【0033】請求項3の発明におけるマルチスレッド・
サーバは、処理実行部の処理結果を外部装置に対して送
信する処理を行う際に、他の処理と競合する場合、該他
の処理より優先度が高いときのみ処理を行う送信部を設
けたことにより、処理結果を外部装置へ送信する処理よ
りも、高速性の要求される処理がある場合には、その高
速性の要求される処理から優先して処理される。
The multithread according to the invention of claim 3
The server is provided with a transmission unit that performs processing only when the processing result of the processing execution unit is transmitted to an external device and conflicts with other processing when the priority is higher than the other processing. As a result, when there is a process requiring high speed processing, the process requiring high speed processing is prioritized over the process of transmitting the processing result to the external device.

【0034】請求項4の発明におけるマルチスレッド・
サーバは、第2の受信部が複数の要求メッセージを保持
している場合、優先度の高い要求メッセージから順次取
り出す処理実行部を設けたことにより、要求メッセージ
の欠損を防止され、また、高速性の要求される要求メッ
セージに対する処理から行なえる。
The multithread according to the invention of claim 4
When the second receiving unit holds a plurality of request messages, the server is provided with a processing execution unit that sequentially extracts request messages with high priorities, so that loss of request messages can be prevented and high speed operation can be achieved. Can be performed from the processing for the required request message of.

【0035】請求項5の発明におけるマルチスレッド・
サーバは、各スレッドが処理を実行する際に必要となる
メモリ領域を各スレッド毎に予め確保しておき、各スレ
ッドに処理を実行させる際に対応するメモリ領域を割り
当てる処理実行部を設けたことにより、ガベージコレク
ションを行う必要がなくなる。
The multithread according to the invention of claim 5
The server has a process execution unit that reserves a memory area required for each thread to execute a process in advance and allocates a corresponding memory area when each thread executes a process. This eliminates the need for garbage collection.

【0036】請求項6の発明におけるマルチスレッド・
サーバは、処理に必要となるスレッドを予め生成し、待
機状態にしておく処理実行部を設けたことにより、スタ
ック領域の不足を理由に、要求メッセージに対する処理
が遅延するのを防止される。
The multithread according to the invention of claim 6
The server is provided with a processing execution unit that previously generates a thread required for processing and puts it in a standby state, and thus delays processing of a request message due to lack of stack area.

【0037】請求項7の発明におけるマルチスレッド・
サーバは、第1の受信部により受信されたサンプルデー
タをメモリに格納中に、処理実行部から所定のアドレス
に格納されているサンプルデータの読み込み要求があっ
た場合、その読み込み要求に係るアドレスが、現在サン
プルデータを格納しているアドレスと一致するときのみ
その読み込み要求を却下するようにしたことにより、同
じデータを同時に読み書きすることによって生じるデー
タ内容の矛盾を防止しつつデータの読み書きの並列処理
が可能になる。
The multithread according to the invention of claim 7
The server, when storing the sample data received by the first receiving unit in the memory and receiving a read request for the sample data stored at the predetermined address from the process executing unit, determines that the address related to the read request is , Parallel processing of reading and writing data while preventing the conflict of data contents caused by reading and writing the same data at the same time by rejecting the reading request only when it matches the address currently storing the sample data Will be possible.

【0038】請求項8の発明におけるマルチスレッド・
サーバは、所定の起動周期毎に周期起動型スレッドを起
動させるとともに、その周期起動型スレッドが起動後所
定時刻経過しても処理を終了しない場合には、その処理
を中断させて獲得している資源を解放させるタイマスレ
ッドを設けたことにより、他の周期起動型スレッドを所
定の起動周期毎に確実に起動できるようになる。
The multithread according to the invention of claim 8
The server activates the periodic activation thread at every prescribed activation cycle, and if the periodic activation thread does not end the processing even after a prescribed time has elapsed after the activation, the server interrupts the processing and acquires. By providing the timer thread for releasing the resources, it becomes possible to surely start another cycle-starting thread every predetermined start-up cycle.

【0039】請求項9の発明におけるマルチスレッド・
サーバは、タイマスレッドより優先度の低いスレッドが
セマフォを獲得しているためにそのタイマスレッドが待
ち状態になっている場合、一時的にその優先度の低いス
レッドの優先度をそのタイマスレッドの優先度と同一に
する優先度継承機能をそのセマフォに持たせたことによ
り、優先度の低いスレッドがセマフォを獲得していて
も、その優先度の低いスレッドの処理が速やかに行われ
るため、タイマスレッドがセマフォを獲得するまでの待
ち時間が短縮される。
The multithread according to the invention of claim 9
If the timer thread is waiting because the thread with a lower priority than the timer thread has acquired the semaphore, the server temporarily assigns the priority of the thread with a lower priority to that timer thread. Since the semaphore has the priority inheritance function that makes it the same as the priority, even if a thread with a low priority has acquired the semaphore, the thread with a low priority can be processed promptly. The waiting time for a semaphore to acquire is shortened.

【0040】請求項10の発明におけるマルチスレッド
・サーバは、共有資源を使用しているか否かを示すフラ
グ及びそのフラグを読み書きするためのセマフォを各ス
レッド毎に設けるとともに、タイマスレッドより優先度
の低いスレッドが当該セマフォを獲得しているためにそ
のタイマスレッドが待ち状態になっている場合、一時的
にその優先度の低いスレッドの優先度をそのタイマスレ
ッドの優先度と同一にする優先度継承機能をそのセマフ
ォに持たせたことにより、優先度の低いスレッドがセマ
フォを獲得していても、その優先度の低いスレッドの処
理が速やかに行われるため、タイマスレッドがセマフォ
を獲得するまでの待ち時間が短縮される。
According to the tenth aspect of the invention, in the multithreaded server, a flag indicating whether or not a shared resource is used and a semaphore for reading and writing the flag are provided for each thread, and a priority is given to the timer thread. If the timer thread is waiting because the low thread has acquired the semaphore, the priority inheritance that temporarily sets the priority of the thread with the low priority to the priority of the timer thread By giving the function to that semaphore, even if the thread with the low priority has acquired the semaphore, the processing with the thread with the low priority is performed promptly.Therefore, wait until the timer thread acquires the semaphore. Time is reduced.

【0041】[0041]

【実施例】【Example】

実施例1.以下、この発明の一実施例を図について説明
する。図1はこの発明の実施例1によるマルチスレッド
・サーバを示す構成図であり、図において、従来のもの
と同一符号は同一または相当部分を示すので説明を省略
する。11はプラント1からサンプルデータを受信する
FIFOキュー(第1の受信部)、12はFIFOキュ
ー11が受信したサンプルデータを一定周期でリングバ
ッファ13に書き込む周期起動型スレッド、13はその
サンプルデータを格納するリングバッファ(メモリ)、
14は周期起動型スレッド12が現在書き込み中である
リングバッファ13のインデックス(アドレス)より少
し過去のサンプルデータをいくつかまとめてディスク1
5へ一定周期で書き込む周期起動型スレッド、15はデ
ィスク(メモリ)である。
Example 1. An embodiment of the present invention will be described below with reference to the drawings. FIG. 1 is a block diagram showing a multithreaded server according to a first embodiment of the present invention. In the figure, the same reference numerals as those of the conventional one indicate the same or corresponding portions, and the explanation thereof will be omitted. 11 is a FIFO queue (first receiving unit) that receives the sample data from the plant 1, 12 is a cyclic start-up thread that writes the sample data received by the FIFO queue 11 to the ring buffer 13 at a constant cycle, and 13 is the sample data Ring buffer (memory) to store,
Reference numeral 14 is a disk 1 in which some sample data slightly past the index (address) of the ring buffer 13 currently being written by the cyclically activated thread 12 are collected.
Reference numeral 5 is a periodic start type thread for writing in a constant cycle, and 15 is a disk (memory).

【0042】また、16はクライアント2からネットワ
ーク3を介して要求メッセージを受信するレシーバ、1
7はレシーバ16が受信したその要求メッセージを保持
するFIFOキューであり、レシーバ16及びFIFO
キュー17から第2の受信部が構成されている。
Reference numeral 16 is a receiver for receiving a request message from the client 2 via the network 3,
Reference numeral 7 denotes a FIFO queue that holds the request message received by the receiver 16, and the receiver 16 and the FIFO queue
The queue 17 constitutes a second receiver.

【0043】また、18はFIFOキュー17により保
持された要求メッセージを順次取り出し、その要求メッ
セージの内容に応じてチャイルドスレッド6,7,8の
いずれかを起動することにより、その要求メッセージの
内容に応じた処理をリングバッファ13及びディスク1
5に格納されたサンプルデータに基づいて行うマザース
レッドであり、マザースレッド18及びチャイルドスレ
ッド6,7,8から処理実行部が構成されている。
Further, 18 sequentially fetches the request messages held by the FIFO queue 17 and activates one of the child threads 6, 7 and 8 in accordance with the content of the request message to change the content of the request message. The corresponding processing is performed by the ring buffer 13 and the disk 1.
5 is a mother thread that is executed based on the sample data stored in 5, and the processing execution unit is composed of the mother thread 18 and the child threads 6, 7, and 8.

【0044】また、19はチャイルドスレッド6,7,
8の処理結果を一時的に保持するFIFOキュー、20
はFIFOキュー19により保持されたその処理結果を
ネットワーク3を介してクライアント2に対して送信す
るトランスミッタであり、FIFOキュー19及びトラ
ンスミッタ20から送信部が構成されている。
Further, 19 is a child thread 6, 7,
A FIFO queue for temporarily holding the processing result of 8, 20
Is a transmitter for transmitting the processing result held by the FIFO queue 19 to the client 2 via the network 3, and the transmitter includes the FIFO queue 19 and the transmitter 20.

【0045】次に動作について説明する。まず、サンプ
ルデータは、例えば、10msec毎にプラント1から
送信され、FIFOキュー11がこれを受信する。そし
て、FIFOキュー11に受信されたサンプルデータ
は、周期起動型スレッド12によって周期的にリングバ
ッファ13に格納される。また、リングバッファ13に
ある程度サンプルデータが蓄積されていくと、周期起動
型スレッド14によってサンプルデータをいくつかまと
めてディスク15に格納される。なお、リングバッファ
13及びディスク15にサンプルデータを格納する際、
いつサンプルされたサンプルデータであるか分かるよう
に時刻情報もいっしょに格納される。
Next, the operation will be described. First, the sample data is transmitted from the plant 1 every 10 msec, for example, and the FIFO queue 11 receives the sample data. Then, the sample data received in the FIFO queue 11 is periodically stored in the ring buffer 13 by the cyclic activation type thread 12. When the sample data is accumulated in the ring buffer 13 to some extent, the cyclically-starting thread 14 collectively stores some sample data in the disk 15. When storing the sample data in the ring buffer 13 and the disk 15,
Time information is also stored together so that it can be known when the sampled data is sampled.

【0046】一方、要求メッセージは、不定期にクライ
アント2からネットワーク3を介して送信され、レシー
バ16がこれを受信する。そして、レシーバ16に受信
された要求メッセージは、一時的にFIFOキュー17
に格納される。そして、FIFOキュー17に格納され
た要求メッセージを、マザースレッド18が順次取り込
み、その要求メッセージの内容に応じてチャイルドスレ
ッド6,7,8のいずれかを生成して起動する(チャイ
ルドスレッド6,7,8を起動する際、処理に必要なメ
モリ領域を動的に確保する。詳細は後述する。)。ここ
で、要求メッセージには、下記に示すようなものがあ
る。 あるイベントが起こった場合にそのイベントの発生
を通知 現在時刻のサンプルデータの周期転送 過去のある時刻からある時刻までのサンプルデータ
の一斉転送
On the other hand, the request message is transmitted from the client 2 via the network 3 at irregular intervals, and the receiver 16 receives the request message. Then, the request message received by the receiver 16 is temporarily transferred to the FIFO queue 17
Stored in. Then, the mother thread 18 sequentially takes in the request messages stored in the FIFO queue 17, and one of the child threads 6, 7, and 8 is generated and activated according to the content of the request message (child threads 6, 7). , 8, the memory area required for the process is dynamically secured when starting. (Details will be described later). Here, there are the following request messages. Notifies that an event has occurred when an event occurs. Periodic transfer of sample data at the current time. Batch transfer of sample data from a certain time in the past to a certain time.

【0047】そして、マザースレッド18により起動さ
れたチャイルドスレッド6,7,8は、要求メッセージ
の内容に応じた処理をリングバッファ13及びディスク
15に格納されているサンプルデータに基づいて行う
(必要とするサンプルデータがリングバッファ13に格
納されていない場合、ディスク15とアクセスする)。
例えば、要求メッセージの内容が、上記の内容であれ
ば、イベントの起動があった旨の通知をクライアント2
に対して送信する処理を行う。また、要求メッセージの
内容が、上記の内容であれば、リングバッファ13
等から該当するサンプルデータを読み込んでクライアン
ト2に対して送信する処理を行う。
Then, the child threads 6, 7, and 8 started by the mother thread 18 perform processing according to the contents of the request message based on the sample data stored in the ring buffer 13 and the disk 15 (necessary). If the sample data to be processed is not stored in the ring buffer 13, the disk 15 is accessed).
For example, if the content of the request message is the above content, the client 2 is notified that an event has been activated.
To send to. If the content of the request message is the above content, the ring buffer 13
A process of reading the corresponding sample data from the above and transmitting it to the client 2 is performed.

【0048】そして、チャイルドスレッド6,7,8の
処理結果はFIFOキュー19に送信され、一時的に保
持される。なお、チャイルドスレッド6,7,8は並列
処理が可能であるため、FIFOキュー19に複数の処
理結果が保持されることがある。そして、FIFOキュ
ー19に保持された処理結果は、トランスミッタ20が
順次取り込んでネットワーク3を介してクライアント2
に対して送信し、一連の処理を終了する。
Then, the processing results of the child threads 6, 7, and 8 are transmitted to the FIFO queue 19 and temporarily held. Since the child threads 6, 7, and 8 can perform parallel processing, the FIFO queue 19 may hold a plurality of processing results. Then, the transmitter 20 sequentially fetches the processing result held in the FIFO queue 19 and the client 2 receives the processing result via the network 3.
To end the series of processing.

【0049】このように、実施例1では、要求メッセー
ジを受信するレシーバ16の他に、プラント1から送信
されるサンプルデータを受信する専用のFIFOキュー
11を設けるようにしているので、要求メッセージの処
理と別個独立にサンプルデータのサンプル処理を行うこ
とができるようになり、従って、要求メッセージの処理
によってサンプル処理が妨げられる事態が発生すること
がなくなり、サンプル処理をその時間上の制約を保って
行うことができる。また、要求メッセージを一時的に保
持するFIFOキュー17を設けているので、前に送ら
れた要求メッセージに対する処理が終了する前に他の要
求メッセージが複数個クライアント2から送信されてき
たとしても、要求メッセージが欠損するという事態は発
生しない。因に、この実施例1は請求項1の発明に対応
している。
As described above, in the first embodiment, the dedicated FIFO queue 11 for receiving the sample data transmitted from the plant 1 is provided in addition to the receiver 16 for receiving the request message. It is now possible to sample the sample data independently of the processing, so that the processing of the request message does not interfere with the sample processing, and the sample processing can be performed with time constraints. It can be carried out. Further, since the FIFO queue 17 for temporarily holding the request message is provided, even if a plurality of other request messages are transmitted from the client 2 before the processing for the previously transmitted request message is completed, The situation where the request message is lost does not occur. The first embodiment corresponds to the invention of claim 1.

【0050】実施例2.上記実施例1では、FIFOキ
ュー19に複数の処理結果を保持された場合、FIFO
キュー19に保持された順にその処理結果を送信するも
のについて説明したが、図2に示すように、複数の処理
結果を保持した場合には優先度の高い処理結果から順次
クライアント2に対して送信するようにしてもよい。図
2において、19a、19b、19cはFIFOキュー
19の構成要素であり、それぞれチャイルドスレッド
6,7,8の処理結果を一時的に保持する。また、21
はFIFOキュー19が複数の処理結果を保持した場合
には優先度の高い処理結果から順次クライアント2に対
して送信するトランスミッタ(送信部)である。
Example 2. In the first embodiment described above, when a plurality of processing results are held in the FIFO queue 19, the FIFO
Although the one in which the processing results are transmitted in the order held in the queue 19 has been described, as shown in FIG. 2, when a plurality of processing results are held, the processing results with higher priority are sequentially transmitted to the client 2. You may do it. In FIG. 2, 19a, 19b, and 19c are components of the FIFO queue 19, and temporarily hold the processing results of the child threads 6, 7, and 8, respectively. Also, 21
Is a transmitter (transmitting unit) that sequentially transmits to the client 2 from the processing result with the highest priority when the FIFO queue 19 holds a plurality of processing results.

【0051】次に動作について説明する。まず、要求メ
ッセージは、上記のごとく内容がそれぞれ異なってお
り、従って、それぞれクライアント2に対して応答する
に際して時間上の制約に関係した優先度が存在する。例
えば、チャイルドスレッド6は、上記の要求メッセー
ジに対する処理を行うものである場合、かかる処理は、
イベント発生に対するクライアント2の対応が間に合う
ように、ある時間以内にクライアント2に送信される必
要があるので極めて高い優先度Pmq2 を有している。ま
た、チャイルドスレッド7は、上記の要求メッセージ
に対する処理を行うものである場合、かかる処理は、ク
ライアント2がまだ最新のサンプルデータとして利用す
る価値のある時間以内に送信される必要があるので、チ
ャイルドスレッド6の処理に次いで高い優先度Pmq1
有する。また、チャイルドスレッド8は、上記の要求
メッセージに対する処理を行うものである場合、かかる
処理は、送信が多少遅れても支障が少ないのでチャイル
ドスレッド6,7の処理より低い優先度Pmq0 を有して
いる。 Pmq0 <Pmq1 <Pmq2
Next, the operation will be described. First, the request message has different contents as described above, and therefore, there is a priority related to a time constraint when responding to each client 2. For example, if the child thread 6 is to process the above request message,
It has an extremely high priority P mq2 because it needs to be transmitted to the client 2 within a certain time so that the client 2 can respond to the event occurrence in time. If the child thread 7 is to process the above-mentioned request message, the child thread 7 needs to be transmitted within a valuable time for the client 2 to use as the latest sample data. It has the highest priority P mq1 next to the processing of thread 6. Further, when the child thread 8 performs the processing for the above request message, such processing has a lower priority P mq0 than the processing of the child threads 6 and 7 because there is little trouble even if the transmission is delayed a little. ing. P mq0 <P mq1 <P mq2

【0052】この場合において、チャイルドスレッド8
から優先度Pmq0 の処理結果がFIFOキュー19cに
送信されて格納された後、直ちにチャイルドスレッド6
から優先度Pmq2 の処理結果がFIFOキュー19aに
送信されて格納されたとする。実施例1では、FIFO
キュー19に格納された順に送信するので、チャイルド
スレッド8の処理結果を先に送信することになるが、実
施例2では、処理結果の優先度を考慮して送信するの
で、優先度の高いチャイルドスレッド6の処理結果を先
に送信することになる。これにより、クライアント2の
要求に則した処理が可能になる。因に、この実施例2は
請求項2の発明に対応している。
In this case, the child thread 8
From the processing result of the priority P mq0 to the FIFO queue 19c is stored and immediately thereafter, the child thread 6
It is assumed that the processing result of the priority P mq2 is transmitted to and stored in the FIFO queue 19a. In the first embodiment, the FIFO
Since the transmission is performed in the order stored in the queue 19, the processing result of the child thread 8 is transmitted first. However, in the second embodiment, since the transmission is performed in consideration of the priority of the processing result, a child with a high priority is transmitted. The processing result of the thread 6 will be transmitted first. This enables processing according to the request of the client 2. The second embodiment corresponds to the invention of claim 2.

【0053】実施例3.上記実施例2では、トランスミ
ッタ21は、送信以外の他の処理を行うスレッド22の
存在を確認せずに処理結果を送信するものについて説明
したが、図3に示すように、チャイルドスレッド6,
7,8の処理結果をクライアント2に対して送信する処
理を行う際に、送信以外の他の処理を行うスレッド22
と競合する場合、スレッド22の処理の優先度Petc
り高い優先度をトランスミッタ21の送信スレッドが有
するときのみ送信処理を行うようにしてもよい。図にお
いて、21a、21b、21cはトランスミッタ21の
送信スレッド、22は送信以外の他の処理を行うスレッ
ド、23はセマフォである。
Example 3. In the second embodiment, the transmitter 21 transmits the processing result without confirming the existence of the thread 22 that performs processing other than the transmission. However, as shown in FIG.
A thread 22 that performs processing other than transmission when performing processing of transmitting the processing results of 7 and 8 to the client 2.
When the transmission thread of the transmitter 21 has a higher priority than the processing priority P etc of the thread 22, the transmission processing may be performed. In the figure, 21a, 21b, and 21c are transmission threads of the transmitter 21, 22 is a thread that performs other processing other than transmission, and 23 is a semaphore.

【0054】次に動作について説明する。例えば、送信
スレッド21a,21b,21cの優先度をそれぞれP
tr2 ,P tr1 ,Ptr0 とし、優先度の高さの関係は下記
のようにあるとする。 Ptr0 <Ptr1 <Petc <Ptr2
Next, the operation will be described. For example, send
The priority of each thread 21a, 21b, 21c is P
tr2 , P tr1 , Ptr0 And the relationship of high priority is as follows
It is supposed to be. Ptr0 <Ptr1 <Petc <Ptr2

【0055】この場合において、送信スレッド21aが
送信処理を行うときは、送信スレッド21aの優先度P
tr2 は、スレッド22の優先度Petc より高いので、ス
レッド22が存在していても直ちに送信処理が行われ
る。一方、送信スレッド21cが送信処理を行うとき
は、送信スレッド21cの優先度Ptr0 は、スレッド2
2の優先度Petc より低いので、スレッド22の処理が
終了するまで送信処理が待機される。
In this case, when the transmission thread 21a performs the transmission process, the priority P of the transmission thread 21a is set.
Since tr2 is higher than the priority P etc of the thread 22, the transmission process is immediately performed even if the thread 22 exists. On the other hand, when the transmission thread 21c performs the transmission process, the priority P tr0 of the transmission thread 21c is the thread 2
Since the priority is lower than the priority P etc of 2, the transmission process waits until the process of the thread 22 ends.

【0056】なお、セマフォ23は、複数の送信スレッ
ド21a,21b,21cが同時にネットワーク3へ送
信するのを避けるために設けられている。セマフォ23
を獲得できる送信スレッドは1つであり、セマフォ23
を獲得している送信スレッド(図3の例では送信スレッ
ド21aが獲得している)のみがネットワーク3に対し
て送信することができる。
The semaphore 23 is provided to prevent a plurality of transmission threads 21a, 21b, 21c from simultaneously transmitting to the network 3. Semaphore 23
The number of sending threads that can acquire
Only the transmission thread that has acquired (the transmission thread 21a has acquired in the example of FIG. 3) can transmit to the network 3.

【0057】ここで、セマフォ23を設けた場合下記の
不具合がある。即ち、低い優先度を有する送信スレッド
21cがセマフォ23を獲得した後に、高い優先度を有
する送信スレッド21aがFIFOキュー19aに格納
されたような場合、低い優先度を有する送信スレッド2
1cがセマフォ23を獲得しているので、高い優先度を
有する送信スレッド21aは送信スレッド21cの送信
処理を待たなければならいが、送信スレッド21cの優
先度はスレッド22の優先度より低いので、送信スレッ
ド21cはスレッド22の処理が終了するまで待機状態
になる。従って、スレッド21aは高い優先度を有して
いるのにもかかわらず、結果として、スレッド22及び
送信スレッド21cの処理が終了するまで送信処理を行
うことができない不具合がある。
Here, when the semaphore 23 is provided, the following problems occur. That is, when the transmission thread 21c having a low priority acquires the semaphore 23 and then the transmission thread 21a having a high priority is stored in the FIFO queue 19a, the transmission thread 2 having a low priority is transmitted.
Since 1c has acquired the semaphore 23, the transmission thread 21a having a high priority must wait for the transmission processing of the transmission thread 21c, but since the priority of the transmission thread 21c is lower than the priority of the thread 22, transmission is performed. The thread 21c waits until the processing of the thread 22 is completed. Therefore, although the thread 21a has a high priority, as a result, there is a problem that the transmission processing cannot be performed until the processing of the thread 22 and the transmission thread 21c is completed.

【0058】そこで、セマフォ23に優先度継承機能
(送信スレッドの優先度変更機能)を持たせることによ
り上記不具合を解消することができる。即ち、一時的に
送信スレッド21cの優先度を送信スレッド21aの優
先度まで高めることにより、送信スレッド21cの送信
処理をスレッド22に優先させる。送信スレッド21c
の処理が終了すれば、送信スレッド21aがセマフォ2
3を獲得し、送信スレッド21aの優先度はスレッド2
2の優先度より高いので、送信スレッド21aはスレッ
ド22の処理を待たずに送信が可能になる。従って、送
信スレッド21aの待ち時間を短縮することができる。
因に、この実施例3は請求項3の発明に対応している。
Therefore, by giving the semaphore 23 a priority inheritance function (sending thread priority changing function), the above-mentioned problem can be solved. That is, the transmission process of the transmission thread 21c is prioritized over the thread 22 by temporarily increasing the priority of the transmission thread 21c to the priority of the transmission thread 21a. Sending thread 21c
When the processing of step 2 is completed, the transmission thread 21a moves to the semaphore 2
3 is acquired, and the priority of the transmission thread 21a is thread 2
Since the priority is higher than 2, the transmission thread 21a can perform transmission without waiting for the processing of the thread 22. Therefore, the waiting time of the transmission thread 21a can be shortened.
The third embodiment corresponds to the invention of claim 3.

【0059】実施例4.上記実施例1では、要求メッセ
ージがFIFOキュー17に保持された順に、マザース
レッド18が取り出して処理するものについて説明した
が、図4に示すように、要求メッセージに優先度を持た
せ、FIFOキュー17に先に格納された要求メッセー
ジの優先度より、後に格納された要求メッセージの優先
度が高い場合、後に格納された要求メッセージからマザ
ースレッド18が取り込んで処理するようにしてもよ
い。これにより、高速性の要求される要求メッセージに
対する処理から行うことができるようになる。因に、こ
の実施例4は請求項4の発明に対応している。
Example 4. In the first embodiment described above, the case where the mother thread 18 takes out and processes the request messages in the order in which the request messages are held in the FIFO queue 17 has been described. However, as shown in FIG. When the priority of the request message stored later in 17 is higher than the priority of the request message stored earlier in 17, the mother thread 18 may fetch and process the request message stored later. As a result, the processing can be performed from the processing for the request message requiring high speed. The fourth embodiment corresponds to the invention of claim 4.

【0060】実施例5.上記実施例1では、要求メッセ
ージの内容に応じてマザースレッド18がチャイルドス
レッド6,7,8のいずれかを生成して起動する際、処
理に必要なメモリ領域を動的に確保するものについて説
明したが、図5に示すように、各チャイルドスレッド
6,7,8が処理を実行する際に必要となるメモリ領域
を各スレッド6,7,8毎に予め確保しておき、各スレ
ッド6,7,8に処理を実行させる際に対応するメモリ
領域を割り当てるようにしてもよい。また、上記実施例
1では、マザースレッド18がその都度チャイルドスレ
ッド6,7,8を生成するようにしていたが、チャイル
ドスレッド6,7,8を予め生成して待機状態にしてお
いてもよい。
Example 5. In the above-described first embodiment, when the mother thread 18 generates and starts any one of the child threads 6, 7, and 8 according to the content of the request message, the one that dynamically secures the memory area required for the processing will be described. However, as shown in FIG. 5, a memory area required for each child thread 6, 7, 8 to execute a process is secured in advance for each thread 6, 7, 8 and each thread 6, 7, 8 is secured. Corresponding memory areas may be allocated when the processes are executed by 7 and 8. In the first embodiment, the mother thread 18 creates the child threads 6, 7, and 8 each time, but the child threads 6, 7, and 8 may be created in advance and set in the standby state. .

【0061】以下、図5について詳細に説明する。図5
において、31はスレッドプール、32,33,34は
それぞれチャイルドスレッド6,7,8が処理を行う際
に必要となるメモリ領域であり、スレッドを実行すべき
関数へのポインタ、その関数への引数、スレッドの優先
度、周期起動型スレッドの場合には、周期及びデッドラ
イン、イベント起動型スレッドの場合には、待つべきイ
ベント(以下、起動イベントという)の種類などの情報
が格納される。なお、各チャイルドスレッド6,7,8
は初期化時には待機状態にある。
Hereinafter, FIG. 5 will be described in detail. Figure 5
, 31 is a thread pool, 32, 33, and 34 are memory areas required when the child threads 6, 7, and 8 perform processing, respectively, a pointer to a function to execute a thread, and an argument to the function. Information such as a priority of a thread, a cycle and a deadline in the case of a cyclic activation type thread, and a type of event to be waited for (in the following, an activation event) in the case of an event activation type thread are stored. In addition, each child thread 6, 7, 8
Is in a standby state at initialization.

【0062】また、35はスレッドプール31を管理す
るスレッドプール管理テーブル、36は管理テーブルセ
マフォ、37は待機中のチャイルドスレッド6,7,8
の数を格納する領域、38はマザースレッド18の起動
要求をスレッドプール31に対して知らせる要求セマフ
ォ、39は起動要求を受けつけたチャイルドスレッド
6,7,8のスレッドIDを格納する領域、40はスレ
ッドプール31からマザースレッド18へ要求の受領を
知らせるための受領セマフォ、41はマザースレッド1
8からスレッドプール31へ起動命令を伝えるための起
動セマフォである。また、42はマザースレッド18以
外にスレッドプール31を用いるスレッドである。
Further, 35 is a thread pool management table for managing the thread pool 31, 36 is a management table semaphore, 37 is a waiting child thread 6, 7, 8
, 38 is a request semaphore for notifying the thread pool 31 of the activation request of the mother thread 18, 39 is an area for storing the thread IDs of the child threads 6, 7, and 8 that have accepted the activation request, and 40 is A reception semaphore for notifying the receipt of the request from the thread pool 31 to the mother thread 18, 41 is the mother thread 1
It is an activation semaphore for transmitting an activation instruction from 8 to the thread pool 31. Reference numeral 42 is a thread that uses the thread pool 31 in addition to the mother thread 18.

【0063】次に動作について説明する。まず、マザー
スレッド18は、スレッドプール管理テーブル35への
アクセス権を得るために管理テーブルセマフォ36にロ
ックをかける(動作1)。そして、管理テーブルセマフ
ォ36へのロックに失敗した場合には、一定時間後に再
度ロックを試みる。管理テーブルセマフォ36へのロッ
クに成功した場合には、領域37に格納されている待機
中のスレッドを確認し(動作2)、“0”であれば起動
不可能として例外処理を行うか、あるいは、一定時間後
に再度起動を試みる。“1”以上であれば要求セマフォ
38に対してシグナルを送信する(動作3)。
Next, the operation will be described. First, the mother thread 18 locks the management table semaphore 36 in order to gain access to the thread pool management table 35 (operation 1). Then, if the lock on the management table semaphore 36 fails, the lock is retried after a certain period of time. If the lock on the management table semaphore 36 succeeds, the waiting thread stored in the area 37 is confirmed (operation 2), and if it is “0”, it is determined that the thread cannot be started and exception processing is performed, or , Try again after a certain time. If it is "1" or more, a signal is transmitted to the request semaphore 38 (operation 3).

【0064】また、待機中のチャイルドスレッド6,8
はすべて要求セマフォ38からのシグナルの到着を待っ
ており、マザースレッド18からのシグナルは、これら
の待機中のチャイルドスレッド6,8のいずれか1つに
よって受信される。この例の場合では、チャイルドスレ
ッド6によって受信されたものとする。
Also, the child threads 6 and 8 waiting
Are all waiting for the arrival of signals from the request semaphore 38, and the signals from the mother thread 18 are received by any one of these waiting child threads 6, 8. In the case of this example, it is assumed that it is received by the child thread 6.

【0065】チャイルドスレッド6は、起動を受領した
スレッドが自分であることをマザースレッド18に知ら
せるため、自分のスレッドIDを領域39に書き込み
(動作5)、その後、受領セマフォ40にシグナルを送
信し(動作6)、起動セマフォ41へのシグナルの到着
を待つ。
The child thread 6 writes its thread ID in the area 39 (operation 5) in order to inform the mother thread 18 that the thread which received the activation is itself (operation 5), and then sends a signal to the reception semaphore 40. (Operation 6), wait for arrival of a signal to the activation semaphore 41.

【0066】一方、マザースレッド18は、動作3の終
了後、受領セマフォ40へのシグナルの到着を待ってお
り、チャイルドスレッド6からのシグナルを受信すると
(動作7)、領域39から要求を受領したスレッドID
を読み取る(動作8)。
On the other hand, the mother thread 18 waits for the arrival of the signal to the reception semaphore 40 after the end of the operation 3, and upon receiving the signal from the child thread 6 (operation 7), receives the request from the area 39. Thread ID
Is read (operation 8).

【0067】ここで、マザースレッド18は、予め確保
されているメモリ領域32に対して起動に必要な情報を
書き込み(動作9)、書き込みが完了すると、起動セマ
フォ41へシグナルを送信する(動作10)。チャイル
ドスレッド6は、起動セマフォ41からシグナルを受信
すると(動作11)、領域37の待機中のスレッドの数
を“1”減らし(動作12)、管理テーブルセマフォ3
6へのロックを解除する(動作13)。
Here, the mother thread 18 writes information necessary for activation into the memory area 32 secured in advance (operation 9), and when the writing is completed, sends a signal to the activation semaphore 41 (operation 10). ). When the child thread 6 receives the signal from the activation semaphore 41 (operation 11), the number of waiting threads in the area 37 is reduced by "1" (operation 12), and the management table semaphore 3
The lock to 6 is released (operation 13).

【0068】このように、予め各チャイルドスレッド
6,7,8が実行時に必要となるメモリ領域32,3
3,34を確保しておくことにより、メモリ領域確保の
繰り返しを原因とするメモリ空間上の不要なメモリが増
加していくという事態は発生しなくなる。従って、ガベ
ージコレクションを行う必要もなくなる。また、予め各
チャイルドスレッド6,7,8を初期化時に生成してお
くことにより、スタック領域の不足を原因とするチャイ
ルドスレッド6,7,8の生成不可という事態は発生し
なくなる。従って、スタック領域が解放されるまで処理
を待機しなければならないという従来の問題点は解消さ
れる。因に、この実施例5は請求項5及び請求項6の発
明に対応している。
As described above, the memory areas 32, 3 which are required in advance by the child threads 6, 7, 8 are executed.
By securing 3, 34, it is possible to prevent an unnecessary memory from increasing in the memory space due to repeated memory area securing. Therefore, it is not necessary to perform garbage collection. In addition, since the child threads 6, 7, and 8 are created in advance at the time of initialization, the situation in which the child threads 6, 7, and 8 cannot be created due to the lack of the stack area does not occur. Therefore, the conventional problem that the process has to wait until the stack area is released is solved. The fifth embodiment corresponds to the inventions of claims 5 and 6.

【0069】次に、リアルタイム性を要求されないチャ
イルドスレッドのスレッドプール31内の構成及び動作
について説明する。図6はスレッドプール31内のチャ
イルドスレッドが有する起動情報の構成図である。実行
すべき関数へのポインタ、その関数への起動要求をだし
たマザースレッド18からの引数、実行の優先度が含ま
れている。また、図7はスレッドプール31内のチャイ
ルドスレッドの動作を示すフローチャートであり、マザ
ースレッド18、あるいは他のスレッド42から終了の
割り込みがかかると、ステップST11に制御を移す。
Next, the configuration and operation in the thread pool 31 of the child thread which is not required to be real-time will be described. FIG. 6 is a configuration diagram of activation information included in the child thread in the thread pool 31. It includes a pointer to a function to be executed, an argument from the mother thread 18 which issued a start request to the function, and an execution priority. FIG. 7 is a flowchart showing the operation of the child thread in the thread pool 31. When the mother thread 18 or another thread 42 receives an end interrupt, the control is transferred to step ST11.

【0070】次に、周期起動型スレッドのスレッドプー
ル31内の構成及び動作について説明する。図8はスレ
ッドプール31内のチャイルドスレッドが有する起動情
報の構成図である。一周期ごとに実行すべき関数へのポ
インタ、その関数への起動要求をだしたマザースレッド
18からの引数、実行の優先度、起動の周期、一周期あ
たりの処理のデッドラインが含まれている。また、図9
はスレッドプール31内のチャイルドスレッドの動作を
示すフローチャートであり、マザースレッド18、ある
いは他のスレッド42が実行中の周期起動型スレッドを
停止させる場合には、各周期起動型スレッドの持つ終了
フラグを立てる。各周期起動型スレッドはその一周期ご
とに終了フラグをチェックし、それが立っていれば処理
を終了し、待機状態に戻る。
Next, the structure and operation of the thread pool 31 of the cyclic activation type threads will be described. FIG. 8 is a configuration diagram of the start information included in the child thread in the thread pool 31. It contains a pointer to the function to be executed in each cycle, arguments from the mother thread 18 that issued a start request to the function, execution priority, start cycle, and deadline for processing per cycle. . In addition, FIG.
Is a flowchart showing the operation of the child thread in the thread pool 31. When the mother thread 18 or another thread 42 is to stop the cyclically activated thread being executed, the end flag of each cyclically activated thread is set. Stand up. Each cyclically activated thread checks the end flag for each cycle, and if it is set, the processing is ended and the thread returns to the waiting state.

【0071】次に、イベント起動型スレッドのスレッド
プール31内の構成及び動作について説明する。図10
はスレッドプール31内のチャイルドスレッドが有する
起動情報の構成図である。イベントが発生したときに実
行すべき関数へのポインタ、その関数への起動要求をだ
したマザースレッド18からの引数、実行の優先度、起
動イベントに関する情報、処理のデッドラインが含まれ
ている。また、図11はスレッドプール31内のチャイ
ルドスレッドの動作を示すフローチャートである。マザ
ースレッド18、あるいは他のスレッド42がイベント
待ちをしているイベント起動型スレッドを待機状態にす
る場合には、そのスレッドに対して終了イベントを送信
する。終了イベントを受信したスレッドは待機状態に戻
る。
Next, the structure and operation of the thread pool 31 of event-triggered threads will be described. Figure 10
FIG. 4 is a configuration diagram of activation information included in a child thread in the thread pool 31. It includes a pointer to a function to be executed when an event occurs, an argument from the mother thread 18 that issued a start request to the function, execution priority, information about the start event, and a processing deadline. FIG. 11 is a flow chart showing the operation of the child thread in the thread pool 31. When the mother thread 18 or another thread 42 puts an event-triggered thread waiting for an event into a waiting state, an end event is transmitted to that thread. The thread receiving the end event returns to the waiting state.

【0072】スレッドプール31内の各チャイルドスレ
ッド6,7,8に、リアルタイム性を要求されないスレ
ッド、周期起動型スレッド、イベント起動型スレッドの
いずれの動作をも行わせるようにすることができる。マ
ザースレッド18からスレッドプール31内の各チャイ
ルドスレッド6,7,8へ受け渡す起動情報の中に起動
するスレッドの種類を含ませる。スレッドプール31内
のチャイルドスレッド6,7,8はこの情報に基づき行
う処理を決定する。また、図12はスレッドプール31
内の各チャイルドスレッド6,7,8がもつ起動情報の
構成図であり、図13はスレッドプール31内の各チャ
イルドスレッドの動作を示すフローチャートである。
The child threads 6, 7, and 8 in the thread pool 31 can be made to perform any operation of a thread that does not require real-time processing, a periodic activation thread, and an event activation thread. The type of thread to be activated is included in the activation information passed from the mother thread 18 to each child thread 6, 7, 8 in the thread pool 31. The child threads 6, 7, and 8 in the thread pool 31 determine the processing to be performed based on this information. Further, FIG. 12 shows the thread pool 31.
FIG. 13 is a configuration diagram of activation information of each child thread 6, 7, and 8 in FIG. 13, and FIG. 13 is a flowchart showing the operation of each child thread in the thread pool 31.

【0073】ここで、スレッドプール31内の数をnと
する。クライアント2から送られるスレッドの起動要求
(要求メッセージ)によってこれらのスレッドに処理が
受け渡される。あるイベントが生じた場合の緊急通知を
行うスレッドの数の上限をn1 、現在起動されている数
をi1 、サンプルデータの周期的な転送を行うスレッド
の数の上限をn2 、現在起動されている数をi2 、ある
イベントが生じた場合の任意期間のサンプルデータの転
送を行うスレッドの数の上限をn3 、現在起動されてい
る数をi3 とする。また、下記の関係があるとする。 n1 +n2 +n3 >n n1 ≦n n2 ≦n n3 ≦n
Here, the number in the thread pool 31 is n. Processing is passed to these threads in response to a thread activation request (request message) sent from the client 2. The upper limit of the number of threads that perform emergency notification when an event occurs is n 1 , the number of threads that are currently activated is i 1 , the upper limit of the number of threads that periodically transfer sample data is n 2 , and the current activation is The number of active threads is i 2 , the upper limit of the number of threads that transfer sample data in an arbitrary period when an event occurs is n 3 , and the number of threads that are currently activated is i 3 . Moreover, it is assumed that there is the following relationship. n 1 + n 2 + n 3 > n n 1 ≦ n n 2 ≦ n n 3 ≦ n

【0074】この場合において、i1 ,i2 が小さく、
下記の関係がある場合には、任意期間のサンプルデータ
の転送を行うスレッドを最大数n3 まで起動することが
できる。 i1 +i2 +i3 ≦n ・・・(1) そして、緊急通知を行うスレッドや周期転送を行うスレ
ッドの起動要求がクライアント2から送られて式(1)
の関係を満たさなくなった場合には、これを満たすよう
に任意期間のサンプルデータの転送を行うスレッドのい
くつかを中断あるいは終了させる。
In this case, i 1 and i 2 are small,
When there is the following relationship, a maximum number n 3 of threads that transfer sample data for an arbitrary period can be activated. i 1 + i 2 + i 3 ≦ n (1) Then, the client 2 sends an activation request for the thread that performs the emergency notification or the thread that performs the periodic transfer, and the formula (1)
When the relationship of (3) is no longer satisfied, some of the threads that transfer sample data for an arbitrary period are suspended or terminated so as to satisfy this relationship.

【0075】実施例6.図14はリングバッファ13及
びディスク15に対して複数のスレッドが書き込み及び
読み出しを行う動作を説明する構成図である。以下、リ
ングバッファ13等をアクセスするスレッドの機能に応
じて説明する。
Example 6. FIG. 14 is a configuration diagram illustrating an operation in which a plurality of threads perform writing and reading with respect to the ring buffer 13 and the disk 15. Hereinafter, description will be made according to the function of the thread that accesses the ring buffer 13 or the like.

【0076】 書き込みスレッド まず、周期起動型スレッド12(書き込みスレッド)
は、リングバッファ13へ周期ごとに書き込みを行う。
書き込まれるリングバッファ13のインデックスは書き
込みごとに一つずつ移動する。ここで、周期起動型スレ
ッド12が現在書き込みを行っているインデックス(図
中、×で示してあるインデックス)を格納する領域51
が予め用意されている。また、領域51は複数のスレッ
ドからアクセスされるため、領域51の相互排除のため
セマフォ52が設けられている。
Write Thread First, the cyclically activated thread 12 (write thread)
Writes to the ring buffer 13 every cycle.
The index of the ring buffer 13 to be written moves one by one for each writing. Here, an area 51 for storing an index (index indicated by x in the figure) which the cyclically activated thread 12 is currently writing.
Is prepared in advance. Since the area 51 is accessed by a plurality of threads, a semaphore 52 is provided for mutual exclusion of the area 51.

【0077】そして、周期起動型スレッド12は書き込
み中に、他のスレッドが書き込み中のインデックスにア
クセスするのを防止すべく、書き込むインデックスを変
えるごとに、領域51にそのインデックスを書き込む。
なお、各スレッドの領域51へのアクセスに要する時間
は小さく、またセマフォ52に優先度承継機能を持たせ
ているので、各スレッドがセマフォ52の獲得のために
長い時間待たされることはない。
During the writing, the periodically activated thread 12 writes the index in the area 51 every time the writing index is changed in order to prevent other threads from accessing the index being written.
The time required for each thread to access the area 51 is small, and since the semaphore 52 has the priority inheritance function, each thread does not have to wait a long time to acquire the semaphore 52.

【0078】 バックアップスレッド 周期起動型スレッド14(バックアップスレッド)はリ
ングバッファ13上のサンプルデータを、それらが失わ
れないうちにディスク15へ格納する。ディスク15上
にはバックアップ用のファイルがいくつか用意され、各
スレッドからは図に示すように、リング状に配置されて
いるように見ることができる。周期起動型スレッド14
は、リングバッファ13上に対して周期起動型スレッド
12が書き込んでいるインデックスのサンプルデータよ
りある程度遅れた時刻のサンプルデータを一度にいくつ
かまとめてディスクに転送する。
Backup Thread The cyclic thread 14 (backup thread) stores the sample data in the ring buffer 13 in the disk 15 before the data is lost. Several files for backup are prepared on the disk 15, and can be seen from each thread as if they are arranged in a ring shape as shown in the figure. Periodically activated thread 14
Transfers several pieces of sample data at a time which is later than the sample data of the index written by the cyclically activated thread 12 on the ring buffer 13 to the disk all at once.

【0079】周期スレッド12及び周期スレッド14が
アクセスするリングバッファ13上のインデックスの移
動の速度は等しく、また、周期スレッド14は周期スレ
ッド12が書き込みを行っているインデックスから十分
はなれたインデックスを読み出すので、周期スレッド1
2及び周期スレッド14が同じインデックスを同時にア
クセスすることはない。また、ディスク15上のファイ
ルには、各ファイルに定められた容量まで書き込み、そ
の容量に達するとそのファイルをクローズし、次のファ
イルへの書き込みを始める。
Since the moving speeds of the indexes on the ring buffer 13 accessed by the periodic thread 12 and the periodic thread 14 are equal, and the periodic thread 14 reads out an index far apart from the index written by the periodic thread 12. , Cycle thread 1
2 and the periodic thread 14 never access the same index at the same time. In addition, the file on the disk 15 is written up to the capacity determined for each file, and when the capacity is reached, the file is closed and writing to the next file is started.

【0080】ここで、ディスク15に対しても、現在書
き込みを行っているファイルに関する領域53を用意す
るとともに、領域53の相互排除のためセマフォ54を
設けている。領域53の格納する情報は、現在書き込み
が行われているファイルの番号とそのファイル上にある
最も過去のサンプルデータの時刻である。従って、周期
起動型スレッド14は、現在書き込みを行っているファ
イルの番号を領域53に書き込むようにしている。ま
た、新しいファイルに書き込みを始める際には、そのフ
ァイルに書き込んだ最初のサンプルデータの時刻を領域
53に書き込むようにしている。
Here, also on the disk 15, an area 53 relating to the file currently being written is prepared, and a semaphore 54 is provided for mutual exclusion of the area 53. The information stored in the area 53 is the number of the file currently being written and the time of the earliest sample data on that file. Therefore, the cyclic startup thread 14 writes the number of the file currently being written in the area 53. Also, when writing to a new file, the time of the first sample data written to that file is written to the area 53.

【0081】 周期的な読み出しを行うスレッド 例えば、チャイルドスレッド7が周期起動型スレッドの
場合、チャイルドスレッド7は、一周期ごとに、リング
バッファ13上に格納されている最新のサンプルデータ
を読み出す。チャイルドスレッド7はその周期ごとに領
域51の内容を読み出し、現在周期起動型スレッド12
が書き込みを行っているインデックスの1つ手前のイン
デックス(図中、○で示してあるインデックス)の内容
を読み出す。
Thread that Performs Periodic Reading For example, when the child thread 7 is a cyclic activation type thread, the child thread 7 reads the latest sample data stored in the ring buffer 13 for each cycle. The child thread 7 reads the contents of the area 51 for each cycle, and the current cycle start-type thread 12
Reads the contents of the index (index indicated by ◯ in the figure) immediately before the index being written by.

【0082】 任意期間の読み出しを行うスレッド 例えば、チャイルドスレッド8が任意期間の読み出しを
行うスレッドの場合、チャイルドスレッド8は、任意時
刻から任意時刻までのサンプルデータを任意の間隔で読
み出す。要求されたサンプルデータのうちリングバッフ
ァ13及びディスク15上にないものがある場合には、
リングバッファ13及びディスク15上にあるサンプル
データのみを読み出しに先行して、そのサンプルデータ
をリングバッファ13から読み出すべきか、ディスク1
5から読み出すべきかを決定する。
Thread for Reading for Arbitrary Period For example, when the child thread 8 is a thread for reading for an arbitrary period, the child thread 8 reads sample data from arbitrary time to arbitrary time at arbitrary intervals. If some of the requested sample data is not on the ring buffer 13 and the disk 15,
Whether only the sample data on the ring buffer 13 and the disk 15 should be read from the ring buffer 13 prior to the reading,
5 to determine whether to read.

【0083】領域53に格納されている現在書き込まれ
ているファイル上の最も過去のサンプルデータの時刻
と、読み出すべきサンプルデータの時刻を比較する。後
者の方が過去のものであれば、既にディスク15上から
失われているほどの過去のサンプルデータでない限り、
ディスク15から読み出す。後者が前者と同じ、あるい
は後者の方が前者より新しい時刻であれば、領域51の
示すインデックスに格納されているサンプルデータより
新しい時刻でない限り、リングバッファ13から読み出
す(図中、△で示してあるインデックス)。
The time of the oldest sample data on the currently written file stored in the area 53 is compared with the time of the sample data to be read. If the latter is past, unless it is past sample data that has already been lost from the disk 15,
Read from the disk 15. If the latter is the same as the former or the latter is newer than the former, it is read from the ring buffer 13 unless it is newer than the sample data stored in the index indicated by the area 51 (indicated by Δ in the figure). There is an index).

【0084】このように、実施例6によれば、FIFO
キュー11により受信されたサンプルデータをリングバ
ッファ13に格納中に、チャイルドスレッド7,8から
所定のアドレスに格納されているサンプルデータの読み
込み要求があった場合、現在サンプルデータを格納して
いるアドレスよりも手間のアドレスの内容に限り読み出
せるようにしているので、即ち、読み込み要求に係るア
ドレスが現在サンプルデータを格納しているアドレスと
一致するときはその読み込み要求を却下するようにして
いるので、同じデータを同時に読み書きすることによっ
て生じるデータ内容の矛盾を防止しつつデータの読み書
きの並列処理が可能になり、その結果、高速に処理を行
うことができる効果がある。因に、この実施例6は請求
項7の発明に対応している。
As described above, according to the sixth embodiment, the FIFO
When the child threads 7 and 8 request reading of the sample data stored at a predetermined address while storing the sample data received by the queue 11 in the ring buffer 13, the address at which the sample data is currently stored Since it is possible to read only the contents of the troublesome address, that is, when the address related to the read request matches the address currently storing the sample data, the read request is rejected. The parallel processing of data reading and writing is possible while preventing the contradiction of the data content caused by reading and writing the same data at the same time, and as a result, there is an effect that the processing can be performed at high speed. The sixth embodiment corresponds to the invention of claim 7.

【0085】実施例7.上記実施例1〜6では、周期起
動型スレッドの処理の終了については特に言及しなかっ
たが、周期起動型スレッドが起動後所定時刻経過しても
処理を終了しない場合には、その処理を中断させて獲得
している資源を解放させるようにしてもよい。これによ
り、上記実施例1〜6であれば、ある周期起動型スレッ
ドの処理が複雑である等のため処理時間内に処理が終了
しない場合には、リアルタイム性を要求される他の周期
起動型スレッドの処理の開始が遅れる等の不具合があっ
たが、他の周期起動型スレッドを所定の起動周期毎に確
実に起動できるようになる。
Example 7. In the first to sixth embodiments, the end of the process of the cyclic activation type thread is not particularly referred to, but if the process is not completed even after a predetermined time has elapsed after the activation of the cyclic activation type thread, the process is interrupted. The resources that have been acquired may be released. As a result, according to the first to sixth embodiments, if the processing of a certain cycle-start type thread is complicated and the processing is not completed within the processing time, another cycle-start type thread that requires real-time processing is provided. Although there was a problem such as the delay in the start of processing of the thread, it becomes possible to reliably start another cyclically activated thread at every predetermined activation cycle.

【0086】図15はこの発明の実施例7によるマルチ
スレッド・サーバを示す構成図であり、図において、6
1はマザースレッド18が生成するチャイルドスレッド
6,7,8等のうち、周期的に起動される周期起動型ス
レッド7,12,14の起動及び終了を管理するタイマ
スレッドであり、そのタイマスレッド61は所定の起動
周期毎にその周期起動型スレッド7,12,14を起動
させるとともに、その周期起動型スレッド7,12,1
4が起動後、所定時刻(デッドライン)経過しても処理
を終了しない場合には、その処理を中断させて獲得して
いる資源を解放させる機能を有している。62は各スレ
ッドの情報を格納するスレッド管理テーブル(資源)で
ある(図16参照)。
FIG. 15 is a block diagram showing a multithreaded server according to a seventh embodiment of the present invention. In FIG.
Reference numeral 1 denotes a timer thread that manages the activation and termination of the cyclically activated threads 7, 12, and 14 that are activated cyclically among the child threads 6, 7, and 8 generated by the mother thread 18. Activates the periodic activation type threads 7, 12, 14 at every prescribed activation period, and at the same time, activates the periodic activation type threads 7, 12, 1
4 has a function of interrupting the processing and releasing the acquired resource when the processing is not finished even after a lapse of a predetermined time (deadline) after the activation. Reference numeral 62 is a thread management table (resource) that stores information on each thread (see FIG. 16).

【0087】次に動作について説明する。まず、スレッ
ド管理テーブル62には、図16に示すように、当該ス
レッドが周期起動型スレッドであるか否かを示すUフラ
グ、当該スレッドが周期毎の処理を実行中であるか否か
を示すEフラグ、当該スレッドの起動時刻までの時間を
タイマスレッド61の起動回数(例えば、タイマスレッ
ド61の起動周期が100msであって、スレッドの起
動時刻までの時間が200msであれば、起動回数は2
回となる)で示すUSフィールド(既に起動されている
場合には負の値になる)、当該スレッドの次の起動まで
の時間をタイマスレッド61の起動回数で示すUWフィ
ールド、当該スレッドのデッドラインまでの時間をタイ
マスレッド61の起動回数示すUDフィールド、当該ス
レッドの周期を格納する周期フィールド、当該スレッド
のデッドラインを格納するデッドラインフィールドが記
憶されている。
Next, the operation will be described. First, in the thread management table 62, as shown in FIG. 16, a U flag indicating whether or not the thread is a cyclic activation type thread, and whether or not the thread is executing processing for each cycle. E flag, the time until the activation time of the thread is the number of activations of the timer thread 61 (for example, if the activation cycle of the timer thread 61 is 100ms and the time until the activation time of the thread is 200ms, the number of activations is 2
Field (shown as a negative value if it has already started), a UW field that indicates the time until the next startup of the thread by the number of times the timer thread 61 has started, and a deadline of the thread. A UD field indicating the number of times the timer thread 61 is activated, a period field for storing the period of the thread, and a deadline field for storing the deadline of the thread are stored.

【0088】そして、スレッド管理テーブル62に記憶
されている各スレッドの情報は、マザースレッド18が
管理しており、具体的には、マザータスク18が要求メ
ッセージにしたがってチャイルドスレッドを生成等する
ときに、そのチャイルドスレッドの情報をスレッド管理
テーブル62に登録する。一方、当該スレッドの消滅、
停止要求等を受けるとそのスレッドの登録を抹消する。
The information about each thread stored in the thread management table 62 is managed by the mother thread 18. Specifically, when the mother task 18 creates a child thread according to a request message, etc. , Information of the child thread is registered in the thread management table 62. On the other hand, the disappearance of the thread,
When a stop request etc. is received, the registration of the thread is deleted.

【0089】従って、スレッド管理テーブル62の記憶
内容を解読すれば、どのスレッドが周期起動型のスレッ
ドであるか否か、当該スレッドの起動周期、当該スレッ
ドのデッドライン等の情報を得ることができることにな
るので、タイマスレッド61は、周期起動型スレッドの
起動周期に比べて極めて短い周期毎にスレッド管理テー
ブル62の記憶内容を解読する。
Therefore, by decoding the stored contents of the thread management table 62, it is possible to obtain information such as which thread is a cyclic activation type thread, the activation cycle of the thread, and the deadline of the thread. Therefore, the timer thread 61 deciphers the stored contents of the thread management table 62 in each cycle that is extremely shorter than the activation cycle of the cyclic activation type thread.

【0090】そして、タイマスレッド61は、ある周期
起動型スレッドが起動時刻に到達していれば、その周期
起動型スレッドに対して起動シグナルを通知することに
より、その周期起動型スレッドを起動させる。また、そ
の周期起動型スレッドが起動してから所定時刻経過して
も処理が終了しない場合には、その周期起動型スレッド
にタイムアウトを通知することにより、その周期起動型
スレッドの処理を強制的に中断させるとともに、他の周
期起動型スレッドの処理を妨げないために、その周期起
動型スレッドが獲得している資源を解放させるなどの必
要なタイムアウト処理を実行させる。
Then, when a certain periodic activation type thread reaches the activation time, the timer thread 61 activates the periodic activation type thread by notifying the periodic activation type thread of the activation signal. In addition, if the processing does not end even after a lapse of a predetermined time from the activation of the cyclic startup thread, the processing of the cyclic startup thread is forced by notifying the periodic startup thread of timeout. In addition to suspending, the necessary timeout processing such as releasing the resources acquired by the periodic startup thread is executed so as not to interfere with the processing of other periodic startup threads.

【0091】このように、実施例7によれば、タイマス
レッド61が、周期起動型スレッドが起動後所定時刻経
過しても処理を終了しない場合には、その処理を中断さ
せて獲得している資源を解放させるようにしているの
で、ある周期起動型スレッドの処理が複雑である等のた
め処理時間内に処理が終了しない場合でも、他の周期起
動型スレッドの起動に影響が及ぶことがなく、周期起動
型スレッドのリアルタイム性を確保することができる。
因に、この実施例7は請求項8の発明に対応している。
As described above, according to the seventh embodiment, when the timer thread 61 does not end the processing even after the lapse of a predetermined time after the activation of the cyclic thread, the processing is interrupted and acquired. Since resources are released, even if processing is not completed within the processing time due to the complexity of processing of a certain cyclic startup thread, the startup of other cyclic startup threads will not be affected. It is possible to secure the real-time property of the cyclically activated thread.
The seventh embodiment corresponds to the invention of claim 8.

【0092】実施例8.上記実施例7では、各スレッド
間の共有資源であるスレッド管理テーブル62に対する
読み書きの相互排除について特に言及しなかったが、ス
レッド管理テーブル62は各スレッド間の共有資源であ
るため、複数のスレッドが同一のデータを同時に読み書
きする場合が考えられる。そして、同一データの同時読
み書きがなされた場合には、その影響でデータ内容に矛
盾が生じる場合があるので、読み書きに対して相互排除
の必要性がある。例えば、タイマスレッド61がスレッ
ド管理テーブル62の内容を読み込み中に、周期起動型
スレッド等がスレッド管理テーブル62の内容を書き換
えてしまうと、タイマスレッド61は正しいデータが得
られなくなる場合がある。
Example 8. In the above-described seventh embodiment, mutual exclusion of reading and writing from and to the thread management table 62, which is a shared resource between threads, is not particularly mentioned. However, since the thread management table 62 is a shared resource between threads, a plurality of threads are It is possible to read and write the same data at the same time. When the same data is read and written at the same time, the data content may be inconsistent due to the influence of the simultaneous reading and writing. Therefore, it is necessary to mutually exclude the reading and writing. For example, if the periodically activated thread or the like rewrites the contents of the thread management table 62 while the timer thread 61 is reading the contents of the thread management table 62, the timer thread 61 may not be able to obtain correct data.

【0093】そこで、相互排除の方法として、スレッド
がセマフォを獲得した場合に限りスレッド管理テーブル
62に対して読み書きできるようにする手法が考えられ
るが、単にセマフォの獲得だけを読み書きできる条件と
すると、例えば下記に示すような不具合を生じる場合が
ある。即ち、タイマスレッド61より優先度の低いスレ
ッド7等がセマフォを獲得しているためにそのタイマス
レッド61が待ち状態になっている場合、タイマスレッ
ド61がセマフォを獲得して起動するためには、その優
先度の低いスレッド7等が処理を終了してセマフォを解
放しなければならないが、そのスレッド7等は優先度が
低いために、他のスレッドの処理が終了するのを待つ待
機状態になる場合があり、この場合、スレッド7等は処
理を終了することができないためセマフォを解放するこ
とができず、その結果、タイマスレッド61が起動でき
ないという不具合を生じることがある。因に、タイマス
レッド61は、他のスレッドの起動等を管理するスレッ
ドであるため、マザースレッド18や周期起動型スレッ
ド等よりも優先度が高く設定されている。
Therefore, as a mutual exclusion method, a method is conceivable in which the threads can read and write to the thread management table 62 only when the semaphore is acquired. For example, the following problems may occur. That is, when the timer thread 61 is in a waiting state because the thread 7 having a lower priority than the timer thread 61 has acquired the semaphore, in order for the timer thread 61 to acquire and start the semaphore, The thread 7 or the like having a low priority has to finish the processing and release the semaphore, but the thread 7 or the like has a low priority, and thus waits for the processing of another thread to finish. In this case, in this case, the thread 7 and the like cannot finish the processing, and thus cannot release the semaphore, and as a result, the timer thread 61 cannot start. Incidentally, since the timer thread 61 is a thread for managing the activation of other threads, the timer thread 61 is set to have a higher priority than the mother thread 18, the cyclic activation type thread, and the like.

【0094】この実施例8は、上記のような不具合を解
消しつつスレッド管理テーブル62に対する読み書きの
相互排除を行うものであり、実施例8の構成を下記に示
す。即ち、この実施例8では、図16に示すように、ス
レッド管理テーブル62に対する読み書きの相互排除を
行うためにセマフォ63,64を設けるとともに、タイ
マスレッド61より優先度の低いスレッド7等がそのセ
マフォ63,64を獲得しているためにそのタイマスレ
ッド61が待ち状態になっている場合、一時的にその優
先度の低いスレッド7等の優先度をそのタイマスレッド
61の優先度と同一にする優先度継承機能をセマフォ6
3,64に持たせるようにしたものである。
The eighth embodiment is intended to perform mutual exclusion of reading and writing with respect to the thread management table 62 while solving the above problems, and the configuration of the eighth embodiment is shown below. That is, in the eighth embodiment, as shown in FIG. 16, semaphores 63 and 64 are provided in order to perform mutual exclusion of reading and writing to the thread management table 62, and the thread 7 having a lower priority than the timer thread 61 and the like semaphore. When the timer thread 61 is in a waiting state because it has acquired 63 and 64, priority is given to temporarily set the priority of the thread 7 having a low priority to the priority of the timer thread 61. Semaphore 6 degree inheritance function
It is provided to 3, 64.

【0095】これにより、本来優先度の低いスレッド7
等の優先度が、優先度の高いタイマスレッド61の優先
度と一時的に同一になるため、優先度の関係で他のスレ
ッドの処理の実行に伴ってスレッド7等が待機状態にな
る場合がほとんどなくなり、その結果、スレッド7等の
処理が速やかに行われてセマフォ63,64が解放され
るので、タイマスレッド61は速やかにセマフォ63,
64を獲得できるようになる。従って、周期起動型スレ
ッドのリアルタイム性を確保できるとともに、装置の信
頼性が向上する。
As a result, the thread 7 with the originally low priority is
Since the priority of the thread 7 and the like temporarily becomes the same as the priority of the timer thread 61 having a high priority, the thread 7 and the like may be in a standby state due to the execution of the processing of another thread due to the priority. Almost disappeared, and as a result, the processing of the thread 7 and the like is performed promptly and the semaphores 63 and 64 are released.
You will be able to obtain 64. Therefore, the real-time property of the cyclically activated thread can be secured and the reliability of the device is improved.

【0096】ここで、図17はタイマスレッド61の動
作を示すフローチャートであり、その動作を簡単に説明
すると、タイマスレッド61は、周期起動型スレッドの
起動時刻、周期、デッドラインを表す時間の粒度(最小
単位)を周期として起動される。例えば、起動時刻、周
期、デッドラインがすべて100ms単位で表されるも
のであれば、タイマスレッド61は、100ms周期で
起動する。そして、タイマスレッド61は各周期毎に起
動され、ステップST51でUフラグを読み取るために
セマフォ63を獲得し、ステップST67及びステップ
ST72でEフラグを読み取るためのセマフォ64を獲
得する。また、ステップST53でセマフォ63を解放
し、ステップST69及びステップST74でセマフォ
64を解放する。
Here, FIG. 17 is a flow chart showing the operation of the timer thread 61. The operation will be briefly described. The timer thread 61 has a granularity of the start time, the cycle, and the time indicating the deadline of the cyclic start type thread. It is started with the (minimum unit) as the cycle. For example, if the activation time, the cycle, and the deadline are all expressed in 100 ms units, the timer thread 61 is activated in the 100 ms cycle. Then, the timer thread 61 is activated in each cycle, acquires the semaphore 63 for reading the U flag in step ST51, and acquires the semaphore 64 for reading the E flag in steps ST67 and ST72. Further, the semaphore 63 is released in step ST53, and the semaphore 64 is released in steps ST69 and ST74.

【0097】次に、図18はマザースレッド18がスレ
ッド管理テーブル62に周期起動型スレッドを登録する
動作を示すフローチャートであり、その動作を簡単に説
明すると、ステップST81でセマフォ63を獲得した
のちステップST82でUフラグの読み取りを行い、ス
テップST83でセマフォ63を解放する(以下、ステ
ップST81〜83の間をクリティカルセクションU1
という)。また、ステップST86でセマフォ63を獲
得したのちステップST87でUフラグの書き込み読み
を行い、ステップST88でセマフォ63を解放する
(以下、ステップST86〜88の間をクリティカルセ
クションU2という)。
Next, FIG. 18 is a flow chart showing the operation in which the mother thread 18 registers the cyclically activated thread in the thread management table 62. The operation will be briefly described. After the semaphore 63 is acquired in step ST81, the step is performed. The U flag is read in ST82, and the semaphore 63 is released in step ST83 (hereinafter, the critical section U1 during steps ST81 to 83).
That). Further, after the semaphore 63 is acquired in step ST86, the U flag is written and read in step ST87, and the semaphore 63 is released in step ST88 (hereinafter, steps ST86 to 88 are referred to as critical section U2).

【0098】次に、図19はマザースレッド18がスレ
ッド管理テーブル62から周期起動型スレッドの登録を
削除する動作を示すフローチャートであり、その動作を
簡単に説明すると、ステップST91でセマフォ63を
獲得したのちステップST92でUフラグの書き込みを
行い、ステップST93でセマフォ63を解放する(以
下、ステップST91〜93の間をクリティカルセクシ
ョンU3という)。
Next, FIG. 19 is a flow chart showing the operation for the mother thread 18 to delete the registration of the cyclic activation type thread from the thread management table 62. To briefly explain the operation, the semaphore 63 is acquired in step ST91. After that, the U flag is written in step ST92, and the semaphore 63 is released in step ST93 (hereinafter, steps ST91 to ST93 are referred to as critical section U3).

【0099】次に、図20は各周期起動型スレッドの動
作を示すフローチャートであり、その動作を簡単に説明
すると、ステップST103でセマフォ64を獲得した
のちステップST104でEフラグの書き込みを行い、
ステップST105でセマフォ64を解放する(以下、
ステップST103〜105の間をクリティカルセクシ
ョンE1という)。また、ステップST111でセマフ
ォ64を獲得したのちステップST112でEフラグの
書き込み読みを行い、ステップST113でセマフォ6
4を解放する(以下、ステップST111〜113の間
をクリティカルセクションE2という)。
Next, FIG. 20 is a flow chart showing the operation of each cyclic activation type thread. To briefly explain the operation, the semaphore 64 is acquired in step ST103, and then the E flag is written in step ST104.
In step ST105, the semaphore 64 is released (hereinafter,
A critical section E1 is defined between steps ST103 and ST105). After the semaphore 64 is acquired in step ST111, the E flag is written and read in step ST112, and the semaphore 6 is read in step ST113.
4 is released (hereinafter, steps ST111 to 113 are referred to as critical section E2).

【0100】以上で明らかなように、タイマスレッド6
1が起動時に、優先度の低いスレッド(マザースレッド
18、周期起動型スレッド)によって待たされる時間
は、セマフォ63,64が優先度継承機能を有している
ので、最も待たされる場合でも、クリティカルセクショ
ンU1,U2,U3のうちの何れか1つを実行するのに
要する時間と、クリティカルセクションE1,E2のう
ちの何れか一方の実行に要する時間とを加えた時間に限
られる。また、その加えた時間は、高々フラグ2個の読
み書きに要する時間であって、タイマスレッド61が行
うすべての処理に比べて極めて短い時間であり、無視で
きる程度の時間である。因に、この実施例8は請求項9
の発明に対応している。
As is clear from the above, the timer thread 6
When 1 is started, the semaphores 63 and 64 have a priority inheritance function, so that the critical section is kept waiting by the critical section even if it is the most waited time. It is limited to the time required to execute any one of U1, U2 and U3 and the time required to execute one of the critical sections E1 and E2. The added time is at most the time required for reading and writing the two flags, which is extremely short compared to all the processing performed by the timer thread 61, and is a negligible time. By the way, the eighth embodiment is claimed in claim 9.
It corresponds to the invention of.

【0101】実施例9.上記実施例8では、Uフラグま
たはEフラグの全体にセマフォ63,64を設けたもの
について示したが、図21に示すように、スレッド管理
テーブル62を使用しているか否かを示すSフラグ及び
そのSフラグを読み書きするためのセマフォ65を各ス
レッド毎に設け、そして、タイマスレッド61より優先
度の低いスレッド7等が当該セマフォ65を獲得してい
るためにそのタイマスレッド61が待ち状態になってい
る場合、一時的にその優先度の低いスレッド7等の優先
度をそのタイマスレッド61の優先度と同一にする優先
度継承機能をセマフォ65に持たせるようにしてもよ
く、上記実施例8と同様の効果を奏する。因に、この実
施例9は請求項10の発明に対応している。
Example 9. Although the semaphores 63 and 64 are provided on the entire U flag or E flag in the eighth embodiment, as shown in FIG. 21, an S flag indicating whether or not the thread management table 62 is used and A semaphore 65 for reading and writing the S flag is provided for each thread, and since the thread 7 having a lower priority than the timer thread 61 has acquired the semaphore 65, the timer thread 61 is in a waiting state. In this case, the semaphore 65 may be provided with a priority inheritance function for temporarily setting the priority of the thread 7 having a low priority to the priority of the timer thread 61. Has the same effect as. The ninth embodiment corresponds to the invention of claim 10.

【0102】[0102]

【発明の効果】以上のように、請求項1の発明によれ
ば、第2の受信部により保持された要求メッセージを順
次取り出し、その要求メッセージの内容に応じた処理を
第1の受信部が受信してメモリに格納したサンプルデー
タに基づいて行うように構成したので、要求メッセージ
を受信している途中であっても、サンプルデータを受信
してメモリに格納できるようになり、その結果、サンプ
ル処理をその時間上の制約を保って行うことができる効
果がある。
As described above, according to the first aspect of the present invention, the request messages held by the second receiving section are sequentially taken out, and the first receiving section performs the processing according to the content of the request message. Since it is configured to be performed based on the sample data received and stored in the memory, the sample data can be received and stored in the memory even while the request message is being received. There is an effect that the processing can be performed while keeping the time constraint.

【0103】請求項2の発明によれば、処理実行部の処
理結果を一時的に保持するとともに、複数の処理結果を
保持した場合には優先度の高い処理結果から順次外部装
置に対して送信するように構成したので、高速性の要求
される処理結果から順次送信できるようになり、その結
果、外部装置の要求を十分満足できるようになる効果が
ある。
According to the second aspect of the present invention, the processing results of the processing execution unit are temporarily stored, and when a plurality of processing results are stored, the processing results of higher priority are sequentially transmitted to the external device. With this configuration, the processing results that require high speed can be sequentially transmitted, and as a result, it is possible to sufficiently satisfy the requirements of the external device.

【0104】請求項3の発明によれば、処理実行部の処
理結果を外部装置に対して送信する処理を行う際に、他
の処理と競合する場合、該他の処理より優先度が高いと
きのみ処理を行うように構成したので、処理結果を外部
装置へ送信する処理よりも、高速性の要求される処理が
ある場合には、その高速性の要求される処理を優先して
処理ができるようになる効果がある。
According to the third aspect of the present invention, when the processing result of the processing execution unit is transmitted to the external device, if there is competition with other processing, the priority is higher than the other processing. Since it is configured to perform only processing, if there is processing that requires high speed processing, the processing that requires high processing speed can be given priority over processing that sends processing results to an external device. There is an effect that becomes.

【0105】請求項4の発明によれば、第2の受信部が
複数の要求メッセージを保持している場合、優先度の高
い要求メッセージから順次取り出すように構成したの
で、要求メッセージの欠損を防止できるとともに、高速
性の要求される要求メッセージに対する処理から行うこ
とができる効果がある。
According to the fourth aspect of the invention, when the second receiving unit holds a plurality of request messages, the request messages having higher priority are sequentially taken out, so that loss of the request messages is prevented. In addition to the above, there is an effect that the processing can be performed from the processing for the request message requiring high speed.

【0106】請求項5の発明によれば、各スレッドが処
理を実行する際に必要となるメモリ領域を各スレッド毎
に予め確保しておき、各スレッドに処理を実行させる際
に対応するメモリ領域を割り当てるように構成したの
で、ガベージコレクションを行う必要がなくなり、その
結果、ガベージコレクションを原因とする要求メッセー
ジに対する応答が妨げられるという事態が発生しなくな
る効果がある。
According to the fifth aspect of the present invention, a memory area required when each thread executes a process is secured in advance for each thread, and the memory area corresponding to each thread when executing the process is reserved. Since there is no need to perform a garbage collection, it is possible to prevent a situation in which the response to the request message due to the garbage collection is prevented from occurring.

【0107】請求項6の発明によれば、処理に必要とな
るスレッドを予め生成し、待機状態にしておくように構
成したので、スタック領域の不足を理由に、要求メッセ
ージに対する処理が遅延するのを防止できる効果があ
る。
According to the sixth aspect of the present invention, the threads required for processing are generated in advance and set in the standby state. Therefore, the processing for the request message is delayed due to lack of the stack area. There is an effect that can prevent.

【0108】請求項7の発明によれば、第1の受信部に
より受信されたサンプルデータをメモリに格納中に、処
理実行部から所定のアドレスに格納されているサンプル
データの読み込み要求があった場合、その読み込み要求
に係るアドレスが、現在サンプルデータを格納している
アドレスと一致するときのみその読み込み要求を却下す
るように構成したので、同じデータを同時に読み書きす
ることによって生じるデータ内容の矛盾を防止しつつデ
ータの読み書きの並列処理が可能になり、その結果、高
速に処理を行うことができる効果がある。
According to the invention of claim 7, while the sample data received by the first receiving section is being stored in the memory, the processing execution section makes a request for reading the sample data stored at the predetermined address. In this case, because the read request is rejected only when the address related to the read request matches the address that currently stores the sample data, there is a contradiction in the data content caused by reading and writing the same data at the same time. It is possible to perform parallel processing of reading and writing data while preventing it, and as a result, it is possible to perform high-speed processing.

【0109】請求項8の発明によれば、所定の起動周期
毎に周期起動型スレッドを起動させるとともに、その周
期起動型スレッドが起動後所定時刻経過しても処理を終
了しない場合には、その処理を中断させて獲得している
資源を解放させるタイマスレッドを設けるように構成し
たので、他の周期起動型スレッドを所定の起動周期毎に
確実に起動できるようになり、周期起動型スレッドのリ
アルタイム性を確保できる効果がある。
According to the eighth aspect of the present invention, the cyclically-starting thread is started at every predetermined starting cycle, and if the cyclically-starting thread does not end the processing even after a predetermined time has passed after the starting, Since the timer thread that suspends the processing and releases the acquired resource is provided, it becomes possible to reliably start other periodic activation type threads at every prescribed activation period, and the real time of the periodic activation type thread. There is an effect that can secure the sex.

【0110】請求項9の発明によれば、タイマスレッド
より優先度の低いスレッドがセマフォを獲得しているた
めにそのタイマスレッドが待ち状態になっている場合、
一時的にその優先度の低いスレッドの優先度をそのタイ
マスレッドの優先度と同一にする優先度継承機能をその
セマフォに持たせるように構成したので、同じデータを
同時に読み書きすることによって生じるデータ内容の矛
盾を防止しつつ、タイマスレッドが速やかにセマフォを
獲得できる結果、周期起動型スレッドのリアルタイム性
を確保できるとともに、装置の信頼性が向上する効果が
ある。
According to the ninth aspect of the invention, when the timer thread is waiting because the thread having a lower priority than the timer thread has acquired the semaphore,
Since the semaphore has a priority inheritance function that temporarily sets the priority of the thread with the low priority to the priority of the timer thread, the data content generated by reading and writing the same data at the same time As a result of the timer thread being able to quickly acquire the semaphore while preventing the contradiction, there is an effect that the real-time property of the periodically activated thread can be secured and the reliability of the device is improved.

【0111】請求項10の発明によれば、共有資源を使
用しているか否かを示すフラグ及びそのフラグを読み書
きするためのセマフォを各スレッド毎に設けるととも
に、タイマスレッドより優先度の低いスレッドが当該セ
マフォを獲得しているためにそのタイマスレッドが待ち
状態になっている場合、一時的にその優先度の低いスレ
ッドの優先度をそのタイマスレッドの優先度と同一にす
る優先度継承機能をそのセマフォに持たせるように構成
したので、同じデータを同時に読み書きすることによっ
て生じるデータ内容の矛盾を防止しつつ、タイマスレッ
ドが速やかにセマフォを獲得できる結果、周期起動型ス
レッドのリアルタイム性を確保できるとともに、装置の
信頼性が向上する効果がある。
According to the tenth aspect of the invention, a flag indicating whether or not a shared resource is used and a semaphore for reading and writing the flag are provided for each thread, and a thread having a lower priority than the timer thread is provided. If the timer thread is waiting because the semaphore has been acquired, the priority inheritance function that temporarily sets the priority of the thread with the lower priority to the priority of the timer thread is Since the semaphore is configured to have it, the timer thread can acquire the semaphore promptly while preventing the contradiction of the data content caused by reading and writing the same data at the same time, and as a result, the real-time property of the cyclic startup thread can be secured The effect is to improve the reliability of the device.

【図面の簡単な説明】[Brief description of drawings]

【図1】この発明の実施例1によるマルチスレッド・サ
ーバを示す構成図である。
FIG. 1 is a configuration diagram showing a multithreaded server according to a first embodiment of the present invention.

【図2】実施例2における送信部の詳細を示す構成図で
ある。
FIG. 2 is a configuration diagram illustrating details of a transmission unit according to a second embodiment.

【図3】実施例3における送信部の詳細を示す構成図で
ある。
FIG. 3 is a configuration diagram illustrating details of a transmission unit according to a third embodiment.

【図4】実施例4における第2の受信部の詳細を示す構
成図である。
FIG. 4 is a configuration diagram showing details of a second receiving unit in the fourth embodiment.

【図5】スループット機構の構成を示す構成図である。FIG. 5 is a configuration diagram showing a configuration of a throughput mechanism.

【図6】スレッドプール31内のチャイルドスレッドが
有する起動情報の構成図である。
FIG. 6 is a configuration diagram of activation information of a child thread in the thread pool 31.

【図7】スレッドプール31内のチャイルドスレッドの
動作を示すフローチャートである。
FIG. 7 is a flowchart showing an operation of a child thread in the thread pool 31.

【図8】スレッドプール31内のチャイルドスレッドが
有する起動情報の構成図である。
FIG. 8 is a configuration diagram of activation information of a child thread in the thread pool 31.

【図9】スレッドプール31内のチャイルドスレッドの
動作を示すフローチャートである。
9 is a flowchart showing the operation of a child thread in the thread pool 31. FIG.

【図10】スレッドプール31内のチャイルドスレッド
が有する起動情報の構成図である。
FIG. 10 is a configuration diagram of activation information of a child thread in the thread pool 31.

【図11】スレッドプール31内のチャイルドスレッド
の動作を示すフローチャートである。
FIG. 11 is a flowchart showing an operation of a child thread in the thread pool 31.

【図12】スレッドプール31内のチャイルドスレッド
が有する起動情報の構成図である。
FIG. 12 is a configuration diagram of activation information included in a child thread in the thread pool 31.

【図13】スレッドプール31内のチャイルドスレッド
の動作を示すフローチャートである。
FIG. 13 is a flowchart showing the operation of a child thread in the thread pool 31.

【図14】リングバッファ13及びディスク15に対し
て複数のスレッドが書き込み及び読み出しを行う動作を
説明する構成図である。
FIG. 14 is a configuration diagram illustrating an operation in which a plurality of threads perform writing and reading with respect to the ring buffer 13 and the disk 15.

【図15】この発明の実施例7によるマルチスレッド・
サーバを示す構成図である。
FIG. 15 is a diagram showing a multithread according to a seventh embodiment of the present invention
It is a block diagram which shows a server.

【図16】スレッド管理テーブルの内容を説明する説明
図である。
FIG. 16 is an explanatory diagram illustrating contents of a thread management table.

【図17】タイマスレッドの動作を示すフローチャート
である。
FIG. 17 is a flowchart showing the operation of the timer thread.

【図18】マザースレッドがスレッド管理テーブルに周
期起動型スレッドを登録する動作を示すフローチャート
である。
FIG. 18 is a flowchart showing an operation in which a mother thread registers a cyclically activated thread in a thread management table.

【図19】マザースレッドがスレッド管理テーブルから
周期起動型スレッドの登録を削除する動作を示すフロー
チャートである。
FIG. 19 is a flowchart showing an operation in which the mother thread deletes the registration of the cyclic activation type thread from the thread management table.

【図20】各周期起動型スレッドの動作を示すフローチ
ャートである。
FIG. 20 is a flowchart showing the operation of each cyclic activation type thread.

【図21】スレッド管理テーブルの内容を説明する説明
図である。
FIG. 21 is an explanatory diagram illustrating contents of a thread management table.

【図22】従来のマルチスレッド・サーバを示す構成図
である。
FIG. 22 is a configuration diagram showing a conventional multithreaded server.

【図23】従来の送信部の詳細を示す構成図である。FIG. 23 is a configuration diagram showing details of a conventional transmission unit.

【符号の説明】[Explanation of symbols]

1 プラント 2 クライアント(外部装置) 3 ネットワーク(外部装置) 6、7、8 チャイルドスレッド(処理実行部) 11 FIFOキュー(第1の受信部) 13 リングバッファ(メモリ) 15 ディスク(メモリ) 16 レシーバ(第2の受信部) 17 FIFOキュー(第2の受信部) 18 マザースレッド(処理実行部) 19 FIFOキュー(送信部) 20、21 トランスミッタ(送信部) 21a、21b、21c 送信スレッド(送信部) 32、33、34 メモリ領域 61 タイマスレッド 62 スレッド管理テーブル(資源) 63〜65 セマフォ 1 Plant 2 Client (External Device) 3 Network (External Device) 6, 7, 8 Child Thread (Process Execution Unit) 11 FIFO Queue (First Reception Unit) 13 Ring Buffer (Memory) 15 Disk (Memory) 16 Receiver ( Second receiving unit) 17 FIFO queue (second receiving unit) 18 Mother thread (processing execution unit) 19 FIFO queue (transmitting unit) 20, 21 Transmitter (transmitting unit) 21a, 21b, 21c Transmission thread (transmitting unit) 32, 33, 34 memory area 61 timer thread 62 thread management table (resource) 63 to 65 semaphore

Claims (10)

【特許請求の範囲】[Claims] 【請求項1】 プラント等からサンプルデータを受信す
る第1の受信部と、上記第1の受信部により受信された
サンプルデータを格納するメモリと、外部装置から要求
メッセージを受信するとともに、その要求メッセージを
保持する第2の受信部と、上記第2の受信部により保持
された要求メッセージを順次取り出し、その要求メッセ
ージの内容に応じた処理を上記メモリに格納されたサン
プルデータに基づいて行う処理実行部と、上記処理実行
部の処理結果を一時的に保持したのち、その処理結果を
上記外部装置に対して送信する送信部とを備えたマルチ
スレッド・サーバ。
1. A first receiving unit for receiving sample data from a plant, a memory for storing the sample data received by the first receiving unit, a request message from an external device, and a request thereof. A second receiving unit that holds a message, a process of sequentially taking out the request message held by the second receiving unit, and performing a process according to the content of the request message based on the sample data stored in the memory A multithreaded server comprising: an execution unit; and a transmission unit that temporarily holds the processing result of the processing execution unit and then transmits the processing result to the external device.
【請求項2】 プラント等からサンプルデータを受信す
る第1の受信部と、上記第1の受信部により受信された
サンプルデータを格納するメモリと、外部装置から要求
メッセージを受信するとともに、その要求メッセージを
保持する第2の受信部と、上記第2の受信部により保持
された要求メッセージを順次取り出し、その要求メッセ
ージの内容に応じた処理を上記メモリに格納されたサン
プルデータに基づいて行う処理実行部と、上記処理実行
部の処理結果を一時的に保持するとともに、複数の処理
結果を保持した場合には優先度の高い処理結果から順次
上記外部装置に対して送信する送信部とを備えたマルチ
スレッド・サーバ。
2. A first receiving unit for receiving sample data from a plant, a memory for storing the sample data received by the first receiving unit, a request message from an external device, and a request thereof. A second receiving unit that holds a message, a process of sequentially taking out the request message held by the second receiving unit, and performing a process according to the content of the request message based on the sample data stored in the memory An execution unit and a transmission unit that temporarily holds the processing result of the processing execution unit and sequentially transmits the processing results with higher priority to the external device when a plurality of processing results are held. Multithreaded server.
【請求項3】 上記送信部は、上記処理実行部の処理結
果を上記外部装置に対して送信する処理を行う際に、他
の処理と競合する場合、該他の処理より優先度が高いと
きのみ処理を行うことを特徴とする請求項1または請求
項2記載のマルチスレッド・サーバ。
3. The transmission unit, when performing a process of transmitting the processing result of the process execution unit to the external device, conflicts with another process, and has a higher priority than the other process. The multithreaded server according to claim 1 or 2, wherein only the processing is performed.
【請求項4】 上記処理実行部は、上記第2の受信部が
複数の要求メッセージを保持している場合、優先度の高
い要求メッセージから順次取り出すことを特徴とする請
求項1または請求項2記載のマルチスレッド・サーバ。
4. The processing execution unit, when the second reception unit holds a plurality of request messages, sequentially extracts request messages with a high priority. The described multi-threaded server.
【請求項5】 上記処理実行部は、各スレッドが処理を
実行する際に必要となるメモリ領域を各スレッド毎に予
め確保しておき、各スレッドに処理を実行させる際に対
応するメモリ領域を割り当てることを特徴とする請求項
1または請求項2記載のマルチスレッド・サーバ。
5. The process execution unit secures a memory area required for each thread to execute a process in advance, and allocates a memory area corresponding to each thread to execute the process. 3. The multi-threaded server according to claim 1, wherein the multi-threaded server is assigned.
【請求項6】 上記処理実行部は、処理に必要となるス
レッドを予め生成し、待機状態にしておくことを特徴と
する請求項1または請求項2記載のマルチスレッド・サ
ーバ。
6. The multi-thread server according to claim 1, wherein the processing execution unit generates a thread required for processing in advance and sets it in a standby state.
【請求項7】 上記メモリは、上記第1の受信部により
受信されたサンプルデータを格納中に、上記処理実行部
から所定のアドレスに格納されているサンプルデータの
読み込み要求があった場合、その読み込み要求に係るア
ドレスが、現在サンプルデータを格納しているアドレス
と一致するときのみその読み込み要求を却下することを
特徴とする請求項1または請求項2記載のマルチスレッ
ド・サーバ。
7. The memory, while storing the sample data received by the first receiving unit, receives a read request of the sample data stored at a predetermined address from the processing executing unit, The multi-thread server according to claim 1 or 2, wherein the read request is rejected only when the address relating to the read request matches the address currently storing the sample data.
【請求項8】 上記処理実行部が生成するスレッドの
ち、周期的に起動される周期起動型スレッドの起動及び
終了を管理するタイマスレッドを設け、そのタイマスレ
ッドは所定の起動周期毎にその周期起動型スレッドを起
動させるとともに、その周期起動型スレッドが起動後所
定時刻経過しても処理を終了しない場合には、その処理
を中断させて獲得している資源を解放させることを特徴
とする請求項1または請求項2記載のマルチスレッド・
サーバ。
8. A timer thread for managing activation and termination of a cyclically activated thread, which is periodically activated after the thread generated by the processing execution unit, is provided, and the timer thread is activated periodically at a predetermined activation cycle. A type thread is activated, and when the periodic activation type thread does not terminate the processing even after a predetermined time has elapsed after the activation, the processing is interrupted to release the acquired resource. 1 or the multithread according to claim 2
server.
【請求項9】 上記処理実行部が生成するスレッドと上
記タイマスレッド間の共有資源に対する読み書きの相互
排除を行うためにセマフォを設けるとともに、上記タイ
マスレッドより優先度の低いスレッドがそのセマフォを
獲得しているためにそのタイマスレッドが待ち状態にな
っている場合、一時的にその優先度の低いスレッドの優
先度をそのタイマスレッドの優先度と同一にする優先度
継承機能を上記セマフォに持たせたことを特徴とする請
求項8記載のマルチスレッド・サーバ。
9. A semaphore is provided for mutual exclusion of reading and writing to a shared resource between a thread generated by the processing execution unit and the timer thread, and a thread having a lower priority than the timer thread acquires the semaphore. When the timer thread is in the waiting state because of the above, the semaphore has a priority inheritance function that temporarily sets the priority of the thread with the lower priority to the priority of the timer thread. The multi-threaded server according to claim 8, characterized in that:
【請求項10】 上記処理実行部が生成するスレッドと
上記タイマスレッド間の共有資源に対する読み書きの相
互排除を行うために、当該共有資源を使用しているか否
かを示すフラグ及びそのフラグを読み書きするためのセ
マフォを各スレッド毎に設けるとともに、上記タイマス
レッドより優先度の低いスレッドが当該セマフォを獲得
しているためにそのタイマスレッドが待ち状態になって
いる場合、一時的にその優先度の低いスレッドの優先度
をそのタイマスレッドの優先度と同一にする優先度継承
機能を上記セマフォに持たせたことを特徴とする請求項
8記載のマルチスレッド・サーバ。
10. A flag indicating whether or not the shared resource is used and a flag indicating whether or not the shared resource is used for mutual exclusion of reading and writing of the shared resource between the thread generated by the processing execution unit and the timer thread. A semaphore for each thread is provided, and when the timer thread is waiting because the thread with a lower priority than the timer thread has acquired the semaphore, the priority is temporarily low. 9. The multithreaded server according to claim 8, wherein the semaphore has a priority inheritance function for making the priority of the thread the same as the priority of the timer thread.
JP6034742A 1993-03-05 1994-03-04 Multithreaded server Pending JPH076043A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP6034742A JPH076043A (en) 1993-03-05 1994-03-04 Multithreaded server

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
JP5-69055 1993-03-05
JP6905593 1993-03-05
JP6034742A JPH076043A (en) 1993-03-05 1994-03-04 Multithreaded server

Publications (1)

Publication Number Publication Date
JPH076043A true JPH076043A (en) 1995-01-10

Family

ID=26373590

Family Applications (1)

Application Number Title Priority Date Filing Date
JP6034742A Pending JPH076043A (en) 1993-03-05 1994-03-04 Multithreaded server

Country Status (1)

Country Link
JP (1) JPH076043A (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH09319600A (en) * 1996-03-05 1997-12-12 Internatl Business Mach Corp <Ibm> Method for executing remote procedure call and transaction manager
JPH10320216A (en) * 1997-05-14 1998-12-04 Sony Corp Computer readable recording medium
JP2000155693A (en) * 1998-11-18 2000-06-06 Fujitsu Ltd Message control unit
JP2000511321A (en) * 1997-05-02 2000-08-29 ライブピクチャー,インコーポレイテッド Method and system for improving online interactivity via a server-client network
JP2000284980A (en) * 1999-01-28 2000-10-13 Mitsubishi Electric Inf Technol Center America Inc Multi-task system and message transmission scheduling method in the system
US6261389B1 (en) 1997-04-30 2001-07-17 Nippon Piston Ring Co., Ltd. Synchronizer ring
JP2007058541A (en) * 2005-08-24 2007-03-08 Matsushita Electric Ind Co Ltd Processor, processing method and processing program
JP2008522535A (en) * 2004-12-02 2008-06-26 エレクトロニクス アンド テレコミュニケーションズ リサーチ インスチチュート Mobile Internet system terminal device and uplink data transmission method in terminal device
JP2009151685A (en) * 2007-12-21 2009-07-09 Fujitsu Ltd Disk array device management system, disk array device, disk array device control method, and management server
JP2011181032A (en) * 2010-03-04 2011-09-15 Nec Corp Server device, information processing method, and program
WO2018042644A1 (en) * 2016-09-05 2018-03-08 三菱電機株式会社 Embedded system, embedded system control method, and data consistency determination method
WO2024184941A1 (en) * 2023-03-03 2024-09-12 三菱電機株式会社 Function transmission device, function execution device, function transmission method, function execution method, function transmission program, and function execution program

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63129427A (en) * 1986-11-20 1988-06-01 Toshiba Corp Conversion circuit for interruption response logic
JPH0251740A (en) * 1988-08-15 1990-02-21 Fujitsu Ltd Control system for process allocation
JPH03134732A (en) * 1989-10-17 1991-06-07 Internatl Business Mach Corp <Ibm> Buffer controller
JPH04191934A (en) * 1990-11-26 1992-07-10 Hitachi Ltd Method and device for managing functional program
JPH0520102A (en) * 1991-07-15 1993-01-29 Shikoku Nippon Denki Software Kk Priority changing system for resources acquisition waiting processing
JPH0535506A (en) * 1991-07-25 1993-02-12 Fujitsu Ltd Program day patch processing method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63129427A (en) * 1986-11-20 1988-06-01 Toshiba Corp Conversion circuit for interruption response logic
JPH0251740A (en) * 1988-08-15 1990-02-21 Fujitsu Ltd Control system for process allocation
JPH03134732A (en) * 1989-10-17 1991-06-07 Internatl Business Mach Corp <Ibm> Buffer controller
JPH04191934A (en) * 1990-11-26 1992-07-10 Hitachi Ltd Method and device for managing functional program
JPH0520102A (en) * 1991-07-15 1993-01-29 Shikoku Nippon Denki Software Kk Priority changing system for resources acquisition waiting processing
JPH0535506A (en) * 1991-07-25 1993-02-12 Fujitsu Ltd Program day patch processing method

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH09319600A (en) * 1996-03-05 1997-12-12 Internatl Business Mach Corp <Ibm> Method for executing remote procedure call and transaction manager
US6261389B1 (en) 1997-04-30 2001-07-17 Nippon Piston Ring Co., Ltd. Synchronizer ring
JP2000511321A (en) * 1997-05-02 2000-08-29 ライブピクチャー,インコーポレイテッド Method and system for improving online interactivity via a server-client network
JPH10320216A (en) * 1997-05-14 1998-12-04 Sony Corp Computer readable recording medium
JP2000155693A (en) * 1998-11-18 2000-06-06 Fujitsu Ltd Message control unit
JP2000284980A (en) * 1999-01-28 2000-10-13 Mitsubishi Electric Inf Technol Center America Inc Multi-task system and message transmission scheduling method in the system
JP4763715B2 (en) * 2004-12-02 2011-08-31 エレクトロニクス アンド テレコミュニケーションズ リサーチ インスチチュート Mobile Internet system terminal device and uplink data transmission method in terminal device
JP2008522535A (en) * 2004-12-02 2008-06-26 エレクトロニクス アンド テレコミュニケーションズ リサーチ インスチチュート Mobile Internet system terminal device and uplink data transmission method in terminal device
US7944824B2 (en) 2004-12-02 2011-05-17 Samsung Electronics Co., Ltd. Terminal of portable internet system and method of transmitting uplink data in terminal
JP2007058541A (en) * 2005-08-24 2007-03-08 Matsushita Electric Ind Co Ltd Processor, processing method and processing program
JP2009151685A (en) * 2007-12-21 2009-07-09 Fujitsu Ltd Disk array device management system, disk array device, disk array device control method, and management server
JP2011181032A (en) * 2010-03-04 2011-09-15 Nec Corp Server device, information processing method, and program
WO2018042644A1 (en) * 2016-09-05 2018-03-08 三菱電機株式会社 Embedded system, embedded system control method, and data consistency determination method
JP6351901B1 (en) * 2016-09-05 2018-07-04 三菱電機株式会社 Embedded system and embedded system control method
CN109690490A (en) * 2016-09-05 2019-04-26 三菱电机株式会社 Embedded system, embedded system control method and data matching determination method
WO2024184941A1 (en) * 2023-03-03 2024-09-12 三菱電機株式会社 Function transmission device, function execution device, function transmission method, function execution method, function transmission program, and function execution program

Similar Documents

Publication Publication Date Title
JP4170227B2 (en) Executing processing in a multiprocessing environment
US5390328A (en) Data processing system and method for providing notification in a central processor of state changes for shared data structure on external storage
CA2200929C (en) Periodic process scheduling method
US5274809A (en) Task execution control method for a multiprocessor system with enhanced post/wait procedure
JP3549081B2 (en) Task execution control method with priority and data processing device
US7373640B1 (en) Technique for dynamically restricting thread concurrency without rewriting thread code
US20050015768A1 (en) System and method for providing hardware-assisted task scheduling
EP0532333A2 (en) A system and method for preventing deadlock in a multiprocessor environment
US8914800B2 (en) Behavioral model based multi-threaded architecture
CN103729480B (en) Method for rapidly finding and scheduling multiple ready tasks of multi-kernel real-time operating system
US10331500B2 (en) Managing fairness for lock and unlock operations using operation prioritization
JP3010400B2 (en) Shared memory control method and shared memory control device
TW200406672A (en) Free list and ring data structure management
JPH1055284A (en) Method and system for scheduling a thread
JPH09167145A (en) How to access the message queue
JPH076043A (en) Multithreaded server
US6721948B1 (en) Method for managing shared tasks in a multi-tasking data processing system
KR100617228B1 (en) Implementation method of event delivery system of real-time operating system kernel
US20070033384A1 (en) Real-time embedded simple monitor method and computer product
CN112749020A (en) Microkernel optimization method of Internet of things operating system
EP0343646B1 (en) Task execution control method for a multiprocessor system with enhanced post/wait procedure
JPH07141208A (en) Multitasking processor
JP2000502202A (en) Instruction Processor Job Scheduling
JPH09160790A (en) Task schedule device and task schedule method
JP2021060707A (en) Synchronization control system and synchronization control method