JPH04262425A - Exclusive control system for commonly shared resource - Google Patents

Exclusive control system for commonly shared resource

Info

Publication number
JPH04262425A
JPH04262425A JP4446291A JP4446291A JPH04262425A JP H04262425 A JPH04262425 A JP H04262425A JP 4446291 A JP4446291 A JP 4446291A JP 4446291 A JP4446291 A JP 4446291A JP H04262425 A JPH04262425 A JP H04262425A
Authority
JP
Japan
Prior art keywords
lock
task
priority
resource
exclusive control
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP4446291A
Other languages
Japanese (ja)
Inventor
Yoshinao Suzuki
鈴木 善尚
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
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP4446291A priority Critical patent/JPH04262425A/en
Publication of JPH04262425A publication Critical patent/JPH04262425A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To upgrade an efficiency of using a commonly shared resource by reducing lock waiting time for a successive lock waiting task. CONSTITUTION:When a task locks a resource and the task terminates the execution of a lock right, a lock priority setting means 4 sets up as a lock priority for a relevant task a value calculated from a function f(x) where values a and b are present that have a relation of a>b that satisfies f(a)>=f(b) with respect to variable x of resource in the lock of the relevant task and also from a function f(x) where values c and d are present that have a relation of c>d that satisfies f(c)>f(d) with respect to variable x of resource in the lock of the relevant task. Further, when a task becomes ready for lock waiting, a lock sequency change means 3 changes a lock queue so that a lock right transfer sequence to a lock waiting task becomes higher in lock priority.

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 method in a computer system.

【0002】0002

【従来の技術】電子計算機システムにおいて、複数のタ
スクから使用される資源(共有資源)については、それ
らへのアクセスを逐次化するために排他制御が必要であ
る。
2. Description of the Related Art In a computer system, exclusive control is required for resources (shared resources) used by a plurality of tasks in order to serialize access to them.

【0003】このような排他制御のために、電子計算機
システムには、ロック/アンロックあるいはENQ(エ
ンキュー)/DEQ(デキュー)と呼ばれる基本機能が
備えられている。なお、ロック要求には排他モードと共
有モードとの2種類がある。
For such exclusive control, electronic computer systems are equipped with basic functions called lock/unlock or ENQ (enqueue)/DEQ (dequeue). Note that there are two types of lock requests: exclusive mode and shared mode.

【0004】排他制御の基本的動作は次のように行われ
る。
The basic operation of exclusive control is performed as follows.

【0005】あるタスクがロック要求を出した場合、ロ
ック要求対象の資源が他のタスクによりロックされてい
ない場合、または、その資源のロックモードとそのタス
クのロック要求のモードがともに共有モードの場合には
、要求したタスクに対してすぐにロック権が付与される
[0005] When a task issues a lock request, the resource for which the lock request is made is not locked by another task, or the lock mode of the resource and the mode of the lock request of the task are both shared mode. is immediately granted lock rights to the requested task.

【0006】しかし、その資源がロックされている場合
、その資源のロックモードまたはタスクのロック要求の
モードのいずれかが排他モードの時は、ロック待ちとな
る。
However, if the resource is locked and either the lock mode of the resource or the lock request mode of the task is exclusive mode, the task is placed in a lock wait state.

【0007】一方、資源をロックしていたタスクが資源
の使用を終えてアンロック要求を出した場合は、そのタ
スクのロック権の行使が終了する。
On the other hand, when a task that has locked a resource issues an unlock request after finishing using the resource, that task's exercise of locking rights ends.

【0008】この場合、アンロック要求を出したタスク
が排他モードでロックをしていた場合には、待ち合わせ
していたタスクがあれば、最も早くロック要求をしたタ
スクの要求モードが排他モードであれば、そのタスクの
みにロック権を付与し、共有モードであれば現在共有モ
ードでロック待ちしているタスク全てにロック権を付与
する。
[0008] In this case, if the task that issued the unlock request has locked the lock in exclusive mode, if there is a task that is waiting, even if the request mode of the task that requested the lock earliest is exclusive mode. For example, the lock right is granted only to that task, and if the task is in shared mode, the lock right is granted to all tasks currently waiting for a lock in shared mode.

【0009】また、アンロック要求を出したタスクが共
有モードでロックをしていた場合には、待ち合わせをし
ていた排他モードのタスクがあれば、そのタスクにロッ
ク権を付与する。
[0009] Furthermore, if the task that issued the unlock request holds the lock in shared mode, if there is a task in exclusive mode that is waiting, that task is given the locking right.

