JPH09319601A - Process control method for semaphore - Google Patents

Process control method for semaphore

Info

Publication number
JPH09319601A
JPH09319601A JP15761696A JP15761696A JPH09319601A JP H09319601 A JPH09319601 A JP H09319601A JP 15761696 A JP15761696 A JP 15761696A JP 15761696 A JP15761696 A JP 15761696A JP H09319601 A JPH09319601 A JP H09319601A
Authority
JP
Japan
Prior art keywords
semaphore
queue
link
unused
links
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.)
Granted
Application number
JP15761696A
Other languages
Japanese (ja)
Other versions
JP2861943B2 (en
Inventor
Kazuhiro Mori
一浩 森
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 JP15761696A priority Critical patent/JP2861943B2/en
Publication of JPH09319601A publication Critical patent/JPH09319601A/en
Application granted granted Critical
Publication of JP2861943B2 publication Critical patent/JP2861943B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To prevent the deterioration of performance by reducing lock acquisition waiting time by decreasing competition caused by the lock acquisition of queue of a process link in non-use state. SOLUTION: Concerning a multiprocessor system having an OS for synchronizing processes through a semaphore, when generating a semaphore 15-2, several process links in non-use state are taken out of a queue 3 of process link in non-use state shared between plural processors 40-1 and 40-2, and linked to a queue 9-2 of process link in non-use state to be dedicated and used for the semaphore 15-2. When turning a process 20 issuing a P instruction to the semaphore 15-2 into standby by the semaphore 15-2, one process link 103 in non-use state is taken out of a queue 9-2 of process link in non-use state to be used only for the semaphore 15-2, the name of the process 20 is set to this taken-out process link 103, and this is linked through the semaphore 15-2 to a queue 4-2 of processes waiting for events.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明はセマフォに関するプ
ロセス制御方法に関し、特にセマフォを介してプロセス
の同期や排他制御を行うオペレーティング・システムを
有するマルチプロセッサシステムに好適な制御方法に関
する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a semaphore process control method, and more particularly to a control method suitable for a multiprocessor system having an operating system for performing process synchronization and exclusive control via a semaphore.

【0002】[0002]

【従来の技術】一般に計算機のソフトウェアシステム
は、互いにほとんど独立に動く多数のプロセスの集まり
として実現される。しかし、他のプロセスに仕事を依頼
する場合や、複数のプロセスが逐次再使用可能な資源を
共用する場合には、相互に連絡を取り合う必要がある。
そこで、計算機では、プロセス間の連絡に関する基本的
な機能と共に、その機能を各プロセスが使えるような同
期基本命令を提供しており、その一種に、セマフォとそ
れを使用したP命令,V命令がある。
2. Description of the Related Art Generally, a computer software system is realized as a group of many processes that operate almost independently of each other. However, it is necessary to communicate with each other when requesting work from another process or when a plurality of processes share a reusable resource in sequence.
Therefore, the computer provides not only basic functions related to communication between processes, but also synchronous basic commands that allow each process to use that function. One of these is the semaphore and the P and V commands that use it. is there.

【0003】図11は従来のプロセス制御方法で使用さ
れるセマフォとセグメントの構成を示す。セマフォ5は
主記憶上にあり、図13に示すように、負の値もとりう
るセマフォカウンタSCTと、このセマフォ5を介して
事象を待っているプロセスの待ち行列の先頭アドレスP
QHPとを含んでいる。なお、一般にセマフォカウンタ
SCTの初期値が0の場合はプロセス間の同期に使用さ
れ、正の場合は共用資源の排他制御に使用される。
FIG. 11 shows the structure of a semaphore and a segment used in a conventional process control method. The semaphore 5 is in the main memory, and as shown in FIG. 13, the semaphore counter SCT that can take a negative value and the head address P of the queue of the process waiting for an event via this semaphore 5
Includes QHP. Generally, when the initial value of the semaphore counter SCT is 0, it is used for synchronization between processes, and when it is positive, it is used for exclusive control of shared resources.

【0004】セグメント1も主記憶上にあり、複数(図
11の例では9個)のプロセスリンク6と2つのポイン
タ7,8とが格納されている。各々のプロセスリンク6
は、図12に示すようにプロセス名と他のプロセスリン
クとの連結用のリンクアドレスとを格納する。従来のプ
ロセス制御方法では、各々のプロセスリンク6は以下の
3種類の待ち行列の何れかにつなげられて管理される。
The segment 1 is also on the main memory and stores a plurality of (9 in the example of FIG. 11) process links 6 and two pointers 7 and 8. Each process link 6
Stores a process name and a link address for connecting with another process link, as shown in FIG. In the conventional process control method, each process link 6 is managed by being connected to any of the following three types of queues.

【0005】複数のプロセッサで共有している未使用
状態のプロセスリンクの待ち行列(Q/PL/FLSと
も言う) セマフォを介して事象を待っているプロセスの待ち行
列(Q/PR/Sとも言う) 実行可能状態のプロセスの待ち行列(Q/PR/RD
Yとも言う)
Unused process link queue shared by a plurality of processors (also called Q / PL / FLS) Process queue waiting for an event via a semaphore (also called Q / PR / S) ) Executable process queue (Q / PR / RD
Also called Y)

【0006】即ち、初期の状態においては全てのプロセ
スリンク6は未使用状態であるため、それらのリンクア
ドレスによって一つなぎに連結されての待ち行列で管
理され、この待ち行列の先頭のプロセスリンクのアドレ
スをセグメント1のポインタ7が指し示す。また、セマ
フォを介して事象を待つプロセスが出現すると、そのプ
ロセスのために未使用状態のプロセスリンクがの待ち
行列から1つ取り出され、このプロセスリンクにそのプ
ロセスのプロセス名等が設定されて、の待ち行列につ
ながれ、この待ち行列の先頭のプロセスリンクのアドレ
スをセマフォ5の先頭アドレスPQHPが指し示す。さ
らに、セマフォで事象を待っていたプロセスが実行可能
状態に遷移すると、の待ち行列からそのプロセスのプ
ロセスリンクが取り出されて、の待ち行列につなが
れ、この待ち行列の先頭のプロセスリンクのアドレスを
セグメント1のポインタ8が指し示す。そして、実行可
能状態のプロセスが実行状態に遷移するのに伴って、そ
のプロセスが使用していたプロセスリンクが未使用状態
になると、の待ち行列に戻される。
That is, in the initial state, all the process links 6 are unused, so that the process links 6 are managed by a queue connected in a line by their link addresses. The pointer 7 of the segment 1 points to the address. Also, when a process that waits for an event appears through a semaphore, one unused process link for that process is taken out of the queue, and the process name of that process is set in this process link. Of the semaphore 5 is pointed to by the start address PQHP of the semaphore 5. Furthermore, when the process waiting for the event in the semaphore transitions to the ready state, the process link of that process is taken out of the queue of and is connected to the queue of, and the address of the process link at the head of this queue is segmented. The pointer 8 of 1 points. Then, when the process link used by the process in the runnable state transitions to the run state and the process link used by the process becomes the unused state, the process link is returned to the queue.

【0007】図11の例では、9個のプロセスリンク6
のうち、4個のプロセスリンクが使用中であり、そのう
ちの1個のプロセスリンクは、セマフォ5を介して事象
を待っているプロセスの待ち行列4につなげられてお
り、3個のプロセスリンクは、実行可能状態のプロセス
の待ち行列2につなげられている。そして、残り5個の
未使用状態のプロセスリンクは、未使用状態のプロセス
リンクの待ち行列3につなげられている。
In the example of FIG. 11, nine process links 6 are used.
Of these, four process links are in use, one of them is linked to the queue 4 of processes waiting for an event via the semaphore 5, and three process links are , Are connected to the queue 2 of the process in the ready state. The remaining five unused process links are linked to the queue 3 of unused process links.

