[go: up one dir, main page]

JPH0478932A - Shared resource exclusion control system - Google Patents

Shared resource exclusion control system

Info

Publication number
JPH0478932A
JPH0478932A JP19238290A JP19238290A JPH0478932A JP H0478932 A JPH0478932 A JP H0478932A JP 19238290 A JP19238290 A JP 19238290A JP 19238290 A JP19238290 A JP 19238290A JP H0478932 A JPH0478932 A JP H0478932A
Authority
JP
Japan
Prior art keywords
lock
task
request
mode
tasks
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
JP19238290A
Other languages
Japanese (ja)
Inventor
Yoshihisa 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 JP19238290A priority Critical patent/JPH0478932A/en
Publication of JPH0478932A publication Critical patent/JPH0478932A/en
Pending legal-status Critical Current

Links

Landscapes

  • Multi Processors (AREA)

Abstract

PURPOSE:To improve the use efficiency of shared resources by permitting a fact that a lock request task outruns in a shared mode, only in the case the number of shared mode lock request tasks which outrun the task for waiting for a lock in an exclusion mode is less than the maximum outrunning task number. CONSTITUTION:A shared resource exclusion control function 9 consists of a lock request processing part 6, an unlock request processing part 7 and an exclusion control table 8. In such a state, in the case resources are not locked against a lock request of a shared mode, the lock right is given to a task 10 which outputs a request, and in the case of the resources are locked in the shared mode, the lock right is given to the task 10 of the request unless there is a lock waiting task in an exclusion mode. Also, in the case there is the lock waiting task in the exclusion mode, and in any case of lock waiting, the number (the number of outrunning tasks) of shared mode lock request tasks which outrun the request sequence of the lock request in the exclusion mode is less than the maximum outrunning task number, the lock right is given to the task 10 which outputs the request. In such a way, by preventing generation of a permanent blockage, resources can be used efficiently.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は計算機システムにおける共存資源排他制御方式
に関する。
DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention relates to a coexisting resource exclusive control method in a computer system.

〔従来の技術〕[Conventional technology]

計算機システムにおいて複数のタスクから使用される資
源については、それへのアクセスを逐次化するために排
他制御が必要である。このような排他制御のために、計
算機システムには、ロック/アフロツタおよびエンキュ
ー/デキューと呼ばれる基本機能が備えられており、ロ
ック要求には通常排他モードと共有モードとの2種類が
ある。
Exclusive control is required for resources used by multiple tasks in a computer system in order to serialize access to them. For such exclusive control, computer systems are equipped with basic functions called lock/afrost and enqueue/dequeue, and there are usually two types of lock requests: exclusive mode and shared mode.

従来の排他制御の基本的動作は次のようになっている。The basic operation of conventional exclusive control is as follows.

即ち、あるタスクがロック要求を出した場合、ロック要
求対象資源が他のタスクによりロックされていないなら
ば、すぐにロック権が与えられる。しかし、他のタスク
によりすでにロックされている場合は、その資源がロッ
クされたモードまたは要求を出したタスクのロック要求
のモードが排他モードのときはロック待ちとなる。その
資源がロックされたモードと要求を出したタスクのロッ
ク要求のモードとがともに共有モードのときは、 (1)ロック待ちタスクがない場合は、要求を出したタ
スクにロック権を与え、ロック待ちタスクがある場合は
、要求を出したタスクをロック待ちとする。
That is, when a certain task issues a lock request, the lock right is immediately granted if the resource to which the lock request is made is not locked by another task. However, if the resource is already locked by another task and the mode in which the resource is locked or the lock request mode of the requesting task is in exclusive mode, the task waits for a lock. If the mode in which the resource is locked and the lock request mode of the task that issued the request are both shared mode, (1) If there is no task waiting for the lock, the task that issued the request is given the lock right, and If there is a waiting task, the task that issued the request is made to wait for a lock.

(2)要求を出したタスクに直ちにロック権を与える。(2) Immediately grant lock rights to the task that issued the request.

のいずれかの方法がとられる。Either of the following methods may be used.

また、資源をロックしていたタスクがアンロツタ要求を
出した場合はこのタスクのロック権の行使が終了する。
Further, if the task that has locked the resource issues an unlotter request, the exercise of the locking right by this task ends.

このとき、他にロックしているタスクがなく、かつロッ
ク待ちタスクがある場合には、それらの内、最も早くロ
ック要求したタスクの要求モードが排他モードならば、
このタスクのみにロック権を与え、共有モードならば上
述の(1)(2)に対応して、 (1)現在排他モードでロック待ちしているどのタスク
よりも早く共有モードでロック待ちしているタスクすべ
てにロック権を与える。
At this time, if there is no other task holding the lock and there is a task waiting for the lock, if the request mode of the task that requested the lock earliest among them is exclusive mode,
If the lock is granted only to this task, and if it is in shared mode, then (1) it will wait for a lock in shared mode earlier than any task that is currently waiting for a lock in exclusive mode, corresponding to (1) and (2) above. Give lock rights to all tasks that are currently in the list.