【0010】なお、アンロック要求をした時点で待ち合
わせをしているタスクがない場合には、当然のことなが
らロック権の付与は行わない。
[0010] Note that if there is no task waiting at the time the unlock request is made, the lock right is not granted, as a matter of course.

【0011】[0011]

【発明が解決しようとする課題】上述したように、従来
の共有資源排他制御方式では、複数の資源を同時に使用
して処理する場合、各資源に対し逐次にロック要求をす
るが、いくつかの資源のロックが成功し、次の資源をロ
ックしようとしてロック待ちとなった場合、既にそのタ
スクがロックした資源に対してロック待ちしている他の
タスクの待ち時間が不必要に長くなり、資源の使用効率
が低下するという欠点があった。
[Problems to be Solved by the Invention] As mentioned above, in the conventional shared resource exclusive control method, when multiple resources are used and processed simultaneously, lock requests are made for each resource sequentially, but some If a resource is successfully locked and the task is placed in a lock wait state when attempting to lock the next resource, the waiting time of other tasks that are already waiting to lock the resource that the task has already locked becomes unnecessarily long, and the resource The disadvantage was that the usage efficiency of

【0012】なお、このような場合、必要な資源を全て
確保できない限り何も資源を確保しないというオールオ
アナッシングの技法等を適用すれば解決できるが、制御
が複雑になり、処理性能に影響を与えるので好ましくな
い。
[0012] In such a case, it can be solved by applying an all-or-nothing technique in which no resources are secured unless all the necessary resources are secured, but this will complicate control and affect processing performance. It is not desirable because it gives

【0013】本発明は上記の点に鑑み提案されたもので
あり、その目的とするところは、後続のロック待ちタス
クのロック待ち時間を減少させ、共有資源の使用効率を
向上させることのできる共有資源排他制御方式を提供す
ることにある。
The present invention has been proposed in view of the above points, and its purpose is to reduce the lock waiting time of subsequent lock waiting tasks and improve the efficiency of using shared resources. The purpose of this invention is to provide a resource exclusive control method.

【0014】[0014]

【課題を解決するための手段】本発明は上記の目的を達
成するため、電子計算機システムの共有資源排他制御方
式において、タスク対応にロック優先度を設け、タスク
が資源をロックした時、およびタスクがロック権の行使
を終了した時、当該タスクのロック中資源の数xにつき
f(a)≧f(b)が成立するa>bなるa,bが存在
し、かつf(c)>f(d)が成立するc>dなるc,
dが存在する関数f(x)によって算出された値を当該
タスクのロック優先度として設定するロック優先度設定
手段と、タスクがロック待ちとなった時、ロック待ちタ
スクへのロック権付与順序がロック優先度の高い順とな
るようロック待ち行列を並べ換えるロック順序変更手段
とを備えるようにしている。
[Means for Solving the Problems] In order to achieve the above object, the present invention provides a lock priority for each task in a shared resource exclusive control method of a computer system, When the task finishes exercising the locking right, there exists a and b such that f(a)≧f(b) holds true for the number of locked resources x of the task, and f(c)>f (d) holds, c > d,
lock priority setting means for setting a value calculated by a function f(x) where d exists as the lock priority of the task; and a lock priority setting means for setting a value calculated by a function f(x) where The lock order changing means rearranges the lock queue in order of lock priority.

【0015】[0015]

【作用】本発明の共有資源排他制御方式にあっては、タ
スクが資源をロックした時、およびタスクがロック権の
行使を終了した時、ロック優先度設定手段が当該タスク
のロック中資源の数xにつきf(a)≧f(b)が成立
するa>bなるa,bが存在し、かつf(c)>f(d
)が成立するc>dなるc,dが存在する関数f(x)
によって算出された値を当該タスクのロック優先度とし
て設定し、タスクがロック待ちとなった時、ロック順序
変更手段がロック待ちタスクへのロック権付与順序がロ
ック優先度の高い順となるようロック待ち行列を並べ換
える。
[Operation] In the shared resource exclusive control method of the present invention, when a task locks a resource and when a task finishes exercising the locking right, the lock priority setting means sets the number of locked resources of the task. For x, there exist a and b such that f(a)≧f(b) holds, and f(c)>f(d
) holds true, c > d, and there exists a function f(x)
The value calculated by is set as the lock priority of the task, and when the task becomes a lock waiter, the lock order changing means sets the lock so that the order in which lock rights are granted to tasks waiting for a lock is in descending order of lock priority. Reorder the queue.

