JPH036654A - Mutual exclusion system - Google Patents

Mutual exclusion system

Info

Publication number
JPH036654A
JPH036654A JP13928489A JP13928489A JPH036654A JP H036654 A JPH036654 A JP H036654A JP 13928489 A JP13928489 A JP 13928489A JP 13928489 A JP13928489 A JP 13928489A JP H036654 A JPH036654 A JP H036654A
Authority
JP
Japan
Prior art keywords
processor
mutual exclusion
dangerous part
execution
processes
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
JP13928489A
Other languages
Japanese (ja)
Inventor
Naohisa Takahashi
直久 高橋
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.)
Nippon Telegraph and Telephone Corp
Original Assignee
Nippon Telegraph and Telephone 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 Nippon Telegraph and Telephone Corp filed Critical Nippon Telegraph and Telephone Corp
Priority to JP13928489A priority Critical patent/JPH036654A/en
Publication of JPH036654A publication Critical patent/JPH036654A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To attain the effective mutual exclusion control in a system where a 'dangerous part' is frequently carried out by deciding selectively a method to obtain a process in accordance with the state of a process which owns the executing right of the 'dangerous part' and performing selectively the process switching and error processes. CONSTITUTION:The processors 1 and 2 and a main storage 3 are connected to a system bus 4, and each processor can read and write the optional data stored in the storage 3 and also can execute an optional program. The storage 3 stores a processor control block, a processor waiting process matrix, a key, a 'dangerous part', etc. When plural processes carry out the inlet operations at one time, only a single process can carry out the 'dangerous part'. Thus other process are unable to carry out the 'dangerous part' before the process finishes an outlet operation. As a result, the effective mutual exclusion control is attained in a system where a user process having the small process value carries out frequently the 'dangerous part'.

Description

【発明の詳細な説明】 〔発明の目的〕 (産業上の利用分野) 本発明は、マルチプロセッサシステムにおける共有資源
に対する相互排除方式に関する。
DETAILED DESCRIPTION OF THE INVENTION [Object of the Invention] (Field of Industrial Application) The present invention relates to a mutual exclusion scheme for shared resources in a multiprocessor system.

(従来の技術) マルチプロセッサシステムにおける共有資源に対する相
互排除の基本方式として、スピンロック方式、および、
2値セマフォ方式がある。以下に各方式の構成と欠点を
述べる。
(Prior Art) As a basic method of mutual exclusion for shared resources in a multiprocessor system, the spin lock method and the
There is a binary semaphore method. The configuration and drawbacks of each method are described below.

(a)スピン口・ジク方式 (a−1)スピンロック方式の構成 第1図は、スピンロック方式を用いた相互排除を行なう
システムの構成例である。プロセッサ1゜2および、主
記憶装置3は一つのシステムバス4に接続されている。
(a) Spin-lock system (a-1) Structure of spin-lock system FIG. 1 shows an example of the structure of a system that performs mutual exclusion using the spin-lock system. The processor 1.2 and the main storage device 3 are connected to one system bus 4.

各プロセッサは、主記憶装置3に格納された任意のデー
タの読みだし、書き込み、および、任意のプログラムの
実行が可能である。図に示すように、主記憶装置3には
、鍵、きわどい部分、1ock操作、un 1 ock
操作のプログラム等が格納される。きわどい部分とは、
一時には一つのプロセスしか実行することのできないプ
ログラムをさし、相互排除の対象である。
Each processor is capable of reading and writing arbitrary data stored in the main memory 3 and executing arbitrary programs. As shown in the figure, the main memory 3 stores keys, critical parts, 1 ock operations, un 1 ock operations, etc.
Operation programs, etc. are stored. What is the dangerous part?
A program that can only run one process at a time and is subject to mutual exclusion.

鍵の値は、1または0であり、「きわどい部分」の実行
権を所有するプロセスが存在しているか否かを示す。1
ock操作とunlock操作は、「きわどい部分」に
対する相互排除を行なうプログラムである。
The value of the key is 1 or 0, and indicates whether a process exists that has the right to execute the "sensitive part." 1
The ock operation and the unlock operation are programs that mutually exclude "critical parts".