【0008】図14はセマフォに対するP命令実行の従
来の処理の流れを示す。P命令は引数としてセマフォを
一意に識別し得る識別子であるセマフォ番号(セマフォ
名)をもつ。実行中の或るプロセスからセマフォ5のセ
マフォ番号を引数としてP命令が発行されると、プロセ
ッサのハードウェアやファームウェア(以下、単にファ
ームウェアと称す)は、セマフォ5のロックを取得し
(A−1)、セマフォ5のセマフォカウンタSCTの値
から1を減じ(A−2)、その値が負であるか否かを調
べる(A−3)。
FIG. 14 shows a conventional processing flow of P instruction execution for a semaphore. The P instruction has a semaphore number (semaphore name) that is an identifier that can uniquely identify the semaphore as an argument. When a P command is issued from a certain process being executed with the semaphore number of the semaphore 5 as an argument, the hardware or firmware of the processor (hereinafter, simply referred to as firmware) acquires the lock of the semaphore 5 (A-1 ), 1 is subtracted from the value of the semaphore counter SCT of the semaphore 5 (A-2), and it is checked whether the value is negative (A-3).

【0009】セマフォカウンタSCTの値が負であれ
ば、P命令を発行したプロセスを待機状態とすべく、プ
ロセッサのファームウェアは、未使用状態のプロセスリ
ンクの待ち行列3のロックを取得してこの待ち行列3か
ら未使用状態のプロセスリンクを1つ取り出し(A−
4)、現在実行中のプロセス(P命令を発行したプロセ
ス)を閉塞し、上記未使用状態のプロセスリンクにその
プロセスのプロセス名等の情報を書き込んでセマフォ5
を介して事象を待っているプロセスの待ち行列4につな
げた後、未使用状態のプロセスリンクの待ち行列3のア
ンロックを行う(A−5)。そして、セマフォ5のアン
ロックを行い(A−6)、命令を終了する。その後にデ
ィスパッチャに制御を移し、後述するように実行可能状
態のプロセスの待ち行列2から実行待ちのプロセスを取
り出し実行する。
If the value of the semaphore counter SCT is negative, the processor firmware acquires the lock of the queue 3 of the unused process link in order to put the process that issued the P instruction in the waiting state, and waits for this. Extract one unused process link from matrix 3 (A-
4) Block the currently executing process (process that issued the P instruction), write information such as the process name of the process into the unused process link, and then semaphore 5
After connecting to the queue 4 of the process waiting for an event via the, the queue 3 of the unused process link is unlocked (A-5). Then, the semaphore 5 is unlocked (A-6), and the instruction ends. After that, the control is transferred to the dispatcher, and the process waiting for execution is taken out from the queue 2 of processes in the ready state and executed as described later.

【0010】他方、セマフォカウンタSCTの値が負で
ない場合(0以上の場合)、セマフォ5のアンロックを
行い、命令を終了して、そのままそのプロセスの処理を
継続する(A−7)。
On the other hand, when the value of the semaphore counter SCT is not negative (0 or more), the semaphore 5 is unlocked, the instruction is terminated, and the processing of the process is continued as it is (A-7).

【0011】図15にセマフォに対するV命令実行の従
来の処理の流れを示す。V命令も引数としてセマフォ番
号をもつ。実行中の或るプロセスからセマフォ5のセマ
フォ番号を引数としてV命令が発行されると、プロセッ
サのファームウェアは、セマフォ5のロックを取得し
(B−1)、セマフォ5のセマフォカウンタSCTの値
に1を加え(B−2)、その値が正であるか否かを調べ
る(B−3)。
FIG. 15 shows a conventional process flow of V instruction execution for a semaphore. The V instruction also has a semaphore number as an argument. When a V instruction is issued from a certain process being executed with the semaphore number of the semaphore 5 as an argument, the firmware of the processor acquires the lock of the semaphore 5 (B-1) and sets the value of the semaphore counter SCT of the semaphore 5 to the value. 1 is added (B-2), and it is checked whether the value is positive (B-3).

【0012】セマフォカウンタSCTの値が正であれ
ば、セマフォ5のアンロックを行って、命令を終了し、
そのままそのプロセスの処理を継続する(B−6)。
If the value of the semaphore counter SCT is positive, the semaphore 5 is unlocked, the instruction is terminated,
The processing of the process is continued as it is (B-6).

【0013】他方、セマフォカウンタSCTの値が正で
なければ(0以下であれば)、セマフォ5を介して事象
を待っているプロセスの待ち行列4の中から1つのプロ
セスリンクを取り出し、実行可能状態のプロセスの待ち
行列2のロックを取得し、前記取り出したプロセスリン
クを実行可能状態のプロセスの待ち行列2につなげて当
該プロセスリンクにかかるプロセスを実行可能状態と
し、実行可能状態のプロセスの待ち行列2のアンロック
を行う(B−4)。そして、セマフォ5のアンロックを
行い(B−5)、命令を終了し、ディスパッチャへ制御
を移す。
On the other hand, if the value of the semaphore counter SCT is not positive (0 or less), one process link can be extracted from the queue 4 of processes waiting for an event via the semaphore 5 and executed. The lock of the queue 2 of the process in the state is acquired, the extracted process link is connected to the queue 2 of the process in the executable state, the process related to the process link is set to the executable state, and the process in the executable state is waited. The matrix 2 is unlocked (B-4). Then, the semaphore 5 is unlocked (B-5), the instruction is terminated, and the control is transferred to the dispatcher.

【0014】図16はディスパッチャによりプロセスが
実行可能状態のプロセスの待ち行列2から実行状態に遷
移する場合の従来の処理の流れの一部を示す。まず、実
行可能状態のプロセスの待ち行列2と未使用状態のプロ
セスリンクの待ち行列3のロックを取得し(C−1)、
実行可能状態のプロセスの待ち行列2から実行状態に遷
移するプロセスのプロセスリンクを取り外し、プロセス
の情報をプロセッサに取り込んだ後、未使用状態になっ
たプロセスリンクを未使用状態のプロセスリンクの待ち
行列3につなげる(C−2)。そして、実行可能状態の
プロセスの待ち行列2及び未使用状態のプロセスリンク
の待ち行列3をアンロックする(C−3)。
FIG. 16 shows a part of the conventional processing flow when a process is transited from the queue 2 of the process in the executable state to the execution state by the dispatcher. First, the lock of the queue 2 of the process in the executable state and the queue 3 of the process link in the unused state is acquired (C-1),
After removing the process link of the process that transits to the running state from queue 2 of the process in the ready state and fetching the process information into the processor, the process link that has become the unused state is the queue of the process link in the unused state. Connect to 3 (C-2). Then, the queue 2 of the process in the executable state and the queue 3 of the process link in the unused state are unlocked (C-3).

【0015】ここで、複数のプロセッサが存在するマル
チプロセッサシステムの場合、実行可能状態のプロセス
の待ち行列2,未使用状態のプロセスリンクの待ち行列
3およびセマフォ5は複数のプロセッサから同時にアク
セスされる可能性があるため、プロセスの状態遷移のた
めにプロセスリンクを操作する際には、上述したように
該当する待ち行列及びセマフォのロックを取得し排他的
にプロセスリンクを操作する必要がある。
Here, in the case of a multiprocessor system having a plurality of processors, the queue 2 of the process in the executable state, the queue 3 of the process link in the unused state and the semaphore 5 are simultaneously accessed by the plurality of processors. Therefore, when operating the process link for the process state transition, it is necessary to acquire the lock of the corresponding queue and semaphore and exclusively operate the process link as described above.

【0016】[0016]

【発明が解決しようとする課題】セマフォに関するプロ
セス制御に関し従来は上述したような方法を採用してい
たが、その構成上、ロック取得による競合が発生し易
く、そのためにロック取得待ちによる性能低下が発生す
るという問題点があった。その理由は、未使用状態のプ
ロセスリンクの待ち行列が複数のプロセッサで共用され
るため、その待ち行列を共有するプロセッサの数が多く
存在すると、そのプロセッサ台数に比例して未使用状態
のプロセスリンクの待ち行列にアクセスする頻度が増
え、その待ち行列のロック取得による競合が発生する割
合も増え、このためロック取得待ちによる性能低下が発
生するからである。
Conventionally, the above-described method has been adopted for the process control related to the semaphore, but due to its configuration, lock acquisition is likely to cause contention, which causes performance deterioration due to lock acquisition waiting. There was a problem that it occurred. The reason is that the queue of unused process links is shared by multiple processors, so if there are many processors sharing the queue, the unused process links will be proportional to the number of processors. This is because the frequency of accessing the queue is increased, and the ratio of contention due to lock acquisition of the queue also increases, which causes performance degradation due to lock acquisition wait.

