Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
JP2518134B2 - Shared resource exclusive control method - Google Patents
[go: Go Back, main page]

JP2518134B2 - Shared resource exclusive control method - Google Patents

Shared resource exclusive control method

Info

Publication number
JP2518134B2
JP2518134B2 JP5093656A JP9365693A JP2518134B2 JP 2518134 B2 JP2518134 B2 JP 2518134B2 JP 5093656 A JP5093656 A JP 5093656A JP 9365693 A JP9365693 A JP 9365693A JP 2518134 B2 JP2518134 B2 JP 2518134B2
Authority
JP
Japan
Prior art keywords
lock
task
resource
priority
request
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 - Lifetime
Application number
JP5093656A
Other languages
Japanese (ja)
Other versions
JPH06282448A (en
Inventor
善尚 鈴木
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
Nippon Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nippon Electric Co Ltd filed Critical Nippon Electric Co Ltd
Priority to JP5093656A priority Critical patent/JP2518134B2/en
Publication of JPH06282448A publication Critical patent/JPH06282448A/en
Application granted granted Critical
Publication of JP2518134B2 publication Critical patent/JP2518134B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Description

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

【0001】[0001]

【産業上の利用分野】本発明は共有資源排他制御方式に
関し、特に計算機システムの共有資源排他制御方式に関
する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a shared resource exclusive control system, and more particularly to a shared resource exclusive control system for a computer system.

【0002】[0002]

【従来の技術】計算機システムにおいて複数のタスクか
ら使用される資源については、それへのアクセスを逐次
化するために排他制御が必要である。このような排他制
御のために、計算機システムには、ロック/アンロック
(あるいはENQ/DEQ)と呼ばれる基本機能が備え
られており、ロック要求には通常排他モードと共有モー
ドとの2種類がある。
2. Description of the Related Art A resource used by a plurality of tasks in a computer system requires exclusive control in order to serialize access to the resource. For such exclusive control, the computer system is provided with a basic function called lock / unlock (or ENQ / DEQ), and there are two types of lock requests, a normal exclusive mode and a shared mode. .

【0003】排他制御の基本的動作は、次のようなもの
である。あるタスクがロック要求を出したとき、ロック
要求対象資源が他のタスクによりロックされていない場
合、または、その資源のロックモードと該タスクのロッ
ク要求のモードとがともに共有モードの場合、すぐにロ
ック権が付与される。しかし、その資源のロックモー
ド、または該タスクのロック要求のモードが排他モード
の場合には、ロック待ちとなる。
The basic operation of exclusive control is as follows. When a task issues a lock request, if the lock request target resource is not locked by another task, or if the lock mode of the resource and the lock request mode of the task are both in shared mode, immediately Lock right is granted. However, when the lock mode of the resource or the lock request mode of the task is the exclusive mode, the lock is waited.

【0004】また、資源をロックしていたタスクがアン
ロック要求を出したときは、該タスクのロック権の行使
が終了する。他にロックしているタスクがなく、かつロ
ック待ちタスクがあり、それらのうちの最も早くロック
要求したタスクの要求モードが排他モードの場合は、該
タスクのみにロック権を付与し、共有モードならば現在
共有モードでロック待ちしているタスクすべてにロック
権を付与する。
When the task that has locked the resource issues an unlock request, the exercise of the lock right of the task ends. If there is no other locked task and there is a lock waiting task, and the request mode of the task that made the lock request earliest among them is the exclusive mode, the lock right is given only to that task, and if it is the shared mode. For example, it grants the lock right to all tasks currently waiting for the lock in shared mode.

【0005】従来技術の文献としては、例えば特開平2
−118843号公報,特開平3−83142号公報等
がある。
As a prior art document, for example, Japanese Unexamined Patent Publication No. Hei.
There are Japanese Patent Laid-Open No. 118843 and Japanese Patent Laid-Open No. 3-83142.

【0006】[0006]

【発明が解決しようとする課題】上述した従来の共有資
源排他制御方式では、複数の資源を同時に使用して処理
するときに各資源に対し逐次ロック要求するが、いくつ
かの資源のロックが成功し、次の資源をロックしようと
してロック待ちとなった場合、すでにロックした資源に
対してロック待ちしている他のタスクの待ち時間が不必
要に長くなり、資源の使用効率が低下するという欠点が
ある。
In the above-mentioned conventional shared resource exclusive control method, when a plurality of resources are simultaneously used and processed, a lock request is issued to each resource, but some resources are successfully locked. However, if a lock wait occurs while trying to lock the next resource, the waiting time of other tasks waiting for the lock of the already locked resource becomes unnecessarily long, and the resource usage efficiency decreases. There is.

【0007】本発明の目的は、上述の点に鑑み、後続の
ロック待ちタスクのロック待ち時間を減少させるととも
に共有資源の使用効率を向上させるようにした共有資源
排他制御方式を提供することにある。
In view of the above points, an object of the present invention is to provide a shared resource exclusive control system which reduces the lock waiting time of the subsequent lock waiting task and improves the use efficiency of the shared resource. .

【0008】[0008]

【課題を解決するための手段】本発明の共有資源排他制
御方式は、計算機システムの共有資源排他制御方式にお
いて、あらかじめ各資源に重みを設定しておき、タスク
のロック中資源のうちのロック待ちしているタスクが存
在する資源の重みの和xの関数f(x)(a>bならば
f(a)≧f(b)が成立し、かつf(c)>f(d)
を満たすc>dなるcおよびdが存在する関数)によっ
て算出された値を、該タスクのロック優先度として設定
するロック優先度設定手段と、ロック待ちタスクへのロ
ック権付与順序がロック優先度の高い順となるようロッ
ク待ち行列を並べ換えるロック順序変更手段とを有す
る。
According to the shared resource exclusive control method of the present invention, in the shared resource exclusive control method of a computer system, a weight is set in advance for each resource, and the lock waiting of the locked resources of the task is waited for. The function f (x) of the sum x of the weights of the resources in which the task is present (if a> b, f (a) ≧ f (b) is satisfied, and f (c)> f (d)
A value calculated by a function satisfying c> d and c satisfying c> d) that satisfies the above condition, and a lock priority setting unit that sets a value as a lock priority of the task, and a lock right is assigned to the lock waiting task. Lock order changing means for rearranging the lock queues so that the lock queues are arranged in descending order.

【0009】[0009]

【実施例】次に、本発明について図面を参照して詳細に
説明する。
The present invention will be described in detail with reference to the drawings.

【0010】図1は、本発明の一実施例に係る共有資源
排他制御方式の構成を示すブロック図である。本実施例
の共有資源排他制御方式を実現する共有資源排他制御機
能7は、ロック要求の処理を行うロック要求処理手段1
と、アンロック要求の処理を行うアンロック要求処理手
段2と、ロック優先度の高い順にロック待ち行列を並べ
換えるロック順序変更手段3と、タスクのロック中資源
のうちのロック待ちしているタスクが存在する資源の重
みの和の関数で算出される値を該タスクのロック優先度
として設定するロック優先度設定手段4と、排他制御テ
ーブル5と、ロック優先度テーブル6とから構成されて
いる。なお、図1中、符号T1〜Tn(nは正整数)
は、共有資源使用タスク(以下、単にタスクという)を
示す。
FIG. 1 is a block diagram showing the configuration of a shared resource exclusive control system according to an embodiment of the present invention. The shared resource exclusive control function 7 for realizing the shared resource exclusive control method of the present embodiment is a lock request processing means 1 for processing a lock request.
An unlock request processing means 2 for processing an unlock request, a lock order changing means 3 for rearranging the lock queues in order of high lock priority, and a task waiting for a lock among the locked resources of the task. Is composed of a lock priority setting means 4 for setting a value calculated by a function of the sum of weights of existing resources as the lock priority of the task, an exclusive control table 5, and a lock priority table 6. . In FIG. 1, symbols T1 to Tn (n is a positive integer)
Indicates a shared resource use task (hereinafter, simply called a task).

【0011】排他制御テーブル5は、図2に示すよう
に、計算機システム内の排他制御対象資源を一意に識別
するための名前である資源名をキーとする。各資源に対
するエントリは、資源名部と、重み部と、ロックモード
部と、ロック中タスクリストと、ロック待ち行列とから
なる。重み部は、その資源の重みを記録する。ロックモ
ード部は、資源がロックされているときのロックモード
を記録する。ロック中タスクリストは、その資源をロッ
クしているタスクのタスク識別子を記録する。ロック待
ち行列は、ロック待ち状態にあるロック要求の待ち行列
であり、これらのロック要求を出しているタスクのタス
ク識別子とロックモードとの組を記録する。
As shown in FIG. 2, the exclusive control table 5 uses a resource name, which is a name for uniquely identifying the exclusive control target resource in the computer system, as a key. The entry for each resource consists of a resource name part, a weight part, a lock mode part, a locked task list, and a lock queue. The weight section records the weight of the resource. The lock mode section records the lock mode when the resource is locked. The locked task list records task identifiers of tasks that lock the resource. The lock queue is a queue of lock requests in a lock wait state, and records a set of task identifiers and lock modes of tasks issuing these lock requests.

【0012】ロック優先度テーブル6は、図2に示すよ
うに、計算機システム内のタスクを一意に識別するため
の名前であるタスク識別子をキーとする。各タスクに対
するエントリは、タスク識別子部と、ロック待ち資源名
部と、重み総和部と、ロック優先度部とからなる。ロッ
ク待ち資源名部は、そのタスクがロック待ちしている資
源の資源名を記録する。重み総和部は、そのタスクがロ
ックしている資源のうちのロック待ちしているタスクが
存在している資源の重みの和を記録する。ロック優先度
部は、そのタスクのロック優先度を記録する。
As shown in FIG. 2, the lock priority table 6 uses a task identifier, which is a name for uniquely identifying a task in the computer system, as a key. The entry for each task consists of a task identifier part, a lock wait resource name part, a weight summation part, and a lock priority part. The lock waiting resource name section records the resource name of the resource waiting for the lock of the task. The weight summation unit records the sum of the weights of the resources in which the task waiting for the lock exists among the resources locked by the task. The lock priority section records the lock priority of the task.

【0013】ロック要求処理手段1は、下記(1)また
は(2)のロック要求の処理を行う。
The lock request processing means 1 performs the following lock request processing (1) or (2).

【0014】(1) ロック要求の対象資源に対応する
排他制御テーブル5のエントリのロックモード部(以
下、特に断らない限り、単に重み部,ロックモード部,
ロック中タスクリストおよびロック待ち行列と呼んだと
きには、ロック要求またはアンロック要求の対象資源に
対応する排他制御テーブル5のエントリを考える)が空
の場合、またはロックモード部と該ロック要求のロック
モードとがともに共有モードの場合は、ロック要求処理
手段1は、ロックモード部に該ロック要求のロックモー
ドを記録し、ロック中タスクリストに該ロック要求を出
したタスクのタスク識別子を追加する。次に、ロック要
求処理手段1は、ロック待ち行列が空でなければ、該ロ
ック要求の対象資源の資源名と該ロック要求を出したタ
スクのタスク識別子と優先度増加要求の旨とをパラメー
タとしてロック優先度設定手段4を呼び出す。最後に、
ロック要求処理手段1は、該ロック要求を出したタスク
の処理を中断させる。
(1) The lock mode part of the entry of the exclusive control table 5 corresponding to the target resource of the lock request (hereinafter, unless otherwise specified, the weight part, the lock mode part,
When calling the locked task list and the lock queue, consider the entry in the exclusive control table 5 corresponding to the target resource of the lock request or unlock request), or if the lock mode part and the lock mode of the lock request If both are in the shared mode, the lock request processing means 1 records the lock mode of the lock request in the lock mode section, and adds the task identifier of the task issuing the lock request to the locked task list. Next, if the lock queue is not empty, the lock request processing means 1 uses the resource name of the target resource of the lock request, the task identifier of the task that issued the lock request, and the effect of the priority increase request as parameters. The lock priority setting means 4 is called. Finally,
The lock request processing means 1 suspends the processing of the task that issued the lock request.

【0015】(2) ロックモード部が空でなくかつ該
ロック要求のロックモードが排他モードの場合、または
ロックモード部が排他モードの場合は、ロック要求処理
手段1は、該ロック要求を出したタスクのタスク識別子
とロックモードとの組をロック待ち行列の最後に追加
し、該タスクのタスク識別子に対応するロック優先度テ
ーブル6のロック待ち資源名部(以下、特に断らない限
り、単にロック待ち資源名部,重み総和部およびロック
優先度部と呼んだときには、タスクに対応するロック優
先度テーブル6のエントリを考える)に該ロック要求の
対象資源の資源名を記録し、該資源名をパラメータとし
てロック順序変更手段3を呼び出す。次に、ロック要求
処理手段1は、ロック待ち行列に記録されている要求の
数が1ならば、ロック中タスクリストに記録されている
各タスクに対し、そのタスクのタスク識別子と該ロック
要求の対象資源の資源名と優先度増加要求の旨とをパラ
メータとしてロック優先度設定手段4を呼び出し、その
タスクに対応するロック優先度テーブル6のエントリの
ロック待ち資源名部が空でない場合は、該ロック待ち資
源名部の資源名をパラメータとしてロック順序変更手段
3を呼び出す。最後に、ロック要求処理手段1は、該ロ
ック要求を出したタスクの処理を中断させる。
(2) When the lock mode unit is not empty and the lock mode of the lock request is the exclusive mode, or when the lock mode unit is the exclusive mode, the lock request processing means 1 issues the lock request. A pair of a task identifier and a lock mode of a task is added to the end of the lock queue, and the lock wait resource name part of the lock priority table 6 corresponding to the task identifier of the task (hereinafter simply referred to as lock wait unless otherwise noted). When calling the resource name part, the total weight part, and the lock priority part, consider the entry of the lock priority table 6 corresponding to the task), record the resource name of the target resource of the lock request, and use the resource name as a parameter. Then, the lock order changing means 3 is called. Next, if the number of requests recorded in the lock queue is 1, the lock request processing means 1 gives, for each task recorded in the locked task list, the task identifier of the task and the lock request. When the lock priority setting means 4 is called with the resource name of the target resource and the request for the priority increase request as parameters, and the lock waiting resource name part of the entry of the lock priority table 6 corresponding to the task is not empty, The lock order changing means 3 is called with the resource name in the lock waiting resource name section as a parameter. Finally, the lock request processing means 1 suspends the processing of the task that issued the lock request.