第2図は、1 ock操作とun 1ock操作を用い
て相互排除を行なう操作手順である。複数のプロセスが
同時に1ock操作を実行した場合には、以下に述べる
1ock操作の機能により、ただ一つのプロセスが「き
わどい部分」を実行できる。このプロセスがunloc
k操作を行なうまで、他のプロセスは「きわどい部分」
に入れずに空転して待つ。
FIG. 2 shows an operation procedure for performing mutual exclusion using a 1 ock operation and an un 1 ock operation. If multiple processes execute the 1ock operation at the same time, the functionality of the 1ock operation described below allows only one process to execute the "tight part". This process is unlocked
Until the k operation is performed, other processes remain in the "critical part"
I idled and waited without entering it.

第3図は、1ock操作の実現例である。1Ock操作
は、次の手順で行なわれる。
FIG. 3 is an example of realizing the 1ock operation. The 1Ock operation is performed in the following steps.

■鍵を読み出す。読み出した値をXとする。次に鍵を1
にする。ここで、鍵に対する読み出し・書き込みはte
s t−and−set命令など、メモリの読み出しと
書き込みが細分化されない基本演算により行なわれる。
■Read out the key. Let the read value be X. Next, put the key 1
Make it. Here, reading and writing to the key is done by te.
Memory reading and writing are performed by undivided basic operations such as st-and-set instructions.

■XがOの場合には、1ock操作を終了する。(2) If X is O, the 1ock operation is completed.

そうでない場合には、■に行き空転する。If not, go to ■ and idle.

第4図は、unlock操作の実現例である。FIG. 4 is an example of implementation of the unlock operation.

unlock操作は、鍵に0を書き込む。uniock
操作で鍵に0を書き込むと、上記1ock操作で空転し
ていたプロセスが0を鍵の値として読み出し、1ock
操作を終了して「きわどい部分」に入ることができるよ
うになる。
The unlock operation writes 0 to the key. uniock
When the operation writes 0 to the key, the process that was idling during the 1ock operation reads 0 as the key value and executes the 1ock operation.
You will be able to finish the operation and move on to the "dangerous part".

(a−2)スピンロック方式の欠点 プロセスが空転して鍵の状態を調べ、鍵がOになるまで
待っているので、「きわどい部分」のプログラムに対し
て次のような制約が課せられる。
(a-2) Disadvantages of spin lock method Since the process idles, checks the state of the key, and waits until the key becomes O, the following restrictions are imposed on the "critical part" of the program.

・短いプログラムであること ・割り込み禁止状態にするなどして、「きわどい部分」
の実行途中でプロセッサを取り上げられないようにする
こと。
・It must be a short program ・It must be possible to avoid “dangerous parts” by disabling interrupts, etc.
To prevent the processor from being taken away in the middle of execution.

・入出力など待ち状態になる操作は行なわないこと。- Do not perform operations such as input/output that result in a wait state.

・誤りを起こして例外処理プログラムにプロセッサを取
り上げられないこと。
- The processor cannot be taken over by the exception handling program due to an error.

上記の制約のため、スピンロック方式は、OSカーネル
など限られたプログラムの相互排除に用いられるのが一
般的であり、通常のユーザプログラムには適していない
という欠点があった。すなわち、ユーザプログラムでス
ピンロック方式を用いた場合には、次のような問題が生
じる。
Due to the above limitations, the spinlock method is generally used for mutual exclusion of limited programs such as an OS kernel, and has the disadvantage that it is not suitable for normal user programs. That is, when the spin lock method is used in a user program, the following problem occurs.

■バグのため「きわどい部分」から出ないで割り込み禁
止状態を長時間作り出す可能性がある。
- Due to a bug, there is a possibility that interrupts will be disabled for a long time without leaving the "critical part".

■1ock操作は「きわどい部分」の実行権を所有する
プロセスの状態変化を検出する機能を備えていない。こ
のため、「きわどい部分」の実行権を所有するプロセス
が待ち状態に入ったりプロセッサを取り上げられた場合
に、空転を続けるプロセスを実行するプロセッサは、そ
のまま空転を続けて多大に無駄な時間を費やす。
■The 1ock operation does not have a function to detect a change in the state of the process that owns the execution right for the "critical part". Therefore, when a process that has the right to execute a "critical part" enters a wait state or has its processor taken away, the processor running the process that continues to idle will continue to idle, wasting a lot of time. .

■1ock操作の使い方に関する簡単な誤りをおかすだ
けで容易にデッドロックに陥ってしまう。
■A simple mistake in how to use the 1ock operation can easily lead to a deadlock.