【0017】そこで本発明の目的は、未使用状態のプロ
セスリンクの待ち行列のロック取得による競合を減らす
ことにより、ロック取得待ち時間を減らし、性能低下を
防ぐことにある。
An object of the present invention is to reduce lock acquisition waiting time and prevent performance degradation by reducing contention due to lock acquisition of a queue of an unused process link.

【0018】[0018]

【課題を解決するための手段】本発明は、セマフォを介
してプロセスの同期や排他制御を行うオペレーティング
・システムを有するマルチプロセッサシステムにおい
て、セマフォの生成時に、複数のプロセッサで共有して
いる未使用状態のプロセスリンクの待ち行列から幾つか
の未使用状態のプロセスリンクを取り出し、前記生成し
たセマフォで専用に使用する未使用状態のプロセスリン
クの待ち行列につなげる第1のステップと、セマフォに
対してP命令を発行したプロセスを当該セマフォで待機
中にする場合、当該セマフォで専用に使用する未使用状
態のプロセスリンクの待ち行列から未使用のプロセスリ
ンクを1つ取り出し、この取り出したプロセスリンクに
当該プロセスの名前を設定して、当該セマフォを介して
事象を待っているプロセスの待ち行列につなぐ第2のス
テップとを含むことを特徴とする。
SUMMARY OF THE INVENTION The present invention, in a multiprocessor system having an operating system for performing process synchronization and exclusive control via a semaphore, unused unused by a plurality of processors when the semaphore is created. For the semaphore, the first step is to take out some unused process links from the state process link queue and connect them to the unused process link queue dedicated to the created semaphore. When the process that issued the P instruction is put on standby by the semaphore, one unused process link is taken out from the queue of the unused process link that is used exclusively by the semaphore, and the extracted process link Set the name of the process and wait for the event via the semaphore. Characterized in that it comprises a second step of connecting the queue process.

【0019】また本発明は、前記第1のステップにおい
て、セマフォで専用に使用する未使用状態のプロセスリ
ンクの待ち行列につなげる未使用状態のプロセスリンク
の数をソフトウェアから指定可能とすることを特徴とす
る。
Further, the present invention is characterized in that, in the first step, the number of unused process links connected to the queue of unused process links exclusively used by the semaphore can be designated by software. And

【0020】さらに本発明は、前記第1のステップにお
いて、セマフォで専用に使用する未使用状態のプロセス
リンクの待ち行列につなげた各々のプロセスリンクに当
該セマフォの識別子を設定し、前記第2のステップにお
いて、セマフォで専用に使用する未使用状態のプロセス
リンクの待ち行列に1つも未使用状態のプロセスリンク
が存在しない場合には、複数のプロセッサで共有してい
る未使用状態のプロセスリンクの待ち行列から未使用状
態のプロセスリンクを1つ取り出し、この取り出したプ
ロセスリンクに当該プロセスの名前を設定して、当該セ
マフォを介して事象を待っているプロセスの待ち行列に
つなぐようにし、且つ、セマフォを介して事象を待って
いるプロセスの待ち行列につながれたプロセスリンクを
そのプロセスの実行状態への遷移に伴って未使用状態の
プロセスリンクとする際、そのプロセスリンクにセマフ
ォの識別子が設定されているときは設定された識別子の
セマフォで専用に使用する未使用状態のプロセスリンク
の待ち行列に戻し、セマフォの識別子が設定されていな
いときは複数のプロセッサで共有している未使用状態の
プロセスリンクの待ち行列に戻す第3のステップを含む
ことを特徴とする。
Further, according to the present invention, in the first step, the identifier of the semaphore is set to each process link connected to the queue of the unused process link dedicated to the semaphore, and the second semaphore is set. In the step, if there is no unused process link in the queue of unused process links used exclusively by the semaphore, wait for an unused process link shared by multiple processors. Takes out one unused process link from the queue, sets the name of the process in the fetched process link, and connects it to the queue of the process waiting for the event via the semaphore, and A process link linked to the queue of a process waiting for an event via When making a process link in an unused state with a transition to a state, if a semaphore identifier is set for that process link, wait for an unused process link that is used exclusively by the semaphore with the set identifier It is characterized by including a third step of returning to the queue and returning to the queue of the unused process link shared by a plurality of processors when the semaphore identifier is not set.

【0021】複数のプロセッサで共有している未使用状
態のプロセスリンクの待ち行列から未使用状態のプロセ
ッサリンクを取り出す場合、複数のプロセッサが同時に
取得する可能性があることを考えるとその待ち行列のロ
ックを取得する必要がある。しかし、セマフォの生成時
に、複数のプロセッサで共有している未使用状態のプロ
セスリンクの待ち行列から幾つかの未使用状態のプロセ
スリンクを取り出して、そのセマフォで専用に使用する
未使用状態のプロセスリンクの待ち行列につなげておく
と、この待ち行列に対するアクセスはそのセマフォのロ
ックを取得したプロセッサに限られるため、その待ち行
列から未使用状態のプロセスリンクを取り出す際にその
待ち行列のロックをあえて行う必要がなくなり、ロック
取得による競合を減らすことができる。
When an unused processor link is taken out from the queue of an unused process link shared by a plurality of processors, considering that there is a possibility that a plurality of processors may acquire it at the same time, the queue Need to get a lock. However, when a semaphore is created, some unused process links are taken out of the queue of unused process links shared by multiple processors, and an unused process dedicated to that semaphore is used. If you connect to the queue of the link, access to this queue is limited to the processor that acquired the lock of the semaphore, so when you take out an unused process link from the queue, you dare to lock the queue. There is no need to do it, and contention due to lock acquisition can be reduced.

【0022】[0022]

【発明の実施の形態】次に本発明の実施の形態の例につ
いて図面を参照して詳細に説明する。
BEST MODE FOR CARRYING OUT THE INVENTION Next, an example of an embodiment of the present invention will be described in detail with reference to the drawings.