(2)現在共有モードでロック待ちしているタスクすべ
てにロック権を与える。
(2) Give lock rights to all tasks currently waiting for a lock in shared mode.

のいずれかの方法がとられる。Either of the following methods may be used.

〔発明が解決しようとする課題〕[Problem to be solved by the invention]

上述した(1)の方法を採用した従来の共有資源排他制
御方式では、いかなる場合も共有モードのロック要求を
出したタスクが排他モードのロック要求を出したタスク
を追越してロックできないため、現在のロックが解け、
次のロック待ちタスクにロック権を与える際、ロック待
ちタスクのロックモードが共有モードであるときは、排
他モードのロック待ちタスクがあると、それ以後に共有
モードでロック待ちになったタスクにはロック権が与え
られず、資源を効率良く使用できない。
In the conventional shared resource exclusive control method that adopts method (1) above, the task that issued the shared mode lock request cannot overtake and lock the task that issued the exclusive mode lock request under any circumstances. unlocked,
When granting the lock right to the next task waiting for a lock, if the lock mode of the task waiting for the lock is shared mode, if there is a task waiting for the lock in exclusive mode, the task that is waiting for the lock in shared mode after that Lock rights are not granted and resources cannot be used efficiently.

また、上述した(2)の方法を採用した従来の共有資源
排他制御方式では、共有モードのロック要求が排他モー
ドのロック要求よりも頻繁に行われると、いつまでも排
他モードでロック要求したタスクにロック権が与えられ
ない状況、即ち永久封鎖が発生するという欠点がある。
In addition, in the conventional shared resource exclusive control method that adopts method (2) above, if shared mode lock requests are made more frequently than exclusive mode lock requests, the task that requested the lock will be locked in exclusive mode forever. The disadvantage is that a situation in which rights are not granted, that is, a permanent blockade occurs.

〔課題を解決するための手段〕[Means to solve the problem]

本発明の共有資源排他制御方式は、計算機システムの共
有資源排他制御方式において、共有モードのロック要求
に対し、 資源がロックされていない場合は、前記要求を出したタ
スクにロック権を与え、 資源が共有モードでロックされている場合は、排他モー
ドのロック待ちタスクがなければ前記要求を出したタス
クにロック権を与え、排他モードのロック待ちタスクが
あり、このロック待ちのいずれにおいても、その排他モ
ードのロック要求の要求順序を追越した共有モードロッ
ク要求タスクの数(以下「追越しタスク数」という)が
最大追越しタスク数N未満であれば前記要求を出したタ
スクにロック権を与え、 最大追越しタスク数Nの排他モードのロック待ちタスク
があり、さらに最大追越しタスク数N未満の排他モード
ロック待ちタスクがある場合は、最大追越しタスク数N
未満のタスクの中で最も多く共有モードロック要求タス
クに追越されたタスクの前にロック権が与えられるよう
ロック権の付与順序を変更して前記要求を出したタスク
をロック待ちとし、 最大追越しタスク数Nの排他モードロック待ちタスクが
ある場合は、現在のロック待ちタスクの中で最後にロッ
ク権が与えられるよう前記要求を出したタスクをロック
待ちとする共有要求処理手段と、 アンロック要求に対し、次にロック権を与えるべきロッ
ク待ちタスクが共有モードで要求している場合は、どの
排他モードのロック待ちタスクよりも先にロック権を与
えるべき共有モードのロック要求を出したタスクすべて
にロック権を与えるアンロック要求処理手段とを有する
ことにより構成される。
The shared resource exclusive control method of the present invention is a shared resource exclusive control method for a computer system in which, in response to a shared mode lock request, if the resource is not locked, the task that issued the request is given the locking right, and the resource is locked. is locked in shared mode, if there is no task waiting for a lock in exclusive mode, the lock right is given to the task that issued the request, and if there is a task waiting for a lock in exclusive mode, that If the number of shared mode lock requesting tasks that have overtaken the request order of the exclusive mode lock request (hereinafter referred to as the "overtaking task number") is less than the maximum overtaking task number N, the locking right is given to the task that issued the above request, and the maximum If there are lock-waiting tasks in exclusive mode with the number of overtaking tasks N, and there are tasks waiting for exclusive mode locks with a number less than the maximum number of overtaking tasks N, then the maximum number of overtaking tasks is N.
The order in which the lock rights are granted is changed so that the lock rights are granted before the task that has been overtaken by the shared mode lock requesting task the most among the tasks with less than the maximum number of overtaken tasks, and the task that issued the request is placed in a lock wait state. If there are N tasks waiting for an exclusive mode lock, a shared request processing means makes the task that issued the request wait for the lock so that it will be granted the lock right last among the tasks currently waiting for the lock; and an unlock request. However, if the next lock-waiting task to which the lock right should be granted is making a request in shared mode, all tasks that have issued a shared-mode lock request to which the lock right should be granted before any exclusive mode lock-waiting task and unlock request processing means for granting lock rights to.