しかし、1ock操作は、「きわどい部分」の実行権を
どのプロセスが所有しているか調べる機能を備えていな
いので、簡単なプログラム誤りが原因で「きわどい部分
」の実行権を決して得ることができないのに待っている
状態を検出し適切な処理を行なわせることができない。
However, the 1ock operation does not have a function to check which process owns the execution right for the "sensitive part", so it is possible that a simple program error may result in the user never being able to obtain the execution right for the "sensitive part". It is not possible to detect a waiting state and perform appropriate processing.

■ユーザプロセスはプロセッサを取り上げられてもよい
状態でできる限り実行させたいというO8の一般的な目
標と相反する。
- This conflicts with the general goal of O8, which is to have user processes run as long as possible without having to worry about taking away the processor.

(b)2値セマフォ方式 (b−1)2値セマフォ方式の構成 第5図は、2値セマフォ方式を用いた相互排除を行なう
システムの構成例である。プロセッサ1゜2および、主
記憶装置3は一つのシステムバス4に接続されている。
(b) Binary semaphore system (b-1) Configuration of binary semaphore system FIG. 5 shows an example of the configuration of a system that performs mutual exclusion using the binary semaphore system. The processor 1.2 and the main storage device 3 are connected to one system bus 4.

各プロセッサは、主記憶装置3に格納された任意のデー
タの読みだし、書き込み、および、任意のプログラムの
実行が可能である。図に示すように、主記憶装置3には
、前記きわどい部分の他、セマフォS、セマフォSの待
ちプロセス行列、プロセッサ待ちプロセス行列、P操作
、■操作、プロセス切り替えプログラムが格納される。
Each processor is capable of reading and writing arbitrary data stored in the main memory 3 and executing arbitrary programs. As shown in the figure, the main storage device 3 stores a semaphore S, a waiting process queue for the semaphore S, a processor waiting process queue, a P operation, a ■ operation, and a process switching program, in addition to the critical parts described above.

きわどい部分は、前述したように一時には一つのプロセ
スしか実行することのできないプログラムであり、相互
排除の対象である。セマフォSは、0または1をとり、
それぞれ「きわどい部分」が使用中である、あるいは、
空いていることを表わす。セマフォSの待ちプロセス行
列は、「きわどい部分」の使用が終わるのを待っている
プロセスを整列させたO8の制御データである。
As mentioned above, the critical parts are programs that can only execute one process at a time, and are subject to mutual exclusion. Semaphore S takes 0 or 1,
Each "sensitive part" is in use, or
Indicates that it is vacant. The semaphore S waiting process queue is O8 control data in which processes waiting for the use of the "critical part" to finish are lined up.

プロセッサ待ち行列は、プロセッサを割り付けると直ち
に実行可能なプロセスを整列させたO8の制御データで
ある。P操作とV操作は、「きわどい部分」に対する相
互排除を行なうプログラムである。
The processor queue is O8 control data that lines up processes that can be executed as soon as a processor is allocated. P operation and V operation are programs that mutually exclude "critical parts".

第6図は、P操作とV操作を用いて相互排除を行なう操
作手順である。複数のプロセスが同時にP操作を実行し
た場合には、以下に述べるP操作の機能により、ただ一
つのプロセスが「きわどい部分」を実行できる。このプ
ロセスがV操作を行なうまで、他のプロセスはセマフォ
Sの待ちプロセス行列で待たされる。
FIG. 6 shows an operation procedure for mutual exclusion using the P operation and the V operation. If multiple processes execute a P operation at the same time, the functionality of the P operation described below allows only one process to execute the "critical part." Until this process performs the V operation, other processes are kept waiting in the semaphore S waiting process queue.

第7図は、P操作の実現例である。P操作は、次の手順
で行なわれる。
FIG. 7 is an example of realizing the P operation. The P operation is performed in the following steps.

■セマフォSを読み出す。読み出した値をoldとする
。次にoldが1の場合には、Sを1減じて0にする。
■Read semaphore S. The read value is set as old. Next, if old is 1, S is subtracted by 1 and becomes 0.

ここで、セマフォに対する読み出しと書き込みはプロセ
スからは細分化されない基本演算として見えるものであ
る。
Here, reading and writing to a semaphore are visible to the process as basic operations that are not subdivided.

■oldが1の場合には、P操作を終了する。そうでな
い場合には、P操作を実行中のプロセスをセマフォ待ち
プロセス行列の最後尾に加え、プロセス切り替えプログ
ラムに制御を移す。
(2) If old is 1, end the P operation. If not, the process executing the P operation is added to the end of the semaphore waiting process queue, and control is transferred to the process switching program.