【0016】アンロック要求処理手段2は、アンロック
要求の処理を行い、該アンロック要求を出したタスクの
タスク識別子をロック中タスクリストから削除し、ロッ
ク待ち行列が空でない場合は、該アンロック要求を出し
たタスクのタスク識別子と該アンロック要求の対象資源
の資源名と優先度減少要求の旨とをパラメータとしてロ
ック優先度設定手段4を呼び出す。次に、アンロック要
求処理手段2は、ロック中タスクリストが空となってい
る場合は、ロックモード部を消去する。さらに、ロック
待ちタスクがあれば、アンロック要求処理手段2は、
次のロック待ちタスクが排他モードでロック要求してい
る場合は、ロックモード部に排他モードを、ロック中タ
スクリストに該タスクのタスク識別子をそれぞれ記録
し、該タスクのロック要求をロック待ち行列から削除
し、次のロック待ちタスクが共有モードでロック要求
している場合は、ロックモード部に共有モードを記録
し、ロック待ち行列内の共有モードでロック要求を出し
ているすべてのタスクのタスク識別子をロック中タスク
リストに記録し、ロック待ち行列内のすべての共有モー
ドのロック要求を削除する。
The unlock request processing means 2 processes the unlock request, deletes the task identifier of the task that issued the unlock request from the locked task list, and if the lock queue is not empty, unlocks the task. The lock priority setting means 4 is called with the task identifier of the task that issued the lock request, the resource name of the target resource of the unlock request, and the effect of the priority reduction request as parameters. Next, the unlock request processing means 2 erases the lock mode part when the locked task list is empty. Further, if there is a lock waiting task, the unlock request processing means 2
When the next lock waiting task requests a lock in the exclusive mode, the exclusive mode is recorded in the lock mode part, the task identifier of the task is recorded in the locked task list, and the lock request of the task is issued from the lock queue. If the task is deleted and the next lock-waiting task makes a lock request in shared mode, the shared mode is recorded in the lock mode section, and the task identifiers of all tasks that issue a lock request in shared mode in the lock queue. To the locked task list and delete all shared mode lock requests in the lock queue.