〔実施例〕〔Example〕

次に、本発明について図面を参照して説明する。 Next, the present invention will be explained with reference to the drawings.

第1図は本発明の一実施例の構成図である。本実施例に
おいて、共有資源排他制御機能9はロック要求処理部6
とアンロック要求処理部7と排他制御テーブル8とから
なる。ロック要求処理部6は共有モードのロック要求を
処理する共有要求処理手段1と、排他モードのロック要
求を処理する排他要求処理手段2とからなる。また、ア
ンロック要求処理部7はアンロック要求したタスクのロ
ック解除を行うロック解除手段3と、次のロック待ちタ
スクの要求モードが共有モードの場合のロック処理を行
う共有待ちロック手段4と、次のロック待ちタスクの要
求モードが排他モードの場合のロック処理を行う排他待
ちロック手段5とからなる。
FIG. 1 is a block diagram of an embodiment of the present invention. In this embodiment, the shared resource exclusive control function 9 is the lock request processing unit 6.
, an unlock request processing section 7 , and an exclusive control table 8 . The lock request processing unit 6 includes a shared request processing means 1 that processes lock requests in a shared mode, and an exclusive request processing means 2 that processes lock requests in an exclusive mode. Further, the unlock request processing unit 7 includes an unlocking means 3 that unlocks a task that has requested an unlock, a shared waiting locking means 4 that performs a locking process when the request mode of the next lock waiting task is a shared mode, and an exclusive wait lock means 5 that performs lock processing when the request mode of the next lock wait task is exclusive mode.

第2図は第1図の排他制御テーブル8の構成図である。FIG. 2 is a configuration diagram of the exclusive control table 8 of FIG. 1.

排他制御テーブル8は、システム内の排他制御対象資源
を一意に識別するための名前である資源名をキーとする
。各資源に対するエントリは、資源名部81とロックモ
ード部82とロック中タスクリスト83とロック待ちタ
スクキュー84とからなる。ロックモード部82は資源
がロックされているときのロックモードを記録する。ロ
ック中タスクリスト83はその資源をロックしているタ
スクのタスク識別子を記録する。ロック待ちタスクキュ
ー84は待ち状態にあるロック要求の待ち行列であり、
共有モードのロック要求を出しているタスクではタスク
識別子とロックモードとの組を、排他モードのロック要
求を出しているタスクではタスク識別子とロックモード
と追越しタスク数との組を記録する。
The exclusive control table 8 uses resource names as keys to uniquely identify resources subject to exclusive control within the system. The entry for each resource consists of a resource name field 81, a lock mode field 82, a locked task list 83, and a lock waiting task queue 84. The lock mode section 82 records the lock mode when a resource is locked. The locked task list 83 records the task identifiers of tasks that have locked the resource. The lock waiting task queue 84 is a queue of lock requests in a waiting state,
For a task issuing a shared mode lock request, a pair of task identifier and lock mode is recorded, and for a task issuing an exclusive mode lock request, a pair of task identifier, lock mode, and number of overtaking tasks is recorded.

次に第1図の各処理部の動作について説明する。Next, the operation of each processing section shown in FIG. 1 will be explained.

共有要求処理手段1は、共有モードのロック要求の処理
を行う。即ち、 (1)ロックモード部82が空の場合、共有モードをロ
ックモード部82に記録し、要求を出したタスクのタス
ク識別子をロック中タスクリスト83に追加し、このタ
スクにロック権を与える。
The share request processing means 1 processes lock requests in the share mode. That is, (1) If the lock mode section 82 is empty, the shared mode is recorded in the lock mode section 82, the task identifier of the task that issued the request is added to the locked task list 83, and the locking right is given to this task. .

(2)ロックモード部82が空でない場合、ロック待ち
タスクキュー84内のロック要求を先頭がら順に走査し
、追越しタスク数が最大追越しタスク数N未満の場合は
走査を終了する。また、全てのロック要求を検査し終わ
った場合は走査を終了する。この走査の結果、最大追越
しタスク数がN未満の排他モードロック要求が見っから
ながった場合は、ロック待ちタスクキュー84の最後に
この共有モードロック要求を出したタスクのタスク識別
子とロックモードとの組を追加し、このタスクの処理を
中断させてロック待ちとする。ロック待ちタスクキュー
84の先頭の要求で走査が終了し、資源が共有モードで
ロックされている場合は、この要求を出したタスクのタ
スク識別子をロック中タスクリスト83に追加してこの
タスクにロック権を与え、ロック待ちタスクキュー84
のすべての排他モードロック要求の追越しタスク数に1
を加える。その他の場合は、走査を終了した排他モード
ロック要求の直前にこの共有モードロック要求を出した
タスクのタスク識別子とロックモードとの組を挿入し、
このタスクの処理を中断させて、ロック待ちとし、走査
を終了した排他モードロック要求を含め、後続するすべ
ての排他モードロック要求の追越しタスク数に1を加え
る。
(2) If the lock mode section 82 is not empty, the lock requests in the lock waiting task queue 84 are scanned in order from the beginning, and if the number of overtaking tasks is less than the maximum number N of overtaking tasks, the scanning is ended. Furthermore, when all lock requests have been checked, the scan ends. As a result of this scanning, if an exclusive mode lock request for which the maximum number of overtaking tasks is less than N disappears, the task identifier of the task that issued this shared mode lock request and the lock Add a pair with mode, interrupt the processing of this task, and wait for a lock. If the scan ends with the request at the head of the lock waiting task queue 84 and the resource is locked in shared mode, the task identifier of the task that issued this request is added to the locked task list 83 and this task is locked. Lock waiting task queue 84
1 for the number of overtaking tasks for all exclusive mode lock requests.
Add. In other cases, insert the task identifier and lock mode pair of the task that issued this shared mode lock request immediately before the exclusive mode lock request that has finished scanning,
The processing of this task is interrupted, the task is made to wait for a lock, and 1 is added to the number of overtaking tasks for all subsequent exclusive mode lock requests, including the exclusive mode lock request that has finished scanning.