【0016】[0016]

【実施例】以下、本発明の実施例につき図面を参照して
説明する。
Embodiments Hereinafter, embodiments of the present invention will be described with reference to the drawings.

【0017】図1は本発明の共有資源排他制御方式の一
実施例を示す構成図である。
FIG. 1 is a block diagram showing an embodiment of the shared resource exclusive control system of the present invention.

【0018】図1において、共有資源排他制御機構7は
、ロック要求の処理を行うロック要求処理手段1と、ア
ンロック要求の処理を行うアンロック要求処理手段2と
、ロック優先度の高い順にロック待ち行列を並べ換える
ロック順序変更手段3と、タスクのロック優先度として
当該タスクのロック中資源数から所定の関数で算出され
る値を設定するロック優先度設定手段4と、排他制御テ
ーブル5と、ロック優先度テーブル6とから構成されて
いる。
In FIG. 1, the shared resource exclusive control mechanism 7 includes a lock request processing means 1 for processing lock requests, an unlock request processing means 2 for processing unlock requests, and locks in descending order of lock priority. A lock order changing means 3 for rearranging the queue, a lock priority setting means 4 for setting a value calculated by a predetermined function from the number of locked resources of the task as the lock priority of the task, and an exclusive control table 5. , and a lock priority table 6.

【0019】図2は排他制御テーブル5およびロック優
先度テーブル6の論理的構成を示したものである。
FIG. 2 shows the logical configuration of the exclusive control table 5 and the lock priority table 6.

【0020】すなわち、排他制御テーブル5はシステム
内の排他制御対象資源を一意に識別するための名前であ
る資源名をキーとするものであり、各資源に対するエン
トリは、資源名部とロックモード部とロック中タスクリ
ストとロック待ち行列とから構成されている。ここで、
ロックモード部は、資源がロックされているときのロッ
クモードが記録され、ロック中タスクリストは、その資
源をロックしているタスクのタスク識別子が記録され、
ロック待ち行列は、待ち状態にあるロック要求の待ち行
列であり、これらの要求を出しているタスクのタスク識
別子とロックモードとの組が記録される。なお、ロック
モードは共有モードを「S」、排他モードを「E」と表
すこととする。
In other words, the exclusive control table 5 uses resource names as keys to uniquely identify resources subject to exclusive control within the system, and entries for each resource include a resource name section and a lock mode section. , a locked task list, and a lock queue. here,
The lock mode section records the lock mode when the resource is locked, and the locked task list records the task identifier of the task that locks the resource.
The lock queue is a queue of waiting lock requests, and records the task identifier and lock mode pairs of the tasks issuing these requests. Note that the lock mode is expressed as "S" for shared mode and "E" for exclusive mode.

【0021】また、ロック優先度テーブル6はタスク識
別子をキーとするものであり、各タスクに対するエント
リは、タスク識別子部と、ロック中資源数部と、ロック
優先度部とから構成されている。ここで、ロック中資源
数部は、そのタスクがロックしている資源数が記録され
、ロック優先度部は、そのタスクのロック優先度が記録
される。
The lock priority table 6 uses a task identifier as a key, and the entry for each task is composed of a task identifier section, a number of locked resources section, and a lock priority section. Here, the number of locked resources section records the number of resources locked by the task, and the lock priority section records the lock priority of the task.

【0022】以下、各処理部の動作を説明する。The operation of each processing section will be explained below.

【0023】(1)ロック要求処理手段1いずれかのタ
スクT1〜Tnからロック要求がされると、ロック要求
処理手段1はロック要求の処理を行う。
(1) Lock request processing means 1 When a lock request is made from any of the tasks T1 to Tn, the lock request processing means 1 processes the lock request.

【0024】すなわち、ロック要求処理手段1は、排他
制御テーブル5の要求された資源に対応するエントリを
参照し、ロックモード部が空の場合、または、その要求
のロックモードとロックモード部の値とがともに共有モ
ードSの場合は、ロックモード部にその要求のロックモ
ードを記録し、ロック中タスクリストにその要求を出し
たタスクのタスク識別子を追加する。
That is, the lock request processing means 1 refers to the entry corresponding to the requested resource in the exclusive control table 5, and if the lock mode section is empty, or the lock mode of the request and the value of the lock mode section are If both are in shared mode S, the lock mode of the request is recorded in the lock mode section, and the task identifier of the task that issued the request is added to the locked task list.

