JP2010026575A - Scheduling method, scheduling device, and multiprocessor system - Google Patents

Scheduling method, scheduling device, and multiprocessor system Download PDF

Info

Publication number
JP2010026575A
JP2010026575A JP2008183743A JP2008183743A JP2010026575A JP 2010026575 A JP2010026575 A JP 2010026575A JP 2008183743 A JP2008183743 A JP 2008183743A JP 2008183743 A JP2008183743 A JP 2008183743A JP 2010026575 A JP2010026575 A JP 2010026575A
Authority
JP
Japan
Prior art keywords
processor
thread
shared resource
inter
shared
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
JP2008183743A
Other languages
Japanese (ja)
Inventor
Makoto Sato
信 佐藤
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 Electronics Corp
Original Assignee
NEC Electronics 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 Electronics Corp filed Critical NEC Electronics Corp
Priority to JP2008183743A priority Critical patent/JP2010026575A/en
Publication of JP2010026575A publication Critical patent/JP2010026575A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Multi Processors (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To efficiently prevent deadlock in a multiprocessor system. <P>SOLUTION: A real time system 100 equipped with a CPU 110 and a CPU 150 performs exclusive control of a shared resource by a priority sealing system. A thread which has made a request for acquiring a shared resource to be shared by the CPU 110 and the CPU 150 acquire the shared resource under such conditions that the priority sealing value of the shared resource is larger than any priority sealing value of the shared resource during exclusive control by the thread in any CPU other than the CPU executing the thread by referring to shared resource acquisition information 210 stored in a shared memory 200. <P>COPYRIGHT: (C)2010,JPO&INPIT

Description

本発明は、スケジューリング、特にマルチプロセッサシステムにおけるスケジューリング技術に関する。   The present invention relates to scheduling, particularly scheduling technology in a multiprocessor system.

リアルタイムシステムで実行される逐次処理の単位は「スレッド」または「タスク」などの呼称があり、本明細書においては、「スレッド」と呼ぶ。多くのリアルタイムOS(オペレーティングシステム)は、リアルタイム性を確保するためのスケジューリングポリシとしてプリエンプティブな優先度ベースのスケジューリングポリシをサポートする。このスケジューリングポリシは、下記のように定められている。
1.その時点で最も高い優先度のスレッドが実行される。
2.その時点で最も高い優先度のスレッドの処理は中断されてはいけない。
3.同一優先度の場合は先着順とする。「先着順」は、スレッドが実行可能状態に遷移した順番を意味する。
4.優先度の高いスレッドが実行可能状態になった場合、該スレッドより優先度が低いスレッドの処理の途中であっても、スレッドの切替えを行って高い優先度のスレッドを実行させる。
A unit of sequential processing executed in the real-time system has a name such as “thread” or “task”, and is referred to as “thread” in this specification. Many real-time OSs (operating systems) support a preemptive priority-based scheduling policy as a scheduling policy for ensuring real-time performance. This scheduling policy is defined as follows.
1. The thread with the highest priority at that time is executed.
2. The processing of the highest priority thread at that time must not be interrupted.
3. In the case of the same priority, the order of arrival is first. “First-come-first-served order” means the order in which threads have transitioned to an executable state.
4). When a thread with a high priority is in an executable state, the thread is switched to execute a thread with a high priority even during the processing of a thread with a lower priority than the thread.

上述した「実行可能状態」は、プリエンプトされた他のスレッドが無いとき、またはプリエンプトされた他のスレッドがCPU(Central Processing Unit)の実行権を解放すれば実行できる状態を意味する。   The “executable state” described above means a state that can be executed when there is no other preempted thread, or when the other preempted thread releases the execution right of a CPU (Central Processing Unit).

リアルタイムシステムにおいて、スレッドにより共有可能なリソース(以下共有リソースという)の衝突問題を解決するために、共有リソースの排他制御(以下単に排他制御という)が行われる。図5は、排他制御処理の模式図である。   In a real-time system, exclusive control of shared resources (hereinafter simply referred to as exclusive control) is performed in order to solve a collision problem of resources that can be shared by threads (hereinafter referred to as shared resources). FIG. 5 is a schematic diagram of exclusive control processing.

図5に示すように、あるスレッドは、共有リソースの操作に当たって、まず、OSに対してリソース獲得要求(以下単に獲得要求ともいう)を発行する。そして、リソース獲得要求に応じてOSから共有リソースの操作が許可されれば、共有リソースを操作し、操作完了後、リソース解放要求(以下単に解放要求ともいう)をOSに発行して該共有リソースを解放する。スレッドが共有リソースを獲得してから、共有リソースを解放するまでの期間は、「ブロック期間」といい、ブロック期間における共有リソースの状態は、「排他制御中」という。   As shown in FIG. 5, when operating a shared resource, a thread first issues a resource acquisition request (hereinafter also simply referred to as an acquisition request) to the OS. Then, if the operation of the shared resource is permitted from the OS in response to the resource acquisition request, the shared resource is operated, and after the operation is completed, a resource release request (hereinafter also simply referred to as a release request) is issued to the OS to execute the shared resource. To release. A period from when a thread acquires a shared resource to when the shared resource is released is referred to as a “block period”, and a state of the shared resource in the block period is referred to as “exclusive control”.

OSは、他のスレッドにより排他制御中ではないことを条件に、当該共有リソースの獲得要求を発行したスレッドにリソース操作を許可する。これにより、複数のスレッドが同時に共有リソースを操作することを回避することができる。   The OS permits the resource operation to the thread that issued the shared resource acquisition request on the condition that the exclusive control is not being performed by another thread. Thereby, it is possible to avoid a plurality of threads from operating the shared resource at the same time.

ここで、シングルプロセッサコアのリアルタイムシステムにおける排他処理機構について説明する。なお、以下において、スレッドの表記に「H」、「M」、「L」を付けることにより当該スレッドの優先度が「高」、「中」、「低」であることを示す。   Here, an exclusive processing mechanism in a real-time system having a single processor core will be described. In the following, “H”, “M”, and “L” are added to the notation of a thread to indicate that the priority of the thread is “high”, “medium”, and “low”.

共有リソースの衝突問題を簡単に解決できる排他処理機構として、多くのリアルタイムOSにはセマフォが装備されている。セマフォには、非負整数をとるカウンティングセマフォ、「0」と「1」をとるバイナリ・セマフォがあり、以下バイナリ・セマフォを例に説明する。なお、共有リソースを操作するような、排他処理が必要な区間をクリティカルリージョンという。   Many real-time OSs are equipped with a semaphore as an exclusive processing mechanism that can easily solve the shared resource collision problem. The semaphore includes a counting semaphore that takes a non-negative integer and a binary semaphore that takes “0” and “1”. The binary semaphore will be described below as an example. A section that requires exclusive processing, such as operating a shared resource, is called a critical region.

セマフォを使用する上では、下記の約束事が定められている。
1.スレッドがクリティカルリージョンに入るときにセマフォをとる。
2.セマフォがない間は、他のスレッドはクリティカルリージョンに入れない。
3.セマフォが他のスレッドにとられているときはセマフォが戻るまで待つ。
4.クリティカルリージョンから出るときにセマフォを戻す。
5.スレッドをとる間は不可分に(スレッドが切り替わることがなく)実行される。
6.セマフォを戻す間も不可分に実行される。
7.セマフォを戻すときに待っているスレッドがあればそのスレッドの待ち状態を解除すする。
The following conventions have been established for using semaphores.
1. Take a semaphore when a thread enters a critical region.
2. While there is no semaphore, no other thread can enter the critical region.
3. If the semaphore is taken by another thread, wait until the semaphore returns.
4). Return semaphore when exiting critical region.
5). It is executed indefinitely (without thread switching) while taking a thread.
6). It is inseparably executed while returning the semaphore.
7). If there is a thread waiting when returning the semaphore, the waiting state of the thread is released.

図6は、セマフォを用いたリアルタイムシステムにおけるスレッドの実行模式を示す。図中において、優先度が「L:低」であるスレッドL1は、獲得要求をOSに発行してセマフォを取得してリソース操作をする。その後、スレッドL1が解放要求をOSに発行してセマフォを戻すまでは、ブロック期間であり、この期間において他のスレッドは該共有リソースのセマフォをとることができない。時刻t0において、優先度が「M:中」であるスレッドM1が実行可能状態に遷移したため、スレッドL1の実行は中断され、スレッドM1は実行される。時刻t1において、スレッドM1が獲得要求を発行するものの、セマフォがスレッドL1により排他制御中であるため、スレッドM1は中断され、スレッドL1は再開される。のちに、スレッドL1がセマフォを解放すると、スレッドM1は、やっとセマフォを取得する。これに伴って、スレッドM1は実行され、スレッドL1は中断される。   FIG. 6 shows a thread execution pattern in a real-time system using a semaphore. In the figure, the thread L1 having the priority “L: Low” issues an acquisition request to the OS, acquires a semaphore, and performs resource operations. Thereafter, it is a block period until the thread L1 issues a release request to the OS and returns the semaphore. In this period, other threads cannot take the semaphore of the shared resource. At time t0, since the thread M1 having the priority “M: medium” has changed to an executable state, the execution of the thread L1 is interrupted and the thread M1 is executed. At time t1, the thread M1 issues an acquisition request, but since the semaphore is under exclusive control by the thread L1, the thread M1 is suspended and the thread L1 is resumed. Later, when the thread L1 releases the semaphore, the thread M1 finally acquires the semaphore. Along with this, the thread M1 is executed and the thread L1 is interrupted.