上記(2)により、資源が共有モードでロックされてお
り、かつ排他モードでロック待ちしているタスクがある
場合、新たな共有モードのロック要求タスクが追越せる
排他モードのロック待ちタスクは、追越した共有モード
ロック要求タスク数が最大追越しタスク数N未満のタス
クに限られることになり、永久封鎖は発生しない。
According to (2) above, if a resource is locked in shared mode and there is a task waiting for the lock in exclusive mode, the lock waiting task in exclusive mode that can be overtaken by a new shared mode lock request task is This means that the number of shared mode lock requesting tasks is less than the maximum overtaking task number N, and no permanent blockage occurs.

共有待ちロック手段4は、アンロツタ要求処理において
、次のロック待ちタスクが共有モードで要求している場
合のロック処理を行う。即ち、(1)ロックモード部8
2に共有モードを記録し、ロック待ちタスクキュー84
の先頭から、連続するすべての共有モードロック要求の
タスク識別子をロック中タスクリスト83に記録する。
The shared waiting lock means 4 performs lock processing when the next lock waiting task requests in the shared mode in the unlotter request process. That is, (1) lock mode section 8
2, record the shared mode in the lock waiting task queue 84
The task identifiers of all consecutive shared mode lock requests are recorded in the locked task list 83 from the beginning.

次に、この記録が行われたロック要求をロック待ちタス
クキュー84から削除し、これらのタスクの処理を再開
させ、ロック権を与える。
Next, the recorded lock request is deleted from the lock waiting task queue 84, the processing of these tasks is restarted, and lock rights are granted.

排他要求処理手段2は、排他モードのロック要求の処理
を行う。即ち、 (1)ロックモード部82が空の場合、要求のロックモ
ードをロックモード部82に記録し、この要求を出した
タスクのタスク識別子をロック中タスクリスト83に記
録し、ロック権を与える。
The exclusive request processing means 2 processes exclusive mode lock requests. That is, (1) If the lock mode section 82 is empty, the lock mode of the request is recorded in the lock mode section 82, the task identifier of the task that issued this request is recorded in the locked task list 83, and locking rights are granted. .

(2)ロックモード部82が空でない場合、要求を出し
たタスクのタスク識別子とこの要求のロックモードと追
越しタスク数Oとの組をロック待ちタスクキュー84の
最後に追加し、この要求を出したタスクの処理を中断さ
せ、ロック待ちとする。
(2) If the lock mode field 82 is not empty, add the task identifier of the task that issued the request, the lock mode of this request, and the number of overtaking tasks O to the end of the lock waiting task queue 84, and issue this request. interrupts the processing of the task and waits for the lock.

ロック解除手段3は、アンロツタ要求された場合のロッ
ク解除処理を行い、ロック待ちタスクがある場合には、
次のロック待ちタスクのロック処理を行うため共有待ち
ロック手段4、または排他待ちロック手段5を呼出す。
The lock release means 3 performs a lock release process when an unloading request is made, and if there is a task waiting for a lock,
The shared waiting locking means 4 or the exclusive waiting locking means 5 is called to perform lock processing for the next lock waiting task.

即ち、 (1)アンロツタ要求したタスクのタスク識別子をロッ
ク中タスクリスト83から削除し、ロック中タスクリス
ト83が空になったならば、ロックモード部82の内容
を消去する。
That is, (1) The task identifier of the task that requested unlotta is deleted from the locked task list 83, and when the locked task list 83 becomes empty, the contents of the lock mode section 82 are deleted.

(2)続いて、ロック中タスクリスト82が空になった
場合、ロック待ちタスクキュー84の先頭のロック要求
が共有モードなら共有待ちロック手段4を、排他モード
なら排他待ちロック手段5を呼出す。
(2) Subsequently, when the locked task list 82 becomes empty, if the lock request at the head of the lock waiting task queue 84 is in the shared mode, the shared waiting locking means 4 is called, and if the locking request is in the exclusive mode, the exclusive waiting locking means 5 is called.

