JP3823878B2 - Queue control system, queue control method, and queue control program - Google Patents
Queue control system, queue control method, and queue control program Download PDFInfo
- Publication number
- JP3823878B2 JP3823878B2 JP2002152227A JP2002152227A JP3823878B2 JP 3823878 B2 JP3823878 B2 JP 3823878B2 JP 2002152227 A JP2002152227 A JP 2002152227A JP 2002152227 A JP2002152227 A JP 2002152227A JP 3823878 B2 JP3823878 B2 JP 3823878B2
- Authority
- JP
- Japan
- Prior art keywords
- segment
- queue
- data
- entry
- control information
- 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.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 title claims description 138
- 230000008569 process Effects 0.000 claims description 79
- 238000000605 extraction Methods 0.000 claims description 50
- 230000007717 exclusion Effects 0.000 claims description 46
- 238000012545 processing Methods 0.000 claims description 30
- 230000007850 degeneration Effects 0.000 claims description 24
- 238000013075 data extraction Methods 0.000 claims description 20
- 230000011218 segmentation Effects 0.000 claims description 2
- 230000010365 information processing Effects 0.000 claims 1
- 238000007726 management method Methods 0.000 description 21
- 238000004891 communication Methods 0.000 description 15
- 238000010586 diagram Methods 0.000 description 13
- 230000004044 response Effects 0.000 description 11
- 238000012217 deletion Methods 0.000 description 8
- 230000037430 deletion Effects 0.000 description 8
- 230000000694 effects Effects 0.000 description 8
- 230000006870 function Effects 0.000 description 5
- 230000005540 biological transmission Effects 0.000 description 3
- 230000007423 decrease Effects 0.000 description 3
- 238000012790 confirmation Methods 0.000 description 2
- 238000013479 data entry Methods 0.000 description 2
- 239000000284 extract Substances 0.000 description 2
- 230000005856 abnormality Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
Images
Description
【0001】
【発明の属する技術分野】
本発明は、コンピュータシステムのキュー制御システム、キュー制御方法およびキュー制御用プログラムに関し、特に、プロセス間通信に利用して好適とされるキュー制御システム、キュー制御方法およびキュー制御用プログラムに関する。
【0002】
【従来の技術】
従来より、非同期に発生するデータを、例えばFIFO(先入れ先出し)方式で、順次に登録および取り出すキュー制御システムとしては、キューの先頭エントリおよび各エントリ内の順方向チェインポインタを有する片方向チェインや、インデックスキーを用いたシステム、方法が知られている。キュー管理に関する刊行物として以下のものが参照される。
(a)特開平4−130929号公報
(b)特開平4−259040号公報
(c)特開平11−184716号公報
(d)特開平6−68040号公報
上記刊行物(a)乃至(d)に記載されたシステムについて以下に概説する。
【0003】
特開平4−130929号公報には、同じキー値のイベントをグループ化し、グループ対応にサーチ可能な同一キーポインタを設けることにより、同一キーポインタを用いることによりサーチ処理をスキップして行うスキップサーチ手段と、同一キー値を持つイベントの追加時には、新規にグループを構成し、すでにグループが構成されている場合には、グループへのイベントの追加を行う同一キーポインタ管理手段とを備えたキュー管理方式が開示されている。同一キーポインタは、同一キー値を持ったデータをグループ化し、サーチ処理が可能となるようにデータをチェインするポインタである。
【0004】
このような構成を有するキュー管理方式では、同一キー値のデータが数多く登録されている場合においても、スキップサーチ手段により同一キーポインタを用いることでキー値の異なるデータのサーチをスキップすることができ、サーチ処理を早く行うことができる。また、新たなデータを登録する際には、同一キーポインタ管理手段より、新規グループを構成したり、既存グループへのデータ追加を行うことで、グループを構成する全てのデータのキー値を等しく保つことができる。
【0005】
特開平4−259040号公報には、環状キューのキューイング状態を管理する環状キュー管理手段の管理データを用いて、新たなキューブロックの獲得の必要状態にあるのか否かを判断する判断手段と、判断手段が獲得の必要状態にあると判断するときに、新たなキューブロックを獲得する獲得手段と、獲得手段が新たなキューブロックを環状キューにキューイングする設定手段を備えたキュー管理手段を備え、環状キューのキューブロックの自動増設を実現する。
【0006】
このような構成を有するキュー管理方式では、チェインされたキューのつなぎ換えを行うだけでキュー管理を実行できることから、環状構成を採らないキューに比べてキュー管理のための処理ステップが少なくなり、キュー管理の高速化を図ることができる。また、キューブロックの全てが使用状態になっている場合に、新たなデータを登録すると、獲得手段により、新たなキューブロックが獲得され、設定手段により獲得されたキューブロックが環状キューにキューイングされることで、環状キューのキューブロックの自動増設が実現できる。
【0007】
特開平11−184716号公報には、事象キュー要素のキューイング処理及びキューイングアウト処理を各々別々に実行するマルチタスクを備え、事象キュー要素から構成される事象キューの常に先頭をポイントする先頭ポインタと常に最終をポイントする最終ポインタをキューイング専用及びキューアウト専用の2対備え、事象キュー要素内に、連続的に発生する事象キュー要素を連結するための順方向チェインポインタと逆方向チェインポインタを備えた構成のキュー管理方式が開示されている。すなわち、キューイング処理用タスクと、キューアウト処理用タスクと、確認型タスク間通知手段と、キューバッファと、キューイング専用事象キューの先頭ポインタと、キューイング専用事象キューの最終ポインタと、キューアウト専用事象キューの先頭ポインタと、キューアウト専用事象キューの最終ポインタと、キューイング専用事象キューと、キューアウト専用事象キューと、事象キューを構成する個々の事象キュー要素とから構成されている。また個々の事象キュー要素は、それぞれ順方向チェインポインタと逆方向チェインポインタを持っている。
【0008】
このような構成を有するキュー管理方式では、キューにデータを登録する場合は、キューイング処理用タスクが動作し、キューイング専用先頭ポインタの先にデータを登録し、前後の事象キュー要素内の順方向チェインポインタと逆方向チェインポインタを張り直す。キューからデータを取り出す場合には、キューアウト処理用タスクが動作し、キューアウト専用最終ポインタの先からデータを取り出し、前後の事象キュー要素内の順方向チェインポインタと逆方向チェインポインタを張り直す。このように、キューイング時はキューイング専用の先頭ポインタのポイント先へデータを登録し、キューアウト時はキューアウト専用の最終ポインタのポイント先からデータを取り出すため、キューサーチが不要となり高速なキュー処理が可能となる。
【0009】
また、キューアウト処理用タスクの動作中にデータ登録要求があった場合、キューイング処理用タスクはもう1つ別の事象キューを作成して処理を行い、確認型タスク間通知手段をタイミングにして事象キューの切り替えを行う。このため1つの事象キューに対してキューイング処理およびキューアウト処理が同時に発生せず、マルチタスクでもメモリ排他制御の必要がなくなり効率の良いキュー処理が可能となる。
【0010】
特開平6−68040号公報には、リングバッファ方式の通信キューを使用するキュー制御方式が記載されている。同様に、特開平1−129345号公報(発明の名称:「マルチプロセッサ・システム」)、特開昭60−116064号公報(発明の名称:「分散処理プロセッサー間通信方式」)、および特開昭58−501740号公報(発明の名称:「データ処理システムにおけるホスト、周辺制御プロセッサのような対になったプロセッサのインターフェース機構」)等にも、プロセッサ間通信用キューとしてリングバッファ方式のものを採用して通信制御を行う技術が記載されている。
【0011】
特開平6−68040号公報は、プロセッサ間での送信時、通信用キューのライトポインタの指す場所へ送信データであるリソース番号を書き込み、受信時には、リードポインタの指す場所より受信データであるリソース番号を取り出す構成のプロセッサ間通信用のキュー制御方式が開示されている。通信用キューは受信用リードポインタと、送信用ライトポインタと、通信用リソースとから構成されている。
【0012】
このような構成を有するキュー制御方式では、データの登録時はライトポインタのポイント先へデータを書き込み、ライトポインタを更新する。データの取り出し時はリードポインタのポイント先からデータを取り出し、リードポインタを更新する。このため、チェーン方式に比べ、通信用キューの処理時間を早めることができ、また通信用キューの制御を簡易にすることができる。
【0013】
しかしながら、上記刊行物等に記載されている従来のシステムは、以下のような問題点を有している。
【0014】
第1の問題点として、チェイン方式のキュー管理方式では、データの登録およびデータの取り出し時に前後のキューエントリの順方向チェインポインタあるいは逆方向チェインポインタを設定しなおさねばならず、処理が遅くなるということである。
【0015】
その理由は、各キューエントリをチェインポインタで連結することでキュー管理を行っているためである。
【0016】
第2の問題点は、リングバッファ方式のキュー管理方式では、任意の時点でのキューの拡張ができない、ということである。
【0017】
その理由は、リングバッファ方式では、バッファの末尾と先頭を繋いだ形で管理し、末尾まで行くと先頭に戻るというように無終端方式で連続して使用されるが、バッファの途中に他の領域を挿入することはできないためである。バッファの末尾を拡張することでキューを拡張することはできるが、その方式では任意の時点でのキューの拡張は不可能である。
【0018】
第3の問題点は、プロセス間通信にキューを利用する場合に、データの登録時に空きエントリがない場合や、データの取り出し時に登録されているデータがない場合、それらの待ち合わせ制御を利用者自身が行わなければならず、利用者の負担が大きい、ということである。
【0019】
その理由は、従来のキュー管理方式では、データの登録や取り出しを待ち合わせる機能がないためである。
【0020】
【発明が解決しようとする課題】
したがって、本発明は、上記問題点に鑑みて創案されたものであって、その目的は、キューへのデータ登録およびキューからのデータ取り出しを高速に行うことができるキュー制御システムを提供することにある。
【0021】
本発明の他の目的は、登録されるデータの数が一時的に多くなった場合に自動的にキューを拡張し、データの数が減ったらキューを縮退することで、効率良く資源を利用できるキュー制御システムを提供することにある。
【0022】
本発明のさらに他の目的は、データや空きエントリの待ち合わせを行いプロセス間通信を容易に実現できるキュー制御システムを提供することにある。
【0023】
【課題を解決するための手段】
前記目的の少なくとも1つを達成する本発明の1つのアスペクトに係るキュー制御システムは、キューとして用いるセグメントであって、該セグメント中にキューの制御情報を格納するキュー制御情報部と、データが登録されるエントリよりなるデータ部とを有する複数のセグメントを生成し、前記各セグメントに環状のリンクを設定し、環状にリンクされた複数のセグメントのうちの1つのセグメント(「第1セグメント」という)のキュー制御情報部に初期値を設定するキュー生成手段を備え、前記第1セグメントのキュー制御情報部には、データの登録先のエントリ及び取り出しエントリを指す登録ポインタ及び取り出しポインタが少なくとも保持され、前記第1セグメントのキュー制御情報部の登録ポインタが指すエントリに、データを登録するデータ登録手段と、前記第1セグメントのキュー制御情報部の取り出しポインタが指すエントリからデータを取り出すデータ取り出し手段と、キューの排他制御を行うキュー排他手段と、を備えている。
【0024】
より詳しくは、キューセグメント中にキューの制御情報を格納するキュー制御情報部と、データが登録されるデータ部とを備え、複数のキューセグメントを生成し、各セグメントに環状のリンクを設定し、キュー制御情報部に初期値を設定するキュー初期化手段と、キュー生成手段と、キュー制御情報部の登録ポインタが指すエントリにデータを登録するデータ登録手段と、キュー制御情報部の取り出しポインタが指すエントリからデータを取り出すデータ取り出し手段と、キュー制御情報部の登録ポインタが指すエントリの直前のエントリからデータを取り出すデータ逆取り出し手段と、複数のプロセスから同時に使用できないようにキューを排他するキュー排他手段と、キューを停止状態とし、以降のデータ登録およびデータ取り出しを抑止するキュー停止手段と、キューセグメントを消去するキュー消去手段と、前記キュー停止手段により停止状態となったキューのキュー制御情報部を再初期化し、再度キューを使用できるようにするキュー再初期化手段とを備え、利用者プログラムからの要求により、キューを生成や消去を行い、キューへのデータ登録およびキューからのデータ取り出しを高速に行うよう動作する。
【0025】
また、本発明のキュー制御システムは、データの登録時に空きエントリがない場合、キューとして利用する新たなセグメントを生成しセグメント間のリンクを設定し直すキュー拡張手段と、データの取り出し時に、使用していないセグメントを削除しセグメント間のリンクを設定し直すキュー縮退手段とを備え、登録されるデータの数が一時的に多くなった場合に自動的にキューを拡張し、データの数が減ったらキューを縮退するよう動作する。
【0026】
また、本発明のキュー制御システムは、データの登録時に空きエントリがない場合は、他プロセスによりデータが取り出され空きエントリができるのを待ち合わせ、さらに、データの取り出し時に登録されているデータがない場合は、他プロセスによりデータが登録されるのを待ち合わせる待ち合わせ手段を備え、データ登録時に登録できるエントリがない場合や、データ取り出し時に登録されているデータがない場合に、データの登録やエントリの空きを待ち合わるよう動作する。
【0027】
本発明の別のアスペクトに係るキュー制御方法は、
(a)キューとして用いるセグメントであって、該セグメント中にキューの制御情報を格納するキュー制御情報部と、データが登録されるエントリよりなるデータ部とを有する複数のセグメントを生成し、前記各セグメントに環状のリンクを設定し、環状にリンクされた複数のセグメントのうちの1つのセグメント(「第1セグメント」という)のキュー制御情報部に初期値を設定するステップを有し、前記第1セグメントのキュー制御情報部には、データの登録先のエントリ及び取り出しエントリを指す登録ポインタ及び取り出しポインタが少なくとも保持され、
(b)前記第1セグメントのキュー制御情報部の登録ポインタの示すエントリへデータを登録するステップと、
(c)前記第1セグメントのキュー制御情報部の取り出しポインタの示すエントリからデータを取り出すステップと、
(d)キューを排他制御するステップと、を含む。
【0028】
本発明の他のアスペクトに係るプログラムは、キューの管理をコンピュータで行わせるプログラムであって、キューとして用いるセグメントであって、該セグメント中にキューの制御情報を格納するキュー制御情報部と、データが登録されるエントリよりなるデータ部とを有する複数のセグメントを生成し、前記各セグメントに環状のリンクを設定し、環状にリンクされた複数のセグメントのうちの1つのセグメント(「第1セグメント」という)のキュー制御情報部に初期値を設定する処理を有し、前記第1セグメントのキュー制御情報部には、データの登録先のエントリ及び取り出しエントリを指す登録ポインタ及び取り出しポインタが少なくとも保持され、前記第1セグメントのキュー制御情報部の登録ポインタが指すエントリにデータを登録する処理と、前記第1セグメントのキュー制御情報部の取り出しポインタが指すエントリからデータを取り出す処理と、キューを排他制御する処理と、を前記コンピュータに実行させるためのプログラムよりなる。
【0029】
【発明の実施の形態】
次に、本発明の実施の形態について図面を参照して詳細に説明する。図1は、本発明の一実施の形態の構成を示す図である。図1を参照すると、本発明の第1の実施の形態に係るシステムは、プログラム制御により動作する計算機システム100と、キュー制御システム110と、キューセグメント130と、利用者プログラム140と、を備えて構成されている。
【0030】
キュー制御システム110は、キュー生成手段111と、キュー停止手段112と、キュー消去手段113と、キュー再初期化手段114と、データ登録手段115と、データ取り出し手段116と、データ逆取り出し手段117と、キュー排他手段118とを含む。
【0031】
キューセグメント130は、キュー制御情報部131と、キューデータ部132とを含む。
【0032】
これらの手段はそれぞれ概略つぎのように動作する。
【0033】
キュー生成手段111は、複数のキューセグメントを生成し各セグメントに環状のリンクを設定する。
【0034】
また、キュー生成手段111は、生成したキューセグメントにキュー制御情報部を設け、初期値を設定する。
【0035】
キュー停止手段112は、キューを停止状態とし、以降のデータの登録および取り出しを禁止する。
【0036】
キュー消去手段113は、キュー停止手段112により停止状態となったキューの各キューセグメントを消去する。
【0037】
キュー再初期化手段114は、キュー停止手段112によって停止状態となったキューのキュー制御情報部131を再初期化する。その後、キュー再初期化手段114は、該キューを使用中状態とし、再度キューを使用できるようにする。
【0038】
データ登録手段115は、利用者プログラム140からの要求により、キュー制御情報部131の登録ポインタが示すエントリに、利用者プログラム140より渡されたデータを登録する。
【0039】
データ取り出し手段116は、利用者プログラム140からの要求により、キュー制御情報部131の取り出しポインタが示すエントリからデータを取り出し利用者プログラム140に返却する。
【0040】
データ逆取り出し手段117は、利用者プログラム140からの要求により、キュー制御情報部131の登録ポインタが示すエントリの1つ前のエントリからデータを取り出し利用者プログラム140に返却する。
【0041】
キュー排他手段118は、キュー制御システム110の各手段111〜117から使用され、キューセグメントが他のプロセスから参照・更新されないように、排他制御を行う。
【0042】
キュー制御システム110におけるキュー生成手段111、キュー停止手段112、キュー消去手段113、キュー再初期化手段114、データ登録手段115、データ取り出し手段116、データ逆取り出し手段117、キュー排他手段118は、コンピュータ上で実行されるプログラムによりそれぞれの機能・処理が実現される。
【0043】
次に、図1、図2、図3、および図4乃至図11のフローチャートを参照して本実施の形態の全体の動作について詳細に説明する。図2は、本発明の第1の実施の形態におけるキューセグメントを模式的に示す図である。図3は、キュー制御情報部の一例を示す図である。図4は、本発明の第1の実施の形態におけるキュー生成手段11の動作の一例を説明するための流れ図である。
【0044】
まず、利用者プログラム140はキューを使用するために、キュー生成手段111を用いて、キューセグメント130を生成する。
【0045】
利用者プログラム140は、キュー生成手段111には、セグメント数やデータ長などの情報を伝える。
【0046】
キュー生成手段111は、まず利用者プログラム140から伝えられた初期セグメント数を取得する(図4のステップS11)。
【0047】
次に、キュー生成手段111は、初期セグメント数分のセグメントを生成し(ステップS12)、生成した各セグメント間に環状のリンクを設定する(ステップS13)。
【0048】
キューセグメントは、図2のように、セグメント毎に、環状にリンクされた構造となる。
【0049】
続いて、キュー生成手段111は、第1のセグメントのキュー制御情報部131に初期値を設定し(ステップS14)、排他用セマフォや通知用セマフォといったセマフォを取得して、キュー制御情報部131に格納する(ステップS15)。
【0050】
最後に、キュー生成手段111は、図示されない、状態フラグを、”使用中”状態に設定し(ステップS16)、第1セグメントのアドレスを、利用者プログラム140に返却する(ステップS17)。なお、状態フラグは、図1のキュー制御システムを構成するコンピュータにおいて、書き換え可能なメモリ、レジスタ等、任意の記憶装置に設定され、キューの状態(例えば使用、停止等の状態)が設定される。
【0051】
以降、利用者プログラム140がキューを操作する際には、返却された第1セグメントのアドレスをキュー制御システム110に伝える。すなわち、第1セグメントのアドレスをキーとして用いる。
【0052】
また、図3に示すように、キュー制御情報部131に情報が格納されるのは、第1セグメントのみであり、第2セグメント以降では、次セグメントのアドレスのみを保持している。すなわち図3に示すように、セグメント1は、登録ポインタ、取り出しポインタ、データ長、データ数、次セグメント、使用セグメント数、初期セグメント数、最大セグメント数、排他セマフォ、通知セマフォ、待ち合わせ数の各欄よりなり、セグメント1の次セグメントの欄にはセグメント2、セグメント2の次セグメントの欄にはセグメント3、セグメント3の次セグメントの欄にはセグメント1が初期設定されておいる。セグメント2、3のキュー制御情報部には、次セグメントの欄のみが設定されている。
【0053】
図5は、本発明の第1の実施の形態におけるキュー停止手段112の動作の一例を説明するための流れ図である。利用者プログラム140が、キューの使用を終了する場合は、キュー停止手段112を使用して、キュー停止状態にし、その後、キュー消去手段113を使用してキューセグメント130を消去する。また、キューの停止後に、キュー再初期化手段114を使用することで、再度キューを使用することもできる。
【0054】
キュー停止手段112は、まず、キュー排他手段118を使用して、他のプロセスから同時に使用されないように、キューを排他する(図5のステップS21)。
【0055】
次に、キュー停止手段112は、キューの状態を示す状態フラグをチェックし、状態が”使用中”である場合には(ステップS22でYES)、状態フラグを、”停止”状態に設定する。
【0056】
最後に、キュー停止手段112は、キュー排他手段118を使用してキューの排他を解除する(ステップS24)。
【0057】
また、状態フラグが”使用中”でない場合(ステップS22でNO)は、停止できない状態であるため、停止失敗となる(ステップS25)。
【0058】
図6は、本発明の第1の実施の形態におけるキュー消去手段113の動作の一例を説明するための流れ図である。キュー消去手段113は、まず、キュー排他手段118を使用して、キューを排他する(図6のステップS31)。
【0059】
次に、キュー消去手段113は、状態フラグをチェックし、状態が”停止”状態である場合には(ステップS32でYES)、使用しているキューセグメントを全て消去する(ステップS33)。
【0060】
次に、キュー消去手段113は、キュー排他手段118を使用してキューの排他を解除し(ステップS34)、セマフォを解放し(ステップS35)、終了する。
【0061】
状態フラグが”停止”状態でない場合(ステップS32でNO)、消去できない状態であるため消去失敗となり(ステップS36)、キュー排他手段118により、キューの排他を解除して(ステップS37)、終了する。
【0062】
図7は、本発明の第1の実施の形態におけるキュー再初期化手段114の動作の一例を説明するための流れ図である。キュー再初期化手段114は、まず、キュー排他手段118を使用してキューを排他する(図7のステップS41)。
【0063】
次に、キュー再初期化手段114は、状態フラグをチェックし、状態が”停止”状態である場合には(ステップS42でYES)、第1セグメントのキュー制御情報部131に、初期値を設定する(ステップS43)。キュー再初期化手段114が、第1セグメントのキュー制御情報部131において、初期値に設定する領域は、キューの使用により、値が更新される領域のみである。
【0064】
続いて、キュー再初期化手段114は、状態フラグを、”使用中”状態に設定する(ステップS44)。
【0065】
最後に、キュー再初期化手段114は、キュー排他手段118によりキューの排他を解除して(ステップS45)終了する。
【0066】
また、状態フラグのチェックにおいて、状態フラグが”停止”状態でない場合(ステップS42でNO)、キュー再初期化手段114による再初期化ができない状態であるため、再初期化失敗となる(ステップS46)。
【0067】
利用者プログラム140が、キューにデータを登録する場合、データ登録手段115を使用する。また、利用者プログラム140が、キューからデータを取り出す場合は、データ取り出し手段116、あるいはデータ逆取り出し手段117を使用する。ここで、利用者プログラム140が、LILO(Last In Last Out)方式でデータを取り出す場合には、データ取り出し手段116を使用し、LIFO(Last In First Out)方式でデータを取り出す場合はデータ逆取り出し手段117を使用する。
【0068】
図8は、本発明の第1の実施の形態におけるデータ登録手段115の動作の一例を説明するための流れ図である。データ登録手段115は、まず、キュー排他手段118を使用してキューを排他する(図8のステップS51)。
【0069】
次に、データ登録手段115は、状態フラグをチェックし、状態が”使用中”状態である場合(ステップS52でYES)、続いてエントリのチェックを行う。キュー制御情報部131の登録ポインタの指すエントリ(「登録エントリ」という)がセグメント内の最終エントリではない場合(ステップS53でNO)、次登録ポインタに登録エントリの次のエントリを設定する(ステップS54)。登録エントリの次のエントリは、登録ポインタのセグメント内オフセットにキュー制御情報部131のデータ長の値を加算することで容易に求められる。
【0070】
また、データ登録手段115は、登録エントリがセグメント内の最終エントリである場合(ステップS53でYES)、次登録ポインタに次セグメントの先頭エントリを設定する(ステップS55)。尚、次登録ポインタは、データ登録手段115のみで使用する作業用の領域である。
【0071】
次に、次登録ポインタが指すエントリがキュー制御情報部131の取り出しポインタの指すエントリと同じではない場合には(ステップS56でNO)、データ登録手段115は、データの登録が可能であると判断し、利用者プログラム140から伝えられたデータを登録エントリへ移送する(ステップS57)。
【0072】
続いて、データ登録手段115は、次登録ポインタの指すエントリを指すようにキュー制御情報部131の登録ポインタを更新し(ステップS58)、キュー制御情報部131のデータ数に1を加算する(ステップS59)。
【0073】
最後に、データ登録手段115は、キュー排他手段118を使用してキューの排他を解除し(ステップS60)、終了する。
【0074】
また、次登録ポインタの指すエントリがキュー制御情報部131の取り出しポインタの指すエントリと同じである場合(ステップS56でYES)、登録ポインタが取り出しポインタに追いつくということであり、次に登録できるエントリがない状態である。この場合、空きエントリがないため、データ登録失敗とする(ステップS61)。
【0075】
また、状態フラグのチェックにおいて、状態フラグが”使用中”状態でない場合(ステップS52でNO)、データの登録ができない状態であるため登録失敗となる(ステップS62)。
【0076】
図9は、本発明の第1の実施の形態におけるデータ取り出し手段116の動作の一例を説明するための流れ図である。データ取り出し手段116は、まず、キュー排他手段118を使用してキューを排他する(図9のステップS71)。
【0077】
次に、データ取り出し手段116は、状態フラグをチェックし、状態が”使用中”状態であるならば(ステップS72でYES)、次に登録されているデータの数をチェックする。キュー制御情報部131のデータ数が0より大きい場合(ステップS73でYES)、データが存在するということであり、キュー制御情報部131の取り出しポインタの指すエントリ(「取り出しエントリ」)から、利用者プログラム140から伝えられたデータ返却領域へデータを移送する(ステップS74)。
【0078】
次に、データ取り出し手段116は、キュー制御情報部131のデータ数から1を減算する(ステップS75)。
【0079】
続いて、取り出しエントリがセグメント内の最終エントリではない場合(ステップS76でNO)、データ取り出し手段116は、取り出しエントリの次のエントリを指すようにキュー制御情報部131のデータ取り出しポインタを更新する(ステップS77)。
【0080】
また、取り出しエントリがセグメント内の最終エントリである場合(ステップS76でYES)、データ取り出し手段116は、次セグメントの先頭エントリを指すようにデータ取り出しポインタを更新する(ステップS78)。
【0081】
最後に、データ取り出し手段116は、キュー排他手段118を使用してキューの排他を解除し(ステップS79)、終了する。
【0082】
また、データ数が0である場合は(ステップS73でNO)、登録されているデータがないため、データ取り出し失敗となる(ステップS80)。
【0083】
また、状態フラグのチェックにおいて、状態フラグが”使用中”状態でない場合(ステップS72でNO)、データの取り出しができない状態であるため、取り出し失敗となる(ステップS81)。
【0084】
図10は、本発明の第1の実施の形態におけるデータ逆取り出し手段117の動作の一例を説明するための流れ図である。データ逆取り出し手段117は、まず、キュー排他手段118を使用してキューを排他する(図10のステップS91)。
【0085】
次に、データ逆取り出し手段117は、状態フラグをチェックし、状態が”使用中”状態であるならば(ステップS92でYES)、次に登録されているデータの数をチェックする。
【0086】
キュー制御情報部131のデータ数が0より大きい場合(ステップS93でYES)、キューセグメント中に登録データが存在するということである。
【0087】
キュー制御情報部131の登録ポインタの指すエントリ(登録エントリ)がセグメント内の先頭エントリではない場合(ステップS94でNO)、データ逆取り出し手段117は、登録エントリの1つ前のエントリを指すように登録ポインタを更新する(ステップS95)。
【0088】
登録エントリの1つ前のエントリは、登録ポインタのセグメント内オフセットから、キュー制御情報部131のデータ長の値を減算することで容易に求めることができる。
【0089】
また、登録エントリがセグメント内の先頭エントリである場合には(ステップS94でYES)、データ逆取り出し手段117は、登録ポインタが指すセグメントの1つ前のセグメントを求め(ステップS96)、そのセグメントの最終エントリを指すように登録ポインタを更新する(ステップS97)。
【0090】
ここで、セグメントのキュー制御情報部131には、前セグメントへのリンクは存在しないが、キューを構成する各セグメントは環状にリンクされているため、データ逆取り出し手段117は、次セグメントへのリンクを辿ることで、1つ前のセグメントに到達することができる。
【0091】
続いて、データ逆取り出し手段117は、更新した登録ポインタの指すエントリから、利用者プログラム140から伝えられたデータ返却領域へデータを移送する(ステップS98)。
【0092】
次に、データ逆取り出し手段117は、キュー制御情報部131のデータ数から「1」を減算する(ステップS99)。
【0093】
最後に、データ逆取り出し手段117は、キュー排他手段118を使用してキューの排他を解除し(ステップS100)、終了する。
【0094】
また、データ数が「0」である場合は(ステップS93でNO)、登録されているデータがないため、データ取り出し失敗となる(ステップS101)。
【0095】
また、状態フラグのチェックにおいて、状態フラグが”使用中”状態でない場合(ステップS92でNO)、データの登録ができない状態であるため、登録失敗となる(ステップS102)。
【0096】
次に、本実施の形態の作用効果について説明する。
【0097】
本実施の形態では、データ登録時には、登録ポインタの指すエントリにデータを移送し、登録ポインタを次のエントリを指すように更新し、データの取り出し時には、取り出しポインタの指すエントリからデータを取り出し、取り出しポインタを次のエントリを指すように更新する、というように構成されているため、データ登録とデータ取り出し時における、キューの検索や順方向チェインの張り替えが不要となり、高速にデータの登録および取り出しを行うことができる。
【0098】
また、本実施の形態では、さらに、データの取り出し手段として、順方向に取り出す手段と、逆方向に取り出す手段の2つ有しているため、FIFO方式、およびLIFO方式の混在が可能となっている。これにより、通常は、FIFO方式を用いて一度登録したデータを取り消す場合に、LIFO方式を用いることもできる。
【0099】
また、本実施の形態では、さらに、利用者プログラムからの要求により、キューを生成し、第1セグメントのアドレスをキーとして、以降のキュー操作を行うよう構成されているため、1つの利用者プログラムから、複数のキューを利用することができる。
【0100】
また、本実施の形態では、さらに、使用を終了したキューの消去や、再利用が可能となる構成されているため、メモリ資源を効率良く利用することができる。
【0101】
【実施例】
次に、具体的な実施例を用いて本実施の形態の動作を説明する。
【0102】
利用者プログラム140がキューを使用を開始するとき、キュー生成手段111に対し、データ長48バイト、初期セグメント数3、最大セグメント数10としてキューの生成を要求する。
【0103】
キュー生成手段111では、初期セグメント数の「3」を取得し(図4のステップS11)、3枚のセグメントを生成する(ステップS12)。
【0104】
続いて生成したセグメント間に環状のリンクをリンクを設定する(ステップS13)。
【0105】
セグメントは、図2のように”次セグメント”領域によって環状に連結される。続いて、第1セグメント(図2のセグメント1)のキュー制御情報部131に初期値を設定する(ステップS14)。
【0106】
キュー制御情報部131は、図3に示す内容で構成されており、登録ポインタおよび取り出しポインタの初期値は、セグメント1の先頭エントリを指すように設定する。
【0107】
データ長には、利用者プログラム140から伝えられた”48バイト”を設定し、データ数には”0”を設定する。
【0108】
また、次セグメント領域は、先ほど環状リンクを設定しているので、ここでは設定しない。
【0109】
また、初期セグメント数および最大セグメント数には、利用者プログラムから伝えられた値である”3”および”10”そのまま設定し、使用セグメント数には現在の使用セグメント数、すなわち初期セグメント数の”3”を設定する。
【0110】
排他セマフォ、通知セマフォにはヌル(null)値を設定し、待ち合わせプロセス数は”0”を設定する。
【0111】
次に、キュー生成手段111は、排他セマフォおよび通知セマフォを取得し、キュー制御情報部131に格納する(ステップS15)。
【0112】
続いて、キュー生成手段111は、状態フラグを”使用中”と設定し、セグメント1のアドレスAを利用者プログラム140に返却する。
【0113】
これで、キューの生成が完了し、以降、利用者プログラム140は、返却された第1セグメントのアドレスAを用いて、このキューの操作を行うことができる。
【0114】
次に、データを登録する場合の動作を説明する。
【0115】
図2および図3に示すような、登録ポインタが”セグメント1のエントリ4”を、取り出しポインタが”セグメント2のエントリ6”を指しており、登録されているデータ数が”9”である場合に、新たなデータの登録を要求すると、データ登録手段115は、まずキューを排他し(図8のステップS51)、状態フラグをチェックすると、状態は”使用中”である(ステップS52でYES)。
【0116】
ここで、図2に示すように、セグメント1にはエントリ1〜エントリ6があり、登録エントリは、エントリ4であるため、セグメント1内の最終エントリではない(ステップS53でNO)。よって、作業領域の次登録ポインタに、”セグメント1のエントリ5”を設定する(ステップS54)。
【0117】
また、取り出しポインタは,”セグメント2のエントリ5”であるため、次登録ポインタとは異なる(ステップS56でNO)。
【0118】
そこで、データ登録手段115は、”セグメント1のエントリ4”に、登録データを移送し(ステップS57)、登録ポインタに、”セグメント1のエントリ5”を設定し(ステップS58)、データ数に”1”を加算して”10”とする(ステップS59)。
【0119】
最後に、データ登録手段115は、キューの排他を解除する(ステップS60)。これで、新たなデータの登録が完了する。
【0120】
次に、データを取り出す場合の動作を説明する。
【0121】
図2および図3に示すような、登録ポインタが”セグメント1のエントリ4”を、取り出しポインタが”セグメント2のエントリ6”を指しており、登録されているデータ数が”9”である場合に、FIFO方式でのデータの取り出しを要求すると、データ取り出し手段116は、まずキューを排他し(図9のステップS71)、状態フラグをチェックすると、状態は”使用中”である(ステップS72でYES)。また、データ数は”9”であるため(ステップS73でYES)、セグメント2のエントリ6からデータ返却領域へデータを移送し(ステップS74)、データ数から”1”を減算して”8”とする(ステップS75)。
【0122】
ここで、図2に示すように、セグメント2にはエントリ1〜エントリ6があり、取り出しエントリは、エントリ6であるため、セグメント2内の最終エントリである(ステップS76でYES)。そこで、キュー制御情報部の取り出しポインタに”セグメント3のエントリ1”を設定する(ステップS78)。
【0123】
最後に、データ取り出し手段116は、キューの排他を解除する(ステップS79)。これで、FIFO方式でデータを取り出すことができた。
【0124】
同様に、図2および図3に示すような、登録ポインタが”セグメント1のエントリ4”を、取り出しポインタが”セグメント2のエントリ6”を指しており、登録されているデータ数が”9”である場合に、LIFO方式でのデータの取り出しを要求すると、データ逆取り出し手段117は、まずキューを排他し(図10のステップS91)、状態フラグをチェックすると、状態は”使用中”である(ステップS92でYES)。また、データ数は”9”である(ステップS93でYES)。ここで、図2のように、セグメント1にはエントリ1〜エントリ6があり、登録エントリはエントリ4であるため、セグメント1内の先頭エントリはない(ステップS94でNO)。
【0125】
そこで、データ逆取り出し手段117は、登録エントリの1つ前のエントリである”セグメント1のエントリ3”(最後に登録されたエントリ)を、登録ポインタに設定し(ステップS95)、”セグメント1のエントリ3”から、データ返却領域へデータを移送し(ステップS98)、データ数から「1」を減算して”8”とする(ステップS99)。
【0126】
最後に、データ逆取り出し手段117は、キューの排他を解除する(ステップS100)。これで、LIFO方式でデータを取り出すことができた。
【0127】
次に、本発明の第2の実施の形態について、図面を参照して詳細に説明する。図11は、本発明の第2の実施の形態の構成を示す図である。この実施の形態は、図1に示した前記実施の形態の構成に、キュー拡張手段219と、キュー縮退手段220を追加したものである。
【0128】
図11を参照すると、本発明の第2の実施の形態は、プログラム制御により動作する計算機システム200と、キュー制御システム210と、キューセグメント230と、利用者プログラム240と、を備えて構成されている。
【0129】
キュー制御システム210は、キュー生成手段211と、キュー停止手段212と、キュー消去手段213と、キュー再初期化手段214と、データ登録手段215と、データ取り出し手段216と、データ逆取り出し手段217と、キュー排他手段218と、キュー拡張手段219と、キュー縮退手段220とを含む。
【0130】
キューセグメント230は、キュー制御情報部231と、キューデータ部232とを含む。
【0131】
これらの手段はそれぞれ概略つぎのように動作する。ここでは、第1の実施の形態と動作が異なる動作について説明する。
【0132】
キュー再初期化手段214は、キュー停止手段212により停止状態となったキューのキュー制御情報部を再初期化し、また、キューセグメントの数を初期セグメント数になるようにセグメントを消去し環状リンクを再設定する。その後、キュー再初期化手段214はキューを使用中状態とし、再度キューを使用できるようにする。
【0133】
データ登録手段215は、利用者プログラム240からの要求により、キュー制御情報部231の登録ポインタが示すエントリに利用者プログラム240より渡されたデータを登録する。また、データ登録手段215は、データの登録時にセグメントが不足する場合は、キュー拡張手段219を使用して新たなセグメントを生成しキューを拡張する。
【0134】
データ取り出し手段216は、利用者プログラム240からの要求により、キュー制御情報部231の取り出しポインタが示すエントリからデータを取り出し利用者プログラムに返却する。また、データ取り出し手段216は、キュー縮退手段220を使用してデータが登録されていないセグメントを消去する。
【0135】
データ逆取り出し手段217は、利用者プログラム240からの要求により、キュー制御情報部131の登録ポインタが示すエントリの1つ前のエントリからデータを取り出し、利用者プログラム240に返却する。また、データ逆取り出し手段217は、キュー縮退手段220を使用して、データが登録されていないセグメントを消去する。
【0136】
キュー拡張手段219は、新たにセグメントを1枚生成し、前セグメントの”次セグメント”に生成したセグメントを設定し、生成したセグメントの”次セグメント”には、元々、前セグメントに設定されていたセグメントを設定することで、キューセグメントを追加し、キューを拡張する。
【0137】
キュー縮退手段220は、セグメントを1枚消去し、消去したセグメントの”次セグメント”に設定されていたセグメントを、前セグメントの”次セグメント”に設定することで、キューセグメントを減らし、キューを縮退させる。
【0138】
キュー制御システム210におけるキュー生成手段211、キュー停止手段212、キュー消去手段213、キュー再初期化手段214、データ登録手段215、データ取り出し手段216、データ逆取り出し手段217、キュー排他手段218、キュー拡張手段219、キュー縮退手段220は、コンピュータ上で実行されるプログラムによりそれぞれの機能・処理が実現される。
【0139】
次に、図11および図14〜図19のフローチャートを参照して本実施の形態の全体の動作について詳細に説明する。ここでは、第1の実施の形態と動作が異なる手段について説明する。
【0140】
図14は、本発明の第2の実施の形態におけるキュー再初期化手段214の動作の一例を説明するための流れ図である。キュー再初期化手段214にて、キューを再初期化する場合において、キュー制御情報部231の使用セグメント数と初期セグメント数を比較し、使用セグメント数>初期セグメント数である場合(図14のステップS113でYES)は、キューが拡張されているということであり、初期状態に戻す処理を実行する。
【0141】
まず、キュー再初期化手段214は、拡張したセグメント数、すなわち(使用セグメント数-初期セグメント数)分のセグメントを、第2セグメント以降から削除する(ステップS114)。
【0142】
次に、キュー再初期化手段214は、残ったセグメント間の環状リンクを再設定する(ステップS115)。こうして、キューセグメントの状態が、初期状態となる。
【0143】
また、使用セグメント数≦初期セグメント数である場合(ステップS113でNO)は、キューは拡張されていないため、初期状態に戻す処理(ステップS114,S115)は不要である。
【0144】
図15は、本発明の第2の実施の形態におけるデータ登録手段215の動作の一例を説明するための流れ図である。
【0145】
利用者プログラム240がキューにデータを登録する場合において、データ登録手段215では、キュー制御情報部231の登録ポインタの指すエントリ(「登録エントリ」という)がセグメント内の最終エントリである場合(図15のステップS123でYES)、登録ポインタの指すセグメント(以降、登録セグメント)の次セグメントが、取り出しポインタが指しているセグメントであり(ステップS125でYES)、使用セグメントが増加しても最大セグメント数を超えない場合、すなわち”使用セグメント数+1≦最大セグメント数”である場合(ステップS126でYES)は、キュー拡張手段219に登録セグメントを指定してキューを拡張する(ステップS127)。
【0146】
キュー拡張手段219は、新しいセグメントを1枚生成し(図18のステップS181)、指定されたセグメント、ここでは登録セグメントの次セグメントが生成したセグメントとなるように、環状リンクを再設定し(ステップS182)、使用セグメント数に1を加算する(ステップS183)。
【0147】
これで、データ登録手段215において、登録セグメントの次セグメントとして新しいキューセグメントが追加された。
【0148】
続いて、”次登録ポインタ”に次セグメント、すなわち追加したセグメントの先頭エントリを設定し(ステップS128)、以降の処理を行う。
【0149】
尚、登録セグメントの次セグメントが取り出しポインタが指しているセグメントはない場合(ステップS125でNO)、データが1つも登録されいないセグメントが1枚以上あるということであり、その時点での拡張の必要はないため新たなセグメントは生成しない。
【0150】
また、”使用セグメント数+1>最大セグメント数”
となる場合(ステップS126でNO)、生成時に指定された最大セグメント数を超えてしまうため新たなセグメントは生成しない。
【0151】
図16は、本発明の第2の実施の形態におけるデータ取り出し手段216の動作の一例を説明するための流れ図である。
【0152】
利用者プログラム240がキューからFIFO方式でデータを取り出す場合において、データ取り出し手段216では、キュー制御情報部231の取り出しポインタの指すエントリがセグメント内の最終エントリである場合(図16のステップS146でYES)、次セグメントの先頭エントリを指すようにデータ取り出しポインタを更新する(ステップS148)。
【0153】
ここで、登録ポインタが指すセグメントがデータを取り出したセグメント(以降、「取り出しセグメント」という)でない場合であって(ステップS149でNO)、取り出しセグメントが第1セグメントではなく(ステップS150でNO)、過去にキューの拡張を行っておりセグメントを削除しても、初期セグメント数を下回らない、すなわち
”使用セグメント数−1≧初期セグメント数”
である場合(ステップS151でYES)、キュー縮退手段220に、取り出しセグメントを指定してキューを縮退する(ステップS152)。
【0154】
キュー縮退手段220は、指定されたセグメント、ここでは取り出しセグメントを消去し(図19のステップS191)、指定されたセグメントの前セグメントが次セグメントを指すように環状リンクを再設定し(ステップS192)、使用セグメント数から1を減算する(ステップS193)。
【0155】
尚、登録ポインタの指すセグメントが取り出しセグメントである場合(ステップS149でYES)は、取り出しセグメント中に他のデータが存在する状態であるためセグメントを削除しない。取り出しセグメントが第1セグメントのとき(ステップS150でYES)、第1セグメントは利用者プログラム240にキーとして使用されるセグメントであり、また制御情報が格納されているセグメントであるため、削除しない。
【0156】
また、”使用セグメント数−1<初期セグメント数”
である場合(ステップS151でNO)は、初期状態のセグメント数を下回ってしまうため、セグメントを削除しない。
【0157】
図17は、本発明の第2の実施の形態におけるデータ逆取り出し手段217の動作の一例を説明するための流れ図である。
【0158】
利用者プログラム240がキューからLIFO方式でデータを取り出す場合において、データ逆取り出し手段217では、キュー制御情報部231の登録ポインタが指すエントリが、セグメント内の先頭エントリである場合(図17のステップS164でYES)、前セグメントの最終エントリを指すように、登録ポインタを更新する(図17のステップS166、S167)。
【0159】
ここで、更新前の登録ポインタが指していたセグメント(以降、元セグメント)が取り出しポインタの指すセグメントではない場合であって(ステップS168でNO)、元セグメントが第1セグメントではなく(ステップS169でNO)、過去にキューの拡張が起こっており、
”使用セグメント数−1≧初期セグメント数”
である場合(ステップS170でYES)には、キュー縮退手段220に元セグメントを指定してキューを縮退する(ステップS171)。キュー縮退手段220により、元セグメントは消去される。
【0160】
尚、更新前の登録ポインタが指していたセグメント(「元セグメント」という)が取り出しポインタの指すセグメントの場合には(ステップS168でYES)、元セグメント中に他のデータが存在する状態であるため、セグメントを削除しない。
【0161】
元セグメントが第1セグメントの場合(ステップS169でYES)、第1セグメントは削除しない。
【0162】
また、”使用セグメント数−1<初期セグメント数”
となる場合(ステップS170でNO)は、初期状態のセグメント数を下回ってしまうため、セグメントを削除しない。
【0163】
次に、本実施の形態の作用効果について説明する。
【0164】
本発明の形態では、データの登録時において、エントリが不足しそうな場合にセグメントを追加し、データの取り出し時に、データが存在しないセグメントを検出したらセグメントを消去するように構成されているため、データの数が一時的に多くなった場合に自動的にキューを拡張し、データの数が減ったらキューを縮退することができ、メモリ資源を効率良く利用することができる。
【0165】
また、本実施の形態では、さらに、データの登録時に、登録ポインタと取り出しポインタが同じセグメントを指すとき、すなわち登録ポインタが取り出しポインタに追いつきエントリ不足となる可能性が発生した場合にセグメントを追加する構成となっているため、エントリ不足となる前に事前にキューを拡張することができる。
【0166】
次に、具体的な実施例を用いて本実施の形態の動作を説明する。
【0167】
キューが図2および図3に示すように、登録ポインタが”セグメント1のエントリ4”を、取り出しポインタが”セグメント2のエントリ6”を指しており、登録されているデータ数が”9”、使用セグメント数3、初期セグメント数3、最大セグメント数10であるとする。ここで利用者プログラムよりデータが2つ登録されると、登録ポインタは”セグメント1のエントリ6”を指し、データ数は11となる。この状態で、さらにデータの登録が要求された場合、登録エントリはエントリ6でセグメント1の最終エントリであり(図15のステップS123でYES)、取り出しポインタの指すセグメントは”セグメント2”であり、”セグメント1”の次セグメントである(ステップS125でYES)。
【0168】
また、
使用セグメント数+1=4≦10
であるため(ステップS126でYES)、データ登録手段215は、キュー拡張手段219により、セグメント1の次セグメントとして、セグメント4を追加する(ステップS127)。
【0169】
このように、キューは拡張され、図12および図13に示す状態となる。
【0170】
次に、キューが図12および図13に示すように、登録ポインタが”セグメント4のエントリ1”を、取り出しポインタが”セグメント2のエントリ6”を指しており、登録されているデータ数が”13”、使用セグメント数4、初期セグメント数=3、最大セグメント数=10であるとする。
【0171】
この状態で、FIFO方式でのデータの取り出しを要求する場合、データ取り出し手段216は、取り出しエントリは、エントリ6で、セグメント2の最終エントリであるため(図16のステップS146)、取り出しポインタに、”セグメント3のエントリ1”を設定する(ステップS148)。
【0172】
ここで、登録ポインタの指すセグメントは”セグメント4”であり、”セグメント2”ではなく(ステップS149でNO)、”セグメント2”は第1セグメントではない(ステップS150でNO)。
【0173】
また、
使用セグメント数−1=3≧3
であるため(ステップS151でYES)、データ取り出し手段216は、キュー縮退手段220によりセグメント2を消去する(ステップS152)。
【0174】
このように、キューが縮退され、セグメント2の代わりにセグメント4となった図12および図13の状態となる。
【0175】
同様に、キューが、図12および図13に示すように、登録ポインタが”セグメント4のエントリ1”を、取り出しポインタが”セグメント2のエントリ6”を指しており、登録されているデータ数が”13”、使用セグメント数が”4”、初期セグメント数が”3”、最大セグメント数が”10”であるとする。
【0176】
この状態で、LIFO方式でのデータの取り出しを要求する場合、データ逆取り出し手段217は、登録ポインタの指すエントリはセグメント4の先頭エントリであるため(図17のステップS164でYES)、登録ポインタにセグメント1のエントリ6を設定する(ステップS166、S167)。
【0177】
ここで、取り出しポインタは、セグメント4ではなく、セグメント2を指しており(ステップS168でNO)、セグメント4は、第1セグメントではなく(ステップS169でNO)、
使用セグメント数−1=3≧3
であるため(ステップS170でYES)、データ逆取り出し手段217は、キュー縮退手段220により、セグメント4を消去する(ステップS171)。このように、キューのセグメント4が縮退され、図2および図3の状態となる。
【0178】
次に、本発明の第3の実施の形態について図面を参照して詳細に説明する。
【0179】
図20を参照すると、本発明の第3の実施の形態は、プログラム制御により動作する計算機システム300と、キュー制御システム310と、キューセグメント330と、利用者プログラム340と、利用者プログラム341とから構成されている。
【0180】
キュー制御システム310は、キュー生成手段311と、キュー停止手段312と、キュー消去手段313と、キュー再初期化手段314と、データ登録手段315と、データ取り出し手段316と、データ逆取り出し手段317と、キュー排他手段318と、キュー拡張手段319と、キュー縮退手段320と、待ち合わせ手段321とを含む。
【0181】
キューセグメント330は、キュー制御情報部331と、キューデータ部332とを含む。
【0182】
これらの手段はそれぞれ概略つぎのように動作する。ここでは、第1、第2の実施の形態と動作が異なる手段について説明する。
【0183】
キュー停止手段312は、待ち合わせ手段321を使用してデータあるいはエントリを待ち合わせているプロセスを起動し、キューを停止状態として以降のデータの登録および取り出しを禁止する。
【0184】
データ登録手段315は、利用者プログラム(340/341)からの要求により、キュー制御情報部331の登録ポインタが示すエントリに利用者プログラムより渡されたデータを登録する。
【0185】
このとき、データの登録を待ち合わせているプロセスが存在する場合は、待ち合わせ手段321を使用して待ち合わせているプロセスを起動する。すなわち、データの登録を待ち合わせ数が1以上である場合、通知セマフォに対して通知を行い、待ち合わせを解除する。また、データの登録時に空きエントリがない場合は、待ち合わせ手段321を使用してエントリが空くのを待ち合わせる。
【0186】
データ取り出し手段316は、利用者プログラムからの要求により、キュー制御情報部231の取り出しポインタが示すエントリからデータを取り出し利用者プログラムに返却する。このとき、エントリの空きを待ち合わせているプロセスが存在する場合は、待ち合わせ解除手段323を使用して待ち合わせているプロセスを起動する。すなわち、空きエントリの待ち合わせ数が1以上である場合、通知セマフォに対して通知を行い、待ち合わせを解除する。また、データの取り出し時に登録されているデータがない場合は、待ち合わせ手段321を使用してデータの登録を待ち合わせる。
【0187】
データ逆取り出し手段217は、利用者プログラムからの要求により、キュー制御情報部331の登録ポインタが示すエントリの1つ前のエントリからデータを取り出し利用者プログラムに返却する。このとき、エントリの空きを待ち合わせているプロセスが存在する場合は、待ち合わせ手段321を使用して待ち合わせているプロセスを起動する。すなわち、待ち合わせ数が1以上である場合、通知セマフォに対して通知を行い、待ち合わせを解除する。また、データの取り出し時に登録されているデータがない場合は、待ち合わせ手段321を使用してデータの登録を待ち合わせる。
【0188】
待ち合わせ手段321は、待ち合わせ数に1を加算し、キュー排他手段318を使用してキューの排他を解除した後に、通知セマフォを使用して待ち合わせ解除通知を待ち合わせる。通知が来たら、待ち合わせ手段321は、キュー排他手段318を使用してキューの排他を行い、待ち合わせ数から1を減算する。
【0189】
キュー制御システム310におけるキュー生成手段311、キュー停止手段312、キュー消去手段313、キュー再初期化手段314、データ登録手段315、データ取り出し手段316、データ逆取り出し手段317、キュー排他手段318、キュー拡張手段319、キュー縮退手段320、待ち合わせ手段321は、コンピュータ上で実行されるプログラムによりそれぞれの機能・処理が実現される。
【0190】
次に、図20および図23〜図27のフローチャートを参照して、本実施の形態の全体の動作について詳細に説明する。以下では、この実施の形態を、前記第1、第2の実施の形態の動作と相違する点について説明する。
【0191】
図23は、本発明の第3の実施の形態におけるキュー停止手段312の動作の一例を説明するための流れ図である。キュー停止手段312にてキューの使用が停止される場合、キュー停止手段312では、状態フラグのチェック後に、第1セグメントのキュー制御情報部331の待ち合わせ数を判断する。
【0192】
第1セグメントのキュー制御情報部331の待ち合わせ数が0より大きい場合(図23のステップS213でYES)は、通知を待ち合わせているプロセスが存在するということであるため、その数分の通知セマフォに対して通知を行い(ステップS214)、続いて状態フラグを”停止”とする(ステップS215)。
【0193】
これで待ち合わせているプロセスは、全て起動され、各々処理を継続するが、その後の状態チェックで、”使用中”ではないため、全て処理失敗となり、キューが使用されることはない。尚、待ち合わせ数が0の場合(ステップS213でNO)は、待ち合わせているプロセスは存在しないため通知する必要はない。
【0194】
図24は、本発明の第3の実施の形態におけるデータ登録手段315の動作の一例を説明するための流れ図である。
【0195】
利用者プログラム340がキューにデータを登録する場合において、データ登録手段315では、設定した次登録ポインタの指すエントリがキュー制御情報部331の取り出しポインタの指すエントリと同じである場合には(図24のステップS229でYES)、登録ポインタが取り出しポインタに追いつくということであり、次に登録できるエントリがない状態である。
【0196】
この場合、データ登録手段315では、待ち合わせ手段321を使用して、他プロセスが、データを取り出し、空きエントリができるのを待ち合わる(ステップS236)。
【0197】
図27は、本発明の第3の実施の形態における待ち合わせ手段の動作の一例を説明するための流れ図である。待ち合わせ手段321は、第1セグメントのキュー制御情報部331の待ち合わせ数に1を加算し(図27のステップS281)、キュー排他手段を使用してキューの排他を解除して(ステップS282)、キュー制御情報部331の通知セマフォで待ち合わせを行う(ステップ283)。
【0198】
データ登録手段315、データ取り出し手段316、データ逆取り出し手段317、あるいはデータ停止手段312からの通知により、待ち合わせが解除される。
【0199】
その後、待ち合わせ手段321は、キュー排他手段によりキューを排他し(ステップS284)、待ち合わせ数から1を減算し(ステップS285)、終了する。
【0200】
データ登録手段315にて、待ちあわせが解除された、すなわち空きエントリができたら、データ登録手段315は、状態フラグのチェック(図24のステップS222)から処理を再実行する。
【0201】
また、データが登録できた場合であって(ステップS232まで実行)、待ち合わせ数が0より大きい場合には(ステップS233でYES)、データの登録を待ち合わせているプロセスが存在することを意味する。
【0202】
そこで、データ登録手段315は、通知セマフォに対し通知を行い(ステップS234)、待ち合わせているプロセスを起動する。待ち合わせ数が0の場合(ステップS233でNO)は、待ち合わせているプロセスは存在しないため通知する必要はない。
【0203】
図26は、本発明の第3の実施の形態におけるデータ取り出し手段316の動作の一例を説明するための流れ図である。
【0204】
利用者プログラム340がキューからFIFO方式でデータを取り出す場合において、データ取り出し手段316では、第1セグメントのキュー制御情報部331のデータ数が0である場合(図25のステップS243でNO)、登録されているデータがない状態であるため、待ち合わせ手段321を使用して、他プロセスによるデータの登録を待ち合わせる(ステップS256)。
【0205】
待ちあわせが解除された際に、すなわちデータが登録されたら、データ取り出し手段316は、状態フラグのチェック(ステップS242)から処理を再実行する。また、データを取り出し、ポインタの更新が完了した場合(ステップS247まで実行)に、第1セグメントのキュー制御情報部331の待ち合わせ数が0より大きい場合には(ステップS253でYES)、エントリの空き待ち合わせているプロセスが存在することを意味する。
【0206】
そこで、データ取り出し手段316は、第1セグメントのキュー制御情報部331の通知セマフォに対し通知を行い(ステップS254)、待ち合わせているプロセスを起動する。一方、第1セグメントのキュー制御情報部331の待ち合わせ数が0の場合には(ステップS253でNO)、待ち合わせているプロセスは存在しないため、通知する必要はない。
【0207】
図26は、本発明の第3の実施の形態におけるデータ逆取り出し手段の動作の一例を説明するための流れ図である。
【0208】
利用者プログラム340がキューからLIFO方式でデータを取り出す場合において、データ逆取り出し手段317では、キュー制御情報部331のデータ数が0である場合は(図26のステップS263でNO)、登録されているデータがない状態であるため、待ち合わせ手段321を使用して、他プロセスによるデータの登録を待ち合わせる(ステップS277)。待ちあわせが解除された、すなわちデータが登録されたら、データ逆取り出し手段317は、状態フラグのチェック(ステップS262)から処理を再実行する。また、データを取り出しが完了した場合(ステップS275まで実行)、第1セグメントのキュー制御情報部331の待ち合わせ数が0より大きい場合は(ステップS274でYES)、エントリの空き待ち合わせているプロセスが存在することを意味する。
【0209】
そこでデータ逆取り出し手段317は、第1セグメントのキュー制御情報部331の通知セマフォに対し通知を行い(ステップS275)、待ち合わせているプロセスを起動する。待ち合わせ数が0の場合(ステップS274でNO)は、待ち合わせているプロセスは存在しないため通知する必要はない。
【0210】
次に、本実施の形態の効果について説明する。
【0211】
本実施の形態では、データの登録時に空きエントリが存在しない場合に、他プロセスがデータを取り出しエントリが空くのを自動的に待ちあわせるように構成されているため、キューのオーバフローを意識する必要がなくキューを利用することができる。
【0212】
また、本実施の形態では、さらに、データの取り出し時にデータが存在しない場合には、他プロセスによるデータの登録を自動的に待ち合わせるように構成されているため、登録されているデータの数を意識することなくキューを利用することができる。
【0213】
【実施例2】
次に、具体的な実施例を用いて本実施の形態の動作を説明する。
【0214】
キューが、例えば図21および図22に示すように、登録ポインタが”セグメント1のエントリ4”を、取り出しポインタが”セグメント1のエントリ5”を指しており、登録されているデータ数が”17”、使用セグメント数3、初期セグメント数3、最大セグメント数3であるとする。この状態で、利用者プログラム340がデータを登録すると、データ登録手段315では、登録ポインタが”セグメント1のエントリ4”を指しており最終エントリではない(図25のステップS223でNO)ため、次登録ポインタには”セグメント1のエントリ5”を設定する(ステップS224)。
【0215】
すると、次登録ポインタ=取り出しポインタであるため(ステップS229でYES)、待ち合わせ手段236によりエントリの空きを待ち合わせる(ステップS236)。待ち合わせ手段321は、第1セグメントのキュー制御情報部331の待ち合わせ数を1とし(図27のステップS281)、キューの排他を解除して(ステップS282)、通知を待ち合わせる(ステップS283)。
【0216】
ここで、利用者プログラム341が、FIFO方式でデータを取り出すと、データ取り出し手段316では、”セグメント1のエントリ5”からデータを取り出す(図25のステップS244、S245)。エントリ5は最終エントリではないので(ステップS246でNO)、取り出しポインタに”セグメント1のエントリ6”を設定する(ステップS247)。
【0217】
続いて、データ取り出し手段316は、第1セグメントのキュー制御情報部331の待ち合わせ数が1であることから(ステップS253でYES)、第1セグメントのキュー制御情報部331の通知セマフォに通知する(ステップS254)。
【0218】
待ち合わせ手段321は、利用者プログラム341でのデータ取り出し手段316からの通知を受け、処理を継続する。待ち合わせ手段321は、キューを排他し(図27のステップS284)、第1セグメントのキュー制御情報部331の待ち合わせ数から1を減算する(ステップS285)。
【0219】
続いて、データ登録手段315では、状態チェック(図24のステップS222)から処理を再実行すると、次登録ポインタには”セグメント1のエントリ5”が設定され(ステップS224)、次登録ポインタ≠取り出しポインタであるため(ステップS229でNO)、データの登録が完了する(ステップS230、S231、S232)。
【0220】
続いて、第1セグメントのキュー制御情報部331の待ち合わせ数は0であるため(ステップS233でNO)、データ登録手段315は、通知は行わなず、キューの排他を解除し(ステップS235)、終了する。
【0221】
上記した各実施例のキュー制御システムは、仮想記憶方式を採用し、セグメンテーションで仮想記憶空間を管理するコンピュータのセグメント管理に用いて好適とされる。
【0222】
また、プロセス間通信を実現するにあたり、利用者の負担を減らすことができる。すなわち、上記実施例においては、キューへのデータの登録や空きエントリの待ち合わせをキュー制御システムの内部で行うことで、キュー操作において、データエンプティやオーバフローが発生せず、利用者プログラムの側で、エラー処理等を考慮した複雑なプログラムを組む必要がない。これに以外にも、必要なときにバッファプールからバッファを取得し、使用後、バッファを戻す動的バッファ管理等、情報データを保持するデータエントリと、キュー制御情報部を有する構成の任意のキュー管理システムに適用できることは勿論である。以上本発明を上記実施形態に即して説明したが、本発明は、上記実施形態に限定されるものでなく、特許請求の範囲の各請求項の発明の範囲内で当業者であればなし得るであろう各種変形、修正を含むことは勿論である。
【0223】
【発明の効果】
以上説明したように、本発明によれば下記記載の効果を奏する。
【0224】
本発明の第1の効果は、キューへのデータの登録および取り出しを高速に行うことができる、ということである。
【0225】
その理由は、本発明においては、処理対象となるエントリは、登録ポインタあるいは、取り出しポインタによってあらかじめ決定されており、データの登録および取り出し時に、キューの検索やエントリ間のチェインの張り替えを不要としているためである。
【0226】
本発明の第2の効果は、メモリ資源を効率よく利用することができる、ということである。
【0227】
その理由は、本発明においては、使用を終了したキューを消去し、あるいは再利用することが可能であり、また、登録データの数が一時的に多くなった場合には、自動的にキューを拡張し、登録データの数が減ったら、キューを縮退させる制御が行われるためである。
【0228】
本発明の第3の効果は、プロセス間通信を実現するにあたり、利用者の負担を減らすことができる、ということである。
【0229】
その理由は、本発明においては、キューへのデータの登録や空きエントリの待ち合わせをキュー制御システムの内部で行うことで、キュー操作において、データエンプティやオーバフローが発生せず、利用者プログラムの側で異常を意識する必要がない、すなわち、例えばエラー処理等を考慮したプログラムを組む必要がないためである。
【図面の簡単な説明】
【図1】本発明の第1の実施の形態の構成を示す図である。
【図2】本発明の第1の実施の形態におけるキューセグメントを模式的に示す図である。
【図3】本発明の第1の実施の形態におけるキュー制御情報部の一例を示す図である。
【図4】本発明の第1の実施の形態におけるキュー生成手段の動作の一例を説明するための流れ図である。
【図5】本発明の第1の実施の形態におけるキュー停止手段の動作の一例を説明するための流れ図である。
【図6】本発明の第1の実施の形態におけるキュー消去手段の動作の一例を説明するための流れ図である。
【図7】本発明の第1の実施の形態におけるキュー再初期化手段の動作の一例を説明するための流れ図である。
【図8】本発明の第1の実施の形態におけるデータ登録手段手段の動作の一例を説明するための流れ図である。
【図9】本発明の第1の実施の形態におけるデータ取り出し手段の動作の一例を説明するための流れ図である。
【図10】本発明の第1の実施の形態におけるデータ逆取り出し手段の動作の一例を説明するための流れ図である。
【図11】本発明の第2の実施の形態の構成を示す図である。
【図12】本発明の第2の実施の形態におけるキューセグメントを模式的に示す図である。
【図13】本発明の第2の実施の形態におけるキュー制御情報部の一例を示す図である。
【図14】本発明の第2の実施の形態におけるキュー再初期化手段の動作の一例を説明するための流れ図である。
【図15】本発明の第2の実施の形態におけるデータ登録手段手段の動作の一例を説明するための流れ図である。
【図16】本発明の第2の実施の形態におけるデータ取り出し手段の動作の一例を説明するための流れ図である。
【図17】本発明の第2の実施の形態におけるデータ逆取り出し手段の動作の一例を説明するための流れ図である。
【図18】本発明の第2の実施の形態におけるキュー拡張手段の動作の一例を説明するための流れ図である。
【図19】本発明の第2の実施の形態におけるキュー縮退手段の動作の一例を説明するための流れ図である。
【図20】本発明の第3の実施の形態の構成を示す図である。
【図21】本発明の第3の実施の形態におけるキューセグメントを模式的に示す図である。
【図22】本発明の第3の実施の形態におけるキュー制御情報部の一例を示す図である。
【図23】本発明の第3の実施の形態におけるキュー停止手段の動作の一例を説明するための流れ図である。
【図24】本発明の第3の実施の形態におけるデータ登録手段の動作の一例を説明するための流れ図である。
【図25】本発明の第3の実施の形態におけるデータ取り出し手段の動作の一例を説明するための流れ図である。
【図26】本発明の第3の実施の形態におけるデータ逆取り出し手段の動作の一例を説明するための流れ図である。
【図27】本発明の第3の実施の形態における待ち合わせ手段の動作の一例を説明するための流れ図である。
【符号の説明】
100,200,300 計算機システム
110,210,310 キュー制御システム
111,211,311 キュー生成手段
112,212,312 キュー停止手段
113,213,313 キュー消去手段
114,214,314 キュー再初期化手段
115,215,315 データ登録手段
116,216,316 データ取り出し手段
117,217,317 データ逆取り出し手段
118,218,318 キュー排他手段
219,319 キュー拡張手段
220,320 キュー縮退手段
321 待ち合わせ手段
130,230,330 キューセグメント
131,231,331 キュー制御情報部
132,232,332 キューデータ部
140,240,340 利用者プログラム[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a queue control system, a queue control method, and a queue control program for a computer system, and more particularly to a queue control system, a queue control method, and a queue control program that are preferably used for interprocess communication.
[0002]
[Prior art]
Conventionally, as a queue control system for sequentially registering and retrieving asynchronously generated data in, for example, a FIFO (first-in first-out) method, a one-way chain having a head chain entry and a forward chain pointer in each entry, an index Systems and methods using keys are known. The following are referenced as publications on queue management:
(A) Japanese Patent Laid-Open No. 4-130929
(B) JP-A-4-259040
(C) Japanese Patent Laid-Open No. 11-184716
(D) Japanese Patent Laid-Open No. 6-68040
The system described in the publications (a) to (d) is outlined below.
[0003]
Japanese Patent Laid-Open No. 4-130929 discloses a skip search means for grouping events having the same key value and skipping search processing by using the same key pointer by providing the same key pointer that can be searched corresponding to the group. And a queue management method that includes a new group when an event having the same key value is added, and the same key pointer management means for adding the event to the group when the group is already configured Is disclosed. The same key pointer is a pointer for grouping data having the same key value and chaining the data so that search processing can be performed.
[0004]
In the queue management system having such a configuration, even when a lot of data with the same key value is registered, the search for data with different key values can be skipped by using the same key pointer by the skip search means. The search process can be performed quickly. In addition, when registering new data, the same key pointer management means configures a new group or adds data to an existing group, thereby keeping the key values of all data constituting the group equal. be able to.
[0005]
Japanese Patent Laid-Open No. 4-259040 discloses determination means for determining whether or not a new queue block needs to be acquired using management data of a circular queue management means for managing the queuing state of the circular queue. A queue management means having an acquisition means for acquiring a new queue block and a setting means for queuing the new queue block to the circular queue when the determination means determines that the acquisition is necessary; In addition, an automatic expansion of the queue block of the circular queue is realized.
[0006]
In the queue management method having such a configuration, queue management can be executed simply by switching chained queues. Therefore, processing steps for queue management are reduced compared to queues that do not employ a circular configuration, and Management can be speeded up. In addition, when all the queue blocks are in use, if new data is registered, a new queue block is acquired by the acquisition unit, and the queue block acquired by the setting unit is queued in the circular queue. This makes it possible to automatically add a queue block for the circular queue.
[0007]
Japanese Patent Application Laid-Open No. 11-184716 has a multitask that separately executes queuing processing and queuing out processing of event queue elements, and a head pointer that always points to the head of an event queue composed of event queue elements And two pairs of final pointers dedicated to queuing and dedicated to queuing at all times, and a forward chain pointer and a backward chain pointer for concatenating consecutive event queue elements in the event queue element A queue management system having a configuration provided is disclosed. In other words, a queuing task, a queue-out task, a confirmation type inter-task notification means, a queue buffer, a queuing event queue head pointer, a queuing event queue last pointer, and a queue-out The event queue includes a head pointer of the dedicated event queue, a final pointer of the queue queue dedicated to the queue, a queue queue dedicated event queue, a queue queue dedicated event queue, and individual event queue elements constituting the event queue. Each event queue element has a forward chain pointer and a backward chain pointer.
[0008]
In the queue management method having such a configuration, when registering data in the queue, the queuing processing task operates, registers the data at the end of the queuing dedicated head pointer, and the order in the preceding and succeeding event queue elements. Reposition the direction chain pointer and the reverse chain pointer. When retrieving data from the queue, the queue-out processing task operates, retrieves data from the end of the queue-dedicated final pointer, and re-stretches the forward and backward chain pointers in the preceding and succeeding event queue elements. In this way, data is registered at the point destination of the first pointer dedicated for queuing during queuing, and data is extracted from the point destination of the final pointer dedicated for cueing out during cueing. Processing is possible.
[0009]
In addition, if there is a data registration request during the operation of the queue-out processing task, the queuing processing task creates another event queue for processing, and uses the confirmation type inter-task notification means as the timing. Switch event queue. For this reason, the queuing process and the queue-out process do not occur at the same time for one event queue, and the memory exclusive control is not necessary even in multitasking, and an efficient queue process is possible.
[0010]
Japanese Laid-Open Patent Publication No. 6-68040 describes a queue control method using a ring buffer type communication queue. Similarly, Japanese Patent Application Laid-Open No. 1-129345 (invention name: “multiprocessor system”), Japanese Patent Application Laid-Open No. 60-1116064 (invention name: “communication method between distributed processors”), and Japanese 58-501740 (Title of the Invention: “Interface Mechanism of Paired Processors such as Host and Peripheral Control Processor in Data Processing System”) adopts a ring buffer type queue for interprocessor communication Thus, a technique for performing communication control is described.
[0011]
Japanese Patent Laid-Open No. 6-68040 writes a resource number, which is transmission data, at a location indicated by a write pointer in a communication queue at the time of transmission between processors, and at reception, a resource number, which is reception data, from the location indicated by a read pointer. A queue control method for inter-processor communication configured to take out data is disclosed. The communication queue includes a reception read pointer, a transmission write pointer, and communication resources.
[0012]
In the queue control system having such a configuration, at the time of data registration, data is written to the point destination of the write pointer and the write pointer is updated. At the time of data extraction, data is extracted from the point destination of the read pointer and the read pointer is updated. For this reason, the processing time of the communication queue can be advanced as compared with the chain method, and the control of the communication queue can be simplified.
[0013]
However, the conventional systems described in the above publications have the following problems.
[0014]
As a first problem, in the chain-type queue management method, it is necessary to reset the forward chain pointer or the backward chain pointer of the preceding and following queue entries at the time of data registration and data retrieval, which slows down the processing. That is.
[0015]
The reason is that queue management is performed by connecting each queue entry with a chain pointer.
[0016]
The second problem is that the queue cannot be expanded at an arbitrary point of time in the ring buffer type queue management method.
[0017]
The reason for this is that in the ring buffer method, the end of the buffer is connected to the beginning, and the end of the buffer is used continuously until it reaches the end. This is because an area cannot be inserted. Although the queue can be expanded by extending the end of the buffer, it is impossible to expand the queue at any point in the system.
[0018]
The third problem is that when a queue is used for inter-process communication, if there is no empty entry at the time of data registration, or if there is no data registered at the time of data retrieval, the waiting control is performed by the user himself / herself. Is a heavy burden on users.
[0019]
This is because the conventional queue management method does not have a function of waiting for data registration or retrieval.
[0020]
[Problems to be solved by the invention]
Accordingly, the present invention has been made in view of the above problems, and an object of the present invention is to provide a queue control system capable of performing data registration in a queue and data retrieval from the queue at high speed. is there.
[0021]
Another object of the present invention is to expand the queue automatically when the number of registered data temporarily increases, and degenerate the queue when the number of data decreases, so that resources can be used efficiently. To provide a queue control system.
[0022]
Still another object of the present invention is to provide a queue control system that can easily realize interprocess communication by waiting for data and empty entries.
[0023]
[Means for Solving the Problems]
A queue control system according to one aspect of the present invention that achieves at least one of the above objects is a segment used as a queue, and a queue control information section for storing queue control information in the segment, and data is registered A plurality of segments each having a data portion made up of a plurality of entries, a circular link is set for each segment, and one of the plurality of segments linked in a circular manner (referred to as a “first segment”) Queue generating means for setting an initial value in the queue control information section of the first segment, and the queue control information section of the first segment holds at least a registration pointer and a retrieval pointer indicating a data registration destination entry and a retrieval entry, The entry pointed to by the registration pointer in the queue control information section of the first segment contains data. And it includes a data registration means for registering, and data retrieval means for retrieving the data from the entry extraction pointer queue control information part of the first segment pointed to, and queues the exclusive means for performing exclusive control of the queue.
[0024]
More specifically, a queue control information unit that stores queue control information in the queue segment, and a data unit in which data is registered, a plurality of queue segments are generated, and a circular link is set for each segment. A queue initialization unit that sets an initial value in the queue control information unit, a queue generation unit, a data registration unit that registers data in the entry pointed to by the registration pointer in the queue control information unit, and a retrieval pointer in the queue control information unit Data fetching means for fetching data from the entry, data reverse fetching means for fetching data from the entry immediately before the entry pointed to by the registration pointer of the queue control information section, and queue exclusion means for excluding the queue so that it cannot be used simultaneously by a plurality of processes Then, the queue is stopped, and subsequent data registration and data retrieval are performed. Queue stop means for stopping, Queue erasure means for erasing queue segments, and queue re-initialization for re-initializing the queue control information section of the queue stopped by the queue stop means so that the queue can be used again And a queue is created or deleted in response to a request from the user program, and data is registered in the queue and fetched from the queue at high speed.
[0025]
In addition, the queue control system of the present invention uses a queue expansion unit that generates a new segment to be used as a queue and resets a link between segments when there is no empty entry at the time of data registration, and is used for data retrieval. Queue degeneration means to delete unused segments and re-establish links between segments. When the number of registered data temporarily increases, the queue is automatically expanded. Operates to degenerate the queue.
[0026]
Also, the queue control system according to the present invention waits for data to be taken out by another process when there is no free entry at the time of data registration, and when there is no data registered at the time of data fetching Has a waiting means for waiting for data to be registered by other processes, and if there is no entry that can be registered at the time of data registration or if there is no data registered at the time of data retrieval, the registration of data and the empty space of the entry are cleared. Operates to wait.
[0027]
A queue control method according to another aspect of the present invention includes:
(A) A segment used as a queue, and a plurality of segments each including a queue control information section for storing queue control information in the segment and a data section including entries in which data is registered, A step of setting an annular link to the segment, and setting an initial value in a queue control information part of one segment (referred to as “first segment”) of the plurality of segments linked in a ring, The queue control information part of the segment holds at least a registration pointer and a retrieval pointer that point to a data registration destination entry and a retrieval entry,
(B) registering data in an entry indicated by a registration pointer in the queue control information section of the first segment;
(C) extracting data from the entry indicated by the extraction pointer in the queue control information section of the first segment;
(D) exclusive control of the queue.
[0028]
A program according to another aspect of the present invention is a program for managing a queue by a computer, a segment used as a queue, a queue control information section for storing queue control information in the segment, and a data A plurality of segments each having a data portion made up of registered entries, a circular link is set for each of the segments, and one of the plurality of segments linked in a circular manner (“first segment”) The queue control information part of the first segment stores at least a registration pointer and a retrieval pointer indicating the data registration destination entry and the retrieval entry. The data pointed to the entry pointed to by the registration pointer in the queue control information section of the first segment. A process of registering, and processing to retrieve data from the entry extraction pointer queue control information part of the first segment pointed consists program for executing a process of exclusive control of the queue, to the computer.
[0029]
DETAILED DESCRIPTION OF THE INVENTION
Next, embodiments of the present invention will be described in detail with reference to the drawings. FIG. 1 is a diagram showing the configuration of an embodiment of the present invention. Referring to FIG. 1, the system according to the first embodiment of the present invention includes a
[0030]
The
[0031]
The
[0032]
Each of these means generally operates as follows.
[0033]
The
[0034]
In addition, the
[0035]
The
[0036]
The
[0037]
The
[0038]
In response to a request from the
[0039]
In response to a request from the
[0040]
In response to a request from the
[0041]
The
[0042]
In the
[0043]
Next, the overall operation of the present embodiment will be described in detail with reference to the flowcharts of FIGS. 1, 2, 3, and 4 to 11. FIG. 2 is a diagram schematically showing a queue segment in the first embodiment of the present invention. FIG. 3 is a diagram illustrating an example of the queue control information unit. FIG. 4 is a flowchart for explaining an example of the operation of the queue generation unit 11 according to the first embodiment of the present invention.
[0044]
First, the
[0045]
The
[0046]
The
[0047]
Next, the
[0048]
As shown in FIG. 2, the queue segment has a structure linked in a ring shape for each segment.
[0049]
Subsequently, the
[0050]
Finally, the
[0051]
Thereafter, when the
[0052]
Also, as shown in FIG. 3, information is stored in the queue
[0053]
FIG. 5 is a flowchart for explaining an example of the operation of the
[0054]
First, the
[0055]
Next, the
[0056]
Finally, the
[0057]
If the status flag is not “in use” (NO in step S22), it is in a state where it cannot be stopped, so that the stop fails (step S25).
[0058]
FIG. 6 is a flowchart for explaining an example of the operation of the
[0059]
Next, the
[0060]
Next, the
[0061]
If the status flag is not in the “stop” state (NO in step S32), the deletion is impossible because the state cannot be deleted (step S36), the
[0062]
FIG. 7 is a flowchart for explaining an example of the operation of the queue reinitialization means 114 in the first embodiment of this invention. First, the
[0063]
Next, the
[0064]
Subsequently, the
[0065]
Finally, the
[0066]
In the state flag check, if the state flag is not in the “stop” state (NO in step S42), the reinitialization fails because the
[0067]
When the
[0068]
FIG. 8 is a flowchart for explaining an example of the operation of the
[0069]
Next, the
[0070]
If the registration entry is the last entry in the segment (YES in step S53), the
[0071]
Next, when the entry pointed to by the next registration pointer is not the same as the entry pointed to by the take-out pointer of the queue control information section 131 (NO in step S56), the
[0072]
Subsequently, the
[0073]
Finally, the
[0074]
If the entry pointed to by the next registration pointer is the same as the entry pointed to by the take-out pointer in the queue control information section 131 (YES in step S56), this means that the registration pointer catches up with the take-out pointer. There is no state. In this case, since there is no empty entry, data registration is failed (step S61).
[0075]
In the status flag check, if the status flag is not in the “in use” state (NO in step S52), the registration fails because the data cannot be registered (step S62).
[0076]
FIG. 9 is a flowchart for explaining an example of the operation of the
[0077]
Next, the data fetching means 116 checks the status flag, and if the status is “in use” (YES in step S72), it checks the number of data registered next. If the number of data in the queue
[0078]
Next, the
[0079]
Subsequently, when the fetch entry is not the last entry in the segment (NO in step S76), the data fetch
[0080]
If the fetch entry is the last entry in the segment (YES in step S76), the data fetch means 116 updates the data fetch pointer to point to the first entry of the next segment (step S78).
[0081]
Finally, the data fetch
[0082]
If the number of data is 0 (NO in step S73), there is no registered data, and data fetching fails (step S80).
[0083]
In the status flag check, if the status flag is not in the “in use” state (NO in step S72), the data cannot be extracted, and the extraction fails (step S81).
[0084]
FIG. 10 is a flowchart for explaining an example of the operation of the data reverse
[0085]
Next, the data reverse extraction means 117 checks the status flag, and if the status is “in use” (YES in step S92), it checks the number of data registered next.
[0086]
If the number of data in the queue
[0087]
If the entry (registration entry) pointed to by the registration pointer in the queue
[0088]
The entry immediately before the registration entry can be easily obtained by subtracting the data length value of the queue
[0089]
If the registration entry is the first entry in the segment (YES in step S94), the data reverse
[0090]
Here, the segment queue
[0091]
Subsequently, the data reverse extraction means 117 transfers the data from the entry indicated by the updated registration pointer to the data return area transmitted from the user program 140 (step S98).
[0092]
Next, the data reverse extraction means 117 subtracts “1” from the number of data in the queue control information unit 131 (step S99).
[0093]
Finally, the data reverse
[0094]
When the number of data is “0” (NO in step S93), there is no registered data, and data fetching fails (step S101).
[0095]
In the status flag check, if the status flag is not “in use” (NO in step S92), registration is failed because data cannot be registered (step S102).
[0096]
Next, the effect of this Embodiment is demonstrated.
[0097]
In this embodiment, at the time of data registration, the data is transferred to the entry pointed to by the registration pointer, the registration pointer is updated to point to the next entry, and at the time of data fetching, the data is fetched from the entry pointed to by the fetching pointer and fetched. Since the pointer is updated so that it points to the next entry, it is not necessary to search the queue or replace the forward chain at the time of data registration and data retrieval, and register and retrieve data at high speed. It can be carried out.
[0098]
Further, in the present embodiment, since there are two means for extracting data in the forward direction and means for extracting in the reverse direction, the FIFO method and the LIFO method can be mixed. Yes. As a result, the LIFO method can be normally used when canceling data once registered using the FIFO method.
[0099]
Further, in the present embodiment, a queue is generated in response to a request from the user program, and subsequent queue operations are performed using the address of the first segment as a key. Thus, a plurality of queues can be used.
[0100]
Further, in the present embodiment, the configuration is such that the queues that have been used can be deleted and reused, so that memory resources can be used efficiently.
[0101]
【Example】
Next, the operation of this embodiment will be described using specific examples.
[0102]
When the
[0103]
The
[0104]
Subsequently, an annular link is set between the generated segments (step S13).
[0105]
The segments are connected in a ring by the “next segment” region as shown in FIG. Subsequently, an initial value is set in the queue
[0106]
The queue
[0107]
“48 bytes” transmitted from the
[0108]
The next segment area is not set here because the circular link is set earlier.
[0109]
The initial segment number and the maximum segment number are set to “3” and “10”, which are values transmitted from the user program, and the current segment number, that is, the initial segment number “ 3 ”is set.
[0110]
A null value is set for the exclusive semaphore and the notification semaphore, and the number of waiting processes is set to “0”.
[0111]
Next, the
[0112]
Subsequently, the
[0113]
Thus, the generation of the queue is completed, and thereafter, the
[0114]
Next, an operation for registering data will be described.
[0115]
As shown in FIG. 2 and FIG. 3, when the registration pointer points to “segment 1
[0116]
Here, as shown in FIG. 2, segment 1 has entries 1 to 6 and the registered entry is
[0117]
Further, since the takeout pointer is “entry 5 of segment 2”, it is different from the next registration pointer (NO in step S56).
[0118]
Therefore, the
[0119]
Finally, the
[0120]
Next, the operation for extracting data will be described.
[0121]
As shown in FIG. 2 and FIG. 3, when the registration pointer points to “segment 1
[0122]
Here, as shown in FIG. 2, the segment 2 includes the entries 1 to 6 and the take-out entry is the entry 6, and is the last entry in the segment 2 (YES in step S76). Therefore, “
[0123]
Finally, the
[0124]
Similarly, as shown in FIGS. 2 and 3, the registration pointer points to “
[0125]
Therefore, the data reverse
[0126]
Finally, the data reverse
[0127]
Next, a second embodiment of the present invention will be described in detail with reference to the drawings. FIG. 11 is a diagram showing the configuration of the second exemplary embodiment of the present invention. In this embodiment, a queue expansion means 219 and a queue degeneration means 220 are added to the configuration of the embodiment shown in FIG.
[0128]
Referring to FIG. 11, the second embodiment of the present invention comprises a
[0129]
The
[0130]
The
[0131]
Each of these means generally operates as follows. Here, an operation different from that of the first embodiment will be described.
[0132]
The
[0133]
In response to a request from the
[0134]
In response to a request from the
[0135]
In response to a request from the
[0136]
The queue expansion means 219 newly generates one segment and sets the generated segment as the “next segment” of the previous segment. The “next segment” of the generated segment was originally set as the previous segment. Add a queue segment and extend the queue by setting the segment.
[0137]
The queue degeneration means 220 deletes one segment, sets the segment set as the “next segment” of the deleted segment as the “next segment” of the previous segment, reduces the queue segments, and degenerates the queue. Let
[0138]
[0139]
Next, the overall operation of the present embodiment will be described in detail with reference to the flowcharts of FIGS. 11 and 14 to 19. Here, means different in operation from those of the first embodiment will be described.
[0140]
FIG. 14 is a flowchart for explaining an example of the operation of the queue reinitialization means 214 in the second embodiment of the present invention. When the
[0141]
First, the
[0142]
Next, the queue reinitialization means 214 resets the circular link between the remaining segments (step S115). Thus, the queue segment state becomes the initial state.
[0143]
When the number of used segments ≦ the number of initial segments (NO in step S113), since the queue is not expanded, the process of returning to the initial state (steps S114 and S115) is unnecessary.
[0144]
FIG. 15 is a flowchart for explaining an example of the operation of the
[0145]
When the
[0146]
The queue expansion means 219 generates one new segment (step S181 in FIG. 18), and resets the circular link so that the specified segment, here, the segment next to the registered segment becomes the generated segment (step S181). S182), 1 is added to the number of used segments (step S183).
[0147]
Thus, in the
[0148]
Subsequently, the next segment, that is, the top entry of the added segment is set in the “next registration pointer” (step S128), and the subsequent processing is performed.
[0149]
If there is no segment pointed out by the fetch pointer next to the registered segment (NO in step S125), this means that there is at least one segment in which no data is registered, and expansion at that time is necessary. There is no new segment.
[0150]
Also, “number of used segments + 1> maximum number of segments”
(NO in step S126), the maximum number of segments specified at the time of generation is exceeded, so no new segment is generated.
[0151]
FIG. 16 is a flowchart for explaining an example of the operation of the data fetching means 216 in the second embodiment of the present invention.
[0152]
When the
[0153]
Here, the segment pointed to by the registration pointer is not a segment from which data has been extracted (hereinafter referred to as “extraction segment”) (NO in step S149), and the extraction segment is not the first segment (NO in step S150). If the queue has been expanded in the past and the segment is deleted, the number of initial segments will not fall below.
"Number of segments used-1 = number of initial segments"
If YES (YES in step S151), the queue degeneration means 220 is designated as an extraction segment and the queue is degenerated (step S152).
[0154]
The queue degeneration means 220 deletes the designated segment, here the fetched segment (step S191 in FIG. 19), and resets the circular link so that the previous segment of the designated segment points to the next segment (step S192). Then, 1 is subtracted from the number of used segments (step S193).
[0155]
If the segment pointed to by the registration pointer is an extracted segment (YES in step S149), the segment is not deleted because other data exists in the extracted segment. When the take-out segment is the first segment (YES in step S150), the first segment is a segment used as a key in the
[0156]
In addition, “number of used segments−1 <number of initial segments”
If it is (NO in step S151), the number of segments in the initial state will be less, so the segment is not deleted.
[0157]
FIG. 17 is a flowchart for explaining an example of the operation of the data reverse extraction means 217 in the second embodiment of the present invention.
[0158]
When the
[0159]
Here, the segment pointed to by the registration pointer before the update (hereinafter referred to as the original segment) is not the segment pointed to by the extraction pointer (NO in step S168), and the original segment is not the first segment (in step S169). No), queue expansion has happened in the past,
"Number of segments used-1 = number of initial segments"
If this is the case (YES in step S170), the queue is degenerated by designating the original segment in the queue degeneration means 220 (step S171). The original segment is deleted by the queue degeneration means 220.
[0160]
If the segment pointed to by the registration pointer before update (referred to as “original segment”) is the segment pointed to by the extraction pointer (YES in step S168), there is another data in the original segment. , Do not delete the segment.
[0161]
If the original segment is the first segment (YES in step S169), the first segment is not deleted.
[0162]
In addition, “number of used segments−1 <number of initial segments”
If this is the case (NO in step S170), the number of segments in the initial state is less than the number of segments, so the segments are not deleted.
[0163]
Next, the effect of this Embodiment is demonstrated.
[0164]
In the embodiment of the present invention, a segment is added when data entry is likely to be insufficient at the time of data registration, and a segment is deleted when a segment without data is detected at the time of data retrieval. When the number of data temporarily increases, the queue is automatically expanded. When the number of data decreases, the queue can be degenerated, and memory resources can be used efficiently.
[0165]
Further, in the present embodiment, when data is registered, a segment is added when the registration pointer and the extraction pointer point to the same segment, that is, when there is a possibility that the registration pointer catches up with the extraction pointer and there is a possibility of insufficient entries. Because of the configuration, the queue can be expanded in advance before the entry becomes insufficient.
[0166]
Next, the operation of this embodiment will be described using specific examples.
[0167]
As shown in FIGS. 2 and 3, the registration pointer points to “segment 1
[0168]
Also,
Number of segments used + 1 = 4 ≦ 10
(YES in step S126), the
[0169]
In this way, the queue is expanded to the state shown in FIGS.
[0170]
Next, as shown in FIGS. 12 and 13, the registration pointer points to “entry 1 of
[0171]
In this state, when requesting the data extraction by the FIFO method, the data extraction means 216 is the entry 6 and is the last entry of the segment 2 (step S146 in FIG. 16). “
[0172]
Here, the segment pointed to by the registration pointer is “
[0173]
Also,
Number of segments used-1 = 3 ≥ 3
Therefore (YES in step S151), the
[0174]
In this way, the queue is degenerated and the state shown in FIG. 12 and FIG.
[0175]
Similarly, as shown in FIG. 12 and FIG. 13, the queue indicates that the registration pointer points to “entry 1 of
[0176]
In this state, when requesting data extraction by the LIFO method, the data reverse extraction means 217 determines that the entry pointed to by the registration pointer is the first entry of the segment 4 (YES in step S164 in FIG. 17). An entry 6 of segment 1 is set (steps S166 and S167).
[0177]
Here, the takeout pointer points to segment 2 instead of segment 4 (NO in step S168),
Number of segments used-1 = 3 ≥ 3
Therefore (YES in step S170), the data reverse
[0178]
Next, a third embodiment of the present invention will be described in detail with reference to the drawings.
[0179]
Referring to FIG. 20, the third embodiment of the present invention includes a
[0180]
The
[0181]
The
[0182]
Each of these means generally operates as follows. Here, means different in operation from the first and second embodiments will be described.
[0183]
The
[0184]
The
[0185]
At this time, if there is a process waiting for data registration, the waiting process is started using the waiting means 321. That is, when the number of waiting for data registration is 1 or more, the notification semaphore is notified and the waiting is released. If there is no empty entry at the time of data registration, the waiting means 321 is used to wait for an empty entry.
[0186]
In response to a request from the user program, the
[0187]
In response to a request from the user program, the data reverse fetch
[0188]
The waiting
[0189]
[0190]
Next, the overall operation of the present embodiment will be described in detail with reference to the flowcharts of FIGS. 20 and 23 to 27. In the following, this embodiment will be described with respect to differences from the operations of the first and second embodiments.
[0191]
FIG. 23 is a flowchart for explaining an example of the operation of the
[0192]
If the number of waiting in the queue
[0193]
All processes waiting in this way are activated and continue their respective processes. However, in the subsequent status check, since they are not “in use”, all processes fail and the queue is not used. If the number of waiting is 0 (NO in step S213), there is no need to notify because there is no waiting process.
[0194]
FIG. 24 is a flowchart for explaining an example of the operation of the
[0195]
When the
[0196]
In this case, the
[0197]
FIG. 27 is a flowchart for explaining an example of the operation of the waiting means in the third embodiment of the present invention. The queuing means 321 adds 1 to the queuing number in the queue
[0198]
The waiting is canceled by a notification from the
[0199]
Thereafter, the waiting means 321 excludes the queue by the queue exclusion means (step S284), subtracts 1 from the number of waiting (step S285), and ends.
[0200]
When the
[0201]
If the data can be registered (executed up to step S232) and the number of waiting is greater than 0 (YES in step S233), this means that there is a process waiting for data registration.
[0202]
Therefore, the
[0203]
FIG. 26 is a flowchart for explaining an example of the operation of the data fetching means 316 in the third embodiment of the present invention.
[0204]
When the
[0205]
When waiting is canceled, that is, when data is registered, the
[0206]
Therefore, the
[0207]
FIG. 26 is a flow chart for explaining an example of the operation of the data reverse extraction means in the third embodiment of the present invention.
[0208]
In the case where the
[0209]
Therefore, the data reverse extraction means 317 notifies the notification semaphore of the queue
[0210]
Next, the effect of this embodiment will be described.
[0211]
In this embodiment, when there is no empty entry at the time of data registration, it is configured to wait for another process to take out data and automatically wait for the entry to be empty, so it is necessary to be aware of queue overflow. You can use the queue without.
[0212]
Further, in the present embodiment, it is configured to automatically wait for registration of data by another process when there is no data at the time of data retrieval, so the number of registered data is conscious. You can use the queue without having to.
[0213]
[Example 2]
Next, the operation of this embodiment will be described using specific examples.
[0214]
For example, as shown in FIG. 21 and FIG. 22, the queue indicates that the registration pointer points to “
[0215]
Then, since the next registration pointer = the extraction pointer (YES in step S229), the waiting unit 236 waits for an empty entry (step S236). The waiting
[0216]
Here, when the
[0217]
Subsequently, the
[0218]
The waiting
[0219]
Subsequently, when the
[0220]
Subsequently, since the number of waiting in the queue
[0221]
The queue control system of each embodiment described above is suitable for segment management of a computer that employs a virtual storage system and manages virtual storage space by segmentation.
[0222]
In addition, the burden on the user can be reduced in realizing interprocess communication. That is, in the above-described embodiment, by performing data registration in the queue and waiting for empty entries within the queue control system, data empty and overflow do not occur in the queue operation, and on the user program side, There is no need to build a complicated program that takes error handling into consideration. In addition to this, an arbitrary queue having a data entry for holding information data and a queue control information section such as dynamic buffer management for obtaining a buffer from the buffer pool when necessary and returning the buffer after use. Of course, it can be applied to a management system. Although the present invention has been described with reference to the above-described embodiment, the present invention is not limited to the above-described embodiment, and can be made by those skilled in the art within the scope of the invention of each claim. Of course, various modifications and corrections will be included.
[0223]
【The invention's effect】
As described above, the present invention has the following effects.
[0224]
The first effect of the present invention is that data can be registered and retrieved from a queue at high speed.
[0225]
The reason is that in the present invention, the entry to be processed is determined in advance by the registration pointer or the retrieval pointer, and it is not necessary to search the queue or change the chain between entries when registering and retrieving data. Because.
[0226]
The second effect of the present invention is that memory resources can be used efficiently.
[0227]
The reason for this is that in the present invention, a queue that has been used can be deleted or reused, and when the number of registered data temporarily increases, the queue is automatically set. This is because when the number of registered data decreases, the queue is degenerated.
[0228]
The third effect of the present invention is that the burden on the user can be reduced in realizing inter-process communication.
[0229]
The reason for this is that in the present invention, registration of data to the queue and waiting for empty entries are performed inside the queue control system, so that there is no data empty or overflow in the queue operation, and the user program side. This is because there is no need to be aware of abnormalities, that is, there is no need to build a program that takes into account error processing, for example.
[Brief description of the drawings]
FIG. 1 is a diagram showing a configuration of a first exemplary embodiment of the present invention.
FIG. 2 is a diagram schematically showing a queue segment in the first embodiment of the invention.
FIG. 3 is a diagram illustrating an example of a queue control information unit according to the first embodiment of this invention.
FIG. 4 is a flowchart for explaining an example of the operation of the queue generation unit according to the first embodiment of the present invention.
FIG. 5 is a flowchart for explaining an example of the operation of the queue stopping means in the first embodiment of the invention.
FIG. 6 is a flowchart for explaining an example of the operation of the queue erasing unit in the first embodiment of the invention.
FIG. 7 is a flowchart for explaining an example of the operation of the queue reinitialization means in the first embodiment of the invention;
FIG. 8 is a flowchart for explaining an example of operation of data registration means in the first exemplary embodiment of the present invention.
FIG. 9 is a flowchart for explaining an example of the operation of the data fetching unit in the first embodiment of the present invention.
FIG. 10 is a flowchart for explaining an example of the operation of the data reverse extraction means in the first embodiment of the invention.
FIG. 11 is a diagram showing a configuration of a second exemplary embodiment of the present invention.
FIG. 12 is a diagram schematically illustrating a queue segment according to the second embodiment of the present invention.
FIG. 13 is a diagram illustrating an example of a queue control information unit according to the second embodiment of the present invention.
FIG. 14 is a flowchart for explaining an example of the operation of the queue reinitialization means in the second embodiment of the present invention;
FIG. 15 is a flowchart for explaining an example of operation of data registration means in the second exemplary embodiment of the present invention.
FIG. 16 is a flowchart for explaining an example of the operation of the data fetching unit in the second embodiment of the present invention;
FIG. 17 is a flowchart for explaining an example of the operation of the data reverse extraction means in the second embodiment of the present invention;
FIG. 18 is a flowchart for explaining an example of the operation of the queue extension means in the second exemplary embodiment of the present invention.
FIG. 19 is a flowchart for explaining an example of the operation of the queue degeneration means according to the second embodiment of the present invention.
FIG. 20 is a diagram showing a configuration of a third exemplary embodiment of the present invention.
FIG. 21 is a diagram schematically illustrating a queue segment according to the third embodiment of the present invention.
FIG. 22 is a diagram illustrating an example of a queue control information unit according to the third embodiment of the present invention.
FIG. 23 is a flowchart for explaining an example of the operation of the queue stopping means in the third embodiment of the present invention;
FIG. 24 is a flowchart for explaining an example of the operation of the data registration means in the third embodiment of the invention.
FIG. 25 is a flowchart for explaining an example of the operation of the data fetching unit in the third embodiment of the present invention;
FIG. 26 is a flowchart for explaining an example of the operation of the data reverse extraction means in the third embodiment of the present invention;
FIG. 27 is a flowchart for explaining an example of the operation of the waiting means in the third embodiment of the present invention;
[Explanation of symbols]
100, 200, 300 Computer system
110, 210, 310 Queue control system
111, 211, 311 Queue generation means
112, 212, 312 Queue stop means
113, 213, 313 Queue erasing means
114, 214, 314 Queue re-initialization means
115, 215, 315 Data registration means
116, 216, 316 Data retrieval means
117, 217, 317 Data reverse extraction means
118, 218, 318 Queue exclusion means
219,319 Queue expansion means
220, 320 Queue degeneration means
321 Meeting means
130, 230, 330 Queue segment
131, 231 and 331 Queue control information section
132, 232, 332 Queue data part
140, 240, 340 User program
Claims (57)
前記第1セグメントのキュー制御情報部には、データの登録先のエントリ及び取り出しエントリを指す登録ポインタ及び取り出しポインタが少なくとも保持され、
前記第1セグメントのキュー制御情報部の登録ポインタが指すエントリに、データを登録するデータ登録手段と、
前記第1セグメントのキュー制御情報部の取り出しポインタが指すエントリからデータを取り出すデータ取り出し手段と、
キューの排他制御を行うキュー排他手段と、
を備えている、ことを特徴とするキュー制御システム。A segment to be used as a queue, and a plurality of segments having a queue control information part for storing queue control information in the segment and a data part including entries in which data is registered are generated. A queue generating means for setting an initial value in a queue control information section of one segment (referred to as a “first segment”) of a plurality of segments linked in a ring,
The queue control information portion of the first segment holds at least a registration pointer and a retrieval pointer that point to a data registration destination entry and a retrieval entry,
Data registration means for registering data in the entry pointed to by the registration pointer of the queue control information section of the first segment;
Data fetching means for fetching data from the entry pointed to by the fetch pointer of the queue control information section of the first segment;
A queue exclusion means for performing exclusive control of the queue;
A queue control system comprising:
キューとして利用していたセグメントを消去するキュー消去手段と、
をさらに備えている、ことを特徴とする請求項1又は2記載のキュー制御システム。A queue stop means for stopping the use of the queue and suppressing data registration and data retrieval after the stop of the use of the queue;
A queue clearing means for clearing a segment used as a queue,
The queue control system according to claim 1, further comprising:
前記第1セグメントのキュー制御情報部には、データの登録先のエントリ及び取り出しエントリを指す登録ポインタ及び取り出しポインタが少なくとも保持され、
前記第1セグメントのキュー制御情報部の登録ポインタの示すエントリへデータを登録するステップと、
前記第1セグメントのキュー制御情報部の取り出しポインタの示すエントリからデータを取り出すステップと、
キューを排他制御するステップと、
を含む、ことを特徴とするキュー制御方法。A segment to be used as a queue, a plurality of segments having a queue control information section for storing queue control information in the segment and a data section including entries in which data is registered, and each segment is circular And setting an initial value in a queue control information part of one segment (referred to as “first segment”) of a plurality of segments linked in a ring shape,
The queue control information portion of the first segment holds at least a registration pointer and a retrieval pointer that point to a data registration destination entry and a retrieval entry,
Registering data in an entry indicated by a registration pointer in the queue control information section of the first segment;
Extracting data from the entry indicated by the extraction pointer in the queue control information section of the first segment;
A step of controlling the queue exclusively;
A queue control method comprising:
キューとして利用していたセグメントを消去するステップと、
を含む、ことを特徴とする請求項9又は10記載のキュー制御方法。Stopping the use of the queue and suppressing subsequent data registration and retrieval;
Deleting a segment that was used as a queue;
The queue control method according to claim 9 or 10, characterized by comprising:
データの取り出し時に、空きエントリを待ち合わせているプロセスに対しエントリが空いたことを通知して待ち合わせを解除するステップと、
を含む、ことを特徴とする請求項9乃至14のいずれか一に記載のキュー制御方法。If there is no free entry when registering data, waiting for data to be taken out by another process and a free entry to be created;
A step of releasing the waiting by notifying the process waiting for a free entry when the data is fetched that the entry is free;
The queue control method according to claim 9, further comprising:
データの登録時にデータの登録を待ち合わせているプロセスに対し、データが登録されたことを通知して待ち合わせを解除するステップと、
を含む、ことを特徴とする請求項9乃至15のいずれか一に記載のキュー制御方法。Waiting for data to be registered by another process if no data is registered at the time of data retrieval;
Informing the process that is waiting for data registration at the time of data registration that the data has been registered and releasing the wait;
The queue control method according to claim 9, further comprising:
(a)キューとして用いるセグメントであって、該セグメント中にキューの制御情報を格納するキュー制御情報部と、データが登録されるエントリよりなるデータ部とを有する複数のセグメントを生成し、前記各セグメントに環状のリンクを設定し、環状にリンクされた複数のセグメントのうちの1つのセグメント(「第1セグメント」という)のキュー制御情報部に初期値を設定する処理を有し、前記第1セグメントのキュー制御情報部には、データの登録先のエントリ及び取り出しエントリを指す登録ポインタ及び取り出しポインタが少なくとも保持され、
(b)前記第1セグメントのキュー制御情報部の登録ポインタが指すエントリにデータを登録する処理と、
(c)前記第1セグメントのキュー制御情報部の取り出しポインタが指すエントリからデータを取り出す処理と、
(d)キューを排他制御する処理と、
を有し、
前記(a)乃至(d)の処理を前記コンピュータに実行させるためのプログラム。A program that allows a computer to manage queues,
(A) A segment used as a queue, and a plurality of segments each including a queue control information section for storing queue control information in the segment and a data section including entries in which data is registered, A process of setting an initial value in a queue control information section of one segment (referred to as a “first segment”) of a plurality of segments linked in a ring, and setting a circular link to the segment, The queue control information part of the segment holds at least a registration pointer and a retrieval pointer that point to a data registration destination entry and a retrieval entry,
(B) processing for registering data in the entry pointed to by the registration pointer of the queue control information section of the first segment;
(C) processing for fetching data from the entry pointed to by the fetch pointer in the queue control information section of the first segment;
(D) processing for exclusive control of the queue;
Have
A program for causing the computer to execute the processes (a) to (d).
キューとして利用していたセグメントを消去する処理と、を前記コンピュータにさらに実行させるためのプログラム。The program according to claim 17 or 18, wherein the use of the queue is stopped, and the subsequent data registration and data retrieval are suppressed;
A program for causing the computer to further execute a process of deleting a segment used as a queue.
使用停止となったキューのキュー制御情報部を再初期化し、再度キューを使用できるようにする処理を前記コンピュータにさらに実行させるためのプログラム。The program according to any one of claims 17 to 19,
A program for causing the computer to further execute a process of reinitializing a queue control information part of a queue whose use has been stopped and allowing the queue to be used again.
データの登録時に空きエントリがない場合、キューとして利用する新たなセグメントを生成しセグメント間のリンクを設定し直す処理を前記コンピュータにさらに実行させるためのプログラム。The program according to any one of claims 17 to 20,
A program for causing the computer to further execute a process of generating a new segment to be used as a queue and resetting a link between segments when there is no empty entry at the time of data registration.
データの取り出し時に、使用していないセグメントを削除しセグメント間のリンクを設定し直す処理を前記コンピュータにさらに実行させるためのプログラム。The program according to any one of claims 17 to 21,
A program for causing the computer to further execute a process of deleting unused segments and resetting links between segments when data is fetched.
データの登録時に空きエントリがない場合、他プロセスによりデータが取り出され空きエントリができることを待ち合わせる処理と、
データの取り出し時に空きエントリを待ち合わせているプロセスに対しエントリが空いたことを通知して待ち合わせを解除する処理と、
を前記コンピュータにさらに実行させるためのプログラム。The program according to any one of claims 17 to 22,
If there is no free entry when registering data, the process of waiting for the data to be taken out by another process and creating a free entry,
A process of releasing the wait by notifying the process that is waiting for an empty entry when fetching data that the entry is empty;
For causing the computer to further execute.
データの取り出し時に登録されているデータがない場合、他プロセスによりデータが登録されることを待ち合わせる処理と、
データの登録時にデータの登録を待ち合わせているプロセスに対しデータが登録されたことを通知し待ち合わせを解除する処理と、を前記コンピュータにさらに実行させるためのプログラム。The program according to any one of claims 17 to 23,
When there is no data registered at the time of data retrieval, processing to wait for data to be registered by another process,
A program for causing the computer to further execute a process of notifying a process that waits for data registration when registering data that the data has been registered and releasing the wait.
利用者プログラムに前記第1セグメントのアドレスを返却する手段と、
を備え、
前記利用者プログラムは、データの登録、及び取り出しにあたり、前記アドレスをキーとして、前記データ登録手段及び前記データ取り出し手段に対して、データの登録と取り出しをそれぞれ要求する、ことを特徴とする請求項1乃至8のいずれか一に記載のキュー制御システム。The queue generation means generates a ring-shaped link and initializes the queue control information part of the first segment, and then sets a status flag indicating the status of the queue during use,
Means for returning the address of the first segment to the user program;
With
The user program requests registration and retrieval of data from the data registration unit and the data retrieval unit, respectively, using the address as a key when registering and retrieving data. The queue control system according to any one of 1 to 8.
残りのセグメントはキュー制御情報部に設定される情報として、次セグメントのアドレスよりなるリンク情報を有する、ことを特徴とする請求項1乃至8のいずれか一に記載のキュー制御システム。As information set for the first segment in the queue control information section, a registration pointer indicating an entry of a segment for registering data, an extraction pointer indicating an entry of a segment from which data is extracted, and the data registered in the queue And at least link information consisting of the address of the next segment,
The queue control system according to any one of claims 1 to 8, wherein the remaining segment has link information including an address of a next segment as information set in the queue control information section.
前記第1セグメントを除くセグメントのキュー制御情報部には、次セグメントのアドレスよりなるリンク情報のみが設定される、ことを特徴とする請求項1乃至8のいずれか一に記載のキュー制御システム。The first segment has, as a queue control information part, a registration pointer indicating a segment entry for registering data, a fetch pointer indicating a segment entry for extracting data, the number of data registered in the queue, In addition to link information consisting of segment addresses, the number of currently used segments, the initial segment number that is the initial value of the segment, the maximum segment number that indicates the maximum value of the segment, and the exclusive control of the queue It includes columns for storing the exclusive semaphore used, the notification semaphore for inter-process notification, and the number of waiting for managing the number of waiting processes,
9. The queue control system according to claim 1, wherein only the link information including the address of the next segment is set in the queue control information section of the segment excluding the first segment.
前記状態フラグが停止状態でない場合には、キューの再初期化は行わないように制御する手段を備えている、ことを特徴とする請求項4記載のキュー制御システム。The queue re-initialization means checks a status flag indicating a queue status, and when the status flag is in a stopped state, sets an initial value in the queue control information section of the first segment, and sets the initial value The area where the value is set is only the area where the value is updated by using the queue, the state flag is set to in use,
5. The queue control system according to claim 4 , further comprising means for controlling not to re-initialize the queue when the status flag is not in the stopped state.
前記チェックの結果、最終エントリの場合、次の登録ポインタを次のセグメントの先頭エントリとし、最終エントリでない場合、次の登録ポインタを登録ポインタの指すエントリの次のエントリとする手段と、
前記次の登録ポインタがキュー制御情報部の取り出しポインタと一致するか否か判定する手段と、
前記判定の結果、一致する場合、空きエントリなしとして、データ登録を行わず、一致しない場合、登録ポインタの指すエントリへ登録データを移送する制御を行う手段と、
前記第1セグメントのキュー制御情報部の登録ポインタを次のポインタをさすエントリに設定する手段と、
前記第1セグメントのキュー制御情報部のデータ数を1加算する手段と、
を備えている、ことを特徴とする請求項1乃至8のいずれか一に記載のキュー制御システム。The data registration means, when a status flag indicating the status of the queue is in use, means for checking whether the entry pointed to by the registration pointer of the queue control information section of the first segment is the last entry in the segment;
If the result of the check is the last entry, the next registration pointer is the first entry of the next segment, and if it is not the last entry, the next registration pointer is the next entry of the entry pointed to by the registration pointer;
Means for determining whether or not the next registration pointer matches a take-out pointer of the queue control information section;
If the result of the determination is that there is no match, there is no empty entry, data registration is not performed, and if there is no match, means for controlling the transfer of registered data to the entry pointed to by the registration pointer;
Means for setting a registration pointer of the queue control information part of the first segment to an entry indicating a next pointer;
Means for adding 1 to the number of data in the queue control information section of the first segment;
The queue control system according to any one of claims 1 to 8, further comprising:
前記データ数が正整数の場合、前記第1セグメントのキュー制御情報部の取り出しポインタからデータを取得し、前記データ数を1つ減算する手段と、
データを取り出したエントリがセグメント内の最終エントリの場合、取り出しポインタが次のセグメントの第1エントリを指すように設定する手段と、
データを取り出したエントリがセグメント内の最終エントリでない場合、取り出しポインタが次のエントリを指すように設定する手段と、
を備えている、ことを特徴とする請求項1乃至8のいずれか一に記載のキュー制御システム。The data fetching means, if a status flag indicating the status of the queue is in use, means for checking whether the number of data in the queue control information part of the first segment is a positive integer;
If the data number is a positive integer, means for obtaining data from the take-out pointer of the queue control information part of the first segment, and subtracting the data number by one;
Means for setting the fetch pointer to point to the first entry of the next segment if the entry from which the data was fetched is the last entry in the segment;
Means for setting the fetch pointer to point to the next entry if the entry that fetched the data is not the last entry in the segment;
The queue control system according to any one of claims 1 to 8, further comprising:
前記データ数が正整数のとき、前記第1セグメントのキュー制御情報部の登録ポインタの指すエントリ(「登録エントリ」という)がセグメント内の先頭エントリではない場合、登録エントリの1つ前のエントリを指すように登録ポインタを更新する手段と、
前記登録エントリがセグメント内の先頭エントリである場合、登録ポインタが指すセグメントの1つ前のセグメントを求め、該セグメントの最終エントリを指すように登録ポインタを更新する手段と、
前記更新した登録ポインタの指すエントリから、前記利用者プログラムから伝えられたデータ返却領域へデータを移送する手段と、
前記第1セグメントのキュー制御情報部のデータ数から1を減算する手段と、
を備えている、ことを特徴とする請求項2記載のキュー制御システム。The data reverse fetching means, when a status flag indicating a queue status is in use, means for checking the number of data in the queue control information part of the first segment;
When the number of data is a positive integer, if the entry pointed to by the registration pointer in the queue control information section of the first segment (referred to as “registration entry”) is not the first entry in the segment, the entry immediately before the registration entry is Means for updating the registration pointer to point;
If the registration entry is the first entry in the segment, a means for obtaining a previous segment of the segment pointed to by the registration pointer and updating the registration pointer to point to the last entry of the segment;
Means for transferring data from the entry indicated by the updated registration pointer to a data return area transmitted from the user program;
Means for subtracting 1 from the number of data in the queue control information section of the first segment;
The queue control system according to claim 2 , further comprising:
前記キュー拡張手段は、新しいセグメントを1つ生成し、登録セグメントの次セグメントが生成したセグメントとなるように、環状リンクを再設定し、使用セグメント数に1を加算する手段を備え、
セグメントの次セグメントとして新しいキューセグメントが追加され、
前記データ登録手段は、次登録ポインタに追加したセグメントの先頭エントリを設定し、登録エントリへの登録データのエントリを行う、ことを特徴とする請求項5記載のキュー制御システム。When the entry (referred to as “registered entry”) pointed to by the registration pointer in the queue control information part of the first segment is the last entry in the segment, the data registration means If the next segment is the segment pointed to by the fetch pointer and the number of used segments increases by one or less, the registered segment is designated in the queue extension means. Means to control the queue to expand,
The queue extension means includes means for generating one new segment, resetting the circular link so that the next segment of the registered segment is the generated segment, and adding 1 to the number of used segments.
A new queue segment is added as the next segment of the segment,
6. The queue control system according to claim 5 , wherein the data registering means sets the first entry of the segment added to the next registration pointer and enters the registration data into the registration entry.
前記キュー縮退手段は、指定されたセグメントである取り出しセグメントを消去し、指定されたセグメントの前セグメントが次セグメントを指すように、環状リンクを再設定する手段を備えている、ことを特徴とする請求項6記載のキュー制御システム。The data fetching means updates the data fetch pointer to point to the first entry of the next segment when the entry pointed to by the fetch pointer of the queue control information part of the first segment is the last entry in the segment, When the segment pointed to by the registration pointer is not a segment from which data has been extracted (referred to as “extracted segment”), the extracted segment is not the one segment, but is a value obtained by subtracting one from the number of segments used in the queue control information section of the first segment When the number of segments is equal to or greater than the initial number of segments, the queue degeneration means includes means for controlling the degeneration of the queue by designating the take-out segment,
The queue degeneration means comprises means for erasing a fetch segment that is a designated segment and resetting the circular link so that the previous segment of the designated segment points to the next segment. The queue control system according to claim 6 .
待ちあわせが解除され、空きエントリができた場合、前記データ登録手段は、状態フラグのチェックから処理を再実行し、データが登録できた場合であって、前記第1セグメントのキュー制御情報部の待ち合わせ数が0より大きい場合、前記データ登録手段は、前記第1セグメントのキュー制御情報部の通知セマフォに対し通知を行い、待ち合わせているプロセスを起動する制御を行う、ことを特徴とする請求項7に記載のキュー制御システム。When the entry pointed to by the set next registration pointer is the same as the entry pointed to by the takeout pointer of the queue control information section of the first segment, the data registration means uses the waiting means to allow other processes to Wait for the data to be retrieved and a free entry to be made,
When the waiting is canceled and a free entry is made, the data registration means re-executes the processing from the check of the status flag, and when the data can be registered, the queue control information section of the first segment waits. 8. If the number is larger than 0, the data registration means notifies the notification semaphore of the queue control information section of the first segment, and controls to start a waiting process. The queue control system described in.
前記データ登録手段、前記データ取り出し手段、前記データ逆取り出し手段、前記キュー停止手段の少なくとも1つからの通知により待ち合わせが解除され、
その後、前記待ち合わせ手段は、前記キュー排他手段によりキューを排他し、前記第1セグメントのキュー制御情報部の待ち合わせ数から1を減算する、ことを特徴とする請求項7に記載のキュー制御システム。The waiting means adds 1 to the number of waiting in the queue control information section of the first segment, releases the exclusion of the queue using the queue exclusion means, and uses the notification semaphore in the queue control information section of the first segment. Make a meeting,
Waiting is canceled by notification from at least one of the data registration unit, the data extraction unit, the data reverse extraction unit, and the queue stop unit,
8. The queue control system according to claim 7, wherein the waiting means excludes the queue by the queue exclusion means and subtracts 1 from the waiting number in the queue control information section of the first segment.
待ちあわせが解除され、データが登録されたら、前記データ取り出し手段は、状態フラグのチェックから処理を再実行し、データを取り出し、ポインタの更新が完了した場合に、前記第1セグメントのキュー制御情報部の待ち合わせ数が0より大きい場合には、前記データ取り出し手段は、前記第1セグメントのキュー制御情報部の通知セマフォに対し通知を行い、待ち合わせているプロセスを起動する制御を行う、ことを特徴とする請求項7に記載のキュー制御システム。The data fetching means waits for registration of data by another process using the waiting means when the number of data in the queue control information part of the first segment is 0,
When the waiting is released and the data is registered, the data fetching unit re-executes the processing from the status flag check, fetches the data, and when the pointer update is completed, the queue control information part of the first segment If the number of waiting times is greater than 0, the data fetching means performs control to notify the notification semaphore of the queue control information section of the first segment and to start the waiting process. The queue control system according to claim 7.
待ちあわせが解除された、すなわちデータが登録されたら、前記データ逆取り出し手段は、状態フラグのチェックから処理を再実行し、データの取り出しが完了した場合に、前記第1セグメントのキュー制御情報部の待ち合わせ数が0より大きい場合には、前記データ逆取り出し手段は、前記第1セグメントのキュー制御情報部の通知セマフォに対し通知を行い、待ち合わせているプロセスを起動する制御を行う、ことを特徴とする請求項7に記載のキュー制御システム。When the user program fetches data from the queue, the data reverse fetching means uses the waiting means when the number of data in the queue control information section of the first segment is 0, and is determined by another process. Wait for data registration,
When the waiting is released, that is, when the data is registered, the data reverse fetching means re-executes the processing from the status flag check, and when the data fetching is completed, the queue control information part of the first segment When the number of waiting is larger than 0, the data reverse fetching means performs control to notify the notification semaphore of the queue control information part of the first segment and to start the waiting process. The queue control system according to claim 7.
請求項1乃至8、25乃至40のいずれか一に記載のキュー制御システムを備えている、ことを特徴とするキュー制御システム。In a system that uses a virtual storage method and manages computer segments that manage virtual storage space by segmentation in a queue,
A queue control system comprising the queue control system according to any one of claims 1 to 8 and 25 to 40.
前記利用者プログラムは、前記アドレスをキーとして、データの登録及び取り出しを要求するステップと、
を含む、ことを特徴とする請求項9乃至16のいずれか一に記載のキュー制御方法。In generating the queue, after initial setting the queue control information portion of the first segment, set the status flag to in use, returning the address of the first segment to the user program;
The user program requests registration and retrieval of data using the address as a key;
The queue control method according to claim 9, further comprising:
残りのセグメントはキュー制御情報部として、次セグメントのアドレスよりなるリンク情報を有する、ことを特徴とする請求項9乃至16のいずれか一に記載のキュー制御方法。The first segment, as a queue control information section, includes a registration pointer indicating a segment entry for registering data, a fetch pointer indicating a segment entry for extracting data, the number of registered data, the number of segments, and the address of the next segment. Have link information,
The queue control method according to any one of claims 9 to 16, wherein the remaining segment has link information including an address of a next segment as a queue control information section.
前記第1セグメントを除くセグメントのキュー制御情報部には、次セグメントのアドレスよりなるリンク情報のみが設定される、ことを特徴とする請求項9乃至16のいずれか一に記載のキュー制御方法。The first segment has, as a queue control information part, a registration pointer indicating a segment entry for registering data, a fetch pointer indicating a segment entry for extracting data, the number of data registered in the queue, In addition to link information consisting of segment addresses, the number of currently used segments, the initial segment number that is the initial value of the segment, the maximum segment number that indicates the maximum value of the segment, and the exclusive control of the queue It includes columns for storing the exclusive semaphore used, the notification semaphore for inter-process notification, and the number of waiting for managing the number of waiting processes,
The queue control method according to any one of claims 9 to 16, wherein only the link information including the address of the next segment is set in the queue control information section of the segment excluding the first segment.
状態が停止状態である場合、前記第1セグメントのキュー制御情報部に初期値を設定するステップを有し、
前記初期値を設定する領域はキューの使用により値が更新される領域のみとされ、
前記状態フラグを使用中状態に設定するステップを有する、
ことを特徴とする請求項9乃至16のいずれか一に記載のキュー制御方法。Checking if the status flag indicating the status of the queue is stopped when reinitializing the queue;
When the state is a stopped state, the method includes a step of setting an initial value in the queue control information part of the first segment,
The area where the initial value is set is only the area where the value is updated by using a queue,
Setting the state flag to a busy state;
The queue control method according to any one of claims 9 to 16, wherein
状態が使用中である場合、前記第1セグメントのキュー制御情報部の登録ポインタの指すエントリがセグメント内の最終エントリかチェックするステップと、
最終エントリの場合、次の登録ポインタを次のセグメントの先頭エントリとするステップと、
最終エントリでない場合、次の登録ポインタを登録ポインタの指すエントリの次のエントリとするステップと、
前記次の登録ポインタが前記第1セグメントのキュー制御情報部の取り出しポインタと一致するか否か判定するステップと、一致しない場合、登録ポインタの指すエントリへ登録データを移送するステップと、
を有し、
一方、前記次の登録ポインタが前記第1セグメントのキュー制御情報部の取り出しポインタと一致する場合、空きエントリなしとしてデータ登録を行わず、
前記第1セグメントのキュー制御情報部の登録ポインタを次のポインタをさすエントリに設定するステップと、
前記第1セグメントのキュー制御情報部のデータ数を1加算するステップと、
を含む、ことを特徴とする請求項9乃至16のいずれか一に記載のキュー制御方法。In registering the data, checking whether a status flag indicating the status of the queue is in use;
If the status is in use, checking whether the entry pointed to by the registration pointer in the queue control information section of the first segment is the last entry in the segment;
In the case of the last entry, the step of setting the next registration pointer as the first entry of the next segment,
If it is not the last entry, the step of setting the next registration pointer as the next entry of the entry pointed to by the registration pointer;
Determining whether the next registration pointer matches the take-out pointer of the queue control information section of the first segment; if not, transferring registration data to the entry pointed to by the registration pointer;
Have
On the other hand, if the next registration pointer matches the take-out pointer of the queue control information part of the first segment, data registration is not performed as no empty entry,
Setting a registration pointer of the queue control information part of the first segment to an entry indicating a next pointer;
Adding 1 to the number of data in the queue control information section of the first segment;
The queue control method according to claim 9, further comprising:
状態が使用中ある場合、前記第1セグメントのキュー制御情報部のデータ数が正整数であるかチェックするステップと、
前記データ数が正整数の場合、前記第1セグメントのキュー制御情報部の取り出しポインタからデータを取得するステップと、
前記第1セグメントのキュー制御情報部のデータ数を1つ減算するステップ、データを取り出したエントリがセグメント内の最終エントリの場合、取り出しポインタが次のセグメントの第1エントリを指すように設定するステップと、
セグメント内の最終エントリでない場合、取り出しポインタが次のエントリを指すように設定するステップと、
を含む、ことを特徴とする請求項9乃至16のいずれか一に記載のキュー制御方法。In retrieving the data, checking whether a status flag indicating the status of the queue is in use;
If the state is in use, checking whether the number of data in the queue control information part of the first segment is a positive integer;
When the number of data is a positive integer, obtaining data from a takeout pointer of the queue control information portion of the first segment;
Subtracting 1 from the number of data in the queue control information section of the first segment, and setting the fetch pointer to point to the first entry of the next segment if the entry from which the data was fetched is the last entry in the segment When,
If not the last entry in the segment, setting the fetch pointer to point to the next entry;
The queue control method according to claim 9, further comprising:
状態が使用中である場合、前記第1セグメントのキュー制御情報部のデータの数をチェックするステップと、
データ数が正整数のとき、前記第1セグメントのキュー制御情報部の登録ポインタの指すエントリ(「登録エントリ」という)がセグメント内の先頭エントリではない場合、登録エントリの1つ前のエントリを指すように登録ポインタを更新するステップと、
前記登録エントリがセグメント内の先頭エントリである場合、登録ポインタが指すセグメントの1つ前のセグメントを求め、該セグメントの最終エントリを指すように登録ポインタを更新するステップと、
更新した登録ポインタの指すエントリから、前記利用者プログラムから伝えられたデータ返却領域へデータを移送するステップと、
前記第1セグメントのキュー制御情報部のデータ数から1減算するステップ、
を含む、ことを特徴とする請求項10記載のキュー制御方法。Checking whether the status flag of the first segment is in use when retrieving data from the entry immediately before the entry pointed to by the registration pointer of the queue control information part of the first segment;
If the status is in use, checking the number of data in the queue control information part of the first segment;
When the number of data is a positive integer, if the entry pointed to by the registration pointer in the queue control information part of the first segment (referred to as “registered entry”) is not the first entry in the segment, it points to the entry immediately before the registered entry Updating the registration pointer so that
When the registration entry is the first entry in the segment, obtaining a segment immediately preceding the segment pointed to by the registration pointer, and updating the registration pointer to point to the last entry of the segment;
Transferring the data from the entry indicated by the updated registration pointer to the data return area transmitted from the user program;
Subtracting 1 from the number of data in the queue control information section of the first segment;
The queue control method according to claim 10 , further comprising:
前記第1セグメントのキュー制御情報部の登録ポインタの指すエントリ(「登録エントリ」という)がセグメント内の最終エントリである場合、登録ポインタの指すセグメント(「登録セグメント」という)の次セグメントが、前記第1セグメントのキュー制御情報部の取り出しポインタが指しているセグメントであり、使用セグメント数を1つ増加しても、予め定められた最大セグメント数を超えない場合、登録セグメントを指定してキューを拡張させるステップと、
前記キュー拡張ステップでは、新しいセグメントを1つ生成し、登録セグメントの次セグメントが生成したセグメントとなるように、環状リンクを再設定するステップと、
前記第1セグメントのキュー制御情報部の使用セグメント数に1を加算し、登録セグメントの次セグメントとして新しいキューセグメントが追加するステップと、
次登録ポインタに追加したセグメントの先頭エントリを設定するステップと、
を有し、
登録セグメントの次セグメントが取り出しポインタが指しているセグメントではない場合には、新たなセグメントは生成せず、また、前記第1セグメントのキュー制御情報部の使用セグメント数に1加算した値が最大セグメント数より大となる場合には、新たなセグメントを生成しないように制御するステップを、さらに含む、ことを特徴とする請求項9乃至16のいずれか一に記載のキュー制御方法。In the data registration step when the user program registers data in the queue,
When the entry (referred to as “registered entry”) pointed to by the registration pointer in the queue control information part of the first segment is the last entry in the segment, the next segment of the segment pointed to by the registration pointer (referred to as “registered segment”) If the fetch pointer in the queue control information section of the first segment is the segment pointed to, and the number of segments used is increased by one, the maximum number of segments that has been set in advance will not be exceeded. Expanding steps,
In the queue extension step, a new segment is generated, and the circular link is reset so that the next segment of the registered segment is the generated segment;
Adding 1 to the number of used segments in the queue control information section of the first segment, and adding a new queue segment as the next segment of the registered segment;
Setting the first entry of the segment added to the next registration pointer;
Have
If the next segment of the registered segment is not the segment pointed to by the fetch pointer, no new segment is generated, and the value obtained by adding 1 to the number of used segments in the queue control information section of the first segment is the maximum segment. The queue control method according to claim 9, further comprising a step of controlling not to generate a new segment when the number is larger than the number.
前記第1セグメントのキュー制御情報部の取り出しポインタの指すエントリがセグメント内の最終エントリである場合、次セグメントの先頭エントリを指すようにデータ取り出しポインタを更新するステップを有し、
その際、前記第1セグメントのキュー制御情報部の登録ポインタが指すセグメントがデータを取り出したセグメント(「取り出しセグメント」という)でない場合、取り出しセグメントが前記1つのセグメントではなく、前記第1セグメントのキュー制御情報部の使用セグメント数を1つ減算しても前記第1セグメントのキュー制御情報部の初期セグメント数を下回らない場合、取り出しセグメントを指定してキューを縮退させ、
前記キュー縮退ステップは、指定されたセグメントである取り出しセグメントを消去し、指定されたセグメントの前セグメントが次セグメントを指すように、環状リンクを再設定するステップと、
登録ポインタの指すセグメントが取り出しセグメントである場合、取り出しセグメントが前記1つのセグメントの場合、及び、前記使用セグメント数から1減算した値が前記第1セグメントのキュー制御情報部の初期セグメント数よりも小の場合には、セグメントを削除しないように制御するステップを、さらに含む、ことを特徴とする請求項9乃至16のいずれか一に記載のキュー制御方法。In the data fetching step when the user program fetches data from the queue, if the entry pointed to by the fetch pointer in the queue control information part of the first segment is the last entry in the segment, the first entry of the next segment is pointed to Updating the data retrieval pointer;
At this time, if the segment pointed to by the registration pointer in the queue control information section of the first segment is not a segment from which data has been extracted (referred to as “extracted segment”), the extracted segment is not the one segment but the queue of the first segment. If the number of used segments in the control information section is subtracted by 1 and does not fall below the initial number of segments in the queue control information section of the first segment, the take-out segment is designated to degenerate the queue,
The queue degeneration step comprises erasing a fetch segment that is a designated segment and resetting the circular link so that the previous segment of the designated segment points to the next segment;
When the segment pointed to by the registration pointer is a fetch segment, when the fetch segment is the one segment, and the value obtained by subtracting 1 from the number of used segments is smaller than the initial segment number of the queue control information section of the first segment The queue control method according to claim 9, further comprising a step of controlling not to delete the segment.
前記第1セグメントのキュー制御情報部の登録ポインタが指すエントリがセグメント内の先頭エントリである場合、前セグメントの最終エントリを指すように登録ポインタを更新し、その際、更新前の登録ポインタが指していたセグメント(「元セグメント」という)が取り出しポインタの指すセグメントではない場合、元セグメントが第1セグメントではなく、過去にキューの拡張が起こっており、前記第1セグメントのキュー制御情報部の使用セグメント数から1減算した値が初期セグメント数以上である場合、キュー縮退ステップに元セグメントを指定してキューを縮退させるステップと、
更新前の登録ポインタが指していたセグメント(「元セグメント」という)が取り出しポインタの指すセグメントの場合は、元セグメントが第1セグメントの場合、及び、前記第1セグメントのキュー制御情報部の使用セグメント数から1減算した値が初期セグメント数より小となる場合には、セグメントを削除しないように制御するステップと、を含む、ことを特徴とする請求項10乃至16のいずれか一に記載のキュー制御方法。In the data reverse retrieval step when the user program retrieves data from the queue in the LIFO (Last In First Out) format,
When the entry pointed to by the registration pointer in the queue control information section of the first segment is the first entry in the segment, the registration pointer is updated to point to the last entry of the previous segment, and at this time, the registration pointer before the update points to When the segment that has been stored (referred to as “original segment”) is not the segment pointed to by the fetch pointer, the original segment is not the first segment, queue expansion has occurred in the past, and the queue control information portion of the first segment is used If the value obtained by subtracting 1 from the number of segments is equal to or greater than the initial number of segments, the step of degenerating the queue by designating the original segment in the queue degeneration step;
When the segment pointed to by the registration pointer before the update (referred to as “original segment”) is the segment pointed to by the extraction pointer, the segment used by the queue control information section of the first segment when the original segment is the first segment The queue according to any one of claims 10 to 16, further comprising a step of controlling not to delete a segment when a value obtained by subtracting 1 from the number is smaller than an initial segment number. Control method.
前記データ登録ステップにて、待ちあわせが解除され、空きエントリができたら、キューの状態を示す状態フラグのチェックから処理を再実行するステップと、
データが登録できた場合に、前記第1セグメントのキュー制御情報部の待ち合わせ数が0より大きい場合、前記データ登録ステップは、前記第1セグメントのキュー制御情報部の通知セマフォに対し通知を行い、待ち合わせているプロセスを起動するステップと、
を含む、ことを特徴とする請求項9乃至16のいずれか一に記載のキュー制御方法。When the user program registers data in the queue, in the data registration step, when the entry pointed to by the set next registration pointer is the same as the entry pointed to by the take-out pointer of the queue control information section of the first segment, Waiting for another process to retrieve data and make a free entry;
In the data registration step, when waiting is canceled and a free entry is made, the process is re-executed from the check of the status flag indicating the status of the queue;
When the data can be registered and the number of waiting in the queue control information part of the first segment is larger than 0, the data registration step notifies the notification semaphore of the queue control information part of the first segment, Starting a process that is waiting,
The queue control method according to claim 9, further comprising:
データ登録、データ取り出し,データ逆取り出し,あるいはキュー停止ステップからの通知により待ち合わせが解除され、
その後、キューを排他し、前記第1セグメントのキュー制御情報部の待ち合わせ数から1を減算するステップを含む、ことを特徴とする請求項54記載のキュー制御方法。In the waiting step, adding 1 to the number of waiting in the queue control information part of the first segment, releasing the exclusion of the queue, and waiting in the notification semaphore of the queue control information part of the first segment;
Waiting is canceled by notification from data registration, data retrieval, data reverse retrieval, or queue stop step,
55. The queue control method according to claim 54, further comprising: excluding the queue and subtracting 1 from the number of waiting in the queue control information section of the first segment.
データ逆取り出しステップでは、前記第1セグメントのキュー制御情報部のデータ数が0である場合には、他プロセスによるデータの登録を待ち合わせるステップと、
待ちあわせが解除され、データが登録されたら、データ逆取り出しステップでは、状態フラグのチェックから処理を再実行するステップと、
データの取り出しが完了した場合に、前記第1セグメントのキュー制御情報部の待ち合わせ数が0より大きい場合には、データ逆取り出しステップは、前記第1セグメントのキュー制御情報部の通知セマフォに対し通知を行い、待ち合わせているプロセスを起動するステップと、
を含む、ことを特徴とする請求項10乃至16のいずれか一に記載のキュー制御方法。When the user program retrieves data from the queue,
In the data reverse extraction step, when the number of data in the queue control information part of the first segment is 0, waiting for data registration by another process;
When waiting is canceled and data is registered, in the data reverse fetching step, the process is re-executed from the status flag check;
When the data fetching is completed, if the number of waiting in the queue control information part of the first segment is greater than 0, the data reverse fetching step notifies the notification semaphore of the queue control information part of the first segment. And launching the waiting process,
The queue control method according to claim 10, further comprising:
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2002152227A JP3823878B2 (en) | 2002-05-27 | 2002-05-27 | Queue control system, queue control method, and queue control program |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2002152227A JP3823878B2 (en) | 2002-05-27 | 2002-05-27 | Queue control system, queue control method, and queue control program |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JP2003345611A JP2003345611A (en) | 2003-12-05 |
| JP3823878B2 true JP3823878B2 (en) | 2006-09-20 |
Family
ID=29769604
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2002152227A Expired - Fee Related JP3823878B2 (en) | 2002-05-27 | 2002-05-27 | Queue control system, queue control method, and queue control program |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP3823878B2 (en) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106685856B (en) * | 2016-12-30 | 2020-03-31 | 国网浙江省电力公司绍兴供电公司 | Method, system and equipment for processing mass network messages of intelligent substation |
| CN120429320B (en) * | 2025-06-27 | 2025-10-14 | 中债数字金融科技有限公司 | Database log processing method and device, storage medium and electronic equipment |
-
2002
- 2002-05-27 JP JP2002152227A patent/JP3823878B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JP2003345611A (en) | 2003-12-05 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP3815967B2 (en) | Method and apparatus for transferring data from a cache of one node to a cache of another node | |
| JP2559784B2 (en) | Virtual processing method and virtual processor in multiprocessor array | |
| US6848021B2 (en) | Efficient data backup using a single side file | |
| JPH0954754A (en) | Customer information control system and method in loosely coupled parallel processing environment | |
| JPH0778098A (en) | File management system | |
| EP0533805A1 (en) | Method for efficient non-virtual main memory management | |
| JPH08235046A (en) | Shared data processing device and shared data processing system | |
| US7509443B2 (en) | Storage management system and method using performance values to obtain optimal input/output paths within a storage network | |
| JP2009110477A (en) | File management apparatus and file management program | |
| EP0747813A2 (en) | Customer information control system and method with temporary storage queuing functions in a loosely coupled parallel processing environment | |
| CN112905325A (en) | Method, system and medium for distributed data cache accelerated training | |
| US6708237B1 (en) | Method and apparatus for managing data access and storage of data located on multiple storage devices | |
| CN120125419A (en) | Instruction scheduling device and method thereof, processor, electronic device and storage medium | |
| CN108990422A (en) | A kind of method, apparatus and calculating equipment of lock distribution | |
| JP3823878B2 (en) | Queue control system, queue control method, and queue control program | |
| JPH0944461A (en) | System and method for control of customer information with api start and cancel transaction function in loosely-coupledparallel processing environment | |
| JPH10283228A (en) | System for compressing log stream of multi-system environment | |
| CN113254223B (en) | Resource allocation method, system and related components after system restart | |
| EP3388943A1 (en) | Method and apparatus for managing events in a network that adopts event-driven programming framework | |
| JPH10289217A (en) | Log stream management system | |
| CN108121514A (en) | Metamessage update method, device, computing device and computer storage media | |
| CN114820218A (en) | Content operation method, device, server and storage medium | |
| US8386527B2 (en) | Method and system for efficiently sharing array entries in a multiprocessing environment | |
| CN109344091B (en) | A buffer array regularization method, device, terminal and readable medium | |
| JPWO2005106713A1 (en) | Information processing method and information processing system |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20060124 |
|
| A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20060320 |
|
| TRDD | Decision of grant or rejection written | ||
| A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20060606 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20060619 |
|
| R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20100707 Year of fee payment: 4 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110707 Year of fee payment: 5 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110707 Year of fee payment: 5 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120707 Year of fee payment: 6 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120707 Year of fee payment: 6 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130707 Year of fee payment: 7 |
|
| LAPS | Cancellation because of no payment of annual fees |