【0017】続いて、アンロック要求処理手段2は、前
記またはでロック中タスクリストに記録したすべて
のタスク識別子について、対応するロック優先度テーブ
ル6のエントリのロック待ち資源名部に空を記録する。
次いで、アンロック要求処理手段2は、ロック待ち行列
が空でなければ、ロック中タスクリストに記録したすべ
てのタスク識別子について、各タスク識別子と該アンロ
ック要求の対象資源の資源名と優先度増加要求の旨とを
パラメータとしてロック優先度設定手段4をタスク数分
だけ繰り返し呼び出す。次いで、アンロック要求処理手
段2は、これらのタスクの処理を再開させる。
Subsequently, the unlock request processing means 2 records empty in the lock waiting resource name portion of the corresponding entry of the lock priority table 6 for all the task identifiers recorded in the locked task list in the above or. .
Next, if the lock queue is not empty, the unlock request processing means 2 increases the priority of each task identifier, the resource name of the target resource of the unlock request, and the priority of all the task identifiers recorded in the locked task list. The lock priority setting means 4 is repeatedly called as many times as the number of tasks using the request and parameter as parameters. Then, the unlock request processing means 2 restarts the processing of these tasks.

【0018】ロック順序変更手段3は、パラメータで指
定された資源名に対応する排他制御テーブル5のエント
リに関し、該エントリのロック待ち行列を、ロック優先
度テーブル6のロック優先度部を参照して、各ロック要
求を出したタスクのロック優先度の高い順に並べ換え
る。このとき、ロック優先度の等しいタスクのロック要
求は先着順に並べる。
The lock order changing means 3 refers to the lock queue of the exclusive control table 5 corresponding to the resource name specified by the parameter, and refers to the lock priority section of the lock priority table 6 for the lock queue of the entry. , The tasks that issued each lock request are rearranged in order from the highest lock priority. At this time, the lock requests of the tasks having the same lock priority are arranged on a first-come-first-served basis.