【0025】次いで、ロック優先度テーブル6のそのロ
ック要求を出したタスクに対するエントリのロック中資
源数部に1を加えた後、そのタスクのタスク識別子をパ
ラメータとしてロック優先度設定手段4を呼び出す。
Next, after adding 1 to the number of locked resources section of the entry for the task that issued the lock request in the lock priority table 6, the lock priority setting means 4 is called using the task identifier of the task as a parameter.

【0026】一方、タスクT1〜Tnからのロック要求
に際し、排他制御テーブル5の要求された資源に対応す
るロックモード部が空でなくタスクのロック要求が排他
モードEである場合、または、ロックモード部の値が排
他モードEである場合は、そのタスクのタスク識別子と
ロックモードとの組をロック待ち行列の最後に追加し、
ロック順序変更手段3を呼び出す。
On the other hand, when a lock request is made from tasks T1 to Tn, if the lock mode field corresponding to the requested resource in the exclusive control table 5 is not empty and the lock request of the task is in exclusive mode E, or If the value of section is exclusive mode E, add the task identifier and lock mode pair of that task to the end of the lock queue,
Call the lock order changing means 3.

【0027】次いで、その要求を出したタスクの処理を
中断させる。
Next, the processing of the task that issued the request is interrupted.

【0028】(2)アンロック要求処理手段2いずれか
のタスクT1〜Tnからアンロック要求がされると、ア
ンロック要求処理手段2は、アンロック要求の処理を行
う。
(2) Unlock request processing means 2 When an unlock request is made from any of the tasks T1 to Tn, the unlock request processing means 2 processes the unlock request.

【0029】すなわち、アンロック要求処理手段2は排
他制御テーブル5の対応する資源のエントリのロック中
タスクリストからそのアンロック要求を出したタスクの
タスク識別子を削除し、ロック優先度テーブル6のその
タスクのエントリのロック中資源数部から1を減じた後
、そのタスクのタスク識別子をパラメータとしてロック
優先度設定手段4を呼び出す。
That is, the unlock request processing means 2 deletes the task identifier of the task that issued the unlock request from the locked task list of the corresponding resource entry in the exclusive control table 5, and After subtracting 1 from the number of locked resources in the task entry, the lock priority setting means 4 is called using the task identifier of the task as a parameter.

【0030】次いで、排他制御テーブル5のロック中タ
スクリストが空となっている場合は、ロックモード部を
消去する。
Next, if the locked task list in the exclusive control table 5 is empty, the lock mode section is deleted.

【0031】更に、排他制御テーブル5のロック待ち行
列にロック待ちタスクがある場合、次のロック待ちタス
クが排他モードEでロック要求している場合は、ロック
モード部に排他モードEを、ロック中タスクリストにそ
のタスクのタスク識別子をそれぞれ記録し、そのタスク
のタスク識別子等をロック待ち行列から削除する。
Furthermore, if there is a task waiting for a lock in the lock queue of the exclusive control table 5, and the next task waiting for a lock requests a lock in exclusive mode E, the exclusive mode E is set in the lock mode field. The task identifiers of the tasks are recorded in the task list, and the task identifiers, etc. of the tasks are deleted from the lock queue.

【0032】また、次のロック待ちタスクが共有モード
Sでロック要求している場合は、ロックモード部に共有
モードSを記録し、ロック待ち行列内の共有モードでロ
ック要求を出している全てのタスクのタスク識別子を、
ロック中タスクリストに記録し、ロック待ち行列内の全
ての共有モードのタスク識別子等を削除する。
Furthermore, if the next task waiting for a lock is requesting a lock in shared mode S, the shared mode S is recorded in the lock mode section, and all the tasks in the lock queue that have issued a lock request in shared mode are The task identifier of the task,
It is recorded in the locked task list and all shared mode task identifiers etc. in the lock queue are deleted.

【0033】次いで、ロック中タスクリストに記録した
全てのタスク識別子のタスクについて、ロック優先度テ
ーブル6のロック中資源数部に1を加え、各タスク識別
子をパラメータとしてロック優先度変更手段4をタスク
数分だけ繰り返し呼び出した後、これらのタスクの処理
を再開させる。
Next, for the tasks with all the task identifiers recorded in the locked task list, 1 is added to the number of locked resources in the lock priority table 6, and the lock priority changing means 4 assigns the task to each task using each task identifier as a parameter. After a few minutes of repeated calls, these tasks will resume processing.