排他待ちロック手段5はロック解除手段3から呼出され
、排他モードのロック待ちタスクのロック処理を行う。
The exclusive wait locking means 5 is called by the lock release means 3 and performs lock processing for lock waiting tasks in exclusive mode.

即ち、 (1)ロック待ちタスクキュー84の先頭にある要求の
ロックモードをロックモード部82に、タスク識別子を
ロック中タスクリスト83にそれぞれ記録し、このロッ
ク要求をロック待ちタスクキュー84から削除し、ロッ
ク要求を出したタスクの処理を再開させ、ロック権を与
える。
That is, (1) Record the lock mode of the request at the head of the lock waiting task queue 84 in the lock mode section 82 and the task identifier in the locked task list 83, and delete this lock request from the lock waiting task queue 84. , restarts processing of the task that issued the lock request, and grants lock rights.

次に、本実施例の具体的動作について、第3図の排他制
御テーブル8の内容例を参照して説明する。本実施例で
は最大追越しタスク数Nは固定値2であると仮定する。
Next, the specific operation of this embodiment will be explained with reference to an example of the contents of the exclusive control table 8 in FIG. 3. In this embodiment, it is assumed that the maximum number of overtaking tasks N is a fixed value of two.

第3図(a)〜(f)は、いずれもある時点での排他制
御テーブル8の状態を示している。
3(a) to 3(f) each show the state of the exclusive control table 8 at a certain point in time.

第3図(a)は資源RをタスクT1が共をモードでロッ
クし、タスクT2が排他モード、追越しタスク数Oでロ
ック待ちしている。このときタスクT3が共有モードで
ロック要求すると、共有要求処理手段1が呼ばれる。資
源Rは共有モードでロックされているので、ロック待ち
タスクキュー84を先頭から走査し、タスクT2の排他
モードのロック要求を見つける。この要求の追越しタス
ク数は0であり、最大追越しタスク数2より小さいので
走査を終了する。ロック待ちタスクキュー84の先頭で
走査を終了し、かつ資源Rが共有モードでロックされて
いるので、要求したタスクのタスク識別子T3がロック
中タスクリスト83に追加され、要求したタスクにロッ
ク権が与えられる。また、タスクT2の追越しタスク数
に1が加えられる。この結果、排他制御テーブル8は第
3図(b)の状態となる。
In FIG. 3(a), task T1 has locked resource R in mutual mode, and task T2 is waiting to lock it in exclusive mode with the number of overtaking tasks being O. At this time, when task T3 makes a lock request in the shared mode, the sharing request processing means 1 is called. Since the resource R is locked in shared mode, the lock waiting task queue 84 is scanned from the beginning to find the exclusive mode lock request of task T2. The number of overtaking tasks in this request is 0, which is smaller than the maximum number of overtaking tasks, 2, so scanning is terminated. Since the scan ends at the head of the lock waiting task queue 84 and the resource R is locked in shared mode, the task identifier T3 of the requested task is added to the locked task list 83, and the requested task is given the locking right. Given. Further, 1 is added to the number of overtaking tasks of task T2. As a result, the exclusive control table 8 is in the state shown in FIG. 3(b).

次にタスクT4が排他モードでロック要求すると、排他
要求処理手段2が呼ばれる。すでに資源Rがロックされ
ているため、このタスクのタスク識別子T4と要求モー
ドEと追越しタスク数Oとの組がロック待ちタスクキュ
ー84に記録され、このタスクの処理が中断され、ロッ
ク待ちとなる。
Next, when task T4 makes a lock request in exclusive mode, exclusive request processing means 2 is called. Since the resource R is already locked, a set of the task identifier T4, request mode E, and number of overtaking tasks O for this task is recorded in the lock waiting task queue 84, and the processing of this task is interrupted and the task becomes locked. .

この結果、排他制御テーブル8は第3図(C)の状態と
なる。
As a result, the exclusive control table 8 is in the state shown in FIG. 3(C).

次にタスクT5が共有モードで口・ツク要求すると、共
有要求処理手段1が呼ばれる。資源Rかすでに共存モー
ドでロックされているため、口、ツク待ちタスクキュー
84を先頭から順に走査し、タスクT2の排他モードの
ロック要求を見つける。
Next, when task T5 makes a request in the sharing mode, the sharing request processing means 1 is called. Since the resource R is already locked in the coexistence mode, the task queue 84 waiting for a lock is sequentially scanned from the top to find the exclusive mode lock request of the task T2.