【0019】ロック優先度設定手段4は、パラメータで
指定された要求が優先度増加要求ならば、パラメータで
指定された資源名に対応する排他制御テーブル5のエン
トリの重み部をパラメータで指定されたタスク識別子に
対応するロック優先度テーブル6のエントリの重み総和
部に加算し、優先度減少要求ならば、パラメータで指定
された資源名に対応する排他制御テーブル5のエントリ
の重み部をパラメータで指定されたタスク識別子に対応
するロック優先度テーブル6のエントリの重み総和部か
ら減算する。次に、ロック優先度設定手段4は、パラメ
ータで指定されたタスク識別子に対応するロック優先度
テーブル6のエントリに関し、重み総和部を参照してロ
ック優先度を算出し、この値を該エントリのロック優先
度部に記録する。ロック優先度の算出は、重み総和xの
関数f(x)(a>bならばf(a)≧f(b)が成立
し、かつf(c)>f(d)を満たすc>dなるcおよ
びdが存在する関数)を用いる。
If the request designated by the parameter is a priority increase request, the lock priority setting means 4 designates the weight part of the entry of the exclusive control table 5 corresponding to the resource name designated by the parameter by the parameter. It is added to the weight summation part of the entry of the lock priority table 6 corresponding to the task identifier, and if the priority reduction request is made, the weight part of the entry of the exclusive control table 5 corresponding to the resource name designated by the parameter is designated by the parameter. It is subtracted from the total weight part of the entries of the lock priority table 6 corresponding to the assigned task identifier. Next, the lock priority setting means 4 calculates the lock priority with respect to the entry of the lock priority table 6 corresponding to the task identifier designated by the parameter, by referring to the weight summing unit, and calculates this value of the entry. Record in the lock priority section. The lock priority is calculated by c> d, which satisfies the function f (x) of the sum of weights x (f (a) ≧ f (b) if a> b and satisfies f (c)> f (d)). Function for which c and d exist.

【0020】図3は、4つのタスクT1〜T4が2つの
資源R1およびR2に対して順次ロック要求およびアン
ロック要求を行う状況を示すタイミングチャートであ
る。
FIG. 3 is a timing chart showing a situation in which the four tasks T1 to T4 sequentially issue a lock request and an unlock request to the two resources R1 and R2.

【0021】図4(a)〜(d)は、図3の各タイミン
グta〜tdでの排他制御テーブル5およびロック優先
度テーブル6の状態を示している。なお、資源の重みは
R1に2、R2に1があらかじめ設定されているものと
し、時刻tより前では資源R1およびR2はロックされ
ていないものとする。また、関数f(x)として、f
(0)<f(1)<f(2)<f(3)が成立するよう
な関数が用いられ、ロック優先度テーブル6のロック待
ち資源名部,重み総和部およびロック優先度部がそれぞ
れ空,0およびf(0)に初期化されているものとす
る。
FIGS. 4A to 4D show the states of the exclusive control table 5 and the lock priority table 6 at the respective timings ta to td in FIG. It is assumed that the resource weights are set to 2 for R1 and 1 for R2 in advance, and that resources R1 and R2 are not locked before time t. Further, as the function f (x), f
A function such that (0) <f (1) <f (2) <f (3) is satisfied is used, and the lock waiting resource name portion, the weight summation portion, and the lock priority portion of the lock priority table 6 are respectively It shall be initialized to empty, 0 and f (0).

【0022】次に、このように構成された本実施例の共
有資源排他制御方式の動作について、図3および図4を
参照して具体的に説明する。
Next, the operation of the shared resource exclusive control system of the present embodiment thus configured will be specifically described with reference to FIGS. 3 and 4.

【0023】時刻tでタスクT1が資源R1を排他モー
ドでロック要求すると、ロック要求処理手段1が呼び出
される。ロック要求処理手段1は、資源R1がロックさ
れていないので、該タスクT1にロック権を付与し、ロ
ックモード部に排他モードを、ロック中タスクリストに
タスク識別子T1をそれぞれ記録する。次に、ロック要
求処理手段1は、ロック待ち行列が空なので、ロック優
先度設定手段4を呼び出すことなく、該ロック要求の処
理を完了する。
When the task T1 makes a lock request for the resource R1 in the exclusive mode at time t, the lock request processing means 1 is called. Since the resource R1 is not locked, the lock request processing unit 1 grants the task T1 a lock right, records the exclusive mode in the lock mode section, and records the task identifier T1 in the locked task list. Next, since the lock queue is empty, the lock request processing means 1 completes the processing of the lock request without calling the lock priority setting means 4.