以下、スレッドがセマフォを待つことを「排他待ち」といい、図6に示す時刻t0〜時刻t1のような、排他待ちをしている区間を「排他待ち期間」という。   Hereinafter, waiting for a semaphore by a thread is referred to as “exclusive waiting”, and a section waiting for exclusion such as time t0 to time t1 illustrated in FIG. 6 is referred to as “exclusive waiting period”.

セマフォを利用した場合に、デッドロックの問題が生じる、図7を参照して説明する。
図7の例に示すように、まず、スレッドL1は共有リソースであるリソースAのセマフォを取得してリソースAを操作する。時刻t0において、スレッドM1が実行可能状態に遷移したため、スレッドM1は実行され、スレッドL1は中断される。そして、時刻t1において、スレッドM1は別の共有リソースであるリソースBのセマフォを取得して、リソースBを操作する。処理が進み、時刻t2において、スレッドM1は、リソースAを操作するためにリソースAのセマフォを要求するが、リソースAのセマフォはスレッドL1により所有されているため、スレッドM1は中断され、排他待ち期間に入る。そこで、スレッドL1は、実行が再開される。
With reference to FIG. 7, a problem of deadlock occurs when a semaphore is used.
As shown in the example of FIG. 7, first, the thread L1 acquires the semaphore of the resource A that is a shared resource and operates the resource A. At time t0, since the thread M1 has transitioned to an executable state, the thread M1 is executed and the thread L1 is interrupted. At time t1, the thread M1 acquires a semaphore of resource B, which is another shared resource, and operates resource B. At time t2, the thread M1 requests the semaphore of the resource A to operate the resource A. However, since the semaphore of the resource A is owned by the thread L1, the thread M1 is suspended and waits for exclusion. Enter the period. Therefore, execution of the thread L1 is resumed.

処理がさらに進み、スレッドL1はリソースBを操作するためにリソースBのセマフォを要求するが、リソースBのセマフォはスレッドM1により所有されているため、スレッドL1も中断され、排他待ち期間に入る。
こうなると、スレッドM1とスレッドL1のいずれも実行することができず、いわゆるデットロックが発生する。
The processing further proceeds, and the thread L1 requests the semaphore of the resource B to operate the resource B. However, since the semaphore of the resource B is owned by the thread M1, the thread L1 is also interrupted and enters the exclusion waiting period.
If this happens, neither thread M1 nor thread L1 can be executed, and so-called deadlock occurs.

セマフォを利用する際に生じるデットロックの問題を解決するために、セマフォを取得したスレッドの優先度を一時的に高くするプライオリティ・シーリング方式を用いた手法がある。   In order to solve the problem of deadlock that occurs when using a semaphore, there is a method using a priority sealing method that temporarily raises the priority of a thread that has acquired a semaphore.

プライオリティ・シーリング方式は、プリエンプティブな優先度ベースのスケジューリングポリシの前提下に、スレッドがリソースのセマフォを取得すると、直ちにこのスレッドの優先度を該リソースの優先度シーリング値(以下単にシーリング値という)に一時的に上げる方式である。図8を参照して説明する。なお、シーリング値は、当該リソースを獲得する可能性のあるすべてのスレッドの優先度以上の優先度であり、予めリソースに対して設定されている。また、スレッドは、自身の優先度(優先度が一時的に挙げられているときには、そのときの優先度)より低いシーリング値を有するリソースを取得できないように規定されている。   In the priority ceiling scheme, when a thread acquires a semaphore of a resource under the preemptive priority-based scheduling policy, the priority of the thread is immediately set to the priority ceiling value of the resource (hereinafter simply referred to as a ceiling value). It is a method of raising temporarily. This will be described with reference to FIG. The ceiling value is a priority that is equal to or higher than the priority of all threads that may acquire the resource, and is set in advance for the resource. Further, it is defined that a thread cannot acquire a resource having a ceiling value lower than its own priority (priority when the priority is temporarily listed).

図8の例において、リソースAのシーリング値とリソースBのシーリング値は、「高」である。図示のように、時刻t0において、動作中のスレッドL1はリソースAのセマフォを取得してリソースAを操作する。これに伴って、スレッドL1の優先度は、リソースAのシーリング値「高」に変更される。   In the example of FIG. 8, the ceiling value of resource A and the ceiling value of resource B are “high”. As shown in the figure, at time t0, the operating thread L1 acquires the semaphore of resource A and operates resource A. Accordingly, the priority of the thread L1 is changed to the ceiling value “high” of the resource A.

時刻t1において、スレッドM1が実行可能状態に遷移したが、優先度が「高」に変更されたスレッドL1が動作中であるため、スレッドM1は動作できない。スレッドL1は、時刻t2においてリソースBのセマフォを取得し、時刻t3においてリソースBのセマフォを解放する。   At time t1, the thread M1 transitions to the executable state, but the thread M1 cannot be operated because the thread L1 whose priority has been changed to “high” is operating. The thread L1 acquires the semaphore of resource B at time t2, and releases the semaphore of resource B at time t3.

時刻t4において、スレッドL1は、リソースAのセマフォを解放する。同時に、その優先度は元の「低」に戻る。これにより、スレッドM1の優先度がスレッドL1の優先度より高くなるため、スレッドM1は実行され、スレッドL1の実行は中断される。   At time t4, the thread L1 releases the semaphore of resource A. At the same time, the priority returns to the original “low”. Thereby, since the priority of the thread M1 becomes higher than the priority of the thread L1, the thread M1 is executed and the execution of the thread L1 is interrupted.

その後、スレッドM1はリソースAのセマフォを取得して操作するなどの処理を行う。スレッドM1が実行されている間、スレッドL1は実行されることがない。   Thereafter, the thread M1 performs processing such as acquiring and manipulating the semaphore of the resource A. While the thread M1 is being executed, the thread L1 is not executed.

図8に示す例では、リソースAとリソースBのシーリング値が同一の「高」であるが、リソースAのシーリング値が「高」であり、リソースBのシーリングが「中」である場合においては、スレッドL1がリソースAのセマフォを取得して優先度が「高」に変更されたとき、リソースBを取得することが無い。   In the example shown in FIG. 8, the ceiling value of resource A and resource B is the same “high”, but the ceiling value of resource A is “high” and the ceiling of resource B is “medium”. When the thread L1 acquires the semaphore of the resource A and the priority is changed to “high”, the resource B is not acquired.

このように、プライオリティ・シーリング方式を用いれば、シングルコアプロセッサのリアルタイムシステムにおいて、デットロックを回避することができる。また、スレッドが共有リソースを排他制御している時間を短縮できるため、システム全体の効率が向上する。   Thus, if the priority ceiling method is used, deadlock can be avoided in a real-time system of a single core processor. Further, since the time during which the thread exclusively controls the shared resource can be shortened, the efficiency of the entire system is improved.

ところで、マルチコアプロセッサのリアルタイムシステムでは、複数のプロセッサコアにより共有可能な共有リソースに対して、プライオリティ・シーリング方式を適用しても、デットロックの可能性がある。図9を参照して説明する。   By the way, in a real-time system of a multi-core processor, there is a possibility of deadlock even if the priority sealing method is applied to a shared resource that can be shared by a plurality of processor cores. This will be described with reference to FIG.

図9において、縦軸が優先度を示す。プロセッサコアとしてプロセッサコアAとプロセッサコアBの2つがあり、共有リソースとしてリソースAとリソースBの2つがあるとする。また、リソースAとリソースBのいずれも、シーリング値は「高」である。   In FIG. 9, the vertical axis indicates the priority. Assume that there are two processor cores, processor core A and processor core B, and two resource A and resource B as shared resources. In addition, the ceiling value of both resource A and resource B is “high”.

図9の例では、まず、プロセッサコアAで実行中のスレッドL1は、リソースAを操作するためにリソースAのセマフォを取得する。これにより、スレッドL1の優先度はリソースAのシーリング値「高」に一時的に変更される。   In the example of FIG. 9, first, the thread L1 being executed by the processor core A acquires a semaphore of the resource A in order to operate the resource A. As a result, the priority of the thread L1 is temporarily changed to the ceiling value “high” of the resource A.

優先度「高」で動作するスレッドL1によるリソースAの操作中に、スレッドM1が実行可能状態に遷移する。このとき、プロセッサコアBが空いているので、スレッドM1はプロセッサコアBで実行される。そして、スレッドM1は、リソースBを操作するためにリソースBのセマフォを取得する。これにより、スレッドM1の優先度はリソースBのシーリング値の「高」に一時的に変更される。   During the operation of the resource A by the thread L1 operating with the priority “high”, the thread M1 transitions to an executable state. At this time, since the processor core B is free, the thread M1 is executed by the processor core B. Then, the thread M1 acquires the semaphore of the resource B in order to operate the resource B. As a result, the priority of the thread M1 is temporarily changed to “high” in the ceiling value of the resource B.