【0034】(3)ロック順序変更手段3ロック順序変
更手段3は、ロック要求処理手段1から待ち状態にした
タスクのタスク識別子をパラメータとして呼び出された
際に動作する。
(3) Lock order changing means 3 The lock order changing means 3 operates when called by the lock request processing means 1 with the task identifier of the task placed in the waiting state as a parameter.

【0035】すなわち、ロック順序変更手段3は、排他
制御テーブル5のロック待ち行列を、ロック優先度テー
ブル6のロック優先度部を参照して、各要求を出したタ
スクのロック優先度の高い順に並べ換える。この時、ロ
ック優先度の等しいタスクのロック要求は先着順に並べ
る。
That is, the lock order changing means 3 refers to the lock priority section of the lock priority table 6 in the lock queue of the exclusive control table 5, and sorts the lock queue in the order of the lock priority of the task that issued each request. Sort. At this time, lock requests from tasks with the same lock priority are arranged on a first-come, first-served basis.

【0036】(4)ロック優先度設定手段4ロック優先
度設定手段4は、ロック要求処理手段1もしくはアンロ
ック要求処理手段2からロック中資源数が変更となった
タスクのタスク識別子をパラメータとして呼び出された
際に動作する。
(4) Lock priority setting means 4 The lock priority setting means 4 calls the task identifier of the task whose number of locked resources has been changed from the lock request processing means 1 or the unlock request processing means 2 as a parameter. It works when the

【0037】すなわち、ロック優先度変更手段4は、ロ
ック優先度テーブル6のパラメータで指定されたタスク
識別子に対するエントリに関し、ロック中資源数部を参
照してロック優先度を算出し、その値を当該エントリの
ロック優先度部に記録する。ロック優先度の算出は、ロ
ック中資源の数xにつきf(a)≧f(b)が成立する
a>bなるa,bが存在し、かつf(c)>f(d)が
成立するc>dなるc,dが存在する関数f(x)を用
いる。例えば、f(x)=xとしてロック中資源数その
ものをロック優先度とすることもできる。
That is, the lock priority changing means 4 calculates the lock priority by referring to the number of locked resources for the entry for the task identifier specified by the parameter of the lock priority table 6, and changes the value to the corresponding lock priority. Record in the lock priority section of the entry. Calculation of lock priority is based on the number of locked resources x, there exists a and b such that f(a)≧f(b) holds, and f(c)>f(d) holds. A function f(x) with c and d such that c>d is used. For example, f(x)=x and the number of locked resources itself can be used as the lock priority.

【0038】次に、本実施例の具体的動作について、図
3ないし図7を参照して説明する。
Next, the specific operation of this embodiment will be explained with reference to FIGS. 3 to 7.

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

【0040】図4ないし図7は図3における各時刻ta
〜tdでの排他制御テーブル5およびロック優先度テー
ブル6の状態を示している。なお、時刻tより前では、
資源R1,R2はロックされていないものとする。
FIGS. 4 to 7 show each time ta in FIG.
The states of the exclusive control table 5 and the lock priority table 6 at ~td are shown. Note that before time t,
It is assumed that resources R1 and R2 are not locked.

【0041】また、f(0)<f(1)<f(2)が成
立するような関数f(x)が用いられ、ロック優先度テ
ーブル6のロック中資源数部とロック優先度部とがそれ
ぞれ「0」,「f(0)」に初期化されているものとす
る。
In addition, a function f(x) such that f(0)<f(1)<f(2) holds is used, and the number of locked resources and lock priority part of the lock priority table 6 are are initialized to "0" and "f(0)", respectively.

【0042】時刻tでタスクT1が資源R1を排他モー
ドEでロック要求すると、ロック要求処理手段1が呼び
出され、資源R1はロックされていないので、タスクT
1にロック権が付与され、排他制御テーブル5のロック
モード部に排他モード「E」が、ロック中タスクリスト
にタスク識別子「T1」がそれぞれ記録される。
When task T1 requests to lock resource R1 in exclusive mode E at time t, lock request processing means 1 is called, and since resource R1 is not locked, task T1
1 is granted a lock right, exclusive mode "E" is recorded in the lock mode section of the exclusive control table 5, and task identifier "T1" is recorded in the locked task list.

【0043】また、ロック優先度テーブル6のタスクT
1のロック中資源数部に「1」が加えられ、ロック優先
度設定手段4が呼び出され、タスクT1のロック優先度
部に「f(1)」が設定される。
[0043] Also, the task T of the lock priority table 6
"1" is added to the number of locked resources section of 1, the lock priority setting means 4 is called, and "f(1)" is set in the lock priority section of task T1.