追越しタスク数は1であり、最大追越しタスク数2より
も小さいので走査を終了する。ロック待ちタスクキュー
84の先頭の要求で終了し、かつ資源Rが共有モードで
ロックされているので、口・ツタ中タスクリスト83に
タスク識別子T5が追加され、タスクT5にロック権が
与えられる。また、走査が終了したロック要求以降のす
べての排他モードロック要求の追越しタスク数に1が加
えられる。この結果、排他制御テーブル8は第3図(d
)の状態となる。
The number of overtaking tasks is 1, which is smaller than the maximum number of overtaking tasks 2, so scanning is ended. Since the request ends with the first request in the lock waiting task queue 84 and the resource R is locked in the shared mode, the task identifier T5 is added to the mouth/vine task list 83 and the locking right is given to the task T5. Further, 1 is added to the number of overtaking tasks for all exclusive mode lock requests after the lock request for which scanning has been completed. As a result, the exclusive control table 8 is
).

次にタスクT6が共有モードでロック要求すると、共有
要求処理手段1が呼ばれる。資源Rがすでに共有モード
でロックされているため、ロック待ちタスクキュー84
を先頭から順に走査し、タスクT2の排他モードロック
要求を見つける。追越しタスク数は2であり、最大追越
しタスク数2と等しいので走査を継続する。次に、タス
クT4の排他モードロック要求を見つける。追越しタス
ク数は1であり、最大追越しタスク数2より小さいので
走査を終了する。ロック待ちタスクキュー84の先頭で
の終了ではないので、走査を終了した要求の直前に新し
くロック要求したタスクのタスク識別子T6と要求モー
ドSとの組が挿入され、タスクT6の処理が中断されて
、ロック待ちとなる。また、走査を終了したタスクT4
の排他モードロック要求の追越しタスク数に1が加えら
れる。
Next, when task T6 requests a lock in the shared mode, the sharing request processing means 1 is called. Since resource R is already locked in shared mode, the lock waiting task queue 84
is sequentially scanned from the beginning to find the exclusive mode lock request of task T2. The number of overtaking tasks is 2, which is equal to the maximum number of overtaking tasks 2, so scanning is continued. Next, find the exclusive mode lock request of task T4. The number of overtaking tasks is 1, which is smaller than the maximum number of overtaking tasks 2, so scanning is ended. Since the end is not at the head of the lock waiting task queue 84, the pair of task identifier T6 and request mode S of the task newly requesting the lock is inserted immediately before the request that has finished scanning, and the processing of task T6 is interrupted. , it will be waiting for a lock. Also, task T4 that has finished scanning
1 is added to the number of overtaking tasks for the exclusive mode lock request.

続いて、タスクT7が共有モードでロック要求すると、
共有要求処理手段1が呼ばれる。資源Rがすでに共有モ
ードでロックされているため、ロック待ちタスクキュー
84を先頭から順に走査する。追越しタスク数が最大追
越しタスク数2未満の排他モードロック要求はないので
、ロック待ちタスクキュー84の最後にタスク識別子T
7と要求モードSとの組が追加され、タスクT7の処理
が中断されてロック待ちとなる。この結果、排他制御テ
ーブル8は第3図(e)の状態となる。
Next, when task T7 requests a lock in shared mode,
The sharing request processing means 1 is called. Since resource R is already locked in shared mode, the lock waiting task queue 84 is scanned in order from the beginning. Since there is no exclusive mode lock request for which the number of overtaking tasks is less than the maximum number of overtaking tasks, 2, the task identifier T is placed at the end of the lock waiting task queue 84.
A pair of task T7 and request mode S is added, and the processing of task T7 is interrupted to wait for a lock. As a result, the exclusive control table 8 is in the state shown in FIG. 3(e).

次に、タスクT1、T3、T5がこの順にアンロック要
求すると、各アンロック要求についてロック解除手段3
が呼出される。タスクT1、T3についてはロック中タ
スクリスト83からタスク識別子Tl、T3が削除され
、いずれにおいてもロック中タスクリストは空にならな
いので、これで処理を終わる。タスクT5のアンロック
要求では、ロック中タスクリスト83からタスク識別子
T5を削除すると、ロック中タスクリスト83が空とな
るので、ロック待ちタスクキュー84の先頭の要求を調
べる。先頭は排他モードの要求なので、排他待ちロック
手段5が呼出され、排他モードEをロックモード部82
に、タスク識別子T2をロック中タスクリスト83にそ
れぞれ記録し、この排他モードのロック要求をロック待
ちタスクキュー84から削除し、ロック要求を出したタ
スクの処理を再開させて、ロック権を与える。この結果
、排他制御テーブル8は第3図(f)の状態となる。
Next, when tasks T1, T3, and T5 make unlock requests in this order, the unlocking means 3
is called. For tasks T1 and T3, the task identifiers Tl and T3 are deleted from the locked task list 83, and since the locked task list is not empty in either case, the process ends here. Regarding the unlock request for task T5, if the task identifier T5 is deleted from the locked task list 83, the locked task list 83 becomes empty, so the request at the head of the lock waiting task queue 84 is checked. Since the first request is for the exclusive mode, the exclusive waiting lock means 5 is called and the exclusive mode E is set to the lock mode section 82.
Then, the task identifier T2 is recorded in the locked task list 83, this exclusive mode lock request is deleted from the lock waiting task queue 84, and the task that issued the lock request is restarted and given the lock right. As a result, the exclusive control table 8 is in the state shown in FIG. 3(f).