第8図は、■操作の実現例である。■操作は、セマフォ
待ちプロセス行列が空か調べ、空ならばセマフォSに1
を書き込み、操作を終了する。空でないならば、セマフ
ォSの待ち行列から先頭のプロセスを取り出し、プロセ
ッサ待ちプロセス行列の先頭に入れ、操作を終了する。
FIG. 8 is an example of realizing the operation (2). ■The operation is to check whether the semaphore waiting process queue is empty, and if it is empty, send 1 to semaphore S.
Write and end the operation. If it is not empty, the first process is taken out of the semaphore S queue, placed at the beginning of the processor waiting process queue, and the operation is completed.

適当な時間経過の後、プロセス切り替えプログラムが実
行されると、プロセッサ待ちプロセス行列からプロセス
が取り出され、P操作の終了時点から処理を再開して、
「きわどい部分」を実行する。
When the process switching program is executed after an appropriate period of time has elapsed, the process is taken out from the processor waiting process queue, and processing is resumed from the point at which the P operation ended.
Perform the “dangerous part”.

(b−2)2値セマフォ方式の欠点 2値セマフォ方式では、複数のプロセスが同一の「きわ
どい部分」を実行しようとした場合に、P操作で1を減
じられなかったすべてのプロセスについて次のような操
作が行なわれ、相互排除においてプロセス切り替えが頻
繁に生じるという欠点がある。
(b-2) Disadvantages of the binary semaphore method In the binary semaphore method, when multiple processes try to execute the same "critical part", for all processes that cannot be decremented by 1 with the P operation, the following Such operations are carried out, and there is a disadvantage that process switching occurs frequently in mutual exclusion.

・P操作の度にプロセスをセマフォSの待ちプロセス行
列に入れ、プロセス切り替えを行なつO ・V操作の度にセマフォSの待ちプロセス行列からプロ
セッサ割り付は待ちプロセス行列にプロセスを移す。■
操作の後に、プロセス切り替えが発生する。
・Every time a P operation is performed, a process is placed in the waiting process queue of the semaphore S, and process switching is performed. ・Whenever a V operation is performed, a process is moved from the waiting process queue of the semaphore S to the waiting process queue for processor allocation. ■
After the operation, a process switch occurs.

上記操作に要する処理量はスピンロック方式での相互排
除に要する処理量に比べ極めて大きく、かつ、上記操作
は「きわどい部分」の実行権を所有するプロセスが既に
存在する場合には必須であるので、プロセスの処理で大
きなオーバヘッドとして現われるという欠点がある。特
に、2値セマフォ方式は、処理量の小さなプロセスが頻
繁に「きわどい部分」を実行するシステムでは、プロセ
ス全体の処理において相互排除のためのオーバヘッドが
占める割合が著しく大きくなるという欠点がある。また
、P操作は、「きわどい部分」の実行権を所有するプロ
セスの状態を読み出す機能を備えていないので、該実行
権の所有関係により生じるデッドロックなどの誤りを検
出し適切に処理することができないという欠点がある。
The amount of processing required for the above operation is extremely large compared to the amount of processing required for mutual exclusion using the spinlock method, and the above operation is essential if there is already a process that owns the execution right for the "sensitive part". , it has the disadvantage that it appears as a large overhead in processing the process. In particular, the binary semaphore method has the disadvantage that in systems where processes with a small amount of processing frequently execute "critical parts", the overhead for mutual exclusion becomes extremely large in the processing of the entire process. In addition, since the P operation does not have a function to read the state of the process that owns the execution right of the "critical part," it is difficult to detect and appropriately handle errors such as deadlocks that occur due to the ownership relationship of the execution right. The drawback is that it cannot be done.

(発明が解決しようとする課題) 本発明において解決しようとする課題は、スピンロック
方式における「きわどい部分」のプログラムに課せられ
た制約が大きいのでユーザプログラムの相互排除に適さ
ないという欠点、および、2値セマフォ方式における相
互排除のためにプロセスが頻繁に切り替わることによる
オーバヘッドが大きいという欠点、および、両方式にお
いて相互排除手段が「きわどい部分」の実行権を所有す
るプロセスの状態を読み出す機能を備えていないので相
互排除に係わるプログラムの誤りを検出して処理するこ
とができないという欠点であり、これら欠点を解消し、
処理量の小さなユーザプロセスが頻繁に「きわどい部分
」を実行するシステムにおいて効率的な相互排除方式を
提供することが本発明の目的である。
(Problems to be Solved by the Invention) The problems to be solved by the present invention are the drawbacks that the spinlock system is unsuitable for mutual exclusion of user programs due to large restrictions imposed on programs in "critical parts"; The disadvantage of the binary semaphore method is that there is a large overhead due to frequent switching of processes due to mutual exclusion, and in both methods, the mutual exclusion means has the ability to read the state of the process that owns the execution right of the "critical part". The disadvantage is that it is not possible to detect and process errors in programs related to mutual exclusion because the
It is an object of the present invention to provide an efficient mutual exclusion scheme in systems where low-volume user processes frequently perform "tight parts."