処理が続き、リソースAの操作中のスレッドL1はさらにリソースBのセマフォ獲得要求を発行する。このとき、リソースBのセマフォがスレッドM1により所有されているため、スレッドL1は、実行が中断され、排他待ちする。   The processing continues, and the thread L1 that is operating the resource A further issues a semaphore acquisition request for the resource B. At this time, since the semaphore of the resource B is owned by the thread M1, the thread L1 is interrupted and waits for exclusion.

その後、リソースBの操作中のスレッドM1はさらにリソースAのセマフォ獲得要求を発行する。リソースAのセマフォがスレッドL1により所有されているので、スレッドM1も実行が中断され、排他待ちする。
こうなると、スレッドH1とスレッドM1のいずれも実行することができず、デットロックが発生する。
Thereafter, the thread M1 that is operating the resource B further issues a semaphore acquisition request for the resource A. Since the semaphore of the resource A is owned by the thread L1, the execution of the thread M1 is also interrupted and waits for exclusion.
If this happens, neither thread H1 nor thread M1 can be executed, and a deadlock occurs.

このように、マルチコアプロセッサによるリアルタイムシステムにおいて、優先度が異なる複数のスレッドが同時に動作可能であるため、優先度の高いスレッドの実行中に優先度の低いスレッドが実行されないことを利用したプライオリティ・シーリング方式を適用してもデッドロックが生じ得る。   In this way, in a real-time system using a multi-core processor, multiple threads with different priorities can operate at the same time, so priority sealing using the fact that low priority threads are not executed during execution of high priority threads Even if the method is applied, deadlock may occur.

マルチコアプロセッサシステムにおけるデットロックの問題を解消するために様々な試みがなされている。たとえば、特許文献1に開示された手法は、共有リソース毎に現在排他制御中のスレッド名及び排他待ちのスレッド名を格納した排他制御管理テーブルと、スレッド毎に該スレッドが現在排他制御中の共有リソース名を格納した排他制御共有資源情報テーブルを設ける。   Various attempts have been made to eliminate the deadlock problem in multi-core processor systems. For example, the technique disclosed in Patent Document 1 includes an exclusive control management table that stores the name of a thread that is currently under exclusive control and the name of a thread that is waiting for exclusion for each shared resource, and a share that is currently under exclusive control for each thread. An exclusive control shared resource information table storing resource names is provided.

そして、あるスレッドが共有リソースの獲得要求を行う際に、上記排他制御管理テーブルと排他制御共有資源情報テーブルを参照して、該獲得要求がデットロックを生じさせるかを判断し、デットロックが発生すると判断した場合に、その時点では当該共有リソースの獲得要求を行わないようにする。   When a thread makes a shared resource acquisition request, the exclusive control management table and the exclusive control shared resource information table are referred to determine whether the acquisition request causes a deadlock, and a deadlock occurs. If it is determined, the shared resource acquisition request is not made at that time.

具体的には、あるスレッドから共有リソースの獲得を要求するシステムコールを発行した際に、該スレッドの排他制御共有資源情報テーブルから該スレッドにより排他制御中の共有リソース名を読み取ると共に、排他制御管理テーブルから、該スレッドが獲得要求している共有リソースを現在排他制御中のスレッド名を読み取る。さらに、排他制御共有資源情報テーブルから読み取った各共有リソースについて、排他制御管理テーブルから、これらの共有リソースの排他待ち中のスレッド名を読み取る。そして、上記読み取った両者のスレッド名を比較し、一致するスレッド名がある場合には、このまま獲得要求を行うとデットロックが発生すると判断し、獲得要求をしたスレッドに対して、現在排他制御中の共有リソースを解放してから、次に使用する共有リソースの獲得要求を行うように制御する。   Specifically, when a system call requesting acquisition of a shared resource is issued from a certain thread, the name of the shared resource being controlled exclusively by the thread is read from the thread's exclusive control shared resource information table and exclusive control management is performed. From the table, the name of the thread that is currently exclusively controlling the shared resource requested by the thread is read. Further, for each shared resource read from the exclusive control shared resource information table, the names of threads waiting for exclusion of these shared resources are read from the exclusive control management table. Then, if both of the read thread names are compared and there is a matching thread name, it is determined that a deadlock will occur if an acquisition request is made as it is, and the exclusive control is currently being performed on the thread that has made the acquisition request. Control is performed so as to request acquisition of a shared resource to be used next after releasing the shared resource.

すなわち、スレッドからの共有リソースの獲得要求に対して、該スレッドにより排他制御中の共有リソースを排他待ちしているいずれのスレッドも、上記スレッドが獲得しようとしている共有リソースの排他制御中ではない場合においてのみ、上記獲得要求を発行できるように制御する。こうすることにより、マルチコアプロセッサシステムにおいてもデットロックを回避することができる。
特開平7−105152号公報
In other words, in response to a shared resource acquisition request from a thread, none of the threads waiting for exclusion of the shared resource under exclusive control by the thread is in the exclusive control of the shared resource that the thread is trying to acquire Control is performed so that the acquisition request can be issued only in By doing so, deadlock can be avoided even in a multi-core processor system.
JP-A-7-105152

特許文献1の手法は、実質的には、セマフォのみを用いてマルチコアプロセッサシステムにおけるデットロック問題の解消を図っている。共有リソースの獲得要求を発行させるか否かの判断を行う際に、該スレッドにより排他制御中の共有リソース名の取得、これらの共有リソースの排他待ち中のスレッド名の取得、獲得要求先の共有リソースの排他制御中のスレッド名の取得、取得したスレッド名の比較などの処理を必要とする。これでは、共有リソースの排他制御処理が煩雑になり、時間がかかる。   The technique of Patent Document 1 substantially attempts to solve the deadlock problem in a multi-core processor system using only a semaphore. When determining whether or not to issue a shared resource acquisition request, obtain the names of shared resources that are under exclusive control by the thread, acquire the names of threads that are waiting for exclusion of these shared resources, and share the acquisition request destination Processing such as acquisition of thread names during exclusive control of resources and comparison of acquired thread names is required. This complicates the shared resource exclusive control process and takes time.

本発明の1つの態様は、スケジューリング方法である。この方法は、複数のスレッドにより共有されうる共有リソースを備えたマルチプロセッサシステムにおいて、プライオリティ・シーリング方式でこれらの共有リソースの排他制御を行うと共に、上記共有リソースのうちの、複数のプロセッサコアにより共有されうるプロセッサ間共有リソースの獲得要求をしたスレッドに対して、該プロセッサ間共有リソースの優先度シーリング値が、該スレッドが動作するプロセッサコア以外のプロセッサコアにおけるスレッドにより排他制御中のいずれのプロセッサ間共有リソースの優先度シーリング値よりも大きいことを条件に、上記獲得要求を発行したスレッドに当該プロセッサ間共有リソースを獲得させる。   One aspect of the present invention is a scheduling method. In this method, in a multiprocessor system having shared resources that can be shared by a plurality of threads, exclusive control of these shared resources is performed by a priority ceiling method, and the shared resources are shared by a plurality of processor cores. For any thread that has requested acquisition of a shared resource between processors, the priority ceiling value of the shared resource between processors is between any processors that are under exclusive control by a thread in a processor core other than the processor core on which the thread operates. On the condition that the priority ceiling value of the shared resource is larger, the thread that issued the acquisition request acquires the inter-processor shared resource.

なお、上記態様の方法を実行する装置、該方法を適用したマルチプロセッサシステム、コンピュータに上記方法を実行せしめるプログラム、該プログラムを含むOSなどに置き換えて表現したものも、本発明の態様として有効である。   An apparatus that executes the method of the above aspect, a multiprocessor system to which the method is applied, a program that causes a computer to execute the above method, an OS that includes the program, and the like are also effective as an aspect of the present invention. is there.

本発明にかかるスケジューリング技術によれば、マルチプロセッサシステムにおいて、デットロックの回避を効率よく行う。   According to the scheduling technique of the present invention, deadlock can be efficiently avoided in a multiprocessor system.

以下、図面を参照して本発明の実施の形態について説明する。なお、以下の説明に用いられる図面に、様々な処理を行う機能ブロックとして記載される各要素は、ハードウェア的には、プロセッサ、メモリ、その他の回路で構成することができ、ソフトウェア的には、メモリに記録された、またはロードされたプログラムなどによって実現される。したがって、これらの機能ブロックがハードウェアのみ、ソフトウェアのみ、またはそれらの組合せによっていろいろな形で実現できることは当業者には理解されるところであり、いずれかに限定されるものではない。また、分かりやすいように、これらの図面において、本発明の技術を説明するために必要なもののみを示す。   Embodiments of the present invention will be described below with reference to the drawings. In addition, each element described as a functional block for performing various processes in the drawings used in the following description can be configured with a processor, a memory, and other circuits in terms of hardware, and in terms of software It is realized by a program recorded in a memory or loaded. Therefore, it is understood by those skilled in the art that these functional blocks can be realized in various forms by hardware only, software only, or a combination thereof, and is not limited to any one. Also, for the sake of clarity, only those necessary for explaining the technique of the present invention are shown in these drawings.