【0023】図1は本発明を実施するマルチプロセッサ
システムの一例を示すブロック図である。同図に示すマ
ルチプロセッサシステムは、プログラム制御により動作
する複数個のプロセッサ40−1,…,40−nと、こ
れらのプロセッサで共有される主記憶45とを含んでい
る。また、プロセッサ40−1〜40−nは、各種の待
ち行列(実行可能状態のプロセスの待ち行列,未使用状
態のプロセスリンクの待ち行列,セマフォを介して事象
を待っているプロセスの待ち行列,セマフォで専用に使
用する未使用状態のプロセスリンクの待ち行列)を操作
する手段,V命令,P命令を実行する手段,ユーザプロ
セス等のソフトウェアから指示された数のプロセスリン
クを未使用状態のプロセスリンクの待ち行列から取り出
してセマフォで専用に使用する未使用状態のプロセスリ
ンクの待ち行列につなげる手段,セマフォを作成する手
段およびディスパッチャ手段といった各手段をファーム
ウェアの機能として備えている。
FIG. 1 is a block diagram showing an example of a multiprocessor system embodying the present invention. The multiprocessor system shown in the figure includes a plurality of processors 40-1, ..., 40-n operated by program control, and a main memory 45 shared by these processors. In addition, the processors 40-1 to 40-n include various queues (a queue of executable processes, a queue of unused process links, a queue of processes waiting for an event via a semaphore, A process for operating the unused process link queue used exclusively by the semaphore, a process for executing V and P instructions, and a process for which the number of process links instructed by software such as a user process is not in use The firmware has various functions such as a means to take out from the link queue and connect to an unused process link queue that is used exclusively by the semaphore, a means to create a semaphore, and a dispatcher means.

【0024】図2は本発明の方法で使用するセマフォと
セグメントの構成例を示す。セマフォ15は図1の主記
憶45上にあり、図3に示すように、負の値もとりうる
セマフォカウンタSCTと、このセマフォ15を介して
事象を待っているプロセスの待ち行列の先頭アドレスP
QHP(1つもプロセスがないときは値0)と、更にこ
のセマフォ15で専用に使用する未使用状態のプロセス
リンクの待ち行列の先頭アドレスFLQP(1つもプロ
セスリンクがないときは値0)とを含んでいる。
FIG. 2 shows an example of the structure of semaphores and segments used in the method of the present invention. The semaphore 15 is in the main memory 45 of FIG. 1, and as shown in FIG. 3, the semaphore counter SCT that can take a negative value and the start address P of the queue of the process waiting for an event via this semaphore 15
QHP (value 0 when there are no processes) and the start address FLQP of the queue of unused process links used exclusively by this semaphore 15 (value 0 when there are no process links) Contains.

【0025】セグメント1も主記憶45上にあり、複数
(図2の例では合計9個)のプロセスリンク16と2つ
のポインタ7,8とが格納されている。各々のプロセス
リンク16は、図4に示すように、プロセス名と他のプ
ロセスリンクとの連結用のリンクアドレス(リンク先が
ないときは値0)と更にセマフォを一意に識別するセマ
フォ名とを格納する。本実施の形態では、各々のプロセ
スリンク16は以下の4種類の待ち行列の何れかにつな
げられて管理される。
The segment 1 is also on the main memory 45, and stores a plurality of (9 in total in the example of FIG. 2) process links 16 and two pointers 7 and 8. As shown in FIG. 4, each process link 16 includes a process name, a link address for linking other process links (value 0 when there is no link destination), and a semaphore name that uniquely identifies the semaphore. Store. In this embodiment, each process link 16 is managed by being connected to any of the following four types of queues.

【0026】複数のプロセッサで共有している未使用
状態のプロセスリンクの待ち行列(Q/PL/FLSと
も言う) セマフォを介して事象を待っているプロセスの待ち行
列(Q/PR/Sとも言う) 実行可能状態のプロセスの待ち行列(Q/PR/RD
Yとも言う) セマフォで専用に使用する未使用状態のプロセスリン
クの待ち行列(Q/S/FPLとも言う)
Unused process link queue shared by a plurality of processors (also called Q / PL / FLS) Process queue waiting for an event via a semaphore (also called Q / PR / S) ) Executable process queue (Q / PR / RD
Also called Y) An unused process link queue that is used exclusively by the semaphore (also called Q / S / FPL)

【0027】即ち、初期の状態においては全てのプロセ
スリンク16は未使用状態であるため、それらのリンク
アドレスによって一つなぎに連結されての待ち行列で
管理され、この待ち行列の先頭のプロセスリンクのアド
レスをセグメント1のポインタ7が指し示す。そして、
セマフォの生成時には、複数のプロセッサで共有してい
る未使用状態のプロセスリンクの待ち行列から幾つか
の未使用状態のプロセスリンクを取り出して、その生成
したセマフォで専用に使用する未使用状態のプロセスリ
ンクの待ち行列につなぎかえられ、この待ち行列の先
頭のプロセスリンクのアドレスをセマフォ内の先頭アド
レスFLQPが指し示す。また、セマフォを介して事象
を待つプロセスが出現すると、そのプロセスのために未
使用状態の1つのプロセスリンクがそのセマフォで専用
に使用するの待ち行列から、若しその待ち行列に未
使用状態のプロセスリンクが1つもなければの待ち行
列から確保され、このプロセスリンクにそのプロセスの
プロセス名等が設定されて、の待ち行列につながれ、
この待ち行列の先頭のプロセスリンクのアドレスをセマ
フォの先頭アドレスPQHPが指し示す。さらに、事象
を待っていたプロセスが実行可能状態に遷移すると、
の待ち行列からそのプロセスのプロセスリンクが取り出
されて、の待ち行列につながれ、この待ち行列の先頭
のプロセスリンクのアドレスをセグメント1のポインタ
8が指し示す。そして、実行可能状態のプロセスが実行
状態に遷移するのに伴って、そのプロセスが使用してい
たプロセスリンクが未使用状態になると、やの元々
つながっていた待ち行列に戻される。
That is, since all the process links 16 are unused in the initial state, they are managed in a queue connected by one link by their link addresses, and the process links at the head of this queue are managed. The pointer 7 of the segment 1 points to the address. And
When a semaphore is created, some unused process links are taken out of the queue of unused process links shared by multiple processors, and the unused process dedicated to the created semaphore is used. It is reconnected to the queue of the link, and the head address FLQP in the semaphore indicates the address of the process link at the head of this queue. Also, when a process that waits for an event appears via a semaphore, one process link that is unused for that process changes from the queue that is used exclusively by that semaphore to the queue that is unused. If there is no process link, it is reserved from the queue, the process name of the process is set in this process link, and the process is connected to the queue.
The address of the process link at the head of this queue is indicated by the head address PQHP of the semaphore. Furthermore, when the process waiting for an event transitions to the ready state,
The process link of the process is taken out of the queue of and is connected to the queue of, and the pointer 8 of the segment 1 points to the address of the process link at the head of the queue. Then, when the process link used by the process changes to the unused state as the process in the ready state transitions to the running state, it is returned to the queue originally connected to or.

【0028】図2の例では、9個のプロセスリンク16
(各々のリンクアドレスは1〜9)のうち、3個の未使
用状態のプロセスリンクは、セマフォ15で専用に使用
する未使用状態のプロセスリンクの待ち行列9につなげ
られており、1個のプロセスリンクは、セマフォ15を
介して事象を待っているプロセスの待ち行列4につなげ
られており、3個のプロセスリンクは、実行可能状態の
プロセスの待ち行列2につなげられている。そして、残
り2個の未使用状態のプロセスリンクは、未使用状態の
プロセスリンクの待ち行列3につなげられている。な
お、プロセスリンク16の総数は本例では9個である
が、これは説明の便宜上に過ぎず、不足する事態が生じ
ない程度に十分な数が確保されていることは言うまでも
ない。
In the example of FIG. 2, nine process links 16 are provided.
Of the (each link address is 1 to 9), three unused process links are connected to a queue 9 of unused process links used exclusively by the semaphore 15, and one unused process link is used. The process link is connected to the queue 4 of the process waiting for the event via the semaphore 15, and the three process links are connected to the queue 2 of the process in the ready state. The remaining two unused process links are linked to the queue 3 of unused process links. Note that the total number of process links 16 is nine in this example, but this is merely for convenience of description, and it goes without saying that a sufficient number is secured so that a situation in which there is no shortage will occur.

【0029】次に本実施の形態の動作について説明す
る。
Next, the operation of this embodiment will be described.

【0030】(1)セマフォ作成時 ユーザプロセス等から発行されたシステムマクロに従っ
てプロセッサ40−1〜40−nのファームウェアが新
たなセマフォを作成したとき、ファームウェアは、その
ユーザプロセス等のソフトウェアから指定された数の未
使用状態のプロセスリンクを、未使用状態のプロセスリ
ンクの待ち行列3から取り出し、作成されたセマフォで
専用に使用する未使用状態のプロセスリンクの待ち行列
9につなぐ。すなわち、未使用状態のプロセスリンクの
待ち行列3から取り出した未使用状態の各プロセスリン
クを図4に示したリンクアドレスで一つなぎに連結し
(最後尾のプロセスリンク中のリンクアドレスは0)、
その先頭のリンクアドレスのアドレスをセマフォの先頭
アドレスFLQPに設定する。また、各プロセスリンク
の図4に示したセマフォ名に、作成されたセマフォのセ
マフォ名を登録しておく。また、ソフトウェアから上述
した指定がない場合には、セマフォで専用に使用する未
使用状態のプロセスリンクの待ち行列9へは未使用状態
のプロセスリンクはつながない。なお、未使用状態のプ
ロセスリンクの数の指定をソフトウェアから行う以外
に、固定的な数をハードウェアに設定しておく方法も採
用可能である。
(1) At the time of creating a semaphore When the firmware of the processors 40-1 to 40-n creates a new semaphore according to the system macro issued by the user process or the like, the firmware is designated by the software of the user process or the like. A certain number of unused process links are taken out from the unused process link queue 3 and connected to the unused process link queue 9 used exclusively by the created semaphore. That is, each unused process link extracted from the queue 3 of the unused process link is connected in one link by the link address shown in FIG. 4 (the link address in the last process link is 0),
The address of the leading link address is set in the leading address FLQP of the semaphore. Further, the semaphore name of the created semaphore is registered in the semaphore name shown in FIG. 4 of each process link. If the software does not specify the above, the unused process link is not connected to the queue 9 of the unused process link used exclusively by the semaphore. Note that a method of setting a fixed number in the hardware can be adopted in addition to specifying the number of unused process links from software.