〔発明の構成〕[Structure of the invention]

(課題を解決するための手段) 本発明は、「きわどい部分」の実行権を所有するプロセ
スの実行状態を読み出す機能、および、実行権を新たに
得ることができない状態であることを検出する機能、お
よび、実行権を得るために待っているプロセスの実行を
制御する機能を相互排除手段に備えさせることにより、
「きわどい部分」の実行権を所有するプロセスの状態に
従って、その実行権を得るために待っているプロセスに
対して、プロセッサを割り付けたまま待たせる、あるい
は、プロセッサを取り上げる、あるいは、誤り処理を行
なわせるように実行を制御して相互排除することを最も
主要な特徴とする。
(Means for Solving the Problems) The present invention provides a function to read the execution state of a process that owns the execution right of a "critical part" and a function to detect that the execution right cannot be newly obtained. , and by providing the mutual exclusion means with the ability to control the execution of processes waiting to obtain execution rights.
Depending on the state of the process that owns the execution right for the "critical part," the process that is waiting to get the execution right may be made to wait with a processor allocated to it, take away the processor, or perform erroneous processing. The most important feature is mutual exclusion by controlling execution to ensure

(作用) 前述した本発明の相互排除方式によれば、「きわどい部
分」の実行権を所有するプロセスの状態に従ってプロセ
スを待たせる方法を選択的に定め、プロセス切り替え、
および、誤り処理を選択的に行なうことになる。
(Operation) According to the above-described mutual exclusion method of the present invention, a method for making a process wait is selectively determined according to the state of the process that owns the execution right for the "critical part", and a process switching,
Then, error processing is selectively performed.

(実施例) 以下、図面を使って本発明の一実施例を詳細に説明する
(Example) Hereinafter, an example of the present invention will be described in detail using the drawings.

第9図は、本発明の一実施例のシステム構成図である。FIG. 9 is a system configuration diagram of an embodiment of the present invention.

プロセッサ1.2および、主記憶装置3は一つのシステ
ムバス4に接続されている。各プロセッサは、主記憶装
置3に格納された任意のデータの読みだし、書き込み、
および、任意のプログラムの実行が可能である。図に示
すように、主記憶装置3には、プロセス制御ブロック、
プロセッサ待ちプロセス行列、鍵、きわどい部分、入口
操作、出口操作、例外処理プログラム、プロセス切り替
えプログラムが格納される。
Processor 1.2 and main memory 3 are connected to one system bus 4. Each processor reads and writes arbitrary data stored in the main storage device 3,
And it is possible to execute any program. As shown in the figure, the main storage device 3 includes process control blocks,
Processor waiting process queues, keys, critical parts, entry operations, exit operations, exception handling programs, and process switching programs are stored.

プロセス制御ブロック(PCB)は、O8によりプロセ
スごとに作られる制御データであり、プロセスの実行状
態やプロセスへの資源の割り付は状況などが書き込まれ
る。プロセッサ待ちプロセス行列は、プロセッサを割り
付けると直ちに実行可能なプロセスのPCBを整列させ
たO8の制御データである。鍵は、PCBアドレスとロ
ック変数からなる。PCBアドレスには、「きわどい部
分」の実行権を所有しているプロセスのPCBの先頭ア
ドレス、または、0が格納されている。ロック変数は「
きわどい部分」の実行権を所有するプロセスが存在する
か否かを示す。きわどい部分は、一時には一つのプロセ
スしか実行することのできないプログラムであり、相互
排除の対象である。入口操作と出口操作は、「きわどい
部分」に対する相互排除を行なうプログラムである。例
外処理プログラムは、相互排除に関する誤りを処理する
プログラムであり、プロセス切り替えプログラムはプロ
セッサをプロセスに割り付けるプログラムである。
The process control block (PCB) is control data created by the O8 for each process, and the execution status of the process, the allocation of resources to the process, etc. are written therein. The processor waiting process queue is O8 control data in which the PCBs of processes that can be executed immediately upon allocation of a processor are arranged. The key consists of a PCB address and a lock variable. The PCB address stores the start address of the PCB of the process that has the right to execute the "critical part" or 0. The lock variable is
Indicates whether there is a process that has the right to execute the "sensitive part". The critical parts are programs that can only have one process running at a time, and are subject to mutual exclusion. Entry operations and exit operations are programs that mutually exclude "tight parts." The exception handling program is a program that handles errors related to mutual exclusion, and the process switching program is a program that allocates processors to processes.