本発明の具体的な実施の形態を説明する前に、まず本発明の原理を説明する。
前述したように、シングルプロセッサシステムにおいて、デットロックを回避する手法として、プリオリティ・シーリング方式が有効である。本願発明者は、複数のプロセッサコアにより共有されうる共有リソースを備えたマルチプロセッサシステムにおいて、これらの共有リソースの排他制御について鋭意研究模索した結果、マルチプロセッサシステムにおける排他制御にプライオリティ・シーリング方式を適用し、共有リソースの排他制御の効率向上を図る手法を確立した。
Before describing specific embodiments of the present invention, the principle of the present invention will be described first.
As described above, the priority sealing method is effective as a technique for avoiding deadlock in a single processor system. As a result of earnest research on exclusive control of these shared resources in a multiprocessor system having shared resources that can be shared by a plurality of processor cores, the present inventor has applied a priority ceiling method to exclusive control in a multiprocessor system. And established a method to improve the efficiency of exclusive control of shared resources.

分かりやすいように、マルチプロセッサシステムにおけるリソースを3種類に分類する。1つ目は、スレッドにより共有されることの無いリソースである。このようなリソースに対しては、排他制御を行う必要が無いため、以下の説明においては、このようなリソースの取扱いについて省略する。   For easy understanding, the resources in the multiprocessor system are classified into three types. The first is a resource that is not shared by threads. Since it is not necessary to perform exclusive control for such resources, the handling of such resources is omitted in the following description.

2つ目は、同一のプロセッサコア内で動作する複数のスレッドにのみ共有されうるリソースである。このようなリソースを、以下「プロセッサ内共有リソース」という。   The second is a resource that can be shared only by a plurality of threads operating in the same processor core. Such resources are hereinafter referred to as “in-processor shared resources”.

3つ目は、複数のプロセッサコアにより共有されうるリソースである。このようなリソースは、異なるプロセッサコアでそれぞれ動作する複数のスレッドにより操作される可能性があり、以下「プロセッサ間共有リソース」という。   The third is a resource that can be shared by a plurality of processor cores. Such a resource may be operated by a plurality of threads respectively operating on different processor cores, and is hereinafter referred to as “interprocessor shared resource”.

以下の説明において、単に「共有リソース」をいうときは、プロセッサ間共有リソースとプロセッサ内共有リソースのいずれも含むことを意味する。   In the following description, the term “shared resource” simply means that both an inter-processor shared resource and an intra-processor shared resource are included.

前述したように、マルチプロセッサシステムにおいて、共有リソースの排他制御にプライオリティ・シーリングを適用しても、デットロックが生じ得る。図9に示すように、プロセッサコアAで動作中のスレッドL1がプロセッサ間共有リソースA(シーリング値:H)の排他制御中に、プロセッサBで動作中のスレッドM1がプロセッサ間共有リソースB(シーリング値:H)を獲得した場合、その後、スレッドL1とスレッドM1がそれぞれリソースBとリソースAを獲得しようとするときに、デットロックが発生する。   As described above, in a multiprocessor system, even when priority ceiling is applied to exclusive control of shared resources, deadlock can occur. As shown in FIG. 9, the thread L1 operating in the processor core A is under exclusive control of the inter-processor shared resource A (sealing value: H), and the thread M1 operating in the processor B is the inter-processor shared resource B (ceiling). When the value: H) is acquired, a deadlock occurs when the thread L1 and the thread M1 attempt to acquire the resource B and the resource A, respectively.

すなわち、プライオリティ・シーリング方式を排他制御に適用しただけでは、あるスレッドが、自身による1つのプロセッサ間共有リソースの排他制御中に、該プロセッサ間共有リソースと同一のシーリング値を有し、かつ、他のプロセッサコアにおけるスレッドにより排他制御中の他のプロセッサ間共有リソースを獲得可能であれば、デットロックが生じる。   That is, only by applying the priority ceiling method to exclusive control, a thread has the same ceiling value as that of the inter-processor shared resource during the exclusive control of one inter-processor shared resource by itself, A deadlock occurs if it is possible to acquire another inter-processor shared resource under exclusive control by a thread in the processor core.

本願発明者が確立した手法は、このことに着目してなされたものであり、プライオリティ・シーリング方式を共有リソースの排他制御に適用すると共に、上記可能性を無くすべく、あるプロセッサコアで動作するスレッドがプロセッサ間共有リソースの獲得要求をした際に、該プロセッサ間共有リソースのシーリング値が、他のプロセッサコアにおけるスレッドにより排他制御中のいずれのプロセッサ間共有リソースのシーリング値よりも大きい場合にのみ、当該プロセッサ間共有リソースを獲得させる。   The technique established by the inventor of the present application has been made paying attention to this, and applies a priority ceiling method to exclusive control of a shared resource, and a thread that operates on a processor core in order to eliminate the above-mentioned possibility. Only when the sealing value of the inter-processor shared resource is larger than the sealing value of any inter-processor shared resource that is under exclusive control by a thread in another processor core Acquire the inter-processor shared resource.

こうすることにより、例えば、図9の例では、スレッドL1がリソースAを解放するまで、スレッドM1がリソースBを獲得できないので、デットロックは発生しない。   By doing so, for example, in the example of FIG. 9, since the thread M1 cannot acquire the resource B until the thread L1 releases the resource A, the deadlock does not occur.

この手法によれば、シングルコアプロセッサの場合と比べ、スレッドが獲得要求をしたプロセッサ間共有リソースのシーリング値と、他のプロセッサコアにおけるスレッドにより排他制御中のプロセッサ間共有リソースのシーリング値とを比較する作業のみが多くなるので、処理が簡単である。   Compared to the case of a single-core processor, this method compares the ceiling value of the inter-processor shared resource requested by the thread with the ceiling value of the inter-processor shared resource that is under exclusive control by the thread in another processor core. Since only the work to be performed increases, processing is simple.

本発明にかかる技術は、機能分散型のマルチプロセッサシステムにおいて特に有用である。機能分散型のマルチプロセッサシステムでは、各スレッドは、該スレッドに対して定められた1つのプロセッサコア内でのみ動作する。本発明にかかる技術を適用することによりプロセッサ間共有リソースの獲得に起因するデットロックを防ぐことができるので、スレッドがプロセッサ間共有リソースの獲得要求をしていない限り、夫々のプロセッサコアをシングルコアプロセッサとして看做すことができ、プロセッサコア毎に、シングルコアプロセッサのときと同様のスケジューリングを行うができ、システムの構築が容易である。   The technology according to the present invention is particularly useful in a function-distributed multiprocessor system. In a function-distributed multiprocessor system, each thread operates only within one processor core defined for the thread. By applying the technology according to the present invention, it is possible to prevent a deadlock due to the acquisition of the inter-processor shared resource, so that each processor core is a single core unless a thread requests to acquire the inter-processor shared resource. It can be regarded as a processor, and for each processor core, scheduling similar to that of a single core processor can be performed, and the system can be easily constructed.

以上の原理を踏まえて、本発明の具体的な実施例を説明する。
図1は、本発明の実施の形態にかかるリアルタイムシステム100を示す。リアルタイムシステム100は、複数のCPU(図示の例では2つ:CPU110、CPU150)と、各CPUがバス190を介してアクセス可能な共有メモリ200を備える。
Based on the above principle, a specific embodiment of the present invention will be described.
FIG. 1 shows a real-time system 100 according to an embodiment of the present invention. The real-time system 100 includes a plurality of CPUs (two in the illustrated example: CPU 110 and CPU 150) and a shared memory 200 that can be accessed by each CPU via a bus 190.

CPU110は、プロセッサコア112と、スケジューリング部114と、プロセッサコア112で動作する複数のスレッド(図示の例では4つ:スレッド122〜128)と、複数のリソース(図示の例では4つ:リソース132、134、142、144)を有する。   The CPU 110 includes a processor core 112, a scheduling unit 114, a plurality of threads (four in the illustrated example: threads 122 to 128) operating on the processor core 112, and a plurality of resources (four in the illustrated example: resource 132). , 134, 142, 144).

CPU150は、プロセッサコア152と、スケジューリング部154と、プロセッサコア152で動作する複数のスレッド(図示の例では4つ:スレッド162〜168)と、複数のリソース(図示の例では4つ:リソース172、174、182、184)を有する。   The CPU 150 includes a processor core 152, a scheduling unit 154, a plurality of threads operating in the processor core 152 (four in the illustrated example: threads 162 to 168), and a plurality of resources (four in the illustrated example: resource 172). 174, 182, 184).

リアルタイムシステム100は、機能分散型のマルチプロセッサシステムであり、スレッド122〜128はプロセッサコア112でのみ動作し、スレッド162〜168はプロセッサコア152でのみ動作する。また、各スレッドは、優先度が設定されている。   The real-time system 100 is a function-distributed multiprocessor system. The threads 122 to 128 operate only on the processor core 112, and the threads 162 to 168 operate only on the processor core 152. Each thread has a priority set.

スケジューリング部114は、プロセッサコア112で動作する各スレッドのスケジューリングを行い、スケジューリング部154は、プロセッサコア152で動作する各スレッドのスケジューリングを行う。   The scheduling unit 114 performs scheduling for each thread that operates in the processor core 112, and the scheduling unit 154 performs scheduling for each thread that operates in the processor core 152.