【0024】時刻t+1でタスクT2が資源R1を排他
モードでロック要求すると、ロック要求処理手段1が呼
び出される。ロック要求処理手段1は、資源R1がすで
に排他モードでロックされているので、該タスクT2を
ロック待ちとし、タスク識別子T2と排他モードとの組
をロック待ち行列に記録する。次に、ロック要求処理手
段1は、タスク識別子T2に対応するロック待ち資源名
部に資源名R1を記録し、該資源の資源名R1をパラメ
ータとしてロック順序変更手段3を呼び出す。ロック順
序変更手段3は、ロック待ち行列の並べ換えを行うが、
ロック待ちタスクは1つなので結果は変わらない。続い
て、ロック要求処理手段1は、ロック待ち行列内のロッ
ク要求の数が1なので、ロック中タスクリストのタスク
識別子T1と該ロック要求の対象資源の資源名R1と優
先度増加要求の旨とをパラメータとしてロック優先度設
定手段4を呼び出す。ロック優先度設定手段4は、タス
クT1に対応するロック優先度テーブル6のエントリの
重み総和部に資源名R1に対応する排他制御テーブル5
のエントリの重み部の値2を加算し、タスクT1に対応
するロック優先度テーブル6のエントリのロック優先度
部にf(2)を設定する。続いて、ロック要求処理手段
1は、タスクT1に対応するロック優先度テーブル6の
エントリのロック待ち資源名部が空なので、ロック順序
変更手段3を呼び出すことなく、タスクT2の処理を中
断させる。
When the task T2 makes a lock request for the resource R1 in the exclusive mode at time t + 1, the lock request processing means 1 is called. Since the resource R1 is already locked in the exclusive mode, the lock request processing means 1 sets the task T2 in the lock wait state and records the set of the task identifier T2 and the exclusive mode in the lock queue. Next, the lock request processing means 1 records the resource name R1 in the lock waiting resource name portion corresponding to the task identifier T2, and calls the lock order changing means 3 with the resource name R1 of the resource as a parameter. The lock order changing means 3 rearranges the lock queue,
Since there is only one task waiting for lock, the result does not change. Subsequently, since the number of lock requests in the lock queue is 1, the lock request processing means 1 indicates the task identifier T1 of the locked task list, the resource name R1 of the target resource of the lock request, and the priority increase request. Is used as a parameter to call the lock priority setting means 4. The lock priority setting means 4 uses the exclusive control table 5 corresponding to the resource name R1 in the sum of weights of the entries of the lock priority table 6 corresponding to the task T1.
The value 2 of the weight part of the entry is added and f (2) is set in the lock priority part of the entry of the lock priority table 6 corresponding to the task T1. Subsequently, the lock request processing means 1 suspends the processing of the task T2 without calling the lock order changing means 3 because the lock waiting resource name part of the entry of the lock priority table 6 corresponding to the task T1 is empty.

【0025】時刻t+2でタスクT3が資源R2を共有
モードで、時刻t+3でタスクT4が資源R2を排他モ
ードでそれぞれロック要求すると、タスクT1およびタ
スクT2の場合と同様に処理が行われ、タスクT3にロ
ック権が付与され、タスクT4はロック待ちとなる。こ
の結果、時刻taでの排他制御テーブル5およびロック
優先度テーブル6は、図4(a)の状態となる。
When the task T3 requests the resource R2 in the shared mode at the time t + 2 and the task T4 requests the resource R2 in the exclusive mode at the time t + 3, the processing is performed as in the case of the task T1 and the task T2. The lock right is given to the task T4, and the task T4 waits for the lock. As a result, the exclusive control table 5 and the lock priority table 6 at time ta are in the state of FIG.

【0026】時刻t+4でタスクT3が資源R1を共有
モードでロック要求すると、ロック要求処理手段1が呼
び出される。ロック要求処理手段1は、資源R1がすで
に排他モードでロックされているので、該タスクのタス
ク識別子T3と共有モードとの組を資源名部R1に対応
するロック待ち行列の最後に追加する。次に、ロック要
求処理手段1は、ロック待ち資源名部に資源R1の資源
名を記録し、該資源の資源名R1をパラメータとしてロ
ック順序変更手段3を呼び出す。ロック順序変更手段3
は、タスクT2およびタスクT3のロック優先度がそれ
ぞれf(0)およびf(1)であり、f(0)<f
(1)よりタスクT3のロック要求、タスクT2のロッ
ク要求の順にロック待ち行列を並べ換える。すなわち、
先にロック要求したタスクT2をタスクT3が追い越
し、タスクT3へのロック権付与が優先される。続い
て、ロック要求処理手段1は、ロック待ち行列内のロッ
ク要求の数が1ではないため、ロック優先度設定手段4
を呼び出すことなく、タスクT3の処理を中断させる。
この結果、時刻tbでの排他制御テーブル5およびロッ
ク優先度テーブル6は、図4(b)の状態となる。
When the task T3 makes a lock request for the resource R1 in the shared mode at time t + 4, the lock request processing means 1 is called. Since the resource R1 is already locked in the exclusive mode, the lock request processing means 1 adds the pair of the task identifier T3 of the task and the shared mode to the end of the lock queue corresponding to the resource name part R1. Next, the lock request processing means 1 records the resource name of the resource R1 in the lock waiting resource name part, and calls the lock order changing means 3 using the resource name R1 of the resource as a parameter. Lock order changing means 3
Has task T2 and task T3 lock priorities of f (0) and f (1), respectively, and f (0) <f
From (1), the lock queue is rearranged in the order of the lock request of the task T3 and the lock request of the task T2. That is,
The task T3 overtakes the task T2 that has previously requested the lock, and priority is given to granting the lock right to the task T3. Subsequently, the lock request processing means 1 locks the lock priority setting means 4 because the number of lock requests in the lock queue is not one.
The processing of task T3 is interrupted without calling.
As a result, the exclusive control table 5 and the lock priority table 6 at the time tb are in the state of FIG. 4 (b).