第10図は、入口操作と出口操作を用いて相互排除を行
なう操作手順である。複数のプロセスが同時に人口操作
を実行した場合には、以下に述べる人口操作の機能によ
り、ただ一つのプロセスが「きわどい部分」を実行でき
る。このプロセスが出口操作を行なうまで、他のプロセ
スは「きわどい部分」に入ることができない。
FIG. 10 is an operational procedure for performing mutual exclusion using an inlet operation and an outlet operation. When multiple processes perform population operations at the same time, the population operations feature described below allows only one process to perform the "sensitive parts." No other process can enter the "critical part" until this process performs the exit operation.

第11図は、入口操作の一実施例である。第11図に従
って、入口操作の実現例を以下に詳細に述べる。鍵のP
CBアドレスとロック変数の初期値を0とし、入口操作
を実行しているプロセスをプロセスAとする。
FIG. 11 is an example of an entrance operation. In accordance with FIG. 11, an implementation example of the entrance operation will be described in detail below. key P
The initial values of the CB address and lock variable are set to 0, and the process executing the entry operation is called process A.

■鍵のPCBアドレスを読み出す。読み出した値をaと
する。aがOの場合には、■に行く。aがプロセスA(
自プロセス)のPCBの先頭アドレスの場合には、プロ
セスAのプログラムに誤りがあり、「きわどい部分」の
実行権を新たに得ることができないことを意味するので
、例外処理プログラムに制御を移す。その他の場合には
、■に行く。
■Read the PCB address of the key. Let the read value be a. If a is O, go to ■. a is process A (
In the case of the start address of the PCB of the current process), it means that there is an error in the program of process A and that the right to execute the "critical part" cannot be newly obtained, so control is transferred to the exception handling program. In other cases, go to ■.

■鍵のロック変数を読み出す。読み出した値をXとする
。次に鍵のロック変数を1にする。ここで、ロック変数
に対する読み出し・書き込みはtest−and−se
t命令などにより不可分演算によりなされるものである
。Xが0の場合には、入口操作を実行中のプロセスのP
CBの先頭アドレスを鍵のPCBアドレスに書き込み、
入口操作を終了する。Xが0でない場合には、■に行く
■Read the lock variable of the key. Let the read value be X. Next, set the key's lock variable to 1. Here, reading and writing to the lock variable is done using test-and-se.
This is performed by an atomic operation using a t instruction or the like. If X is 0, P of the process performing the entry operation
Write the first address of the CB to the PCB address of the key,
Finish the entrance operation. If X is not 0, go to ■.

■aを先頭アドレスとするプロセス制御ブロックからプ
ロセスの状態フィールドSを読み出す。プロセスが実行
中であることをSの値が示している場合には、■に行く
。Sの値が、プロセスが終了していることを示している
場合には、「きわどい部分」の実行権は決して返されな
いことを意味するので、例外処理プログラムに制御を移
す。その他の場合には、プロセッサ待ちプロセス行列の
最後尾にプロセスAのPCBを入れ、プロセス切り替え
プログラムに制御を移す。
(2) Read the process status field S from the process control block whose starting address is a. If the value of S indicates that the process is running, go to ■. If the value of S indicates that the process has terminated, then control is transferred to the exception handling program, since it means that the execution right for the "critical part" will never be returned. In other cases, the PCB of process A is placed at the end of the processor waiting process queue, and control is transferred to the process switching program.

第12図は、出口操作の一実現例である。出口操作では
、まず、鍵のPCBアドレスを0にし、次に鍵のロック
変数を0にする。
FIG. 12 is an example of an implementation of the exit operation. The exit operation first sets the key's PCB address to 0, then sets the key's lock variable to 0.

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