CPU110内の各リソースのうち、リソース132とリソース134は、プロセッサコア112で動作するスレッドにのみ共有されるプロセッサ内共有リソースであり、リソース142とリソース144は、プロセッサコア112で動作するスレッドに限らず、プロセッサコア152で動作するスレッドからも操作されうるプロセッサ間共有リソースである。   Among the resources in the CPU 110, the resource 132 and the resource 134 are shared resources within the processor that are shared only by threads that operate on the processor core 112, and the resources 142 and the resources 144 are limited to threads that operate on the processor core 112. In addition, it is an inter-processor shared resource that can be operated from a thread operating on the processor core 152.

CPU150内の各リソースのうち、リソース172とリソース174は、プロセッサコア152で動作するスレッドにのみ共有されるプロセッサ内共有リソースであり、リソース182とリソース184は、プロセッサコア152で動作するスレッドに限らず、プロセッサコア112で動作するスレッドからも操作されうるプロセッサ間共有リソースである。   Among the resources in the CPU 150, the resource 172 and the resource 174 are shared resources within the processor that are shared only by threads that operate on the processor core 152, and the resource 182 and the resource 184 are limited to threads that operate on the processor core 152. In addition, it is an inter-processor shared resource that can be operated from a thread operating in the processor core 112.

なお、スレッドにより共有されることの無いリソースについては、排他制御の必要が無いため、その説明および図示を省略する。   It should be noted that a resource that is not shared by threads does not need exclusive control, and therefore the description and illustration thereof are omitted.

共有メモリ200は、プロセッサ間共有リソース獲得情報210を記憶している。図2に示すように、プロセッサ間共有リソース獲得情報210は、排他制御中のプロセッサ間共有リソースのシーリング値と、該プロセッサ間共有リソースを獲得したスレッドが動作するCPUの識別子とを対応付けてなるものである。   The shared memory 200 stores inter-processor shared resource acquisition information 210. As shown in FIG. 2, the inter-processor shared resource acquisition information 210 associates the ceiling value of the inter-processor shared resource under exclusive control with the identifier of the CPU on which the thread that acquired the inter-processor shared resource operates. Is.

なお、共有メモリ200は、CPU110とCPU150により共有されるプロセッサ間共有リソースであり、最も高いシーリング値が設定されている。   The shared memory 200 is an inter-processor shared resource shared by the CPU 110 and the CPU 150, and has the highest ceiling value.

スケジューリング部114とスケジューリング部154は、スケジューリングする対象スレッドが異なる点を除き、同様の構成と機能を有するため、ここでスケジューリング部114を代表にして、スケジューリング部114とスケジューリング部154を説明する。   The scheduling unit 114 and the scheduling unit 154 have the same configuration and functions except that the target threads to be scheduled are different. Therefore, the scheduling unit 114 and the scheduling unit 154 will be described here with the scheduling unit 114 as a representative.

スケジューリング114は、スレッド122〜128に対して、プリエンプティブな優先度ベースのスケジューリングポリシを用いてスケジューリングを行う。また、共有リソースの排他制御についてはプライオリティ・シーリング方式を用いる。具体的には、プロセッサコア112で動作するいずれかのスレッドが共有リソースを獲得した際に、該スレッドの優先度を、獲得した共有リソースのシーリング値に一時的に上げる。また、実行中のスレッドが、そのときの該スレッドの優先度より低いシーリング値を有する共有リソースを獲得できないように制御する。   The scheduling 114 performs scheduling for the threads 122 to 128 using a preemptive priority-based scheduling policy. For exclusive control of shared resources, the priority ceiling method is used. Specifically, when any thread operating on the processor core 112 acquires a shared resource, the priority of the thread is temporarily increased to the ceiling value of the acquired shared resource. Further, control is performed so that a running thread cannot acquire a shared resource having a ceiling value lower than the priority of the thread at that time.

また、スケジューリング部114は、プロセッサコア112で動作するいずれかのスレッドがプロセッサ間共有リソースを獲得した際に、プロセッサコア112で動作する各スレッド(上記プロセッサ間共有リソースを獲得したスレッドを含む)のうちに、該プロセッサ間共有リソースと同一のシーリング値を有する別のプロセッサ間共有リソースを獲得したスレッドが無い場合に、該プロセッサ間共有リソースのシーリング値と、CPU110の識別子とを対応付けて共有メモリ200に書き込む。また、プロセッサ間共有リソースを獲得したスレッドが該共有リソースを解放した際に、プロセッサコア112で動作する各スレッドのうちに、該プロセッサ間共有リソースと同一のシーリング値を有するプロセッサ間共有リソースを獲得したスレッドが無い場合に、該共有リソースに対応する項目を削除する。   Further, the scheduling unit 114, when any thread operating in the processor core 112 acquires the inter-processor shared resource, includes each thread operating in the processor core 112 (including the thread that acquired the inter-processor shared resource). When there is no thread that has acquired another inter-processor shared resource having the same ceiling value as the inter-processor shared resource, the shared memory is associated with the ceiling value of the inter-processor shared resource and the identifier of the CPU 110. Write to 200. In addition, when a thread that has acquired an inter-processor shared resource releases the shared resource, an inter-processor shared resource having the same sealing value as that of the inter-processor shared resource is acquired from each thread operating in the processor core 112. If there is no thread, the item corresponding to the shared resource is deleted.

後述の説明で分かるが、CPU110内のスレッドがプロセッサ間共有リソースの獲得要求を発行した際に、スケジューリング部114は、該プロセッサ間共有リソースを獲得させるかの決定に必要な情報は、CPU150におけるスレッドにより排他制御中のプロセッサ間共有リソースのうちに、獲得要求された上記プロセッサ間共有リソースのシーリング値以上のシーリング値のプロセッサ間共有リソースの有無を示す情報である。そのため、1つのCPUについて、該CPUにおけるスレッドにより排他制御中であり、かつシーリング値が同一である複数のプロセッサ間共有リソースがある場合にも、プロセッサ間共有リソース獲得情報210には、上記シーリング値とCPUとを対応付けた内容があればよく、これらの全てのプロセッサ間共有リソースについてシーリング値とCPUとを対応付けた内容を書き込む必要が無い。こうすることにより、プロセッサ間共有リソース獲得情報210が共有メモリ200に占める容量を節約できる。   As can be seen from the description below, when a thread in the CPU 110 issues an inter-processor shared resource acquisition request, the scheduling unit 114 determines whether to acquire the inter-processor shared resource. This is information indicating whether or not there is an inter-processor shared resource with a ceiling value equal to or higher than the ceiling value of the inter-processor shared resource requested to be acquired among the inter-processor shared resources under exclusive control. Therefore, even when there is a plurality of inter-processor shared resources that are under exclusive control by a thread in the CPU and have the same sealing value for one CPU, the inter-processor shared resource acquisition information 210 includes the ceiling value. There is no need to write the contents in which the sealing value and the CPU are associated with each other for all the inter-processor shared resources. By doing so, it is possible to save the capacity occupied by the inter-processor shared resource acquisition information 210 in the shared memory 200.

スケジューリング部114は、プロセッサコア112で動作するいずれかのスレッドがプロセッサ間共有リソースの獲得要求した際に、共有メモリ200に記憶されたプロセッサ間共有リソース獲得情報210を参照して、要求されたプロセッサ間共有リソースを該スレッドに獲得させるかを決定する。具体的には、獲得要求されたプロセッサ間共有リソースのシーリング値が、プロセッサ間共有リソース獲得情報210に含まれた、CPU150に対応するいずれのシーリング値もより大きい場合においてのみ、獲得要求されたプロセッサ間共有リソースを当該スレッドに獲得させる。   When any thread operating in the processor core 112 requests acquisition of an inter-processor shared resource, the scheduling unit 114 refers to the inter-processor shared resource acquisition information 210 stored in the shared memory 200 and requests the requested processor. Decide whether to allow the thread to acquire shared resources. Specifically, the requested processor is acquired only when the ceiling value of the inter-processor shared resource requested to be acquired is larger than any of the ceiling values corresponding to the CPU 150 included in the inter-processor shared resource acquisition information 210. Make the thread acquire shared resources.

図3に示すフローチャートを参照して、スケジューリング部114の動作をより詳細に説明する。
プロセッサコア112で実行中のスレッドが共有リソースの獲得要求をした際に(S100)、スケジューリング部114は、該共有リソースがプロセッサ間共有リソースであるかを確認する(S110)。プロセッサ間共有リソースではないときには、CPU110内でリソース獲得処理を行う(S110:No、S160)。CPU110内でのリソース獲得処理は、CPU110をシングルコアプロセッサと看做した場合と同じ処理であるため、ここで詳細な説明を省略する。
With reference to the flowchart shown in FIG. 3, the operation of the scheduling unit 114 will be described in more detail.
When a thread being executed in the processor core 112 requests acquisition of a shared resource (S100), the scheduling unit 114 checks whether the shared resource is an inter-processor shared resource (S110). If it is not an inter-processor shared resource, a resource acquisition process is performed in the CPU 110 (S110: No, S160). Since the resource acquisition process in the CPU 110 is the same process as when the CPU 110 is regarded as a single core processor, a detailed description thereof is omitted here.