【0027】時刻t+5でタスクT1が資源R1をアン
ロック要求すると、アンロック要求処理手段2が呼び出
される。アンロック要求処理手段2は、ロック中タスク
リストからタスク識別子T1を削除する。次に、アンロ
ック要求処理手段2は、ロック待ち行列が空でないの
で、該タスクのタスク識別子T1と該アンロック要求の
対象資源の資源名R1と優先度減少要求の旨とをパラメ
ータとしてロック優先度設定手段4を呼び出す。ロック
優先度設定手段4は、タスク識別子T1に対応するロッ
ク優先度テーブル6のエントリの重み総和部から資源名
R1に対応する排他制御テーブル5のエントリの重み部
の値2を減じ、タスクT1に対応するロック優先度テー
ブル6のエントリのロック優先度部にf(0)を設定す
る。この結果、ロック中タスクリストが空となるので、
アンロック要求処理手段2は、ロックモード部を消去す
る。さらに、アンロック要求処理手段2は、ロック待ち
行列が空ではないので、最初のロック要求のタスクT3
にロック権を付与し、ロックモード部に共有モードを、
ロック中タスクリストにタスク識別子T3をそれぞれ記
録する。次に、アンロック要求処理手段2は、該タスク
T3に対応するロック優先度テーブル6のロック待ち資
源名部を空とし、ロック待ち行列が空でないので、タス
ク識別子T3と該ロック要求の資源名R1と優先度増加
要求の旨とをパラメータとしてロック優先度設定手段4
を呼び出す。ロック優先度設定手段4は、タスクT3に
対応するロック優先度テーブル6のエントリの重み総和
部に資源名R1に対応する排他制御テーブル5のエント
リの重み部の値2を加え、タスクT3に対応するロック
優先度テーブル6のロック優先度部にf(3)を設定し
た後、タスクT3の処理を再開させる。この結果、時刻
tcでの排他制御テーブル5およびロック優先度テーブ
ル6は、図4(c)の状態となる。
When the task T1 makes an unlock request for the resource R1 at time t + 5, the unlock request processing means 2 is called. The unlock request processing means 2 deletes the task identifier T1 from the locked task list. Next, since the lock queue is not empty, the unlock request processing means 2 locks the task with the task identifier T1 of the task, the resource name R1 of the target resource of the unlock request, and the priority reduction request as parameters. Call the degree setting means 4. The lock priority setting means 4 subtracts the value 2 of the weight part of the entry of the exclusive control table 5 corresponding to the resource name R1 from the sum of weight parts of the entries of the lock priority table 6 corresponding to the task identifier T1 to obtain the task T1. Set f (0) in the lock priority part of the corresponding entry of the lock priority table 6. As a result, the locked task list becomes empty, so
The unlock request processing means 2 erases the lock mode part. Further, since the lock queue is not empty, the unlock request processing means 2 causes task T3 of the first lock request.
Give the lock right to the share mode in the lock mode section,
The task identifier T3 is recorded in the locked task list. Next, the unlock request processing means 2 empties the lock wait resource name part of the lock priority table 6 corresponding to the task T3, and the lock queue is not empty. Therefore, the task identifier T3 and the resource name of the lock request. Lock priority setting means 4 with R1 and the request for priority increase request as parameters
Call. The lock priority setting means 4 adds the value 2 of the weight part of the entry of the exclusive control table 5 corresponding to the resource name R1 to the total weight part of the entries of the lock priority table 6 corresponding to the task T3, and corresponds to the task T3. After setting f (3) in the lock priority part of the lock priority table 6, the processing of task T3 is restarted. As a result, the exclusive control table 5 and the lock priority table 6 at time tc are in the state of FIG.

【0028】時刻t+6でタスクT3が資源R1および
R2を続けてアンロック要求すると、タスクT1による
アンロック要求と同様に処理が行われ、資源R1におい
てはタスクT2に、資源R2においてはタスクT4にそ
れぞれロック権が付与される。この結果、時刻tdでの
排他制御テーブル5およびロック優先度テーブル6は、
図4(d)の状態となる。
When the task T3 continuously requests the resources R1 and R2 to unlock at time t + 6, the same processing as the unlock request by the task T1 is performed, and the task T2 in the resource R1 and the task T4 in the resource R2. A lock right is given to each. As a result, the exclusive control table 5 and the lock priority table 6 at the time td are
The state shown in FIG. 4D is obtained.

【0029】なお、上記実施例では、関数f(x)がf
(0)<f(1)<f(2)<f(3)を満足する関数
であると仮定したが、f(a)=f(b)(a<b)の
ような場合を含む関数も用いることができる。この関数
は、重み総和に従って厳密にロック優先度を制御するの
ではなく、重み総和のある範囲に対し1つのロック優先
度を対応させることになり、重み総和が大差ないときに
は先着順にロック権を付与した方がよい場合に向いてい
る。このような関数を用いた場合、動作としては、ロッ
ク順序変更手段3でのロック待ち行列の並べ換え時に重
み総和bのタスクが重み総和aのタスクに優先されずに
先着順に並べられる点が異なる以外は同様の処理とな
る。
In the above embodiment, the function f (x) is f
Although it is assumed that the function satisfies (0) <f (1) <f (2) <f (3), a function including a case such as f (a) = f (b) (a <b) Can also be used. This function does not strictly control the lock priority according to the weight sum, but associates one lock priority with a certain range of the weight sum. When the weight sums are not significantly different, the lock right is given on a first-come-first-served basis. Suitable for when you should. When such a function is used, the operation is different except that when the lock queue is rearranged by the lock order changing unit 3, the task having the weight sum b is not prioritized over the task having the weight sum a but is arranged on a first-come-first-served basis. Is the same processing.