【0031】(2)P命令実行時 図5はセマフォに対するP命令の本実施の形態の処理の
流れを示す。P命令は引数として各セマフォを一意に識
別し得る識別子であるセマフォ番号をもつ。或るプロセ
ッサ上で実行中の或るプロセスからセマフォ15のセマ
フォ番号を引数としてP命令が発行されると、そのプロ
セッサのファームウェアは、セマフォ15のロックを取
得し(A−11)、セマフォ15のセマフォカウンタS
CTの値から1を減じ(A−12)、その値が負である
か否かを調べる(A−13)。
(2) At the time of executing the P instruction FIG. 5 shows the flow of processing of the P instruction for the semaphore in this embodiment. The P instruction has a semaphore number, which is an identifier capable of uniquely identifying each semaphore, as an argument. When a P command is issued from a certain process running on a certain processor with the semaphore number of the semaphore 15 as an argument, the firmware of the processor acquires the lock of the semaphore 15 (A-11) and Semaphore counter S
One is subtracted from the CT value (A-12), and it is checked whether the value is negative (A-13).

【0032】セマフォカウンタSCTの値が負であれ
ば、P命令を発行したプロセスを待機状態とすべく、以
下の処理を行う。先ず、セマフォ15のFLQPの値が
0であるか否かを調べる(A−14)。FLQPの値が
0でなければ、セマフォ15で専用に使用する未使用状
態のプロセスリンクの待ち行列9に1以上のプロセスリ
ンクが存在するので、この待ち行列9から未使用状態の
プロセスリンクを1つ取り出し(A−18)。ここで、
待ち行列9はセマフォ15で専用に使用する待ち行列で
あり、このステップA−18に進むためにはセマフォ1
5のロック取得が必要なため、セマフォ15とは別に待
ち行列9のロックを行う処理は不要である。次に、現在
実行中のプロセス(P命令を発行したプロセス)を閉塞
し、ステップA−18で取り出した未使用状態のプロセ
スリンクにそのプロセスのプロセス名とリンクアドレス
の情報を書き込んでセマフォ15を介して事象を待って
いるプロセスの待ち行列4につなげる(A−19)。そ
して、セマフォ15をアンロックし(A−17)、命令
を終了し、ディスパッチャへ制御を移す。
If the value of the semaphore counter SCT is negative, the following processing is performed in order to put the process which issued the P instruction in the standby state. First, it is checked whether the value of FLQP of the semaphore 15 is 0 (A-14). If the value of FLQP is not 0, one or more process links exist in the queue 9 of the unused process link dedicatedly used by the semaphore 15. Take out one (A-18). here,
Queue 9 is a queue exclusively used by semaphore 15, and semaphore 1 must be used to proceed to step A-18.
Since it is necessary to acquire the lock of 5, the process of locking the queue 9 separately from the semaphore 15 is unnecessary. Next, the currently executing process (the process that issued the P instruction) is blocked, the process name and link address information of that process is written to the unused process link extracted in step A-18, and the semaphore 15 is set. The process is connected to the queue 4 of the process waiting for the event (A-19). Then, the semaphore 15 is unlocked (A-17), the instruction is terminated, and the control is transferred to the dispatcher.

【0033】他方、セマフォ15のFLQPの値が0で
あれば、セマフォ15で専用に使用する未使用状態のプ
ロセスリンクの待ち行列9に1つもプロセスリンクが存
在しないので、従来と同様に、未使用状態のプロセスリ
ンクの待ち行列3のロックを取得してこの待ち行列3か
ら未使用状態のプロセスリンクを1つ取り出し(A−1
5)、現在実行中のプロセス(P命令を発行したプロセ
ス)を閉塞し、上記未使用状態のプロセスリンクにその
プロセスのプロセス名およびリンクアドレスの情報を書
き込んでセマフォ15を介して事象を待っているプロセ
スの待ち行列4につなげた後、未使用状態のプロセスリ
ンクの待ち行列3のアンロックを行う(A−16)。そ
して、セマフォ15のアンロックを行い(A−17)、
命令を終了し、ディスパッチャに制御を移する。
On the other hand, if the value of FLQP of the semaphore 15 is 0, there is no process link in the queue 9 of the unused process link that is used exclusively by the semaphore 15, and therefore, as in the prior art, The lock of the queue 3 of the used process link is acquired, and one unused process link is taken out of this queue 3 (A-1
5) Block the currently executing process (process that issued the P instruction), write the process name and link address information of the process in the unused process link, and wait for an event via the semaphore 15. After connecting to the queue 4 of the existing process, the queue 3 of the unused process link is unlocked (A-16). Then, unlock the semaphore 15 (A-17),
Finish the instruction and transfer control to the dispatcher.

【0034】更に、ステップA−13において、セマフ
ォ15のセマフォカウンタSCTの値が負でないと判定
された場合(0以上の場合)、セマフォ15のアンロッ
クを行い(A−20)、そのままそのプロセスの処理を
継続する。
Further, when it is determined in step A-13 that the value of the semaphore counter SCT of the semaphore 15 is not negative (0 or more), the semaphore 15 is unlocked (A-20) and the process is continued. Continue processing.

【0035】(3)V命令実行時 V命令実行時の処理の流れは図15に示した従来の処理
と同じである。即ち、或るプロセッサで実行中の或るプ
ロセスからセマフォ15のセマフォ番号を引数としてV
命令が発行されると、そのプロセッサのファームウェア
は、セマフォ15のロックを取得し(B−1)、セマフ
ォ15のセマフォカウンタSCTの値に1を加え(B−
2)、その値が正であるか否かを調べ(B−3)、セマ
フォカウンタSCTの値が正であれば、セマフォ15の
アンロックを行ってそのまま処理を継続する(B−
6)。他方、セマフォカウンタSCTの値が正でなけれ
ば(0以下であれば)、このセマフォ15を介して事象
を待っているプロセスの待ち行列4の中から1つのプロ
セスリンクを取り出し、実行可能状態のプロセスの待ち
行列2のロックを取得し、前記取り出したプロセスリン
クを実行可能状態のプロセスの待ち行列2につなげて当
該プロセスリンクにかかるプロセスを実行可能状態と
し、実行可能状態のプロセスの待ち行列2のアンロック
を行う(B−4)。そして、セマフォ15のアンロック
を行い(B−5)、命令を終了し、制御をディスパッチ
ャへ移す。
(3) At the time of executing V instruction The flow of processing at the time of executing V instruction is the same as the conventional processing shown in FIG. That is, the semaphore number of the semaphore 15 is used as an argument from a certain process running on a certain processor as V
When the instruction is issued, the firmware of the processor acquires the lock of the semaphore 15 (B-1) and adds 1 to the value of the semaphore counter SCT of the semaphore 15 (B-
2) It is checked whether the value is positive (B-3). If the value of the semaphore counter SCT is positive, the semaphore 15 is unlocked and the processing is continued (B-).
6). On the other hand, if the value of the semaphore counter SCT is not positive (0 or less), one process link is taken out from the queue 4 of the process waiting for an event via this semaphore 15 and is in the ready state. The lock of the queue 2 of the process is acquired, the extracted process link is connected to the queue 2 of the process in the executable state, the process related to the process link is set to the executable state, and the queue 2 of the process in the executable state is acquired. Unlock (B-4). Then, the semaphore 15 is unlocked (B-5), the instruction is terminated, and the control is transferred to the dispatcher.