【0044】時刻t+1でタスクT2が資源R1を排他
モードEでロック要求すると、ロック要求処理手段1が
呼び出され、資源R1は既に排他モードEでロックされ
ているので、タスクT2はロック待ちとなり、排他制御
テーブル5のロック待ち行列にタスク識別子T2と排他
モードEとの組「T2,E」が記録される。
When task T2 requests to lock resource R1 in exclusive mode E at time t+1, lock request processing means 1 is called, and since resource R1 is already locked in exclusive mode E, task T2 waits for a lock. A pair “T2, E” of task identifier T2 and exclusive mode E is recorded in the lock queue of the exclusive control table 5.

【0045】続いて、ロック順序変更手段3が呼び出さ
れ、排他制御テーブル5のロック待ち行列の並べ換えが
行われるが、この時点でのロック待ちタスクはT2のみ
なので、実質的に意味はない。この後、タスクT2の処
理は中断され待ちに入る。
Subsequently, the lock order changing means 3 is called and the lock queue of the exclusive control table 5 is rearranged, but this is essentially meaningless since the only task waiting for the lock at this point is T2. After this, the processing of task T2 is interrupted and enters a wait state.

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

【0047】時刻t+4でタスクT3が資源R1を共有
モードSでロック要求すると、ロック要求処理手段1が
呼び出され、資源R1は既に排他モードでロックされて
いるので、排他制御テーブル5のロック待ち行列の最後
にタスク識別子T3と共有モードSとの組「T3,S」
が追加される。
When task T3 requests to lock resource R1 in shared mode S at time t+4, lock request processing means 1 is called, and since resource R1 is already locked in exclusive mode, the lock queue of exclusive control table 5 is At the end, a pair "T3,S" of task identifier T3 and shared mode S
will be added.

【0048】次に、ロック順序変更手段3が呼び出され
、タスクT2とタスクT3のロック優先度はそれぞれf
(0),f(1)であり、f(0)<f(1)であるこ
とから、タスクT3のロック要求,タスクT2のロック
要求の順にロック待ち行列が並べ換えられ、その後、タ
スクT3の処理が中断され、待ちに入る。すなわち、先
にロック要求したタスクT2をタスクT3が追い越し、
タスクT3へのロック権付与が優先される。この結果、
時刻tbでの排他制御テーブル5およびロック優先度テ
ーブル6は図5のような状態となる。
Next, the lock order changing means 3 is called, and the lock priorities of tasks T2 and T3 are respectively f.
(0), f(1), and since f(0)<f(1), the lock queue is rearranged in the order of task T3's lock request, task T2's lock request, and then task T3's lock request. Processing is interrupted and the system enters a waiting state. In other words, task T3 overtakes task T2, which requested the lock first, and
Priority is given to granting the lock right to task T3. As a result,
At time tb, the exclusive control table 5 and lock priority table 6 are in a state as shown in FIG.

【0049】時刻t+5でタスクT1が資源R1をアン
ロック要求(U)すると、アンロック処理手段2が呼び
出され、排他制御テーブル5のロック中タスクリストか
らタスク識別子T1が削除される。
When the task T1 requests (U) to unlock the resource R1 at time t+5, the unlock processing means 2 is called and the task identifier T1 is deleted from the locked task list of the exclusive control table 5.

【0050】続いて、ロック優先度テーブル6のタスク
T1のロック中資源数部から「1」が減じられ、タスク
識別子T1をパラメータとしてロック優先度設定手段4
が呼び出され、タスクT1のロック優先度部に「f(0
)」が設定される。この結果、排他制御テーブル5のロ
ック中タスクリストが空となるので、ロックモード部も
消去される。
Subsequently, "1" is subtracted from the number of locked resources of task T1 in the lock priority table 6, and the lock priority setting means 4 uses the task identifier T1 as a parameter.
is called, and “f(0
)” is set. As a result, the locked task list in the exclusive control table 5 becomes empty, and the lock mode section is also erased.

【0051】更に、ロック待ち行列は空ではないので、
最初のロック要求タスクT3にロック権が付与され、ロ
ックモード部に共有モードSが、ロック中タスクリスト
にタスク識別子T3がそれぞれ記録される。
Furthermore, since the lock queue is not empty,
A lock right is granted to the first lock requesting task T3, a shared mode S is recorded in the lock mode section, and a task identifier T3 is recorded in the locked task list.