一方、獲得要求されたリソースがプロセッサ間共有リソースであるときに、スケジューリング部114は、共有メモリ200に記憶されたプロセッサ間共有リソース獲得情報210を参照して、プロセッサコア112で動作する各スレッドのうちに、該プロセッサ間共有リソースと同一のシーリング値を有する別のプロセッサ間共有リソースの排他制御中のスレッドの有無を確認する(S110:Yes、S120、S130)。ステップS130での確認は、具体的には、プロセッサ間共有リソース獲得情報210の中に、獲得要求されたプロセッサ間共有リソースと同一のシーリング値と、CPU110とを対応付けられて記憶された内容の有無の確認である。   On the other hand, when the resource requested to be acquired is an inter-processor shared resource, the scheduling unit 114 refers to the inter-processor shared resource acquisition information 210 stored in the shared memory 200 and determines each thread operating on the processor core 112. In the meantime, it is confirmed whether there is a thread under exclusive control of another inter-processor shared resource having the same sealing value as the inter-processor shared resource (S110: Yes, S120, S130). Specifically, the confirmation in step S130 is the content stored in the inter-processor shared resource acquisition information 210 in association with the CPU 110 and the same ceiling value as the requested inter-processor shared resource. It is confirmation of the presence or absence.

ステップS130での確認の結果が「有」である場合は、他のCPU(ここでCPU150)におけるいずれのスレッドが獲得したプロセッサ間共有リソースのシーリング値も、獲得要求されたプロセッサ間共有リソースのシーリング値以下であることが分かるため、スケジューリング部114は、獲得要求をしたスレッドに当該プロセッサ間共有リソースを獲得させるCPU110内でのリソース獲得処理を行う(S130:Yes、S160)。   If the result of the confirmation in step S130 is “Yes”, the ceiling value of the inter-processor shared resource acquired by any thread in the other CPU (here, CPU 150) is the ceiling of the inter-processor shared resource requested to be acquired. Since the value is less than or equal to the value, the scheduling unit 114 performs a resource acquisition process in the CPU 110 that causes the thread that has requested acquisition to acquire the inter-processor shared resource (S130: Yes, S160).

一方、ステップS130での確認の結果が「無」である場合は、スケジューリング部114は、さらに、獲得要求されたプロセッサ間共有リソースのシーリング値が、他のCPUで排他制御中のいずれのプロセッサ間共有リソースのシーリング値よりも大きいかを確認する(S130:No、S140)。   On the other hand, if the result of the confirmation in step S130 is “None”, the scheduling unit 114 further determines that the ceiling value of the inter-processor shared resource requested to be acquired is between any processors that are exclusively controlled by other CPUs. It is confirmed whether it is larger than the ceiling value of the shared resource (S130: No, S140).

獲得要求されたプロセッサ間共有リソースのシーリング値以上のシーリング値を有するプロセッサ間共有リソースが、他のCPUで排他制御中であれば(S140:Yes)、スケジューリング部114は、他のCPUで上記プロセッサ間共有リソースが解放されるまで、獲得要求されたプロセッサ間共有リソースを当該スレッドに獲得させない(S140:Yes、S140)。なお、スケジューリング部114は、この間において、プロセッサコア112を割込みによるエンプトプリエンプト可能な状態にする。こうすることにより、上記スレッドがプロセッサ間共有リソースを獲得できず、待っているときに、CPU110において、他のスレッドが実行可能状態に遷移したときに、該スレッドをプロセッサコア112で実行させることができる。   If an inter-processor shared resource having a ceiling value equal to or higher than the ceiling value of the inter-processor shared resource requested to be acquired is under exclusive control by another CPU (S140: Yes), the scheduling unit 114 causes the above CPU to execute the above processor. The inter-processor shared resource requested to be acquired is not acquired by the thread until the inter-shared resource is released (S140: Yes, S140). During this period, the scheduling unit 114 puts the processor core 112 into a state where it can be preempted by an interrupt. By doing this, when the thread cannot acquire the inter-processor shared resource and is waiting, the CPU 110 can cause the thread to be executed by the processor core 112 when another thread transitions to an executable state. it can.

一方、獲得要求されたプロセッサ間共有リソースのシーリング値が、他のCPUで排他制御中のいずれのプロセッサ間共有リソースのシーリング値よりも大きいときには、スケジューリング部114は、獲得要求したスレッドに当該プロセッサ間共有リソースを獲得させるCPU110内でのリソース獲得処理を行うとともに、該共有リソースのシーリング値と、CPU110の識別子とを対応付けて共有メモリ200に書き込んでプロセッサ間共有リソース獲得情報を更新する(S140:No、S150、S160)。   On the other hand, when the ceiling value of the inter-processor shared resource requested to be acquired is larger than the ceiling value of any inter-processor shared resource that is under exclusive control by another CPU, the scheduling unit 114 sends the inter-processor A resource acquisition process is performed in the CPU 110 for acquiring the shared resource, and the sealing value of the shared resource and the identifier of the CPU 110 are associated with each other and written to the shared memory 200 to update the inter-processor shared resource acquisition information (S140: No, S150, S160).

図4に示す動作例を用いて、リアルタイムシステム100におけるスケジューリング手法の効用を説明する。   The utility of the scheduling method in the real-time system 100 will be described using the operation example shown in FIG.

<時刻t0>
CPU110において、優先度「L」のスレッド122が実行されており、CPU150には、実行されているスレッドが無い。
<Time t0>
In the CPU 110, the thread 122 having the priority “L” is executed, and the CPU 150 has no thread being executed.

<時刻t1>
スレッド122がプロセッサ間共有リソース142の獲得要求を発行して、プロセッサ間共有リソース142を獲得する。それに伴って、スレッド122の優先度が、プロセッサ間共有リソース142のシーリング値「H」に変更される。また、プロセッサ間共有リソース獲得情報210には、シーリング値「H」とCPU110は、対応付けて書き込まれる。
<Time t1>
The thread 122 issues an acquisition request for the inter-processor shared resource 142 to acquire the inter-processor shared resource 142. Along with this, the priority of the thread 122 is changed to the ceiling value “H” of the inter-processor shared resource 142. In addition, the ceiling value “H” and the CPU 110 are written in the inter-processor shared resource acquisition information 210 in association with each other.

<時刻t2>
CPU150において、スレッド162が実行可能状態に遷移したため、実行される。
<Time t2>
In the CPU 150, the thread 162 is changed to the executable state, so that it is executed.

<時刻t3>
CPU150において、スレッド162がシーリング値「H」であるプロセッサ間共有リソース144の獲得要求をする。しかし、プロセッサ間共有リソース獲得情報210には、CPU110と対応付けて記憶されたシーリング値「H」があるため、スレッド162は、プロセッサ間共有リソース144を取得できずに待ち状態になる。
<Time t3>
In the CPU 150, the thread 162 requests acquisition of the inter-processor shared resource 144 having the ceiling value “H”. However, since the inter-processor shared resource acquisition information 210 has the ceiling value “H” stored in association with the CPU 110, the thread 162 cannot obtain the inter-processor shared resource 144 and enters a waiting state.

<時刻t4>
CPU110において、スレッド122はプロセッサ間共有リソース144の獲得要求を発行してプロセッサ間共有リソース144を獲得する。
<Time t4>
In the CPU 110, the thread 122 issues an acquisition request for the inter-processor shared resource 144 to acquire the inter-processor shared resource 144.

<時刻t5>
CPU110において、スレッド122はプロセッサ間共有リソース144を解放する。
CPU150において、スレッド162は待ち状態を続ける。
<Time t5>
In the CPU 110, the thread 122 releases the inter-processor shared resource 144.
In the CPU 150, the thread 162 continues to wait.

<時刻t6>
CPU110において、スレッド122はプロセッサ間共有リソース142を解放して、優先度が元の「L」に戻る。これに伴って、プロセッサ間共有リソース獲得情報210には、シーリング値「H」とCPU110とを対応付けた内容が削除される。
<Time t6>
In the CPU 110, the thread 122 releases the inter-processor shared resource 142, and the priority returns to the original “L”. Along with this, the content in which the ceiling value “H” is associated with the CPU 110 is deleted from the inter-processor shared resource acquisition information 210.

そのため、CPU150において、スレッド162は、プロセッサ間共有リソース144を取得して処理を再開する。これに伴って、スレッド162の優先度は「H」に変更される。   Therefore, in the CPU 150, the thread 162 acquires the inter-processor shared resource 144 and restarts the process. Along with this, the priority of the thread 162 is changed to “H”.

その後、CPU110において、スレッド122は、優先度「L」で動作する。
CPU150において、スレッド162は、プロセッサ間共有リソース142の取得(時刻t7)、プロセッサ間共有リソース142の解放(時刻t8)、プロセッサ間共有リソース144の解放(時刻t9)を経て、優先度が「M」に戻る。
Thereafter, in the CPU 110, the thread 122 operates with the priority “L”.
In the CPU 150, the thread 162 obtains the inter-processor shared resource 142 (time t7), releases the inter-processor shared resource 142 (time t8), and releases the inter-processor shared resource 144 (time t9). Return to.