次に、タスクT2がアンロック要求すると、ロック解除
手段3が呼出され、ロック中タスクリスト83からタス
ク識別子T2が削除される。ロック中タスクリスト83
が空となったので、ロックモード部82を消去する。ロ
ック待ちタスクキュー84の先頭の要求が共有モードな
ので、共有待ちロック手段4が呼出され、ロックモード
部82に共有モードSが、ロック中タスクリスト83に
、ロック待ちタスクキュー84の先頭から連続するすべ
ての共有モードロック要求のタスク識別子としてT6が
それぞれ記録される。ロック待ちタスクキュー84から
タスクT6の要求を削除し、タスクT6の処理が再開さ
れてロック権が与えられる。この結果、排他制御テーブ
ル8は第3図(g)の状態となる。
Next, when the task T2 makes an unlock request, the lock release means 3 is called and the task identifier T2 is deleted from the locked task list 83. Locked task list 83
Since it is now empty, the lock mode section 82 is deleted. Since the request at the head of the lock-waiting task queue 84 is in the shared mode, the share-waiting lock means 4 is called, and the locking mode section 82 has the shared mode S, and the locking task list 83 has the shared mode continuously from the head of the lock-waiting task queue 84. T6 is recorded as the task identifier for all shared mode lock requests, respectively. The request for task T6 is deleted from the lock waiting task queue 84, the processing of task T6 is restarted, and the lock right is granted. As a result, the exclusive control table 8 is in the state shown in FIG. 3(g).

本実施例では、最大追越しタスク数を資源の種類にかか
わらず固定値Nとしたが、排他制御テーブル8内に最大
追越しタスク数の欄を設けて各資源ごとに異なった最大
追越しタスク数Nを記録し、これを用いて制御すること
も可能である。
In this embodiment, the maximum number of overtaking tasks is set to a fixed value N regardless of the type of resource, but a column for the maximum number of overtaking tasks is provided in the exclusive control table 8 to set a different maximum number of overtaking tasks N for each resource. It is also possible to record and use this to control.

〔発明の効果〕〔Effect of the invention〕

以上説明したように本発明は、排他モードでロック待ち
しているタスクを追越した共有モードロック要求タスク
の数が、最大追越しタスク数N未満である場合に限り、
共有モードでロック要求したタスクが追越すのを許すこ
とにより、永久封鎖の問題を避けながら共有資源の使用
効率を向上させることができる効果がある。
As explained above, in the present invention, only when the number of shared mode lock requesting tasks that have overtaken a task waiting for a lock in exclusive mode is less than the maximum number of overtaking tasks N,
By allowing a task that requests a lock to overtake in shared mode, it is possible to improve the efficiency of using shared resources while avoiding the problem of permanent blockage.

制御テーブルの内容例の図である。It is a figure of the example of the content of a control table.

1・・・共有要求処理手段、2・・・排他要求処理手段
、3・・・ロック解除手段、4・・・共有待ちロック手
段、5・・・排他待ちロック手段、6・・・ロック要求
処理部、7・・・アンロック要求処理部、8・・・排他
制御テーブル、9・・・共有資源排他制御機能、10・
・・共存資源使用タスク。
DESCRIPTION OF SYMBOLS 1...Sharing request processing means, 2...Exclusion request processing means, 3...Lock release means, 4...Sharing waiting locking means, 5...Exclusion waiting locking means, 6...Lock request Processing unit, 7... Unlock request processing unit, 8... Exclusive control table, 9... Shared resource exclusive control function, 10.
...Coexisting resource usage tasks.

Claims (1)