【0030】また、上記実施例では、各資源の重みを異
ならしめた場合について説明したが、各資源の重みをす
べて1に固定するようにしてもよい。このようにする
と、各資源のロック待ち行列長の時間平均値や1回当た
りのロック時間平均値などが大差なく、どの資源も同等
に扱うことができる場合に好適である。また、排他制御
テーブル5の重み部の値をロック優先度テーブル6の重
み総和部に加減算する処理を、重み総和部に定数1を加
減算する処理に置き換えることができる。これにより、
排他制御テーブル5の重み部を削除することができ、排
他制御テーブル5に必要なメモリ量を削減することがで
きる。動作は、重み総和部への加減算処理が、前記処理
になる以外は、上記実施例の場合と同様である。
In the above embodiment, the case where the weights of the resources are made different has been described, but the weights of the resources may all be fixed to one. In this way, it is suitable when the time average value of the lock queue length of each resource and the lock time average value per time are not so different, and all resources can be treated equally. Further, the process of adding / subtracting the value of the weight part of the exclusive control table 5 to / from the weight sum total part of the lock priority table 6 can be replaced with the process of adding / subtracting the constant 1 to / from the weight sum total part. This allows
The weight part of the exclusive control table 5 can be deleted, and the memory amount required for the exclusive control table 5 can be reduced. The operation is the same as that of the above-mentioned embodiment except that the addition / subtraction processing to the weight summing unit is the above processing.

【0031】さらに、上記実施例では、ロック優先度を
算出する関数f(x)を使用する場合について説明した
が、ロック優先度を算出する関数をf(x)=xとし、
重み総和そのものをロック優先度とするようにしてもよ
い。このようにすれば、重み総和による厳密な優先度制
御を必要とする場合に好適である。また、排他制御テー
ブル5の重み部をロック優先度テーブル6の重み総和部
に加減算する処理を、ロック優先度部に直接加減算する
ように変更することにより、ロック優先度テーブル6の
重み総和部を削除することができ、ロック優先度テーブ
ル6に必要なメモリ量とロック優先度算出に必要な実行
ステップ数とを削減することができる。動作は、ロック
優先度算出処理が前記処理になる以外は、上記実施例の
場合と同様である。
Further, in the above embodiment, the case where the function f (x) for calculating the lock priority is used has been described, but the function for calculating the lock priority is f (x) = x,
The sum of weights themselves may be used as the lock priority. This is suitable when strict priority control based on the sum of weights is required. Further, by changing the process of adding / subtracting the weight part of the exclusive control table 5 to / from the weight summation part of the lock priority table 6, to directly add / subtract to the lock priority part, the weight summation part of the lock priority table 6 is changed. It can be deleted, and the amount of memory required for the lock priority table 6 and the number of execution steps required for calculating the lock priority can be reduced. The operation is the same as in the above embodiment except that the lock priority calculation process is the above process.

【0032】[0032]

【発明の効果】以上説明したように本発明は、ロック待
ちが発生している資源の持つ重み総和の増加にともなっ
て増加するようなロック優先度を設け、ロック優先度の
高いタスクに対しロック優先度の低いタスクに優先して
ロック権が付与されるように制御することにより、他の
タスクを待たせているタスクが新たな資源をロック要求
してロック待ちとなった場合にロック待ち時間を減少さ
せることができ、該タスクがロックしている資源に対し
ロック待ちしている他のタスクのロック待ち時間を減少
させるとともに、共有資源の使用効率を向上させる効果
がある。
As described above, according to the present invention, the lock priority is set so as to increase with an increase in the total weight of the resources for which lock waiting is occurring, and a task having a high lock priority is locked. By controlling so that the lock right is given priority to the task with the lower priority, the lock wait time is set when the task waiting for another task locks a new resource and waits for the lock. Can be reduced, the lock waiting time of other tasks waiting for the lock of the resource locked by the task can be reduced, and the utilization efficiency of the shared resource can be improved.

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

【図1】本発明の一実施例に係る共有資源排他制御方式
の構成を示すブロック図である。
FIG. 1 is a block diagram showing a configuration of a shared resource exclusive control method according to an exemplary embodiment of the present invention.

【図2】本実施例の共有資源排他制御方式における排他
制御テーブルおよびロック優先度テーブルの構成を示す
図である。
FIG. 2 is a diagram showing configurations of an exclusive control table and a lock priority table in the shared resource exclusive control method of the present embodiment.

【図3】本実施例の共有資源排他制御方式の動作を説明
するためのロック/アンロックタイミングチャートであ
る。
FIG. 3 is a lock / unlock timing chart for explaining the operation of the shared resource exclusive control method according to the present exemplary embodiment.

【図4】本実施例の共有資源排他制御方式の動作を説明
するための排他制御テーブルおよびロック優先度テーブ
ルの状態を示す図であり、(a)は時刻taにおける排
他制御テーブルおよびロック優先度テーブルの状態を示
し、(b)は時刻tbにおける排他制御テーブルおよび
ロック優先度テーブルの状態を示し、(c)は時刻tc
における排他制御テーブルおよびロック優先度テーブル
の状態を示し、(d)は時刻tdにおける排他制御テー
ブルおよびロック優先度テーブルの状態を示す。
FIG. 4 is a diagram showing the states of the exclusive control table and the lock priority table for explaining the operation of the shared resource exclusive control method according to the present embodiment, in which (a) is the exclusive control table and the lock priority at time ta. The state of the table is shown, (b) shows the states of the exclusive control table and the lock priority table at time tb, and (c) shows the time tc.
Shows the states of the exclusive control table and the lock priority table at (d), and (d) shows the states of the exclusive control table and the lock priority table at time td.

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