このように、本実施の形態のリアルタイムシステム100において、時刻t2〜t3間、時刻t6以降のように、高い優先度のスレッドの実行中にも、他のプロセッサコアで低い優先度のスレッドが実行できる。また、プロセッサ間共有リソース共有リソースが存在する場合にもデットロックの発生を回避することができる。   As described above, in the real-time system 100 according to the present embodiment, the low-priority thread is executed by another processor core even during execution of the high-priority thread between time t2 and time t3 and after time t6. it can. Further, the occurrence of a deadlock can be avoided even when there is a shared resource between the processors.

以上、実施の形態をもとに本発明を説明した。実施の形態は例示であり、本発明の主旨から逸脱しない限り、上述した各実施の形態に対して、さまざまな変更、増減、組合せを行ってもよい。これらの変更、増減、組合せが行われた変形例も本発明の範囲にあることは当業者に理解されるところである。   The present invention has been described above based on the embodiment. The embodiment is an exemplification, and various modifications, increases / decreases, and combinations may be made to the above-described embodiments without departing from the gist of the present invention. It will be understood by those skilled in the art that modifications in which these changes, increases / decreases, and combinations are also within the scope of the present invention.

また、リアルタイムシステム100は、分散型のマルチプロセッサシステムに本発明の技術を適用した例であるが、本発明のスケジューリング技術は、分散型ではないマルチプロセッサシステムにも適用することができる。   The real-time system 100 is an example in which the technique of the present invention is applied to a distributed multiprocessor system, but the scheduling technique of the present invention can also be applied to a non-distributed multiprocessor system.

また、リアルタイムシステム100において、プロセッサ間共有リソース獲得情報210を共有メモリ200に記憶させている。どのCPUからもプロセッサ間共有リソース獲得情報210にアクセスできれば、いかなる態様でプロセッサ間共有リソース獲得情報210を保持してもよい。例えば、プロセッサ間共有リソース獲得情報210をライブラリとして更新しながら保持することもできる。   In the real-time system 100, the inter-processor shared resource acquisition information 210 is stored in the shared memory 200. The inter-processor shared resource acquisition information 210 may be held in any manner as long as any CPU can access the inter-processor shared resource acquisition information 210. For example, the inter-processor shared resource acquisition information 210 can be held while being updated as a library.

本発明の実施の形態にかかるリアルタイムシステムを示す図である。It is a figure which shows the real-time system concerning embodiment of this invention. 図1に示すリアルタイムシステムにおける共有メモリに記憶されたプロセッサ間共有リソース獲得情報の例を示す図である。It is a figure which shows the example of the shared resource acquisition information between processors memorize | stored in the shared memory in the real-time system shown in FIG. 図1に示すリアルタイムシステムにおけるスケジューリング部が、共有リソースに対して獲得要求がなされたときの処理を示すフローチャートである。It is a flowchart which shows a process when the scheduling part in the real-time system shown in FIG. 1 makes an acquisition request with respect to a shared resource. 図1に示すリアルタイムシステムにおける動作例を示す図である。It is a figure which shows the operation example in the real-time system shown in FIG. スレッドによる共有リソースの操作時に行う排他制御の模式図である。It is a schematic diagram of exclusive control performed when a shared resource is operated by a thread. バイナリ・セマフォ方式を説明するための図である。It is a figure for demonstrating a binary semaphore system. バイナリ・セマフォ方式で生じるデッドロック問題を説明するための図である。It is a figure for demonstrating the deadlock problem which arises with a binary semaphore system. プライオリティ・シーリング方式を説明するための図である。It is a figure for demonstrating a priority sealing system. マルチプロセッサシステムの排他処理機構にプライオリティ・シーリング方式を適用した際に生じるデッドロックを説明するための図である。It is a figure for demonstrating the deadlock which arises when a priority ceiling system is applied to the exclusive processing mechanism of a multiprocessor system.

符号の説明Explanation of symbols

100 リアルタイムシステム
110 CPU
112 プロセッサコア
114 スケジューリング部
122〜128 スレッド
132〜134 プロセッサ内共有リソース
142〜144 プロセッサ間共有リソース
150 CPU
152 プロセッサコア
154 スケジューリング部
162〜168 スレッド
172〜174 プロセッサ内共有リソース
182〜184 プロセッサ間共有リソース
190 バス
200 共有メモリ
210 プロセッサ間共有リソース獲得情報
100 Real-time system 110 CPU
112 processor core 114 scheduling unit 122-128 thread 132-134 shared resource in processor 142-144 shared resource between processors 150 CPU
152 Processor Core 154 Scheduling Unit 162 to 168 Thread 172 to 174 Shared Resource in Processor 182 to 184 Shared Resource between Processors 190 Bus 200 Shared Memory 210 Shared Resource Acquisition Information between Processors

Claims (11)