以上説明したように、本発明は、「きわどい部分」の実
行権を所有するプロセスの実行状態を読み出す機能、お
よび、実行権を新たに得ることができない状態であるこ
とを検出する機能、および、実行権を得るために待って
いるプロセスの実行を制御する機能を相互排除手段に備
えさせているので、「きわどい部分」の実行権を所有す
るプロセスの状態に従って、その実行権を得るために待
っているプロセスに対して、プロセッサを割り付けたま
ま待たせる、あるいは、プロセッサを取り上げる、ある
いは、誤りを検出して例外処理を行なわせるように実行
を制御し、処理量の小さなユザプロセスが頻繁に「きわ
どい部分」を実行するシステムにおいて効率的な相互排
除の制御を実現することができる。
As explained above, the present invention provides a function to read the execution state of a process that owns the execution right of a "critical part", a function to detect that the execution right cannot be newly acquired, and Mutual exclusion means is equipped with a function to control the execution of processes that are waiting to obtain the execution right, so that depending on the state of the process that owns the execution right of the "critical part", the process that is waiting to obtain the execution right is Execution is controlled so that a process with a small amount of processing capacity is forced to wait with a processor allocated to it, takes away the processor, or detects an error and performs exception handling. Efficient mutual exclusion control can be realized in a system that executes "parts".

さらに、本発明の相互排除方式において、「きわどい部
分」の実行権を所有するプロセスが実行状態にあるとき
、他のプロセスが空転して待つ手順の中にメモリへの書
き込み命令が存在しないという特徴がある。このことは
、キャシュを備えたメモリ共有型マルチプロセッサの場
合、前記の状態では、キャシュメモリ内のデータを参照
するだけであり、主記憶装置へのアクセスあるいは他の
プロセッサのキャシュへのデータ転送が生じないことを
意味し、空転のために他のプロセッサの性能を劣化させ
ないという利点がある。
Furthermore, in the mutual exclusion method of the present invention, when the process that owns the execution right for the "critical part" is in the execution state, there is no write instruction to memory in the procedure in which other processes idle and wait. There is. This means that in the case of a shared memory multiprocessor with a cache, in the above state, data in the cache memory is only referenced, and access to the main memory or data transfer to the cache of other processors is not possible. This means that the performance of other processors is not degraded due to idling, which is an advantage.

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

第1図から第4図は従来の相互排除技術であるスピンロ
ック方式に関する図面であり、第1図はスピンロック方
式の実施例のシステム構成図、第2図は1ock操作と
unlock操作を用いて相互排除する操作手順のフロ
ーチャート、第3図は1ock操作の詳細手順のフロー
チャート、第4図はunlock操作の詳細手順のフロ
ーチャートである。 第5図から第8図は従来の相互排除技術である2値セマ
フォ方式に関する図面であり、第5図は2値セマフォ方
式の実施例のシステム構成図、第6図はP操作とV操作
を用いて相互排除する操作手順のフローチャート、第7
図はP操作の詳細手順のフローチャート、第8図はV操
作の詳細手順のフローチャートである。 第9図から第12図は本発明の実施例に関する図面であ
り、第9図は本発明の一実施例のシステム構成図、第1
0図は本発明の相互排除手段である入口操作と出口操作
を用いて相互排除する操作手順のフローチャート、第1
1図は入口操作の詳細手順のフローチャート、第12図
は出口操作の詳細手順のフローチャートである。
Figures 1 to 4 are drawings related to the spinlock method, which is a conventional mutual exclusion technology, and Figure 1 is a system configuration diagram of an embodiment of the spinlock method, and Figure 2 is a system configuration diagram using the 1lock operation and the unlock operation. FIG. 3 is a flowchart of a detailed procedure for a 1lock operation, and FIG. 4 is a flowchart of a detailed procedure for an unlock operation. Figures 5 to 8 are diagrams related to the binary semaphore system, which is a conventional mutual exclusion technique. Figure 5 is a system configuration diagram of an embodiment of the binary semaphore system, and Figure 6 shows the P operation and V operation. Flowchart of operating procedures for mutual exclusion using
The figure is a flowchart of the detailed procedure of the P operation, and FIG. 8 is the flowchart of the detailed procedure of the V operation. 9 to 12 are drawings related to an embodiment of the present invention, and FIG. 9 is a system configuration diagram of an embodiment of the present invention.
Figure 0 is a flowchart of the operation procedure for mutual exclusion using the inlet operation and outlet operation, which are the mutual exclusion means of the present invention.
FIG. 1 is a flowchart of the detailed procedure of the entrance operation, and FIG. 12 is a flowchart of the detailed procedure of the exit operation.