【0036】(4)ディスパッチャの処理 図6にディスパッチャによりプロセスが実行可能状態の
プロセスの待ち行列2から実行状態に遷移する場合の処
理の流れを示す。ディスパッチャによりプロセスが実行
可能状態のプロセスの待ち行列2から実行状態に遷移す
る場合、実行可能状態のプロセスの待ち行列2から実行
状態に遷移するプロセスのプロセスリンクにおけるセマ
フォ名のエリアを読み出し、セマフォ名が設定されてい
るか否かを調べる(C−11)。
(4) Process of Dispatcher FIG. 6 shows a process flow when a process by the dispatcher transits from the queue 2 of the process in the ready state to the run state. When a process transitions from queue 2 of an executable process to the execution state by the dispatcher, the area of the semaphore name in the process link of the process of the process transitioning from queue 2 of the executable process to the execution state is read and the semaphore name is read. It is checked whether or not is set (C-11).

【0037】セマフォ名が設定されていれば、当該プロ
セスリンクは、元々、そのセマフォ名のセマフォで専用
に使用する未使用状態のプロセスリンクの待ち行列9か
ら取り出されたものである。そこで、実行可能状態のプ
ロセスの待ち行列2のロックと上記セマフォ名のセマフ
ォのロックを取得し(C−12)、実行可能状態のプロ
セスの待ち行列2から実行状態に遷移するプロセスのプ
ロセスリンクを取り外して当該プロセスの情報をプロセ
ッサへ取り込み、未使用状態になったプロセスリンクを
そのセマフォで専用に使用する未使用状態のプロセスリ
ンクの待ち行列9につなげる(C−13)。そして、実
行可能状態のプロセスの待ち行列2のアンロックとセマ
フォのアンロックとを行い(C−14)、プロセスを実
行する。
If the semaphore name is set, the process link is originally extracted from the queue 9 of the unused process link that is exclusively used by the semaphore with the semaphore name. Therefore, the lock of queue 2 of the process in the executable state and the lock of the semaphore with the above semaphore name are acquired (C-12), and the process link of the process transitioning from the queue 2 of the process of the executable state to the execution state is established. The information of the relevant process is removed and fetched into the processor, and the unused process link is connected to the queue 9 of the unused process link that is exclusively used by the semaphore (C-13). Then, the queue 2 of the executable process is unlocked and the semaphore is unlocked (C-14), and the process is executed.

【0038】他方、セマフォ名が設定されていなけれ
ば、当該プロセスリンクは、元々、未使用状態のプロセ
スリンクの待ち行列3から取り出されたものである。そ
こで、従来と同様に、実行可能状態のプロセスの待ち行
列2と未使用状態のプロセスリンクの待ち行列3のロッ
クを取得し(C−15)、実行可能状態のプロセスの待
ち行列2から実行状態に遷移するプロセスのプロセスリ
ンクを取り外して当該プロセスの情報をプロセッサへ取
り込み、未使用状態になったプロセスリンクを未使用状
態のプロセスリンクの待ち行列3につなげる(C−1
6)。そして、実行可能状態のプロセスの待ち行列2及
び未使用状態のプロセスリンクの待ち行列3をアンロッ
クし(C−17)、プロセスを実行する。
On the other hand, if the semaphore name is not set, the process link is originally taken out from the queue 3 of the unused process link. Therefore, as in the conventional method, the lock of the queue 2 of the process in the executable state and the queue 3 of the process link in the unused state is acquired (C-15), and the execution state is changed from the queue 2 of the process in the executable state. The process link of the process transitioning to is removed, the information of the process is fetched into the processor, and the unused process link is connected to the queue 3 of the unused process link (C-1).
6). Then, the queue 2 of the process in the executable state and the queue 3 of the process link in the unused state are unlocked (C-17), and the process is executed.

【0039】[0039]

【実施例】次に各図を参照して本発明の実施の形態の一
実施例の動作について詳細に説明する。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Next, the operation of one embodiment of the present invention will be described in detail with reference to the drawings.

【0040】今、図7に示すように、リンクアドレスが
それぞれ1〜9である9つのプロセスリンク100〜1
08を含むセグメント1があり、実行可能状態のプロセ
スの待ち行列2にはプロセス名30,31,32とセマ
フォ名S1を含むプロセスリンク100,101,10
2がつながれ、未使用状態のプロセスリンクの待ち行列
3には未使用状態のプロセスリンク103〜108がつ
ながれているとする。また、対象とするマルチプロセッ
サシステムは、2つのプロセッサ40−1,40−2と
主記憶45とを含み、プロセッサ40−1ではプロセス
名20のプロセスが、プロセッサ40−2ではプロセス
名21のプロセスが実行中であるとする。さらに、プロ
セスのプライオリティ(優先順位)は20,21,3
0,31,32の順に低くなっているものとする。ま
た、1つのセマフォ15−1があって、そのセマフォカ
ウンタSCTの初期値は0、セマフォ名はS1で、作成
時にプロセスリンク100,101,102を3つ確保
していたが、プロセス名30,31,32のプロセスに
よってそれらのプロセスリンクがセマフォ15−1で使
用中であるとする。
Now, as shown in FIG. 7, nine process links 100-1 having link addresses 1-9, respectively.
There is a segment 1 including 08, and the process queue 100, 101, 10 including the process names 30, 31, 32 and the semaphore name S1 is in the queue 2 of the process in the executable state.
It is assumed that 2 are connected and the unused process links 103 to 108 are connected to the queue 3 of the unused process link. Further, the target multiprocessor system includes two processors 40-1 and 40-2 and a main memory 45. In the processor 40-1, the process with the process name 20 is processed, and in the processor 40-2, the process with the process name 21 is processed. Is running. Furthermore, the process priority is 20, 21, 3
It is assumed that the number becomes lower in the order of 0, 31, 32. Also, there is one semaphore 15-1, the initial value of the semaphore counter SCT is 0, the semaphore name is S1, and three process links 100, 101, 102 were secured at the time of creation, but the process name 30, It is assumed that the process links of 31 and 32 are in use by the semaphore 15-1.

【0041】このような状況において、図8に示すよう
に、プロセス20からの要求に従ってプロセッサ40−
1のファームウェアがセマフォカウンタSCTの初期値
として0を持つセマフォ15−2(セマフォ名はS2と
する)を作成すると、そのファームウェアは、セマフォ
作成時にプロセス20から指示された数(例えば4つと
する)のプロセスリンク103〜106を未使用状態の
プロセスリンクの待ち行列3から取り外し、それらのプ
ロセスリンク103〜106を一つなぎに連結すると共
にセマフォ名S2を格納し、セマフォ15−2で専用に
使用する未使用状態のプロセスリンクの待ち行列9−2
につなげるべく、セマフォ15−2の先頭アドレスFL
QPに先頭のプロセスリンク103のリンクアドレス
(4)を格納する。
In such a situation, as shown in FIG. 8, the processor 40-
When the firmware of No. 1 creates a semaphore 15-2 (the semaphore name is S2) having 0 as the initial value of the semaphore counter SCT, the firmware has the number (for example, four) instructed by the process 20 at the time of creating the semaphore. Process links 103 to 106 are removed from the queue 3 of the unused process links, the process links 103 to 106 are connected to each other, the semaphore name S2 is stored, and the semaphore 15-2 is used exclusively. Queue 9-2 for unused process links
To connect to the start address FL of the semaphore 15-2.
The link address (4) of the first process link 103 is stored in QP.

【0042】次いでプロセス20でセマフォ15−2に
対しP命令が発行されると、プロセッサ40−1のファ
ームウェアは図5のP命令実行フローに従って動作し、
まずセマフォ15−2のロックを取得し、セマフォカウ
ンタSCTから1を減じる。この結果、図9に示すよう
に、SCTの値は−1になるため、セマフォ15−2で
専用に使用する未使用状態のプロセスリンクの待ち行列
9−2から未使用状態のプロセスリンク103を取り出
し、プロセス20の情報を書き込んでセマフォ15−2
を介して事象を待っているプロセスの待ち行列4−2に
接続し、セマフォ15−2の先頭アドレスPQHPにプ
ロセスリンク103のリンクアドレス(4)を格納す
る。こうしてプロセス20はセマフォ15−2で待機の
状態となる。
Next, when the P instruction is issued to the semaphore 15-2 in the process 20, the firmware of the processor 40-1 operates according to the P instruction execution flow of FIG.
First, the lock of the semaphore 15-2 is acquired, and 1 is subtracted from the semaphore counter SCT. As a result, as shown in FIG. 9, the SCT value becomes -1, so that the unused process link 103 is moved from the unused process link queue 9-2 that is used exclusively by the semaphore 15-2. Semaphore 15-2 by taking out and writing the information of process 20
Is connected to the queue 4-2 of the process waiting for the event, and the link address (4) of the process link 103 is stored in the head address PQHP of the semaphore 15-2. In this way, the process 20 enters a standby state with the semaphore 15-2.