複数のスレッドにより共有されうる共有リソースを備えたマルチプロセッサシステムにおいて、
プライオリティ・シーリング方式で前記共有リソースの排他制御を行い、
前記共有リソースのうちの、複数のプロセッサコアにより共有されうるプロセッサ間共有リソースの獲得要求をしたスレッドに対して、該プロセッサ間共有リソースの優先度シーリング値が、該スレッドが動作するプロセッサコア以外のプロセッサコアにおけるスレッドにより排他制御中のいずれのプロセッサ間共有リソースの優先度シーリング値よりも大きいことを条件に、前記スレッドに当該プロセッサ間共有リソースを獲得させることを特徴とするスケジューリング方法。
In a multiprocessor system with shared resources that can be shared by multiple threads,
Perform exclusive control of the shared resource by priority sealing method,
Among the shared resources, the priority ceiling value of the inter-processor shared resource for a thread that has requested acquisition of the inter-processor shared resource that can be shared by a plurality of processor cores is other than the processor core on which the thread operates. A scheduling method characterized by causing a thread to acquire the inter-processor shared resource on condition that the priority ceiling value of any inter-processor shared resource being exclusively controlled by the thread in the processor core is larger.
各スレッドは、前記複数のプロセッサコアのうちの、該スレッドに対して定められた1つのプロセッサコアでのみ動作するものであり、
自身が動作するプロセッサコア以外のプロセッサコアにおけるスレッドにより排他制御中のプロセッサ間共有リソースの獲得要求をしていないスレッドに対して、該スレッドと同一のプロセッサコアで動作するスレッド同士間でスケジューリングを行うことを特徴とする請求項1に記載のスケジューリング方法。
Each thread operates only on one processor core defined for the thread among the plurality of processor cores,
Scheduling between threads operating on the same processor core as the thread for threads that are not requesting acquisition of shared resources between processors that are under exclusive control by threads in a processor core other than the processor core on which they operate The scheduling method according to claim 1, wherein:
排他制御中のプロセッサ間共有リソースのシーリング値と、該プロセッサ間共有リソースを獲得したスレッドが動作するプロセッサコアの識別子とを対応付けてなるプロセッサ間共有リソース獲得情報を記憶し、
いずれかのプロセッサ間共有リソースの獲得要求をしたスレッドに対して、前記プロセッサ間共有リソース取得情報に基づいて、該プロセッサ間共有リソースを獲得させるかを決定することを特徴とする請求項1または2に記載のスケジューリング方法。
Storing inter-processor shared resource acquisition information that associates the ceiling value of the inter-processor shared resource under exclusive control with the identifier of the processor core on which the thread that acquired the inter-processor shared resource operates;
3. The thread that has requested acquisition of any of the inter-processor shared resources determines whether to acquire the inter-processor shared resources based on the inter-processor shared resource acquisition information. Scheduling method according to claim 1.
複数のスレッドにより共有されうる共有リソースを備えたマルチプロセッサシステムにおけるスケジューリング装置であって、
プライオリティ・シーリング方式で前記共有リソースの排他制御を行い、
前記共有リソースのうちの、複数のプロセッサコアにより共有されうるプロセッサ間共有リソースの獲得要求をしたスレッドに対して、該プロセッサ間共有リソースの優先度シーリング値が、該スレッドが動作するプロセッサコア以外のプロセッサコアにおけるスレッドにより排他制御中のいずれのプロセッサ間共有リソースの優先度シーリング値よりも大きいことを条件に、前記スレッドに当該プロセッサ間共有リソースを獲得させることを特徴とするスケジューリング装置。
A scheduling device in a multiprocessor system having a shared resource that can be shared by a plurality of threads,
Perform exclusive control of the shared resource by priority sealing method,
Among the shared resources, the priority ceiling value of the inter-processor shared resource for a thread that has requested acquisition of the inter-processor shared resource that can be shared by a plurality of processor cores is other than the processor core on which the thread operates. A scheduling apparatus characterized by causing a thread to acquire the inter-processor shared resource on condition that the priority ceiling value of any inter-processor shared resource being exclusively controlled by a thread in the processor core is larger.
各スレッドは、前記複数のプロセッサコアのうちの、該スレッドに対して定められた1つのプロセッサコアでのみ動作するものであり、
自身が動作するプロセッサコア以外のプロセッサコアにおけるスレッドにより排他制御中のプロセッサ間共有リソースの獲得要求をしていないスレッドに対して、該スレッドと同一のプロセッサコアで動作するスレッド同士間でスケジューリングを行うことを特徴とする請求項4に記載のスケジューリング装置。
Each thread operates only on one processor core defined for the thread among the plurality of processor cores,
Scheduling between threads operating on the same processor core as the thread for threads that are not requesting acquisition of shared resources between processors that are under exclusive control by threads in a processor core other than the processor core on which they operate The scheduling apparatus according to claim 4, wherein:
プロセッサコア毎に設けられており、自身が設けられたプロセッサコアで動作するスレッドのスケジューリングを行うことを特徴とする請求項5に記載のスケジューリング装置。   The scheduling apparatus according to claim 5, wherein the scheduling apparatus is provided for each processor core and performs scheduling of a thread that operates in the processor core in which the processor core is provided. 排他制御中のプロセッサ間共有リソースのシーリング値と、該プロセッサ間共有リソースを獲得したスレッドが動作するプロセッサコアの識別子とを対応付けてなるプロセッサ間共有リソース獲得情報を記憶した記憶装置に記憶された前記プロセッサ間共有リソース取得情報に基づいて、いずれかのプロセッサ間共有リソースの獲得要求をしたスレッドに対して該プロセッサ間共有リソースを獲得させるかを決定することを特徴とする請求項4から6のいずれか1項に記載のスケジューリング装置。   Stored in the storage device that stores the inter-processor shared resource acquisition information in which the ceiling value of the inter-processor shared resource under exclusive control is associated with the identifier of the processor core on which the thread that acquired the inter-processor shared resource operates. 7. The method according to claim 4, wherein it is determined based on the inter-processor shared resource acquisition information whether a thread that has requested acquisition of any inter-processor shared resource is to acquire the inter-processor shared resource. The scheduling apparatus according to any one of claims. 複数のプロセッサコアと、
該複数のスレッドにより共有されうる共有リソースと、
プライオリティ・シーリング方式で前記共有リソースの排他制御を行い、
前記共有リソースのうちの、複数のプロセッサコアにより共有されうるプロセッサ間共有リソースの獲得要求をしたスレッドに対して、該プロセッサ間共有リソースの優先度シーリング値が、該スレッドが動作するプロセッサコア以外のプロセッサコアにおけるスレッドにより排他制御中のいずれのプロセッサ間共有リソースの優先度シーリング値よりも大きいことを条件に、前記スレッドに当該プロセッサ間共有リソースを獲得させるスケジューリング装置とを備えることを特徴とするマルチプロセッサシステム。
Multiple processor cores,
A shared resource that can be shared by the plurality of threads;
Perform exclusive control of the shared resource by priority sealing method,
Among the shared resources, the priority ceiling value of the inter-processor shared resource for a thread that has requested acquisition of the inter-processor shared resource that can be shared by a plurality of processor cores is other than the processor core on which the thread operates. And a scheduling device that causes the thread to acquire the inter-processor shared resource on condition that the priority ceiling value of any inter-processor shared resource that is under exclusive control by the thread in the processor core is larger. Processor system.
各スレッドは、前記複数のプロセッサコアのうちの、該スレッドに対して定められた1つのプロセッサコアでのみ動作するものであり、
前記スケジューリング装置は、自身が動作するプロセッサコア以外のプロセッサコアにおけるスレッドにより排他制御中のプロセッサ間共有リソースの獲得要求をしていないスレッドに対して、該スレッドと同一のプロセッサコアで動作するスレッド同士間でスケジューリングを行うことを特徴とする請求項8に記載のマルチプロセッサシステム。
Each thread operates only on one processor core defined for the thread among the plurality of processor cores,
The scheduling apparatus is configured such that threads that operate on the same processor core as a thread that does not request acquisition of an inter-processor shared resource that is under exclusive control by a thread in a processor core other than the processor core on which the scheduling apparatus operates. The multiprocessor system according to claim 8, wherein scheduling is performed between them.
前記スケジューリング装置は、プロセッサコア毎に設けられており、自身が設けられたプロセッサコアで動作するスレッドのスケジューリングを行うことを特徴とする請求項9に記載のマルチプロセッサシステム。   10. The multiprocessor system according to claim 9, wherein the scheduling device is provided for each processor core, and performs scheduling of threads operating in the processor core in which the scheduling device is provided. 排他制御中のプロセッサ間共有リソースのシーリング値と、該プロセッサ間共有リソースを獲得したスレッドが動作するプロセッサコアの識別子とを対応付けてなるプロセッサ間共有リソース獲得情報を記憶した記憶装置をさらに備え、
前記スケジューリング装置は、いずれかのプロセッサ間共有リソースの獲得要求をしたスレッドに対して、記憶装置に記憶された前記プロセッサ間共有リソース取得情報に基づいて、当該プロセッサ間共有リソースを獲得させるかを決定することを特徴とする請求項8から10のいずれか1項に記載のマルチプロセッサシステム。
A storage device storing inter-processor shared resource acquisition information that associates the ceiling value of the inter-processor shared resource under exclusive control with the identifier of the processor core on which the thread that acquired the inter-processor shared resource operates;
The scheduling apparatus determines whether to acquire the inter-processor shared resource based on the inter-processor shared resource acquisition information stored in the storage device for a thread that has requested acquisition of the inter-processor shared resource. The multiprocessor system according to any one of claims 8 to 10, wherein
JP2008183743A 2008-07-15 2008-07-15 Scheduling method, scheduling device, and multiprocessor system Pending JP2010026575A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2008183743A JP2010026575A (en) 2008-07-15 2008-07-15 Scheduling method, scheduling device, and multiprocessor system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2008183743A JP2010026575A (en) 2008-07-15 2008-07-15 Scheduling method, scheduling device, and multiprocessor system

Publications (1)

Publication Number Publication Date
JP2010026575A true JP2010026575A (en) 2010-02-04

Family

ID=41732384

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2008183743A Pending JP2010026575A (en) 2008-07-15 2008-07-15 Scheduling method, scheduling device, and multiprocessor system

Country Status (1)

Country Link
JP (1) JP2010026575A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9940278B2 (en) 2014-11-10 2018-04-10 Samsung Electronics Co., Ltd. System on chip having semaphore function and method for implementing semaphore function
US10185602B2 (en) 2015-03-18 2019-01-22 Ricoh Company, Ltd. Information processing apparatus, information processing method, and computer program product

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9940278B2 (en) 2014-11-10 2018-04-10 Samsung Electronics Co., Ltd. System on chip having semaphore function and method for implementing semaphore function
US10176136B2 (en) 2014-11-10 2019-01-08 Samsung Electronics Co., Ltd. System on chip having semaphore function and method for implementing semaphore function
US10678728B2 (en) 2014-11-10 2020-06-09 Samsung Electronics Co., Ltd. System on chip having semaphore function and method for implementing semaphore function
US11080220B2 (en) 2014-11-10 2021-08-03 Samsung Electronics Co., Ltd. System on chip having semaphore function and method for implementing semaphore function
US11599491B2 (en) 2014-11-10 2023-03-07 Samsung Electronics Co., Ltd. System on chip having semaphore function and method for implementing semaphore function
US11835993B2 (en) 2014-11-10 2023-12-05 Samsung Electronics Co., Ltd. System on chip having semaphore function and method for implementing semaphore function
US10185602B2 (en) 2015-03-18 2019-01-22 Ricoh Company, Ltd. Information processing apparatus, information processing method, and computer program product

Similar Documents

Publication Publication Date Title
JP4170227B2 (en) Executing processing in a multiprocessing environment
US7395383B2 (en) Realtime-safe read copy update with per-processor read/write locks
US9378069B2 (en) Lock spin wait operation for multi-threaded applications in a multi-core computing environment
KR102334511B1 (en) Manage task dependencies
US7661115B2 (en) Method, apparatus and program storage device for preserving locked pages in memory when in user mode
JP2009265963A (en) Information processing system and task execution control method
JP2012104140A (en) Sharing processor execution resources in waiting state
JP2004288162A (en) Operating system architecture using synchronous task
EP1693743A2 (en) System, method and medium for using and/or providing operating system information to acquire a hybrid user/operating system lock
JP5213485B2 (en) Data synchronization method and multiprocessor system in multiprocessor system
US9372724B2 (en) System and method for conditional task switching during ordering scope transitions
JP7042105B2 (en) Program execution control method and vehicle control device
JP7346649B2 (en) Synchronous control system and method
JP2010026575A (en) Scheduling method, scheduling device, and multiprocessor system
JP3893136B2 (en) Embedded computer control program, recording medium recording the program, and embedded system
JP2008276322A (en) Information processing device, system, and method
JP2007122337A (en) Arithmetic unit
JPH07319716A (en) Exclusive control system for resources of computer system
JP2019204387A (en) Program execution control method and program converter
US11860785B2 (en) Method and system for efficient communication and command system for deferred operation
US11809219B2 (en) System implementing multi-threaded applications
JP4833911B2 (en) Processor unit and information processing method
JP2010020683A (en) Thread control method, thread control device and real-time system
Shi et al. DFlow: Efficient Dataflow-based Invocation Workflow Execution for Function-as-a-Service
WO2019188180A1 (en) Scheduling method and scheduling device