Claims (1)

【特許請求の範囲】[Claims] 異なるプロセッサ上で動作する複数のプロセスが資源を
共有する手段と、一時にはただ一つのプロセスでしか使
用できない部分(きわどい部分と呼ぶ)の実行を開始す
る権利(実行権と呼ぶ)を相互に排除する手段とを有す
るマルチプロセッサシステムにおいて、前記相互排除手
段は、実行権を所有するプロセスの実行状態を読み出す
機能と、実行権を新たに得ることができない状態である
ことを検出する機能と、実行権を得るために待っている
プロセスの実行を制御する機能とを有し、「きわどい部
分」の実行権を持つプロセスの状態に従って、その実行
権を得るために待っているプロセスに対して、プロセッ
サを割り付けたまま待たせる、あるいは、プロセッサを
取り上げる、あるいは、誤り処理を行なわせるように実
行を制御することを特徴とした相互排除方式。
Mutual exclusion of the means by which multiple processes running on different processors can share resources and the right to start execution (called the execution right) of a part that can only be used by one process at a time (called the critical part) In a multiprocessor system having means for The processor has a function to control the execution of a process that is waiting to obtain the execution right, and according to the state of the process that has the execution right of the "critical part", the processor A mutual exclusion method that is characterized by controlling execution so that a processor remains allocated and waits, a processor is taken away, or an error process is performed.
JP13928489A 1989-06-02 1989-06-02 Mutual exclusion system Pending JPH036654A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP13928489A JPH036654A (en) 1989-06-02 1989-06-02 Mutual exclusion system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP13928489A JPH036654A (en) 1989-06-02 1989-06-02 Mutual exclusion system

Publications (1)

Publication Number Publication Date
JPH036654A true JPH036654A (en) 1991-01-14

Family

ID=15241700

Family Applications (1)

Application Number Title Priority Date Filing Date
JP13928489A Pending JPH036654A (en) 1989-06-02 1989-06-02 Mutual exclusion system

Country Status (1)

Country Link
JP (1) JPH036654A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007081029A1 (en) * 2006-01-16 2007-07-19 Seiko Epson Corporation Multi-processor system and program for computer to carry out a control method of interrupting multi-processor system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007081029A1 (en) * 2006-01-16 2007-07-19 Seiko Epson Corporation Multi-processor system and program for computer to carry out a control method of interrupting multi-processor system
US7877753B2 (en) 2006-01-16 2011-01-25 Seiko Epson Corporation Multi-processor system and program for causing computer to execute controlling method of interruption of multi-processor system

Similar Documents

Publication Publication Date Title
JP4759273B2 (en) Data processing apparatus and shared resource access control method
US7975271B2 (en) System and method for dynamically determining a portion of a resource for which a thread is to obtain a lock
US7653791B2 (en) Realtime-safe read copy update with per-processor read/write locks
US7797704B2 (en) System and method for performing work by one of plural threads using a lockable resource
JP2514299B2 (en) Serialization method of interrupt handling for process level programming
US6785887B2 (en) Technique for using shared resources on a multi-threaded processor
JPH0120466B2 (en)
JPH01298440A (en) Exclusion control system
JP2539352B2 (en) Hierarchical multi-computer system
US20220035664A1 (en) Reverse restartable sequences for lock polling scalability
US5708808A (en) Method and apparatus for concurrency with critical regions
Michael et al. Relative performance of preemption-safe locking and non-blocking synchronization on multiprogrammed shared memory multiprocessors
WO2001097020A1 (en) Method and apparatus for implementing atomicity of memory operations in dynamic multi-streaming processors
JPH036654A (en) Mutual exclusion system
WO2000033175A2 (en) Method for increasing efficiency of multiprocessing systems
EP1197857A2 (en) Method of controlling a computer
JPS6321941B2 (en)
US20040261080A1 (en) Methods and systems for managing access to shared resources using control flow
JPH01297760A (en) System for lock control and task control in multiprocessor
JPH07319716A (en) Exclusive control system for resources of computer system
JP3422504B2 (en) Exclusive control method between tasks
JPH04343143A (en) Shared resource mutual exclusion method for multiprocessor system
JPH064323A (en) Multiprocessor system
JPH02171952A (en) Dispatching system for multiprocessor
JPH01195542A (en) Multi-programming processor