【0052】次に、そのタスクT3のロック中資源数部
に「1」を加え、タスク識別子T3をパラメータとして
ロック優先度設定手段4が呼び出され、タスクT3のロ
ック優先度部に「f(2)」が設定された後、タスクT
3の処理が再開される。この結果、時刻tcでの排他制
御テーブル5およびロック優先度テーブル6は図6のよ
うな状態となる。
Next, "1" is added to the number of locked resources section of the task T3, the lock priority setting means 4 is called with the task identifier T3 as a parameter, and "f(2) is added to the lock priority section of the task T3. )” is set, task T
The process of step 3 is restarted. As a result, the exclusive control table 5 and lock priority table 6 at time tc are in a state as shown in FIG.

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

【0054】上記の例では、f(0)<f(1)<f(
2)であると仮定したが、a<bに対してf(a)=f
(b)のような関数f(x)も用いることができ、ロッ
ク中資源数が大差ない場合には先着順に処理した方がよ
いと思われるような環境では有利となる。この場合、動
作としては、ロック順序変更手段3でのロック待ち行列
の並べ換え時にロック中資源数bのタスクがロック中資
源数aのタスクに優先されず、先着順に並べられる点が
異なる以外は同様の処理となる。
In the above example, f(0)<f(1)<f(
2), but for a<b, f(a)=f
A function f(x) as shown in (b) can also be used, which is advantageous in an environment where it is considered better to process on a first-come, first-served basis when the number of locked resources is not significantly different. In this case, the operation is the same except that when the lock order changing means 3 rearranges the lock queue, the task with the number of locked resources b is not prioritized over the task with the number of locked resources a, but is arranged on a first-come, first-served basis. This will be the process.

【0055】また、ロック中資源数そのものをロック優
先度とした場合、f(0)<f(1)<……<f(n)
<f(n+1)<……となるので、タスクTa,Tbに
ついてロック中資源数をそれぞれa,bとすると、a>
bならば常にタスクTaのロック要求がタスクTbのロ
ック要求に優先されることになる。
[0055] Furthermore, when the number of locked resources itself is taken as the lock priority, f(0)<f(1)<...<f(n)
<f(n+1)<..., so if the numbers of locked resources for tasks Ta and Tb are a and b, respectively, then a>
If b, the lock request of task Ta always takes priority over the lock request of task Tb.

【0056】[0056]

【発明の効果】以上説明したように、本発明の共有資源
排他制御方式にあっては、ロック中資源数の増加に伴っ
て増加するようなロック優先度を導入し、ロック優先度
の高いタスクに対し、ロック優先度の低いタスクに優先
してロック権が付与されるよう制御することによって、
既にいくつかの資源をロックしているタスクが新たな資
源をロック要求してロック待ちとなった場合にロック待
ち時間を減少させることができ、当該タスクがロックし
ている資源に対しロック待ちしている他のタスクのロッ
ク待ち時間を減少させ、共有資源の使用効率を向上させ
ることができるという効果がある。
Effects of the Invention As explained above, in the shared resource exclusive control method of the present invention, a lock priority is introduced that increases as the number of locked resources increases, and a task with a high lock priority is However, by controlling tasks such that locking rights are given priority to tasks with lower locking priority,
When a task that has already locked some resources requests a lock on a new resource and becomes locked, the lock waiting time can be reduced. This has the effect of reducing the lock waiting time of other tasks, and improving the efficiency with which shared resources are used.

【図面の簡単な説明】[Brief explanation of the drawing]

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

【図2】図1における排他制御テーブルおよびロック優
先度テーブルの論理的構成を示す図である。
FIG. 2 is a diagram showing the logical configuration of an exclusive control table and a lock priority table in FIG. 1;

【図3】具体例を説明するためのタイミングチャートで
ある。
FIG. 3 is a timing chart for explaining a specific example.

【図4】排他制御テーブルおよびロック優先度テーブル
の状態の例を示す図である。
FIG. 4 is a diagram showing an example of the states of an exclusive control table and a lock priority table.

【図5】排他制御テーブルおよびロック優先度テーブル
の状態の例を示す図である。
FIG. 5 is a diagram showing an example of the states of an exclusive control table and a lock priority table.

【図6】排他制御テーブルおよびロック優先度テーブル
の状態の例を示す図である。
FIG. 6 is a diagram showing an example of the states of an exclusive control table and a lock priority table.