【0043】次いでディスパッチャは実行可能状態のプ
ロセスの待ち行列2から最もプライオリティの高いプロ
セス30をプロセッサ40−1で実行するよう図6に従
い制御する。このとき、プロセス30のプロセスリンク
100に格納されているセマフォ名がS1であることか
ら、図10に示すように、実行可能状態のプロセスの待
ち行列2からプロセス30のプロセスリンク100を取
り出し、プロセス30の情報をプロセッサ40−1に取
り込んだ後、空きになったプロセスリンク100をセマ
フォ15−1で専用に使用する未使用状態のプロセスリ
ンクの待ち行列9−1に接続し、セマフォ15−1の先
頭アドレスFLQPにプロセスリンク100のリンクア
ドレス(1)を書き込む。
Then, the dispatcher controls the process 40 having the highest priority from the queue 2 of processes in the ready state to be executed by the processor 40-1 according to FIG. At this time, since the semaphore name stored in the process link 100 of the process 30 is S1, as shown in FIG. 10, the process link 100 of the process 30 is extracted from the queue 2 of the process in the executable state, After fetching the information of 30 into the processor 40-1, the vacant process link 100 is connected to the queue 9-1 of the unused process link which is used exclusively by the semaphore 15-1, and the semaphore 15-1 is connected. The link address (1) of the process link 100 is written to the leading address FLQP of the.

【0044】[0044]

【発明の効果】以上説明したように本発明によれば、セ
マフォの生成時に、複数のプロセッサで共有している未
使用状態のプロセスリンクの待ち行列から幾つかの未使
用状態のプロセスリンクを取り出して前記生成したセマ
フォで専用に使用する未使用状態のプロセスリンクの待
ち行列につなげておき、セマフォに対してP命令を発行
したプロセスを当該セマフォで待機中にするために使う
プロセスリンクを、そのセマフォ専用の未使用状態のプ
ロセスリンクの待ち行列から取り出すようにしたので、
複数のプロセッサで共有している未使用状態のプロセス
リンクの待ち行列から常にプロセスリンクを取り出して
いた従来方法に比べて、待ち行列のロック取得による競
合が減り、ロック取得待ち時間が減って性能を向上させ
ることができる。
As described above, according to the present invention, when a semaphore is created, some unused process links are extracted from the queue of unused process links shared by a plurality of processors. The process link used to hold the process that issued the P instruction to the semaphore by connecting it to the queue of the unused process link that is used exclusively by the generated semaphore. Since it was taken out from the queue of the unused process link dedicated to the semaphore,
Compared to the conventional method that always takes out the process link from the unused process link queue shared by multiple processors, contention due to lock acquisition of the queue is reduced, lock acquisition wait time is reduced, and performance is improved. Can be improved.

【0045】また、セマフォ専用の未使用状態のプロセ
スリンクの数はソフトウェアによって指定できるため、
効率的な運用が可能となる。その理由は、どの程度のプ
ロセスリンクを必要とするかはセマフォの作成を指示し
たユーザプロセス等のソフトウェアが一番良く把握して
いるため、過不足のない数の未使用状態のプロセスリン
クが確保できるからである。
Since the number of unused process links dedicated to the semaphore can be specified by software,
Efficient operation becomes possible. The reason is that the software, such as the user process that instructed the creation of the semaphore, has the best grasp of how many process links are needed, so a sufficient number of unused process links are secured. Because you can.

【0046】さらに、セマフォ専用の未使用状態のプロ
セスリンクが作成されなかった場合や、それが使い果た
された場合には、従来と同様に複数のプロセッサで共有
している未使用状態のプロセスリンクの待ち行列から自
動的に未使用状態のプロセスリンクが取得されるため、
セマフォ作成時にソフトウェアから指定された未使用状
態のプロセスリンクの数が少なすぎた場合や、そもそも
そのような指定を行わない古いバージョンのプロセスの
動作環境においても、支障なくプロセス制御を実施する
ことができる。
Further, when the unused process link dedicated to the semaphore is not created, or when it is exhausted, the unused process shared by a plurality of processors as in the conventional case. Since an unused process link is automatically acquired from the link queue,
Even if the number of unused process links specified by the software when creating a semaphore is too small, or in the operating environment of an old version of the process that does not specify such a process link, process control can be performed without any problems. it can.

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

【図1】本発明を実施するマルチプロセッサシステムの
一例を示すブロック図である。
FIG. 1 is a block diagram illustrating an example of a multiprocessor system that implements the present invention.

【図2】本発明で使用するセマフォとセグメントの構成
例を示す図である。
FIG. 2 is a diagram showing a configuration example of a semaphore and a segment used in the present invention.

【図3】本発明で使用するセマフォの構成例を示す図で
ある。
FIG. 3 is a diagram showing a configuration example of a semaphore used in the present invention.

【図4】本発明で使用するプロセスリンクの構成例を示
す図である。
FIG. 4 is a diagram showing a configuration example of a process link used in the present invention.

【図5】本発明におけるP命令実行処理の一例を示すフ
ローチャートである。
FIG. 5 is a flowchart showing an example of P instruction execution processing in the present invention.

【図6】本発明におけるディスパッチャの処理例を示す
フローチャートである。
FIG. 6 is a flowchart showing a processing example of a dispatcher according to the present invention.

【図7】本発明の一実施例の動作説明に用いるマルチプ
ロセッサシステムとセグメントとセマフォの或る時点の
状態を示す図である。
FIG. 7 is a diagram showing a state of a multiprocessor system, a segment, and a semaphore used for explaining the operation of an embodiment of the present invention at a certain time.

【図8】図7の状態において新たなセマフォが生成され
た時点の各部の状態を示す図である。
8 is a diagram showing a state of each unit when a new semaphore is generated in the state of FIG. 7.

【図9】図8の状態においてP命令を発行したプロセス
が待機状態となった時点の各部の状態を示す図である。
9 is a diagram showing a state of each part at the time when the process that issued the P instruction in the state of FIG. 8 is in a standby state.

【図10】図9の状態においてプロセスが実行状態とな
ったことにより未使用状態のプロセスリンクがセマフォ
で専用に使用する未使用状態のプロセスリンクの待ち行
列に戻された時点の各部の状態を示す図である。
FIG. 10 shows the state of each part at the time when the unused process link is returned to the queue of the unused process link that is used exclusively by the semaphore because the process is in the running state in the state of FIG. FIG.

【図11】従来技術で使用されるセマフォとセグメント
の構成図である。
FIG. 11 is a configuration diagram of a semaphore and a segment used in the related art.

【図12】従来技術で使用されるプロセスリンクの構成
図である。
FIG. 12 is a block diagram of a process link used in the prior art.

【図13】従来技術で使用されるセマフォの構成図であ
る。
FIG. 13 is a configuration diagram of a semaphore used in the related art.

【図14】従来技術におけるP命令実行処理のフローチ
ャートである。
FIG. 14 is a flowchart of a P instruction execution process in the related art.

【図15】従来技術におけるV命令実行処理のフローチ
ャートである。
FIG. 15 is a flowchart of a V instruction execution process in the related art.

【図16】従来技術におけるディスパッチャの処理のフ
ローチャートである。
FIG. 16 is a flowchart of processing of a dispatcher according to the conventional technique.

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