【特許請求の範囲】 計算機システムの共有資源排他制御方式において、共有
モードのロック要求に対し、 資源がロックされていない場合は、前記要求を出したタ
スクにロック権を与え、 資源が共有モードでロックされている場合は、排他モー
ドのロック待ちタスクがなければ前記要求を出したタス
クにロック権を与え、排他モードのロック待ちタスクが
あり、このロック待ちのいずれにおいても、その排他モ
ードのロック要求の要求順序を追越した共有モードロッ
ク要求タスクの数(以下「追越しタスク数」という)が
最大追越しタスク数N未満であれば前記要求を出したタ
スクにロック権を与え、 最大追越しタスク数Nの排他モードのロック待ちタスク
があり、さらに最大追越しタスク数N未満の排他モード
ロック待ちタスクがある場合は、最大追越しタスク数N
未満のタスクの中で最も多く共有モードロック要求タス
クに追越されたタスクの前にロック権が与えられるよう
ロック権の付与順序を変更して前記要求を出したタスク
をロック待ちとし、 最大追越しタスク数Nの排他モードロック待ちタスクが
ある場合は、現在のロック待ちタスクの中で最後にロッ
ク権が与えられるよう前記要求を出したタスクをロック
待ちとする共有要求処理手段と、 アンロック要求に対し、次にロック権を与えるべきロッ
ク待ちタスクが共有モードで要求している場合は、どの
排他モードのロック待ちタスクよりも先にロック権を与
えるべき共有モードのロック要求を出したタスクすべて
にロック権を与えるアンロック要求処理手段とを有する
ことを特徴とする共有資源排他制御方式。
[Claims] In a shared resource exclusive control method for a computer system, in response to a shared mode lock request, if the resource is not locked, a locking right is granted to the task that issued the request, and the resource is in the shared mode. If the lock is locked, if there is no task waiting for a lock in exclusive mode, the lock right is given to the task that issued the request; If the number of shared mode lock requesting tasks that have overtaken the request order (hereinafter referred to as the "number of overtaking tasks") is less than the maximum number of overtaking tasks N, the task that issued the request is given locking rights, and the maximum number of overtaking tasks N If there are exclusive mode lock waiting tasks, and there are exclusive mode lock waiting tasks less than the maximum number of overtaking tasks N, then the maximum number of overtaking tasks N
The order in which the lock rights are granted is changed so that the lock rights are granted before the task that has been overtaken by the shared mode lock requesting task the most among the tasks with less than the maximum number of overtaken tasks, and the task that issued the request is placed in a lock wait state. If there are N tasks waiting for an exclusive mode lock, a shared request processing means makes the task that issued the request wait for the lock so that it will be granted the lock right last among the tasks currently waiting for the lock; and an unlock request. However, if the next lock-waiting task to which the lock right should be granted is making a request in shared mode, all tasks that have issued a shared-mode lock request to which the lock right should be granted before any exclusive mode lock-waiting task 1. A shared resource exclusive control system comprising: unlock request processing means for granting lock rights to a shared resource.
JP19238290A 1990-07-20 1990-07-20 Shared resource exclusion control system Pending JPH0478932A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP19238290A JPH0478932A (en) 1990-07-20 1990-07-20 Shared resource exclusion control system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP19238290A JPH0478932A (en) 1990-07-20 1990-07-20 Shared resource exclusion control system

Publications (1)

Publication Number Publication Date
JPH0478932A true JPH0478932A (en) 1992-03-12

Family

ID=16290368

Family Applications (1)

Application Number Title Priority Date Filing Date
JP19238290A Pending JPH0478932A (en) 1990-07-20 1990-07-20 Shared resource exclusion control system

Country Status (1)

Country Link
JP (1) JPH0478932A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH074401A (en) * 1993-06-16 1995-01-10 Smc Corp Electropneumatic converter and actuator system using electric-pneumatic converter
JP2010029745A (en) * 2008-07-25 2010-02-12 Ngk Insulators Ltd Homogenous valve and homogenizer using the same
JP2011173199A (en) * 2010-02-24 2011-09-08 Makino Milling Mach Co Ltd Machine tool, working fluid feeder, and working fluid

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH074401A (en) * 1993-06-16 1995-01-10 Smc Corp Electropneumatic converter and actuator system using electric-pneumatic converter
JP2010029745A (en) * 2008-07-25 2010-02-12 Ngk Insulators Ltd Homogenous valve and homogenizer using the same
JP2011173199A (en) * 2010-02-24 2011-09-08 Makino Milling Mach Co Ltd Machine tool, working fluid feeder, and working fluid

Similar Documents

Publication Publication Date Title
JPH01298440A (en) Computer system and its task scheduling method
JP2705717B2 (en) Locking device and method, device and method for determining granularity of lock request
US5537645A (en) File lock management in a distributed data processing system
US7325064B2 (en) Distributed locking protocol with asynchronous token prefetch and relinquish
JPH07191944A (en) System and method for prevention of deadlock in instruction to many resources by multiporcessor
US6185650B1 (en) High performance locking facility
KR102450133B1 (en) Distributed sysetm for managing distributed lock and operating method thereof
JP2005509944A (en) Entry lock for large data structures
JPH0478932A (en) Shared resource exclusion control system
EP0013301B1 (en) Multiprocessor system with enqueue facility for access to sharable data facilities
JPH0383142A (en) Shared resource exclusive control system
JP2518134B2 (en) Shared resource exclusive control method
JPS58169659A (en) Shared lock control method
JPH03257568A (en) Exclusive control system for shared resources
JPH0423047A (en) Exclusive control system for shared resources
JPH02118843A (en) Shared resources exclusion control system
JP2898012B2 (en) Exclusive control method for computer resources
JPH0365732A (en) Resource managing method
JPH04116731A (en) Exclusive control for shared resources
JPH02194442A (en) Shared resource controller
JPS62140159A (en) Shared data management method
JPH03141458A (en) Exclusive control system for shared resource
JPH05120040A (en) Computer system
JPH04223533A (en) Common resource exclusive control system
JPH03116260A (en) Spin lock system for multiprocessor system