1 ロック要求処理手段 2 アンロック要求処理手段 3 ロック順序変更手段 4 ロック優先度設定手段 5 排他制御テーブル 6 ロック優先度テーブル 7 共有資源排他制御機能 T1〜Tn タスク R1,R2 資源 1 Lock Request Processing Means 2 Unlock Request Processing Means 3 Lock Order Changing Means 4 Lock Priority Setting Means 5 Exclusive Control Tables 6 Lock Priority Tables 7 Shared Resource Exclusive Control Functions T1-Tn Tasks R1, R2 Resources

Claims (3)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 計算機システムの共有資源排他制御方式
において、 あらかじめ各資源に重みを設定しておき、タスクのロッ
ク中資源のうちのロック待ちしているタスクが存在する
資源の重みの和xの関数f(x)(a>bならばf
(a)≧f(b)が成立し、かつf(c)>f(d)を
満たすc>dなるcおよびdが存在する関数)によって
算出された値を、該タスクのロック優先度として設定す
るロック優先度設定手段と、 ロック待ちタスクへのロック権付与順序がロック優先度
の高い順となるようロック待ち行列を並べ換えるロック
順序変更手段とを有することを特徴とする共有資源排他
制御方式。
1. In a shared resource exclusive control method for a computer system, a weight is set in advance for each resource, and the sum x of the weights of the resources in which the task waiting for lock exists among the locked resources of the task Function f (x) (f if a> b
A value calculated by (a) ≧ f (b) is satisfied and c and d satisfying f (c)> f (d) such that c and d are present) is set as a lock priority of the task. A shared resource exclusive control characterized by having lock priority setting means for setting and lock order changing means for rearranging the lock queues so that the lock right is given to the tasks waiting for lock in order of higher lock priority. method.
【請求項2】 各資源の重みを1に固定したことを特徴
とする請求項1記載の共有資源排他制御方式。
2. The shared resource exclusive control method according to claim 1, wherein the weight of each resource is fixed to 1.
【請求項3】 前記関数をf(x)=xとしたことを特
徴とする請求項1記載の共有資源排他制御方式。
3. The shared resource exclusive control method according to claim 1, wherein the function is f (x) = x.
JP5093656A 1993-03-29 1993-03-29 Shared resource exclusive control method Expired - Lifetime JP2518134B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP5093656A JP2518134B2 (en) 1993-03-29 1993-03-29 Shared resource exclusive control method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP5093656A JP2518134B2 (en) 1993-03-29 1993-03-29 Shared resource exclusive control method

Publications (2)

Publication Number Publication Date
JPH06282448A JPH06282448A (en) 1994-10-07
JP2518134B2 true JP2518134B2 (en) 1996-07-24

Family

ID=14088434

Family Applications (1)

Application Number Title Priority Date Filing Date
JP5093656A Expired - Lifetime JP2518134B2 (en) 1993-03-29 1993-03-29 Shared resource exclusive control method

Country Status (1)

Country Link
JP (1) JP2518134B2 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6862663B1 (en) * 2000-06-30 2005-03-01 Intel Corporation Cache having a prioritized replacement technique and method therefor
JP5625379B2 (en) * 2010-02-16 2014-11-19 日本電気株式会社 Lock contention management device, lock contention management method, and program
US8453150B2 (en) * 2010-06-08 2013-05-28 Advanced Micro Devices, Inc. Multithread application-aware memory scheduling scheme for multi-core processors
WO2012032572A1 (en) * 2010-09-08 2012-03-15 株式会社日立製作所 Computing device
JP5621904B2 (en) 2011-02-25 2014-11-12 富士通株式会社 Lock control device, lock control program, and lock control method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04262425A (en) * 1991-02-15 1992-09-17 Nec Corp Exclusive control system for commonly shared resource

Also Published As

Publication number Publication date
JPH06282448A (en) 1994-10-07

Similar Documents

Publication Publication Date Title
US5790851A (en) Method of sequencing lock call requests to an O/S to avoid spinlock contention within a multi-processor environment
US5564062A (en) Resource arbitration system with resource checking and lockout avoidance
US20040221285A1 (en) Management of dispatch functions in a virtual machine environment
US5251317A (en) Computer system with an access control unit for resource
JP2002521766A (en) Method and system for arbitrating streams of concurrent transactions in a database
CN111124674B (en) A hardware resource management method, storage medium and terminal
JP2518134B2 (en) Shared resource exclusive control method
JP2001084235A (en) Exclusive control method using lock particle size satistical information and computer-readable recording medium with program recorded therein
JP3664021B2 (en) Resource allocation method by service level
US9792419B2 (en) Starvationless kernel-aware distributed scheduling of software licenses
JPH0877025A (en) Task priority control method and task priority control device
JP3068556B2 (en) Shared resource exclusion control method and its program recording medium
JPH1049388A (en) Input and output controller
JPH0512041A (en) Shared resource exclusive control system
JPH05120041A (en) Resource allocation management system
JPH0383142A (en) Shared resource exclusive control system
JPH04262425A (en) Exclusive control system for commonly shared resource
JPH05120040A (en) Computer system
JPH0478932A (en) Shared resource exclusion control system
JP2001142723A (en) Resource allocation method, computer system and recording medium
JPH04223533A (en) Common resource exclusive control system
JPH04116731A (en) Exclusive control for shared resources
JPH0423047A (en) Exclusive control system for shared resources
JPS63259740A (en) Performance estimation device
JPS61136134A (en) Queue resource control system