1…セグメント 2…実行可能状態のプロセスの待ち行列(Q/PR/R
DY) 3…未使用状態のプロセスリンクの待ち行列(Q/PL
/FLS) 4…セマフォを介して事象を待っているプロセスの待ち
行列(Q/PR/S) 5,15…セマフォ 6,16…プロセスリンク 7…未使用状態のプロセスリンクの待ち行列の先頭のプ
ロセスリンクを指し示すポインタ 8…実行可能状態のプロセスの待ち行列の先頭のプロセ
スリンクを指し示すポインタ 9…セマフォで専用に使用する未使用状態のプロセスリ
ンクの待ち行列(Q/S/FPL)
1 ... Segment 2 ... Queue of process in ready state (Q / PR / R
DY) 3 ... Unused process link queue (Q / PL
/ FLS) 4 ... Process queue waiting for an event via a semaphore (Q / PR / S) 5,15 ... Semaphore 6,16 ... Process link 7 ... Unused process link queue head Pointer that points to process link 8 ... Pointer that points to the first process link in the queue of the process that is in the runnable state 9 ... Queue for the unused process link that is used exclusively by the semaphore (Q / S / FPL)

Claims (3)

【特許請求の範囲】[Claims] 【請求項1】 セマフォを介してプロセスの同期や排他
制御を行うオペレーティング・システムを有するマルチ
プロセッサシステムにおいて、 セマフォの生成時に、複数のプロセッサで共有している
未使用状態のプロセスリンクの待ち行列から幾つかの未
使用状態のプロセスリンクを取り出し、前記生成したセ
マフォで専用に使用する未使用状態のプロセスリンクの
待ち行列につなげる第1のステップと、 セマフォに対してP命令を発行したプロセスを当該セマ
フォで待機中にする場合、当該セマフォで専用に使用す
る未使用状態のプロセスリンクの待ち行列から未使用の
プロセスリンクを1つ取り出し、この取り出したプロセ
スリンクに当該プロセスの名前を設定して、当該セマフ
ォを介して事象を待っているプロセスの待ち行列につな
ぐ第2のステップとを含むことを特徴とするセマフォに
関するプロセス制御方法。
1. In a multiprocessor system having an operating system for performing process synchronization and exclusive control via a semaphore, an unused process link queue shared by a plurality of processors when a semaphore is created. The first step of extracting some unused process links and connecting them to the queue of unused process links to be used exclusively by the generated semaphore, and the process that issued the P instruction to the semaphore To put a semaphore into a standby state, take out one unused process link from the queue of unused process links that is used exclusively by that semaphore, set the name of the process to this extracted process link, Connect to the queue of the process waiting for an event via the semaphore Process control method for a semaphore which comprises a second step.
【請求項2】 前記第1のステップにおいて、セマフォ
で専用に使用する未使用状態のプロセスリンクの待ち行
列につなげる未使用状態のプロセスリンクの数をソフト
ウェアから指定可能とすることを特徴とする請求項1記
載のセマフォに関するプロセス制御方法。
2. In the first step, the number of unused process links connected to a queue of unused process links exclusively used by a semaphore can be designated by software. A process control method for a semaphore according to item 1.
【請求項3】 前記第1のステップにおいて、セマフォ
で専用に使用する未使用状態のプロセスリンクの待ち行
列につなげた各々のプロセスリンクに当該セマフォの識
別子を設定し、 前記第2のステップにおいて、セマフォで専用に使用す
る未使用状態のプロセスリンクの待ち行列に1つも未使
用状態のプロセスリンクが存在しない場合には、複数の
プロセッサで共有している未使用状態のプロセスリンク
の待ち行列から未使用状態のプロセスリンクを1つ取り
出し、この取り出したプロセスリンクに当該プロセスの
名前を設定して、当該セマフォを介して事象を待ってい
るプロセスの待ち行列につなぐようにし、且つ、 セマフォを介して事象を待っているプロセスの待ち行列
につながれたプロセスリンクをそのプロセスの実行状態
への遷移に伴って未使用状態のプロセスリンクとする
際、そのプロセスリンクにセマフォの識別子が設定され
ているときは設定された識別子のセマフォで専用に使用
する未使用状態のプロセスリンクの待ち行列に戻し、セ
マフォの識別子が設定されていないときは複数のプロセ
ッサで共有している未使用状態のプロセスリンクの待ち
行列に戻す第3のステップを含むことを特徴とする請求
項2記載のセマフォに関するプロセス制御方法。
3. In the first step, an identifier of the semaphore is set to each process link connected to a queue of unused process links exclusively used by the semaphore, and in the second step, If there is no unused process link in the queue of the unused process link used exclusively by the semaphore, the unused process link queue shared by multiple processors is not Takes out one process link that is in use, sets the name of the process to this fetched process link, connects it to the queue of the process waiting for the event via the semaphore, and via the semaphore Transition of the process link connected to the queue of the process waiting for an event to the execution state of that process Therefore, when making a process link in an unused state, if a semaphore identifier is set for that process link, it is returned to the queue of the unused process link used exclusively by the semaphore with the set identifier, and the semaphore 3. The process control method for a semaphore according to claim 2, further comprising a third step of returning to the queue of an unused process link shared by a plurality of processors when the identifier of is not set.
JP15761696A 1996-05-29 1996-05-29 Process control method for semaphores Expired - Lifetime JP2861943B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP15761696A JP2861943B2 (en) 1996-05-29 1996-05-29 Process control method for semaphores

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP15761696A JP2861943B2 (en) 1996-05-29 1996-05-29 Process control method for semaphores

Publications (2)

Publication Number Publication Date
JPH09319601A true JPH09319601A (en) 1997-12-12
JP2861943B2 JP2861943B2 (en) 1999-02-24

Family

ID=15653629

Family Applications (1)

Application Number Title Priority Date Filing Date
JP15761696A Expired - Lifetime JP2861943B2 (en) 1996-05-29 1996-05-29 Process control method for semaphores

Country Status (1)

Country Link
JP (1) JP2861943B2 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8522250B2 (en) 2010-09-29 2013-08-27 International Business Machines Corporation Managing access to a shared resource in a data processing system
JP2015530679A (en) * 2012-10-04 2015-10-15 クゥアルコム・インコーポレイテッドQualcomm Incorporated Method and apparatus using high efficiency atomic operations

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8522250B2 (en) 2010-09-29 2013-08-27 International Business Machines Corporation Managing access to a shared resource in a data processing system
US8539501B2 (en) 2010-09-29 2013-09-17 International Business Machines Corporation Managing access to a shared resource in a data processing system
JP2015530679A (en) * 2012-10-04 2015-10-15 クゥアルコム・インコーポレイテッドQualcomm Incorporated Method and apparatus using high efficiency atomic operations

Also Published As

Publication number Publication date
JP2861943B2 (en) 1999-02-24

Similar Documents

Publication Publication Date Title
DE4104781C2 (en) Memory access control
US4847754A (en) Extended atomic operations
US8694997B2 (en) Deterministic serialization in a transactional memory system based on thread creation order
US5257372A (en) Methods for efficient distribution of parallel tasks to slave processes in a multiprocessing system
US5867702A (en) Method and apparatus for initializing a multiprocessor system
JP2650965B2 (en) Computer system and task scheduling method thereof
JPH10301834A (en) Management method for shared memory
US20040199927A1 (en) Enhanced runtime hosting
JPH08137707A (en) Distributed transaction processing system
JPH1165863A (en) Common resource managing method
CN109614220A (en) A kind of multiple nucleus system processor and data-updating method
US7770177B2 (en) System for memory reclamation based on thread entry and release request times
JP3113841B2 (en) Parallel transaction processing system
JPH1115793A (en) Protection method for resource maintainability
CN109308213B (en) Multi-task breakpoint debugging method based on improved task scheduling mechanism
CN110297661A (en) Parallel computing method, system and medium based on AMP framework DSP operating system
JPH09319601A (en) Process control method for semaphore
CN112346835A (en) Scheduling processing method and system based on coroutine
JP3621433B2 (en) Database exclusive control method
US20080250412A1 (en) Cooperative process-wide synchronization
EP0529866A2 (en) Processor for a multiprocessor system
JP2973480B2 (en) Communication register multiplexing method
JPH07120302B2 (en) Task debug method
JPH07120301B2 (en) Task debugging method
CN111124697A (en) Task synchronization and execution method facing distributed platform