【図7】排他制御テーブルおよびロック優先度テーブル
の状態の例を示す図である。
FIG. 7 is a diagram showing an example of the states of an exclusive control table and a lock priority table.

【符号の説明】[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 table 6...Lock priority table 7...Shared resource exclusive control mechanism T1~Tn...Task R1, R2...Resources

Claims (2)

【特許請求の範囲】[Claims] 【請求項1】  電子計算機システムの共有資源排他制
御方式において、タスク対応にロック優先度を設け、タ
スクが資源をロックした時、およびタスクがロック権の
行使を終了した時、当該タスクのロック中資源の数xに
つきf(a)≧f(b)が成立するa>bなるa,bが
存在し、かつf(c)>f(d)が成立するc>dなる
c,dが存在する関数f(x)によって算出された値を
当該タスクのロック優先度として設定するロック優先度
設定手段と、タスクがロック待ちとなった時、ロック待
ちタスクへのロック権付与順序がロック優先度の高い順
となるようロック待ち行列を並べ換えるロック順序変更
手段とを備えたことを特徴とする共有資源排他制御方式
[Claim 1] In a shared resource exclusive control method for a computer system, a locking priority is set for each task, and when a task locks a resource, when a task finishes exercising the locking right, and when the task is currently locked. For each number x of resources, there exist a and b such that a>b such that f(a)≧f(b) holds, and there exist c and d such that c>d such that f(c)>f(d) holds. a lock priority setting means that sets a value calculated by a function f(x) as the lock priority of the task; and when a task becomes lock wait, the lock priority is set in the order in which lock rights are granted to the lock waiting task. 1. A shared resource exclusive control method comprising: lock order changing means for rearranging lock queues in descending order of lock queues.
【請求項2】  f(x)=xとしたことを特徴とする
請求項1記載の共有資源排他制御方式。
2. The shared resource exclusive control system according to claim 1, wherein f(x)=x.
JP4446291A 1991-02-15 1991-02-15 Exclusive control system for commonly shared resource Pending JPH04262425A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4446291A JPH04262425A (en) 1991-02-15 1991-02-15 Exclusive control system for commonly shared resource

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4446291A JPH04262425A (en) 1991-02-15 1991-02-15 Exclusive control system for commonly shared resource

Publications (1)

Publication Number Publication Date
JPH04262425A true JPH04262425A (en) 1992-09-17

Family

ID=12692163

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4446291A Pending JPH04262425A (en) 1991-02-15 1991-02-15 Exclusive control system for commonly shared resource

Country Status (1)

Country Link
JP (1) JPH04262425A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06282448A (en) * 1993-03-29 1994-10-07 Nec Corp Shared resource exclusive control system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06282448A (en) * 1993-03-29 1994-10-07 Nec Corp Shared resource exclusive control system

Similar Documents

Publication Publication Date Title
US8341636B2 (en) System and method for queue-less enforcement of queue-like behavior on multiple threads accessing a scarce resource
US7209990B2 (en) Maintain fairness of resource allocation in a multi-node environment
US7174552B2 (en) Method of accessing a resource by a process based on a semaphore of another process
US9361474B2 (en) Network filesystem asynchronous I/O scheduling
WO2008101756A1 (en) Method and system for concurrent message processing
Aranha et al. Implementation of a real-time database system
US9792419B2 (en) Starvationless kernel-aware distributed scheduling of software licenses
JPH0877025A (en) Method and device for controlling priority of task
JP2518134B2 (en) Shared resource exclusive control method
JPH04262425A (en) Exclusive control system for commonly shared resource
Haritsa et al. Real-time index concurrency control
JP3068556B2 (en) Shared resource exclusion control method and its program recording medium
JPH0512041A (en) Shared resource exclusive control system
JPH0478932A (en) Shared resource exclusion control system
JPH05120040A (en) Computer system
JPH0383142A (en) Shared resource exclusive control system
JPH04223533A (en) Common resource exclusive control system
US20130042247A1 (en) Starvationless Kernel-Aware Distributed Scheduling of Software Licenses
JPH02194442A (en) Shared resource controller
JP3036468B2 (en) Exclusive control processing device, exclusive control processing method, and storage medium storing exclusive control processing program
JPH0365732A (en) Resource managing method
JPH03257568A (en) Exclusive control system for shared resources
JPH02118843A (en) Shared resources exclusion control system
JPH09282185A (en) Real-time system and resource managing method for the same
JPH0586574B2 (en)