JP4048638B2 - Scheduling apparatus and method, and recording medium - Google Patents

Scheduling apparatus and method, and recording medium

Info

Publication number
JP4048638B2
JP4048638B2 JP06895899A JP6895899A JP4048638B2 JP 4048638 B2 JP4048638 B2 JP 4048638B2 JP 06895899 A JP06895899 A JP 06895899A JP 6895899 A JP6895899 A JP 6895899A JP 4048638 B2 JP4048638 B2 JP 4048638B2
Authority
JP
Japan
Prior art keywords
thread
time slot
slot data
priority
execution
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.)
Expired - Lifetime
Application number
JP06895899A
Other languages
Japanese (ja)
Other versions
JP2000020323A (en
Inventor
誠二 村田
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.)
Sony Corp
Original Assignee
Sony 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 Sony Corp filed Critical Sony Corp
Priority to JP06895899A priority Critical patent/JP4048638B2/en
Publication of JP2000020323A publication Critical patent/JP2000020323A/en
Application granted granted Critical
Publication of JP4048638B2 publication Critical patent/JP4048638B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Images

Description

【0001】
【発明の属する技術分野】
本発明は、複数の実行主体を時分割処理することが可能なオペレーティングシステムにおけるスケジューリング装置及びスケジューリング方法、並びに、複数の実行主体を時分割処理することが可能なオペレーティングシステムが記録された記録媒体に関する。
【0002】
【従来の技術】
オペレーティングシステム、並びにオペレーティングシステム上で動作するアプリケーションプログラム等における実行実体を、時分割にて並行して動作させることが可能なシステムにおいて、実行主体は、実行主体毎に設定された優先度に基づいてスケジューリングされる。具体的には、通常、各実行主体は、優先度の高い実行主体ほど早く実行されるように、優先度に基づいて待ち行列に入れられ、待ち行列に入っている実行主体が、当該待ち行列の順番に従ってCPU(Central Processing Unit)によって順次実行される。ここで、実行主体は、プロセス、タスク、スレッドなどと一般に呼ばれるものであり、本明細書では以後、代表してスレッドと称する。また、スレッドが実行主体であるシステムのことをマルチスレッドシステムと称する。
【0003】
すなわち、マルチスレッドシステムにおいて、全スレッドは、基本的には各スレッドの生成時等に設定された優先度に基づいて、それらの順序関係が定義される。なお、この順序関係は必ずしも実行順序の関係だけを示すものとは限らず、例えば、いわゆるタイムスライススケジューリングでは、ある時間内に各スレッドに割り当てられるCPUの処理時間の割合として、優先度に基づく順序関係が定義される。また、場合によっては、システムの時間経過や各スレッドの処理時間等に応じて動的に、各スレッドの優先度に重み付けをすることもある。
【0004】
ところで、優先度に基づくスケジューリングのアルゴリズムでは、共有資源に対するアクセスの排他制御において、優先度逆転と呼ばれる問題が生じる場合がある。以下、この優先度逆転について、図26を参照して説明する。
【0005】
図26は、優先度逆転について、その典型的な状況を示す図であり、優先度の高いスレッドAがクリティカルセクションCS1に入ろうとした場合に起こりうる状況を示している。なお、クリティカルセクションCS1は、スレッドAとスレッドCが共通に使用する資源を含んでいるものとする。
【0006】
図26に示すように、先ず、スレッドCがクリティカルセクションCS1に入った後に、より高い優先度を持つスレッドAが動作可能状態になったとする。すると、スレッドCの実行が中断され、スレッドAの実行が開始される。しかし、このとき既にスレッドCがクリティカルセクションCS1に入っているため、スレッドCがクリティカルセクションCS1を抜けるまで、スレッドAは処理を待たねばならない。そこで、スレッドAは待ち状態となり、再びスレッドCの実行が開始される。
【0007】
そして、このような状況のときに、スレッドCがクリティカルセクションAを抜ける前に、スレッドAとスレッドCのそれぞれの優先度の中間の優先度を持つスレッドBが動作可能状態となった場合に、優先度逆転が生じる。すなわち、より優先度の高いスレッドAが待ち状態であるにも関わらずに、より優先度の低いスレッドBの実行が開始されるという状況が生じる。優先度が中間のスレッドBが動作可能状態になると、優先度に従って、スレッドCの実行が中断され、スレッドBの実行が開始される。このとき、スレッドAは中断したままである。しかも、スレッドAとスレッドBの関係は優先度以外には定義されていないので、このような状況になると、スレッドAは、自分がどの程度の時間、処理が中断されるかを見積もることも不可能となる。
【0008】
このように、優先度に基づくスケジューリングのアルゴリズムでは、より高い優先度のスレッドが、より低い優先度のスレッドの実行を待つような優先度逆転と呼ばれる問題が生じる可能性がある。しかも、上述したように、優先度逆転が生じると、より高い優先度のスレッドの中断時間を予測することが不可能となる。このように、高い優先度のスレッドの中断時間が予測不可能に陥ってしまうのは、特に実時間システム(各処理がある一定時間内に終わらなければシステムが成り立たないようなシステム)において、致命的な問題である。
【0009】
そこで、従来、このような優先度逆転の問題を回避する必要がある場合には、優先度継承機構を導入するようにしている。(Lui Sha,Ragunathan Rajkumar,and John P.Lehoczky. Priority Inheritance Protocols: An Approach to Real-Time Synchronization. Technical report, Computer Science Department, Carnegie Mellon University. November 1987. Tech.Report CMU-CS-87-181.) 優先度継承機構とは、高い優先度を持つスレッドが、低い優先度を持つスレッドのために待ち状態になった場合に、高い優先度を持つスレッドの優先度を、低い優先度を持つスレッドに継承する機構である。
【0010】
図26と同様な状況において、優先度継承機構を導入した場合のシナリオを図27に示す。優先度継承機構を導入した場合には、スレッドAが待ち状態となって再びスレッドCの実行が開始されるときに、スレッドCの優先度が、スレッドAと同じレベルの優先度に設定される。この結果、スレッドCがクリティカルセクションCS1から抜けるまでは、スレッドAより優先度が低いスレッド(例えば図中のスレッドB)によって、スレッドCの実行が中断されてしまうようなことはなくなる。
【0011】
このように優先度継承機構を導入した場合、スレッドCは、クリティカルセクションCS1を抜けるまで、スレッドAの優先度でスケジューリングされる。したがって、スレッドAがクリティカルセクションCS1にアクセスするために待たされる時間は、スレッドCがクリティカルセクションCS1を必要とする時間以内に制限されることとなり、優先度の高いスレッドであるスレッドAの中断時間の予測が可能となる。
【0012】
ところで、以上のような優先度継承機構を実際に実現するには、具体的には下記のような処理が行われる。なお、ここでは、上述したように、優先度が低いスレッドCがクリティカルセクションCS1を抜けるまで、優先度が高いスレッドAが処理を待たねばならないような場合を例に挙げる。
【0013】
先ず、スレッドCがクリティカルセクションCS1を抜けるまでスレッドAが処理を待たねばならないと判断されると、スレッドAの状態が待ち状態とされ、当該スレッドAが待ち行列から取り除かれる。次に、スレッドCの優先度が一時的にスレッドAの優先度に変更され、変更された優先度に基づいて、スレッドCが待ち行列に入れ直される。そして、待ち行列に入っているスレッドはCPUによって順次実行されていき、スレッドCが選択された時点で当該スレッドCが実行される。なお、スレッドCの実行中に、スレッドCに割り当てられていた一定の処理時間を使い切った場合、当該スレッドCは、変更された優先度(すなわちスレッドAの優先度)に基づいて再び待ち行列に入れられる。
【0014】
その後、スレッドAの待ち事象が解決した時点(すなわち、スレッドCがクリティカルセクションCS1を抜けた時点)で、スレッドCの優先度が元に戻され、元に戻された優先度に基づいて、スレッドCが待ち行列に入れ直されるとともに、スレッドAの状態が実行可能状態とされ、当該スレッドAが待ち行列に入れられる。
【0015】
以上の処理により、図27に示したような優先度継承機構が実現され、スレッドCがクリティカルセクションCS1から抜けるまでは、スレッドAより優先度が低いスレッド(例えば図中のスレッドB)によって、スレッドCの実行が中断されてしまうようなことはなくなる。
【0016】
【発明が解決しようとする課題】
ところで、従来のスケジューリング機構では、各スレッドが持つその時点の優先度に応じて、スレッドの待ち行列に入る位置を決定している。そして、上述のような優先度継承機構では、優先度が動的に頻繁に変更されるため、待ち行列の変更を頻繁に行う必要が生じる。そのため、上述のような優先度継承機構を導入すると、優先度の動的な変更に伴う待ち行列のリスケジューリングによるオーバーヘッドが大幅に増加してしまう。
【0017】
すなわち、上述のような優先度継承機構は、優先度逆転の問題を回避するためには有効であるが、当該優先度継承機構を導入すると、優先度が頻繁に動的に変更されるため、スケジューリングによるオーバーヘッドが大幅に増加し、システム全体の性能が低下してしまうという問題が生じる。
【0018】
また、優先度がスレッドの単なる実行順序を示すのではなくCPUの処理時間の割合を示すような場合、すなわち時分割スケジューリングを採用しているような場合には、待ち状態の原因となっているスレッド(上記の例ではスレッドC)の優先度を、待ち状態にあるスレッド(上記の例ではスレッドA)と同じレベルの優先度に設定するだけでは、これらのスレッドに割り当てられている処理時間を有効に利用することができない。
【0019】
すなわち、例えば、上記の例のように、スレッドCの優先度を、スレッドAと同じレベルの優先度に設定した場合、スレッドCはスレッドAの優先度にて実行されるため、スレッドAに割り当てられていたCPUの処理時間は使用されるが、スレッドCに割り当てられていたCPUの処理時間が使用されなくなる。そして、このような状態を回避して、CPUの処理時間を有効に使用するためには、待ち状態にあるスレッドAに割り当てられていた処理時間と、待ち状態の原因となっているスレッドCに割り当てられていた処理時間との合計を求めて、その処理時間をスレッドCに改めて割り当てるようにする必要がある。換言すれば、時分割スケジューリングを採用しているような場合には、スレッドAに割り当てられていた処理時間と、スレッドCに割り当てられていた処理時間との合計の処理時間が与えられる優先度を求めて、当該優先度をスレッドCに割り当てるようにすべきである。
【0020】
しかしながら、このようにスレッドに割り当てられる処理時間を計算し直して、スケジューリングし直すようにすると、当該処理に伴うオーバーヘッドが大幅に増大してしまう。そのため、従来の優先度継承機構では、各スレッドに割り当てられたCPUの処理時間を有効に利用することができなかった。
【0021】
本発明は、以上のような従来の実情に鑑みて提案されたものであり、優先度逆転問題を回避することが可能なスケジューリング装置及び方法を提供することを目的としている。本発明にあるようなスケジューリング装置及び方法を用いることにより、オーバヘッドの増加の原因となる待ち行列の変更が少なくて済み、しかも、割り当てられたCPUの処理時間を有効に利用することが可能になる。また、本発明は、複数の実行主体を時分割処理することが可能なオペレーティングシステムのデータ処理プログラムが記録された記録媒体を提供することも目的としている。
【0022】
【課題を解決するための手段】
本発明に係るスケジューリング装置は、複数の実行主体を時分割処理することが可能なオペレーティングシステムのスケジューリング装置であり、各実行主体毎に、スケジューリングの対象として割り当てられたタイムスロットデータを記憶する手段と、タイムスロットデータに処理時間を割り当て、時分割スケジューリングを行うスケジューラと、処理時間が割り当てられたタイムスロットデータに対応する実行主体を実行する手段と、優先度の高い第一の実行主体が、優先度の低い第二の実行主体の処理を待つ必要があるときには、当該第一の実行主体に対応するタイムスロットデータを当該第二の実行主体に割り当てる手段と、当該第二の実行主体の処理が終了したときに、当該第一の実行主体から割り当てられたタイムスロットデータを、当該第一の実行主体に再度割り当てる手段とを具備することを特徴とする。
【0023】
以上のような本発明に係るスケジューリング装置では、実行主体から独立したタイムスロットデータをスケジューリングの対象とすることにより、優先度の高い実行主体が、優先度の低い実行主体の処理を待つ必要のあるときには、タイムスロットデータを受け渡すという低コストな処理によって優先度継承を行うことができる。
【0026】
また、本発明に係るスケジューリング方法は、複数の実行主体を時分割処理することが可能なオペレーティングシステムのスケジューリング方法であり、各実行主体毎に、スケジューリングの対象として割り当てられたタイムスロットデータに処理時間を割り当て、時分割スケジューリングを行うステップと、処理時間が割り当てられたタイムスロットデータに対応する実行主体を実行するステップと、優先度の高い第一の実行主体が、優先度の低い第二の実行主体の処理を待つ必要があるときには、当該第一の実行主体に対応するタイムスロットデータを当該第二の実行主体に割り当てるステップと、当該第二の実行主体の処理が終了したときに、当該第一の実行主体から割り当てられたタイムスロットデータを、当該第一の実行主体に再度割り当てるステップとを具備することを特徴とする。
【0027】
以上のような本発明に係るスケジューリング方法では、実行主体から独立したタイムスロットデータをスケジューリングの対象とすることにより、優先度の高い実行主体が、優先度の低い実行主体の処理を待つ必要のあるときには、タイムスロットデータを受け渡すという低コストな処理によって優先度継承を行うことができる。
【0030】
また、本発明に係る記録媒体は、複数の実行主体を時分割処理することが可能なオペレーティングシステムのデータ処理プログラムが記録された記録媒体であって、各実行主体毎に、スケジューリングの対象として割り当てられたタイムスロットデータに処理時間を割り当て、時分割スケジューリングを行うステップと、処理時間が割り当てられたタイムスロットデータに対応する実行主体を実行するステップと、優先度の高い第一の実行主体が、優先度の低い第二の実行主体の処理を待つ必要があるときには、当該第一の実行主体に対応するタイムスロットデータを当該第二の実行主体に割り当てるステップと、当該第二の実行主体の処理が終了したときに、当該第一の実行主体から割り当てられたタイムスロットデータを、当該第一の実行主体に再度割り当てるステップとをコンピュータに実行させるためのデータ処理プログラムが記録されてなる
【0032】
【発明の実施の形態】
以下、本発明の実施の形態について、図面を参照しながら詳細に説明する。
【0033】
本発明では、複数の実行主体を時分割処理することが可能なオペレーティングシステムにおいて、各スレッドに対応するようにタイムスロットを割り当てて、各スレッドに割り当てられたタイムスロットデータを単位としてスケジューリングを行う。すなわち、本発明では、スレッド自体をスケジューリングの対象とするのではなく、各スレッドにタイムスロットデータを割り当てて、それらのタイムスロットデータをスケジューリングの対象とする。そして、タイムスロットデータに処理時間が割り当てられたら、当該タイムスロットデータに対応したスレッドを実行するようにする。
【0034】
ここで、タイムスロットデータとは、各スレッドに割り当てられている優先度を間接的に表現したものである。各タイムスロットデータは、当該タイムスロットデータにCPUの処理時間が与えられたときに実行すべきスレッドへのリンク情報を保持する。そして、オペレーティングシステムは、スレッドを単位としてスケジューリングを行うのではなく、タイムスロットデータを単位としてスケジューリングを行い、タイムスロットデータにCPUの処理時間が割り当てられたら、その時点において当該タイムスロットデータに対応しているスレッドを実行する。
【0035】
そして、本発明では、タイムスロットデータとスレッドとの対応関係を動的に変更することで、優先度の継承を実現する。すなわち、優先度の高いスレッドが、優先度の低いスレッドの処理を待つ必要がある場合には、当該処理が完了するまでの間、優先度の高いスレッドに対応していたタイムスロットデータを、優先度の低いスレッドに対応したタイムスロットデータとして扱い、当該タイムスロットデータに処理時間が割り当てられたら、優先度の低いスレッドを実行する。
【0036】
なお、本発明は、共有資源に対するアクセスの排他制御だけでなく、オブジェクト指向オペレーティングシステムにおける同期ベースのメッセージ通信や、何らかのイベント待ちなど、複数のスレッド間で依存関係を持つ待ち事象一般に適用することが可能である。
【0037】
以下、このような本発明について、本発明を適用したスケジューリング方法の具体的な例を挙げて詳細に説明する。なお、以下に説明するスケジューリング方法は、例えば、複数のスレッドを時分割処理することが可能なオペレーティングシステムにおけるスケジューリング装置において実行される。そして、このようなオペレーティングシステムが記録された記録媒体が、本発明に係る記録媒体に該当する。
【0038】
1.スケジューリングに使用するデータ
まず、以下に説明するスケジューリング方法において使用されるデータについて説明する。
【0039】
以下に示すスケジューリング方法では、各スレッドに対応するようにタイムスロットデータを割り当てて、各スレッドに割り当てられたタイムスロットデータを単位としてスケジューリングを行う。すなわち、スレッドが生成される毎に、当該スレッドに対応したタイムスロットデータが生成される。そして、このときに、各スレッド毎に、当該スレッドについてのデータ(以下、スレッドデータと称する。)が格納されるデータ領域が、例えば、図24における外部記憶装置10上に確保され、当該データ領域にスレッドデータが格納される。また、タイムスロットデータが格納されるデータ領域が、同じく例えば、図24における外部記憶装置10上に確保される。
【0040】
【表1】

Figure 0004048638
【0041】
スレッドデータには、表1に示すように、スレッドの状態を示すためのデータ型である「ThreadState」型の変数「state」と、スレッドデータを特定するためのデータ型である「Thread*」型の変数「depend」と、スレッドデータリストへのエントリを示すデータ型である「ThreadList」型の変数「inherit」と、タイムスロットを特定するためのデータ型である「TimeSlot*」型の変数「timeSlot」とが含まれる。
【0042】
変数「state」には、スレッドの状態を示す値が設定される。スレッドは、スレッドが停止している状態(以下、「休止状態」と称する。)と、スレッドが何らかの事象を待って中断している状態(以下、「待ち状態」と称する。)と、スレッドが実行可能な状態(以下、「実行可能状態」と称する。)との3つの状態をとりうる。そして、変数「state」は、スレッドがこれらの状態のうちのいずれの状態であるかを示す。なお、スレッドが実行されるのは、スレッドが実行可能状態のときだけである。換言すれば、スケジューリングにおいて、タイムスロットに対してCPUの処理時間が与えられるのは、当該タイムスロットに対応するスレッドが実行可能状態のときだけである。
【0043】
変数「depend」には、スレッドが他のスレッドが起こす事象を待って待ち状態になっている場合に、待ち状態の原因となっているスレッドを指し示す値が設定される。なお、その他の場合、変数「depend」には、NULL値が設定される。
【0044】
変数「inherit」には、スレッドが他のスレッドから優先度を継承している場合に、優先度の継承元のスレッドを指し示す値が設定される。換言すれば、変数「inherit」には、このスレッドが起こす事象を待って待ち状態となっているスレッドを指し示す値が設定される。なお、優先度を継承していない場合、変数「inherit」には、NULL値が設定される。
【0045】
なお、スレッドが起こす事象を待って待ち状態となっているスレッドは、複数ある場合があり、それらのスレッドはスレッドリストに登録される。そして、変数「inherit」は、そのようなスレッドリストへのエントリとなっている。すなわち、変数「inherit」には、優先度の継承元のスレッド自体を指し示す値が設定されるのではなく、そのようなスレッドが登録されたスレッドリストを指し示す値が設定される。
【0046】
変数「timeSlot」には、スレッドに対して、スレッド初期化時から割り当てられているタイムスロットデータを指し示す値が設定される。換言すれば、変数「timeSlot」は、スレッドに割り当てられたタイムスロットデータを指し示すリンクデータである。
【0047】
以上のようなスレッドデータにおいて、変数「depend」及び「inherit」は、優先度継承関係のリンク情報となる。すなわち、例えば、スレッドAが、スレッドBが起こす事象を待って待ち状態となっている場合には、スレッドAのスレッドデータの変数「depend」と、スレッドBのスレッドデータの変数「inherit」とが、対になって双方向リンクを形成することとなる。なお、以下の説明においては、スレッドのスレッドデータの変数のことを、単にスレッドの変数と呼ぶことにする。また、スレッドデータのことを単にスレッドと呼ぶことにする。
【0048】
【表2】
Figure 0004048638
【0049】
タイムスロットデータには、表2に示すように、スレッドを特定するためのデータ型である「Thread*」型の変数「owner」と、優先度を特定するためのデータ型である「Priority」型の変数「prio」と、タイムスロットデータを特定するためのデータ型である「TimeSlot*」型の変数「next」とが含まれる。
【0050】
変数「owner」には、タイムスロットデータにCPUの処理時間が割り当てられたときに実行すべきスレッドを指し示す値が設定される。換言すれば、変数「owner」は、タイムスロットデータに対応したスレッドを指し示すリンクデータである。
【0051】
なお、以下に説明するスケジューリング方法では、変数「owner」が指し示すスレッドを変更することにより、CPUの処理時間が割り当てられるスレッドを変更し、これにより、実質的に優先度の継承を行う。すなわち、タイムスロットデータにCPUの処理時間が割り当てられたら、当該タイムスロットデータの変数「owner」によって示されるスレッドを実行するようにする。そして、優先度の継承は、待ち行列の変更を行うのではなく、変数「owner」を変更することで行う。
【0052】
変数「prio」には、優先度を示す値が設定される。以下に説明するスケジューリング方法では、この変数「prio」に基づいて、各タイムスロットデータに割り当てられるCPUの処理時間が決定される。なお、変数「prio」は、変数「owner」が指し示すスレッドが変更となった場合にも変更されない。すなわち、変数「prio」は、変数「owner」が指し示すスレッドが変更されても、タイムスロットデータにもともと対応していたスレッドの優先度を示す値がそのまま保持される。
【0053】
変数「next」には、次にCPUの処理時間が割り当てられるタイムスロットデータを指し示す値が設定される。すなわち、あるタイムスロットデータに割り当てられていたCPUの処理時間を使い切ったら、その後、当該タイムスロットデータの変数「next」が指し示すタイムスロットデータにCPUの処理時間が割り当てられる。
【0054】
2.スレッドが待ち状態となる場合の処理
つぎに、優先度の高いスレッドが、優先度の低いスレッドが起こす事象を待って待ち状態となる場合に行われる処理の流れについて説明する。
【0055】
優先度の高いスレッドが、優先度の低いスレッドが起こす事象を待って待ち状態となる場合には、関数「makeWait(Thread* target, Thread* depend)」が呼ばれる。ここで、関数「makeWait(Thread* target, Thread* depend)」の第1の引数「target」は、「Thread*」型の引数であり、この引数「target」には、優先度の低いスレッドが起こす事象を待って待ち状態となるスレッドを指し示す値が設定される。また、第2の引数「depend」は、「Thread*」型の引数であり、この引数「depend」には、優先度の高いスレッドの待ち状態の原因となった優先度の低いスレッドを指し示す値が設定される。
【0056】
以下、関数「makeWait(Thread* target, Thread* depend)」が呼ばれた場合の処理について、図1のフローチャートを参照しながら説明する。なお、図1のフローチャートでは、各ステップでの処理をC言語での表記に準じた表現で示している。
【0057】
関数「makeWait(Thread* target, Thread* depend)」が呼ばれた場合には、先ず、ステップST1−1において、「TimeSlot*」型の変数「timeSlot」に、引数「target」が指し示すスレッドの変数「timeSlot」の値を設定する。
【0058】
次に、ステップST1−2において、引数「target」が指し示すスレッドの変数「state」に、当該スレッドが待ち状態であることを示す値「WAIT」を設定する。
【0059】
次に、ステップST1−3において、引数「target」が指し示すスレッドの変数「depend」に、引数「depend」の値を設定する。すなわち、優先度の高いスレッドの待ち状態の原因となったスレッドを、変数「depend」によって参照できるようにする。
【0060】
次に、ステップST1−4において、引数「depend」が指し示すスレッドの変数「inherit」が指し示すスレッドリストの末尾に、引数「target」が指し示すスレッドを追加する。なお、図1中の「AddLast(target)」は、スレッドリストの末尾にスレッドを追加する処理を行う関数を示している。すなわち、タイムスロットデータの継承元である優先度の高いスレッドのリストをスレッドの変数「inherit」によって参照可能にする。
【0061】
次に、ステップST1−5において、引数「target」に、それまで引数「target」が指し示していたスレッドの変数「depend」の値を設定する。すなわち、実行対象となる可能性のあるスレッドを引数「target」によって参照できるようにする。
【0062】
次に、ステップST1−6において、引数「target」が指し示すスレッドのスレッドデータの変数「state」に、当該スレッドが待ち状態であることを示す値「WAIT」が設定されているか否かを判別する。そして、スレッドが待ち状態であることを示す値「WAIT」が設定されている場合は、ステップST1−5へ戻って処理を繰り返し、設定されていない場合は、ステップST1−7へ進む。すなわち、待ち状態でないスレッドが見つかるまでステップST1−5とST1−6の操作を繰り返す。
【0063】
ステップST1−7では、変数「timeSlot」が指し示すタイムスロットの変数「owner」に、現在の引数「target」の値を設定する。すなわち、この処理によって、タイムスロットデータによって間接的に表現された優先度が、優先度の高いスレッドから優先度の低いスレッドへと継承される。
【0064】
そして、最後にステップST1−8において、現在の引数「target」が指し示すスレッドの実行を開始する。
【0065】
以上の処理により、優先度の高いスレッドが待ち状態とされ、優先度の低いスレッドが実行される。このとき、優先度の高いスレッドの変数「depend」と、優先度の低いスレッドの変数「inherit」とによって、実行待ち関係の相互リンクが形成される。
【0066】
なお、優先度の高いスレッドの待ち状態の原因となった優先度の低いスレッドが、更に優先度の低いスレッドが起こす事象を待って待ち状態となっていたときには、ステップST1−5及びステップST1−6の処理の繰り返しにより、引数「target」に更に優先度の低いスレッドを指し示す値が設定され、その結果、更に優先度の低いスレッドが実行されることとなる。換言すれば、関数「makeWait(Thread* target, Thread* depend)」を実行することにより、優先度の高いスレッドに割り当てられていたタイムスロットデータの変数「owner」は、唯一実行可能なスレッドに対応するように変更される。
【0067】
そして、本例に係るスケジューリング方法では、タイムスロットデータにCPUの処理時間が割り当てられたら、当該タイムスロットデータの変数「owner」によって示されるスレッドを実行するようにする。したがって、以上のような処理によって変数「owner」を変更することにより、優先度の高いスレッドにタイムスロットデータの変数「prio」に応じて割り当てられていたCPUの処理時間が、先に実行すべき優先度の低いスレッドに割り当てられることとなる。この結果、優先度の高いスレッドから優先度の低いスレッドへ、優先度が実質的に継承されることとなる。
【0068】
3.スレッドの待ち状態が解消された場合の処理
つぎに、優先度の高いスレッドが、優先度の低いスレッドが起こす事象を待って待ち状態となっていたときに、優先度の低いスレッドでの処理が完了して、優先度の高いスレッドの待ち状態が解消された場合の処理について説明する。
【0069】
優先度の高いスレッドが、優先度の低いスレッドが起こす事象を待って待ち状態となっていたときに、優先度の低いスレッドでの処理が完了して、優先度の高いスレッドの待ち状態が解消された場合には、関数「makeReady(Thread* target)」が呼ばれる。ここで、関数「makeReady(Thread* target)」の引数「target」は、「Thread*」型の引数であり、この引数「target」には、待ち状態が解消されたスレッドを指し示す値が設定される。
【0070】
以下、関数「makeReady(Thread* target)」が呼ばれた場合の処理について、図2のフローチャートを参照しながら説明する。なお、図2のフローチャートでは、各ステップでの処理をC言語での表記に準じた表現で示している。
【0071】
関数「makeReady(Thread* target)」が呼ばれた場合には、先ず、ステップST2−1において、引数「target」が指し示すスレッドの変数「state」に、当該スレッドが実行可能状態であることを示す値「RUNNING」を設定する。
【0072】
次に、ステップST2−2において、引数「target」が指し示すスレッドのタイムスロットデータを継承しているスレッドの変数「inherit」に繋がれた継承元スレッドへのリストから、関数「Remove(target)」によって、引数「target」で示されるスレッドへのリンクを削除する。すなわち、これによって継承先のスレッドに対して、タイムスロットデータ返還の手続きを遂行する。
【0073】
次に、ステップST2−3において、引数「target」が指し示すスレッドの変数「depend」に、NULL値を設定する。すなわち、当該スレッドの待ち状態の原因となっていたスレッドの処理が終了することにより、もはや待ち合わせが必要なくなったことを確かにする。
【0074】
次に、ステップST2−4において、関数「makeReady(Thread* target)」に受け渡されている引数「target」の値を第1の引数及び第2の引数の両方に設定して、関数「changeOwner(Thread* target, Thread* depend)」を呼び出す。すなわち、当該スレッドに元来割り当てられているタイムスロットデータを継承先のスレッドから当該スレッドへと移動する処理を行う。これにより、当該スレッドが当該タイムスロットデータを利用できるようにする。なお、関数「changeOwner(Thread* target, Thread* depend)」では、タイムスロットデータの変数「owner」を変更する処理が行われるが、この処理については後で詳細に説明する。そして、関数「changeOwner(Thread* target, Thread* depend)」での処理が完了したら、ステップST2−5へ進む。
【0075】
そして、最後にステップST2−5において、引数「target」が指し示すスレッドの実行を開始する。
【0076】
以上のような関数「makeReady(Thread* target)」での処理により、優先度の高いスレッドが待ち状態から実行可能状態に戻され、優先度の高いスレッドが実行される。
【0077】
つぎに、関数「changeOwner(Thread* target, Thread* depend)」が呼ばれた場合の処理について、図3のフローチャートを参照しながら説明する。なお、図3のフローチャートでは、各ステップでの処理をC言語での表記に準じた表現で示している。
【0078】
なお、関数「changeOwner(Thread* target, Thread* depend)」の第1の引数「target」及び第2の引数「depend」は、「Thread*」型の引数であり、関数「changeOwner(Thread* target, Thread* depend)」は、引数「target」のタイムスロットデータの変数「owner」を引数「depend」の値に変更する。
【0079】
関数「changeOwner(Thread* target, Thread* depend)」が呼ばれた場合には、先ず、ステップST3−1において、「TimeSlot*」型の変数「timeSlot」に、引数「target」が指し示すスレッドの変数「timeSlot」の値を設定する。
【0080】
次に、ステップST3−2において、変数「timeSlot」が指し示すタイムスロットの変数「owner」に、引数「depend」の値を設定する。すなわち、これにより当該タイムスロットの所有権を引数「depend」で示されるスレッドに継承する。
【0081】
次に、ステップST3−3において、引数「target」が指し示すスレッドの変数「inherit」が指し示すスレッドリストの先頭のスレッドを指し示す値を、「Thread*」型の変数「inherit」に設定する。なお、スレッドリストが空の場合、変数「inherit」にはNULL値を設定する。
【0082】
なお、図3中の「Snoop()」は、スレッドリストの先頭のスレッドを取り出す処理を行う関数を示している。そして、この関数「Snoop()」は、先頭のスレッドを指し示す値を戻り値として返す。
【0083】
次に、ステップST3−4において、変数「inherit」にNULL値が設定されているか否かを判別する。そして、変数「inherit」にNULL値が設定されている場合は、この関数「changeOwner(Thread* target, Thread* depend)」の処理を終了する。また、変数「inherit」にNULL値が設定されていない場合は、ステップST3−5へ進む。
【0084】
ステップST3−5では、現在の変数「inherit」の値を第1の引数に設定するとともに、現在の引数「depend」の値を第2の引数に設定して、改めて関数「changeOwner(Thread* inherit, Thread* depend)」を呼び出す。そして、関数「changeOwner(Thread* inherit, Thread* depend)」での処理が完了したら、ステップST3−6へ進む。
【0085】
ステップST3−6では、引数「inherit」が指し示す次のスレッドを指し示す値を、変数「inherit」に設定する。なお、次のスレッドが無い場合、変数「inherit」にはNULL値を設定する。そして、ステップST3−6での処理が完了したら、ステップST3−4へ戻って処理を繰り返す。
【0086】
以上のような関数「changeOwner(Thread* target, Thread* depend)」での処理により、タイムスロットデータの変数「owner」が変更されるとともに、優先度の高いスレッドの変数「depend」と、優先度の低いスレッドの変数「inherit」とによって形成されていた実行待ち関係のリンクが解消される。
【0087】
なお、優先度の低いスレッドが起こす事象を待って待ち状態となっているスレッドは複数ある場合があり、それらのスレッドはスレッドリストに登録されている。そこで、関数「changeOwner(Thread* target, Thread* depend)」では、ステップST3−4乃至ステップST3−6の処理を繰り返すことより、スレッドリストに登録されている全てのスレッドについて、それらのスレッドに対応するタイムスロットデータの変数「owner」の変更を行うようにしている。
【0088】
4.スケジューリングの具体例
つぎに、スケジューリングの具体例を、図4乃至図23を参照して説明する。
【0089】
なお、以下に説明する例では、いわゆるタイムスライススケジューリングを適用しており、スレッドの優先度が、各スレッドに割り当てられるCPUの処理時間の割合を示すようにしている。そして、以下に示す例では、優先度によって重み付けされたラウンド・ロビン・スケジューリング・アルゴリズム(Round Robin Scheduling Algorithm)を基本としている。
【0090】
以下に説明するスケジューリングを行うにあたっては、先ず、各スレッドに対して、優先度に応じたタイムスロットデータが割り当てられる。なお、本例において、優先度は15〜0の値をとるものとする。すなわち、各タイムスロットデータの変数「prio」には、当該タイムスロットに対応しているスレッドの優先度に応じて、15〜0のうちのいずれかの値が設定される。ここで、15〜0の値は、それぞれCPUの使用率の比1:1/2:1/3:・・・・・:1/16に対応する。
【0091】
そして、各スレッドに対応した各タイムスロットデータは、全部で17列の待ち行列からなるリングバッファに入れられ、各待ち行列毎に順にタイムスロットデータが選択される。そして、選択されたタイムスロットデータに対してCPUの処理時間が割り当てられ、当該タイムスロットデータに対応したスレッドが実行される。
【0092】
CPUの処理時間が割り当てられたタイムスロットデータは、対応するスレッドが、当該タイムスロットに割り当てられた処理時間を使い切った時点で、当該タイムスロットデータの変数「prio」に設定された優先度に従って、何番目か先の待ち行列に繋がれる。ここで、当該タイムスロットデータが次に繋がれるリングバッファ中の待ち行列を、優先度によって調整することにより、優先度に応じたCPU使用率の割り当てが実現される。
【0093】
なお、ここではラウンド・ロビン・スケジューリング・アルゴリズムを基本としたスケジューリング方法を例に挙げるが、本発明はこれに限られるものではない。すなわち、本発明は、例えば、優先度に基づいてFCFS(First Come First Serve)を行うようなスケジューリング方法等にも適用可能である。ここで、優先度に基づいてFCFSを行うようなスケジューリング方法としては、例えば、実時間システムにおいてよく用いられる「Rate Monotonic」(John Lehoczky,Lui Sha,and Ye Ding. The Rate Monotonic Scheduling Algorithm. Exact Characterization And Average Case Behavior. Thchnical report,Department Of Statistics,Carnegie Mellon University,1987)や「Earliest Deadline First」などのアルゴリズムを適用したスケジューリング方法が挙げられる。
【0094】
4−1 優先度の継承が行われないとき
優先度が15のスレッドAと、優先度が13のスレッドBと、優先度3のスレッドCとを時分割処理するような場合であって、優先度の継承が行われない場合について、図4乃至図13を参照して説明する。なお、図4乃至図13並びに後掲する図14乃至図23において、1から17までの数字は、待ち行列の番号を示している。そして、これらの番号に付けられた丸印は、当該番号の待ち行列が現在処理の対象となっていることを示している。
【0095】
スレッドA,B,Cを時分割処理する際は、先ず、図4に示すように、1番目の待ち行列にタイムスロットデータA,B,Cが並べられる。すなわち、タイムスロットデータAの変数「next」がタイムスロットデータBを指し、タイムスロットデータBの変数「next」がタイムスロットデータCを指している。なお、ここでは、スレッドAに割り当てられたタイムスロットデータをタイムスロットデータA、スレッドBに割り当てられたタイムスロットデータをタイムスロットデータB、スレッドCに割り当てられたタイムスロットデータをタイムスロットデータCとしている。
【0096】
そして、先ず、1番目の待ち行列の先頭のタイムスロットデータであるタイムスロットデータAにCPUの処理時間が割り当てられ、タイムスロットデータAに対応したスレッドであるスレッドAが実行される。なお、タイムスロットデータAに対応したスレッドとは、タイムスロットデータAの変数「owner」が指し示すスレッドのことである。
【0097】
そして、当該タイムスロットデータAに割り当てられていた処理時間を、スレッドAが使い切ったら、タイムスロットデータAは、リングバッファ中で、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドAの優先度が15なので、図5に示すように、タイムスロットデータAは、(16−15)=1の分だけ先の待ち行列、すなわち2番目の待ち行列に繋がれる。
【0098】
次に、1番目の待ち行列の次のタイムスロットデータであるタイムスロットデータBにCPUの処理時間が割り当てられ、タイムスロットデータBに対応したスレッドであるスレッドBが実行される。なお、タイムスロットデータBに対応したスレッドとは、タイムスロットデータBの変数「owner」が指し示すスレッドのことである。
【0099】
そして、当該タイムスロットデータBに割り当てられていた処理時間を、スレッドBが使い切ったら、タイムスロットデータBは、リングバッファ中で、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドBの優先度が13なので、図6に示すように、タイムスロットデータBは、(16−13)=3の分だけ先の待ち行列、すなわち4番目の待ち行列に繋がれる。
【0100】
次に、1番目の待ち行列の次のタイムスロットデータであるタイムスロットデータCにCPUの処理時間が割り当てられ、タイムスロットデータCに対応したスレッドであるスレッドCが実行される。なお、タイムスロットデータCに対応したスレッドとは、タイムスロットデータCの変数「owner」が指し示すスレッドのことである。
【0101】
そして、当該タイムスロットデータCに割り当てられていたタイムスライスを使い切ったら、タイムスロットデータCは、リングバッファ中で、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドCの優先度が3なので、図7に示すように、タイムスロットデータCは、(16−3)=13の分だけ先の待ち行列、すなわち14番目の待ち行列に繋がれる。
【0102】
以上で1番目の待ち行列に並んでいたタイムスロットデータの処理が終了し、次に、2番目の待ち行列に並んでいるタイムスロットデータの処理が行われる。このとき、2番目の待ち行列の先頭は、タイムスロットデータAとなっているので、当該タイムスロットデータAにCPUの処理時間が割り当てられ、タイムスロットデータAに対応したスレッドであるスレッドAが実行される。そして、当該タイムスロットデータAに割り当てられていた処理時間を使い切ったら、タイムスロットデータAは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドAの優先度が15なので、図8に示すように、タイムスロットデータAは、(16−15)=1の分だけ先の待ち行列、すなわち3番目の待ち行列に繋がれる。
【0103】
以上で2番目の待ち行列に並んでいたタイムスロットデータの処理が終了し、次に、3番目の待ち行列に並んでいるタイムスロットデータの処理が行われる。このとき、3番目の待ち行列の先頭は、タイムスロットデータAとなっているので、当該タイムスロットデータAにCPUの処理時間が割り当てられ、タイムスロットデータAに対応したスレッドであるスレッドAが実行される。そして、当該タイムスロットデータAに割り当てられていた処理時間を使い切ったら、タイムスロットデータAは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドAの優先度が15なので、図9に示すように、タイムスロットデータAは、(16−15)=1の分だけ先の待ち行列、すなわち4番目の待ち行列に繋がれる。ここで、4番目の待ち行列には、既にタイムスロットデータBが並んでいるので、タイムスロットデータAは、タイムスロットデータBの後ろに繋がれる。
【0104】
以上で3番目の待ち行列に並んでいたタイムスロットデータの処理が終了し、次に、4番目の待ち行列に並んでいるタイムスロットデータの処理が行われる。このとき、4番目の待ち行列の先頭は、タイムスロットデータBとなっているので、先ず、当該タイムスロットデータBにCPUの処理時間が割り当てられ、タイムスロットデータBに対応したスレッドであるスレッドBが実行される。そして、当該タイムスロットデータBに割り当てられていた処理時間を使い切ったら、タイムスロットデータBは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドBの優先度が13なので、図10に示すように、タイムスロットデータBは、(16−13)=3の分だけ先の待ち行列、すなわち7番目の待ち行列に繋がれる。
【0105】
次に、4番目の待ち行列の次のタイムスロットデータであるタイムスロットデータAにCPUの処理時間が割り当てられ、タイムスロットデータAに対応したスレッドであるスレッドAが実行される。そして、当該タイムスロットデータAに割り当てられていた処理時間を使い切ったら、タイムスロットデータAは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドAの優先度が15なので、図11に示すように、タイムスロットデータAは、(16−15)=1の分だけ先の待ち行列、すなわち5番目の待ち行列に繋がれる。
【0106】
以下同様に、待ち行列毎にタイムスロットデータに対してCPUの処理時間を割り当てて、当該タイムスロットデータに対応したスレッドの実行を行うとともに、処理時間を使い切ったタイムスロットデータを優先度に対応した分だけ先の待ち行列に繋ぐ処理を行っていく。なお、以上のように処理を進めていくことにより、待ち行列が17番目にまで達した場合、その後は1番目の待ち行列に戻るものとする。
【0107】
例えば、図12に示すように、17番目の待ち行列にタイムスロットデータAが繋がれており、当該タイムスロットデータAにCPUの処理時間が割り当てられ、タイムスロットデータAに対応したスレッドであるスレッドAが実行された場合、当該タイムスロットデータAに割り当てられていた処理時間を使い切ったら、タイムスロットデータAは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドAの優先度が15なので、(16−15)=1の分だけ先の待ち行列に繋がれる。そして、このとき現在の待ち行列は17番目なので、(16−15)=1の分だけ先の待ち行列は、1番目の待ち行列である。すなわち、タイムスロットデータAは、図13に示すように、1番目の待ち行列に繋がれる。
【0108】
以上のような処理を順次行っていくことにより、スレッドAのCPU使用率と、スレッドBのCPU使用率と、スレッドCのCPU使用率との比が、1:1/3:1/13となる。すなわち、スレッドの対応するタイムスロットデータの優先度に応じて、それぞれのスレッドにCPUの処理時間が割り当てられ、複数のスレッドの時分割処理が実行されることとなる。
【0109】
ところで、従来の多くのタイムスライススケジューリングでは、CPU使用率の割合に応じて待ち行列のソートを行うなどの処理が必要であった。これに対して、上記の方法では、単にタイムスロットデータの繋ぎ換えを行うだけで、タイムスライススケジューリングを実現することができる。すなわち、上記の方法を用いることで、非常に少ない計算量にて、タイムスライススケジューリングを実現することができる。
【0110】
なお、各処理がある一定時間内に終わらなければシステムが成り立たないような実時間システムに上記の方法を適用するような場合には、スケジューリング待ち行列に入れるタイムスロットデータの量を制限するようにすればよい。スケジューリング待ち行列に入れるタイムスロットデータの量を制限することで、CPUの使用率を保証することが可能となり、これにより、実時間システムへの適用が可能となる。
【0111】
例えば、スレッドAが最も優先順位の高いスレッドだと仮定する。ここでスレッドAの実行終了には、CPU処理時間を2単位必要とするとする。また、スレッドAは、5CPU単位処理時間以内に終了しなければならないとする。この場合、スレッドAが図8の状態にあって、スレッドAが実行終了までにあと1CPU単位処理時間となった状態で図9のような状態になるとする。このとき、少なくとも次にスレッドAに処理時間が割り当てられるまでには1CPU単位処理時間待たなければならない(すなわちスレッドBが実行する処理時間)が、次のサイクルでスレッドAは無事に実行を終了することができる。ところが、仮に、図8の状態で現在スレッドBが繋がれている待ち行列に5個のスレッドが繋がっていると考えると、スレッドAに次に処理時間が回ってくるまでには、5CPU単位処理時間待つことになる。この場合、これだけでスレッドAの実行制限時間を超えてしまう。このようなときに、例えば、一つの待ち行列に繋ぐことのできるスレッドの数を、待ち行列理論などによりスレッドAが制限時間を超えることのないことが示されるような数以内に制限することが考えられる。
【0112】
4−2 優先度の継承が行われるとき
優先度が15のスレッドAと、優先度が13のスレッドBと、優先度3のスレッドCとを時分割処理するような場合であって、優先度の継承が行われる場合について、図14乃至図23を参照して説明する。
【0113】
なお、図14乃至図23において、括弧内の符号は、タイムスロットデータの変数「owner」が指し示しているスレッドを表している。すなわち、例えば、A(A)は、タイムスロットデータAの変数「owner」がスレッドAを指し示しているということを表しており、また、例えば、A(B)は、タイムスロットデータAの変数「owner」がスレッドBを指し示しているということを表している。
【0114】
本例においても、図4乃至図13に示した例と同様、先ず、図14に示すように、1番目の待ち行列にタイムスロットデータA,B,Cが並べられる。そして、先ず、1番目の待ち行列の先頭のタイムスロットデータであるタイムスロットデータAにCPUの処理時間が割り当てられ、タイムスロットデータAに対応したスレッドであるスレッドAが実行されるが、本例では、このときに、スレッドAが、スレッドBが起こす事象を待たねばならないとする。すると、ここではスレッドAは実行されずに、図1に示したフローチャートに従って処理が行われる。その結果、スレッドAが待ち状態とされるとともに、図15に示すように、タイムスロットデータAの変数「owner」がスレッドBを指し示すように変更され、スレッドBが実行される。すなわち、タイムスロットデータAからのリンクが、スレッドAからスレッドBに変更され、もともとスレッドAに対して割り当てられていたCPUの処理時間が、スレッドBに割り当てられることとなる。
【0115】
そして、当該タイムスロットデータAに割り当てられていた処理時間を使い切ったら、タイムスロットデータAは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドAの優先度が15なので、図16に示すように、タイムスロットデータAは、(16−15)=1の分だけ先の待ち行列、すなわち2番目の待ち行列に繋がれる。
【0116】
次に、1番目の待ち行列の次のタイムスロットデータであるタイムスロットデータBにCPUの処理時間が割り当てられ、タイムスロットデータBに対応したスレッドであるスレッドBが実行される。なお、タイムスロットデータBに対応したスレッドとは、タイムスロットデータBの変数「owner」が指し示すスレッドのことであり、ここではスレッドBである。
【0117】
そして、当該タイムスロットデータBに割り当てられていた処理時間を使い切ったら、タイムスロットデータBは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドBの優先度が13なので、図17に示すように、タイムスロットデータBは、(16−13)=3の分だけ先の待ち行列、すなわち4番目の待ち行列に繋がれる。
【0118】
次に、1番目の待ち行列の次のタイムスロットデータであるタイムスロットデータCにCPUの処理時間が割り当てられ、タイムスロットデータCに対応したスレッドであるスレッドCが実行される。なお、タイムスロットデータCに対応したスレッドとは、タイムスロットデータCの変数「owner」が指し示すスレッドのことであり、ここではスレッドCである。
【0119】
そして、当該タイムスロットデータCに割り当てられていた処理時間を使い切ったら、タイムスロットデータCは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドCの優先度が3なので、図18に示すように、タイムスロットデータCは、(16−3)=3の分だけ先の待ち行列、すなわち14番目の待ち行列に繋がれる。
【0120】
以上で1番目の待ち行列に並んでいたタイムスロットデータの処理が終了し、次に、2番目の待ち行列に並んでいるタイムスロットデータの処理が行われる。このとき、2番目の待ち行列の先頭は、タイムスロットデータAとなっているので、当該タイムスロットデータAの変数「owner」が指し示すスレッド、すなわちスレッドBが実行される。そして、当該タイムスロットデータAに割り当てられていた処理時間を使い切ったら、タイムスロットデータAは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドAの優先度が15なので、図19に示すように、タイムスロットデータAは、(16−15)=1の分だけ先の待ち行列、すなわち3番目の待ち行列に繋がれる。
【0121】
以上で2番目の待ち行列に並んでいたタイムスロットデータの処理が終了し、次に、3番目の待ち行列に並んでいるタイムスロットデータの処理が行われる。このとき、3番目の待ち行列の先頭は、タイムスロットデータAとなっているので、当該タイムスロットデータAの変数「owner」が指し示すスレッド、すなわちスレッドBが実行される。そして、当該タイムスロットデータAに割り当てられていた処理時間を使い切ったら、タイムスロットデータAは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドAの優先度が15なので、図20に示すように、タイムスロットデータAは、(16−15)=1の分だけ先の待ち行列、すなわち4番目の待ち行列に繋がれる。ここで、4番目の待ち行列には、既にタイムスロットデータBが並んでいるので、タイムスロットデータAは、タイムスロットデータBの後ろに繋がれる。
【0122】
以上で3番目の待ち行列に並んでいたタイムスロットデータの処理が終了し、次に、4番目の待ち行列に並んでいるタイムスロットデータの処理が行われる。このとき、4番目の待ち行列の先頭は、タイムスロットデータBとなっているので、先ず、当該タイムスロットデータBの変数「owner」が指し示すスレッド、すなわちスレッドBが実行される。
【0123】
このときに、スレッドBの実行により、スレッドAの待ち状態の原因が解消されたとする。すると、図2及び図3に示したフローチャートに従って処理が行われ、その結果、スレッドAが実行可能状態にされるとともに、図21に示すように、タイムスロットデータAの変数「owner」がスレッドAを指し示すように変更される。すなわち、タイムスロットデータAからのリンクが、スレッドAに戻される。
【0124】
その後、タイムスロットデータBに割り当てられていた処理時間を使い切ったら、タイムスロットデータBは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドBの優先度が13なので、図22に示すように、タイムスロットデータBは、(16−13)=3の分だけ先の待ち行列、すなわち7番目の待ち行列に繋がれる。
【0125】
次に、4番目の待ち行列の次のタイムスロットデータであるタイムスロットデータAにCPUの処理時間が割り当てられ、タイムスロットデータAに対応したスレッドであるスレッドAが実行される。なお、タイムスロットデータAに対応したスレッドとは、タイムスロットデータAの変数「owner」が指し示すスレッドのことであり、ここではスレッドAとなっている。
【0126】
そして、当該タイムスロットデータAに割り当てられていた処理時間を使い切ったら、タイムスロットデータAは、優先度に対応した分だけ先の待ち行列に繋がれる。具体的には、スレッドAの優先度が15なので、図23に示すように、タイムスロットデータAは、(16−15)=1の分だけ先の待ち行列、すなわち5番目の待ち行列に繋がれる。
【0127】
以下同様に、待ち行列毎にタイムスロットデータの実行を行うとともに、処理時間を使い切ったタイムスロットデータを優先度に対応した分だけ先の待ち行列に繋ぐ処理を行っていく。
【0128】
5.まとめ
上記スケジューリング方法では、優先度の高いスレッドが優先度の低いスレッドの処理を待つ必要があるときに、優先度の高いスレッドの状態を待ち状態にするとともに、優先度の高いスレッドに割り当てられていたタイムスロットデータの変数「owner」が指し示すスレッドを、優先度の高いスレッドから優先度の低いスレッドに変更するようにしている。すなわち、優先度の高いスレッドに割り当てられていたタイムスロットデータからスレッドへのリンクを、一時的に優先度の低いスレッドに切り換えるようにしている。
【0129】
換言すれば、上記スケジューリング方法では、優先度の高いスレッドが優先度の低いスレッドの処理を待つ必要があるときに、優先度の低いスレッドの優先度を上げることにより優先度逆転問題を回避するのではなく、優先度の高いスレッドの代わりに優先度の低いスレッドを動かすようにすることで優先度逆転問題を回避している。
【0130】
このようなスケジューリング方法によれば、優先度の高いスレッドが優先度の低いスレッドの処理を待つ必要があるときに、優先度継承のために待ち行列を変更するような処理や優先度を再計算するような処理等を一切行わずに、優先度の高いスレッドから優先度の低いスレッドに優先度を継承したのと同一の結果を得ることができる。したがって、上記スケジューリング方法によれば、特に実時間システムにおいては致命的な問題となる優先度逆転問題を回避することができる。しかも、上記スケジューリング方法では、優先度継承のために待ち行列を変更するような処理や優先度を再計算するような処理等を一切行う必要がないので、スケジューリングコストを増大させることなく、優先度逆転問題を回避することができる。さらに、上記スケジューリング方法では、待ち状態となるスレッドに割り当てられていたCPUの処理時間は、待ち状態の原因となっているスレッドに割り当てられることとなるので、CPUの処理時間は無駄なく有効に利用される。
【0131】
なお、上記スケジューリング方法では、待ち事象が連結するような場合(例えば、スレッドAがスレッドBを待ち、スレッドBがスレッドCを待つような場合)にも、全タイムスロットデータが連結の先端のスレッドにリンクされることとなる。したがって、CPUの処理時間が全て有効に使用される。すなわち、上記スケジューリング方法では、従来の優先度継承方法では不可能であった、いわゆる複数スレッド待ちが可能となっている。
【0132】
最後に、本発明が適用されるハードウェア構成及びオペレーティングシステム構成の一例について、図24及び図25を参照しながら説明する。なお、図24においては、本発明を適用したテレビジョン受信装置1を例に挙げるが、本発明は他の各種情報処理装置に対して適用することができることは言うまでもない。すなわち、本発明は、時分割処理するマルチスレッドシステムが採用されるオペレーティングシステム(以下、OSという)が搭載される情報処理装置に対して広く適用可能であり、例えば、各種のオーディオ・ビジュアル機器(いわゆるAV機器)、事務用情報処理機器、コンピュータ機器等の情報処理装置に対して適用可能である。
【0133】
図24において、テレビジョン受信装置1は、アンテナ又はケーブル等によって放送局から送信された信号を受信し、受信した信号に基づいて、画像表示装置に映像を表示するとともに、スピーカから音声を出力する装置である。
【0134】
テレビジョン受信装置1は、一般的なテレビジョン受信機能を備えているだけではなく、外部からプログラムやデータ等を受け取ることが可能とされており、図24に示すように、バス/IOブリッジ2を介してバス3に接続されたテレビ機能部4と、バス/メモリブリッジ5を介してバス3に接続されたプロセッサ6と、バス/メモリブリッジ5を介してバス3に接続されたROM(Read Only Memory)7及びRAM(Random Access Memory)8と、バス3に接続された操作パネル9、外部記憶装置10及び通信装置11とを備えている。
【0135】
テレビ機能部4は、アンテナ又はケーブル等によって受信した信号に基づいて、映像や音声を再生する機能を備えている。このテレビ機能部4は、バス/IOブリッジ2を介してバス3に接続されており、これにより、他の各部と信号のやりとりが可能とされている。
【0136】
プロセッサ6は、このテレビジョン受信装置1の各部の制御を行うものであり、バス/メモリブリッジ5を介してバス3に接続されている。また、プロセッサ6には、バス/メモリブリッジ5を介してROM7及びRAM8が接続されている。ROM7は、例えば、テレビジョン受信装置1に関する不変の情報を保持している。RAM8は、プロセッサ6のワークエリアとして使われるメモリ空間を提供する。すなわち、プロセッサ6は、後述するように外部記憶装置10に記録されているOS(本発明のスケジューリング装置、方法を含む)やアプリケーションプログラムを、RAM8をワークエリアとして使用しながら実行することにより、このテレビジョン受信装置1を構成する各部を制御する。
【0137】
操作パネル9は、ユーザからの操作入力を受け付けるための入力装置である。テレビジョン受信装置1は、この操作パネル9から、例えば、チャンネルやボリューム等の切り替えを指示する信号が入力される。この操作パネル9は、具体的には、各種信号を入力するための複数のボタンを備えた入力装置や、いわゆるマウスに代表されるようなポインティングデバイス等によって構成される。この操作パネル9によって入力された信号は、バス3及びバス/メモリブリッジ5を介してプロセッサ6に入力される。そして、プロセッサ6は、操作パネル9から入力された信号に基づいて、所定の演算処理を行い、テレビジョン受信装置1を構成する各部を制御する。
【0138】
外部記憶装置10は、例えばハードディスク装置等の記憶装置から構成され、プロセッサ6による各種制御を行うためのOS(本発明のスケジューリング装置、方法を含む)やアプリケーションプログラム等を記録している。また、外部記憶装置10は、画像データ及び制御データや、外部から通信装置11を介してダウンロードされたプログラム等が記録される。また、通信装置11は、外部との間でデータ通信を行うための入出力部であり、例えばモデムやターミナルアダプター等の通信装置によって構成される。
【0139】
また、テレビジョン受信装置1は、外部記憶装置10に記憶されているOSをプロセッサ6によって実行し、このOS上で、ROM7に記録されている制御情報等を用いて、外部記憶装置10に記録されたアプリケーションプログラムを実行することにより、各部の制御を行う。すなわち、このテレビジョン受信装置1は、OSを構成する各種データ処理プログラム(本発明のスケジューリング装置、方法を含む)を提供するプログラム提供媒体として、外部記憶装置10を備えている。
【0140】
なお、本発明のスケジューリング装置、方法を含むOSは、ROM7やRAM8に記録しておくとしてもよい。この場合には、ROM7やRAM8がプログラム提供媒体となる。ただし、バージョンアップを行う等のようなOSの書き換え操作を行うためには、書き換え可能な記録媒体に本発明のスケジューリング装置、方法を含むOSを備えることが望ましい。また、プログラム提供媒体としては、例えば、このテレビジョン受信装置1に対して着脱自在に用いられる磁気記録媒体や光記録媒体等であってもよいし、このテレビジョン受信装置1と他の各種情報処理装置とを接続するネットワーク回線等であってもよい。
【0141】
テレビジョン受信装置1に搭載されるOSは、純オブジェクト指向OSである。そして、このOS上で、例えば、テレビ機能部4に動画像を表示するためにアプリケーションプログラムや、操作パネル9を制御するためのグラフィカル・ユーザ・インタフェース(GUI)を実現するアプリケーションプログラムが実行される。
【0142】
次に、図25を用いてOSの一例について説明する。このOSは、基本部分であるメタコア(MetaCore)20と、その他のオブジェクト群とから構成される。ここで、メタコア20は、オブジェクトとしては定義できない部分であり、オブジェクト間の実行制御の切り替えをする処理部、すなわち本発明に係る処理時間を割り当てられたスレッドを実行する処理部などを含んでいる。
【0143】
このOSは、純オブジェクト指向OSであり、OS上で実行されるアプリケーションプログラムを構成するオブジェクトと、OSを構成するオブジェクトとが、同様な実行機構を有するOSである。このOSでは、全てのオブジェクトは、各々一つずつのスレッドを持ち、互いに並行に動作することが可能である。各オブジェクトはメッセージを送信することにより互いに通信することができる。ただし、システムオブジェクトと呼ばれる特定のオブジェクトだけは、メッセージを介することなく通信することができ、さらには本発明にあるようなスケジューリングの対象外にあって動作することが保証されている。また、システムオブジェクトは、特定のデータ構造に対して直接操作することを許可されている。このような特定のデータ構造としては、本発明にあるようなスレッドデータやタイムスロットデータ等が含まれる。
【0144】
図25においては、メタコア20以外に、システムオブジェクトであるタイマオブジェクト21とスケジューラ22、及びそれ以外のオブジェクト群として第一のメッセージハンドラ23、第二のメッセージハンドラ24、第一の実行環境マネージャ25、第二の実行環境マネージャ26を示す。なお、図25には実際のシステムに含まれるが省略されている多くのオブジェクト(システムオブジェクトを含む)があることは言うまでもない。
【0145】
本OSにおいては、各アプリケーションを異なる実行環境の上で動作させることが可能である。本実施例においては、2つのアプリケーションがそれぞれ異なる実行環境を利用している例が示されている。具体的には、第一のアプリケーション32は、第一の実行環境30の上で動作し、第一の実行環境30は、タイマオブジェクト21、スケジューラ22、第一のメッセージハンドラ23、第一の実行環境マネージャ25を含んでいる。また、第二のアプリケーション33は、第二の実行環境31の上で動作し、第二の実行環境31は、タイマオブジェクト21、スケジューラ22、第二のメッセージハンドラ24、第二の実行環境マネージャ26を含んでいる。また、第一のアプリケーション32及び第二のアプリケーション33も、各々オブジェクト群によって構成されている。さらに、第一のアプリケーションは、第一のオブジェクト34と第二のオブジェクト35を含んでおり、第一のオブジェクト34の優先度は第二のオブジェクト35の優先度より低いと仮定する。
【0146】
まず、本発明においてスレッドの切り替えがなされる手順について説明する。第一のアプリケーション32を構成する第一のオブジェクト34が、第二のオブジェクト35に対して処理要求メッセージを送ったとする。この場合、メッセージは、第一のメッセージハンドラ23を経由して、第二のオブジェクト35に送られることになる。このとき、第一のメッセージハンドラ23は、送り手である第一のオブジェクト34の優先度と、受け手である第二のオブジェクト35の優先度を比較することにより、優先度逆転が発生することを検出する。この検出を受けて、第一のメッセージハンドラ23は、関数「makeWait(Thread* target, Thread* depend)」を呼び出す。ここで、引数「target」は第一のオブジェクト34のスレッドを示し、引数「depend」は第二のオブジェクト35のスレッドを示す。これによって、第二のオブジェクト35のスレッドに対して、第一のオブジェクト34のスレッドに対応するタイムスロットデータが継承される。
【0147】
次に第二のオブジェクト35が第一のオブジェクト34からの処理要求メッセージによって要求された処理を終了して、第一のオブジェクト34に対して返答メッセージを返すことになる。この返答メッセージは再び第一のメッセージハンドラ23を経由して送られる。このとき、第一のメッセージハンドラ23は、第一のオブジェクト34が第二のオブジェクト35に依存して待ち状態になっていることを検出する。この検出を受けて、第一のメッセージハンドラ23は、関数「makeReady(Thread* target)」を呼び出す。ここで、引数「target」は第一のオブジェクト34のスレッドである。これによって、第二のオブジェクト35のスレッドに対して継承されていたタイムスロットデータが、第一のオブジェクト34のスレッドに対して返還される。
【0148】
次に時分割スケジューリングについて説明する。時分割スケジューリングにおいては、タイマオブジェクト21が一定時間ごとにタイマ割り込みを起こし、スケジューラ22を呼び出す。スケジューラ22は、既に説明されたような方法で、次に実行されるスレッドのタイムスロットデータを選択し、当該選択されたオブジェクトのスレッドを起動する。
【0149】
【発明の効果】
以上詳細に説明したように、本発明では、優先度の高いスレッドに対応していたタイムスロットデータを、優先度の低いスレッドに対応したタイムスロットデータとして扱うようにすることで、優先度の高いスレッドから優先度が低いスレッドへの優先度の継承を実現している。したがって、本発明によれば、優先度逆転の問題を回避することができる。
【0150】
しかも、本発明では、優先度の高いスレッドに対応していたタイムスロットデータを優先度の低いスレッドに対応したタイムスロットデータとして扱うようにすることだけで、優先度の継承が実現されるので、優先度の継承を行うにあたって、待ち行列の変更を頻繁に行うような必要はない。したがって、本発明によれば、オーバーヘッドの増加の原因となる待ち行列の変更を頻繁に行うようなことなく、優先度の継承を実現することができる。
【0151】
さらに、本発明では、優先度の高いスレッドから優先度の低いスレッドに優先度の継承が行われた場合、優先度の低いスレッドは、優先度の高いスレッドに割り当てられていた処理時間と、優先度の低いスレッドにもともと割り当てられていた処理時間との両方を使うこととなる。したがって、本発明によれば、各スレッドに割り当てられた処理時間を有効に利用することが可能となる。
【図面の簡単な説明】
【図1】スレッドが待ち状態となる場合に呼び出される関数「makeWait(Thread* target, Thread* depend)」の処理の流れを示すフローチャートである。
【図2】スレッドの待ち状態が解消された場合に呼び出される関数「makeReady(Thread* target)」の処理の流れを示すフローチャートである。
【図3】関数「makeReady(Thread* target)」の中で呼ばれる関数「changeOwner(Thread* target, Thread* depend)」の処理の流れを示すフローチャートである。
【図4】図4乃至図11は優先度の継承が行われない場合の待ち行列の遷移を順に示す図であり、図4は1番目の待ち行列にタイムスロットデータA,B,Cが並んでいる状態を示す図である。
【図5】タイムスロットデータA,B,Cの待ち行列について、図4の次の状態を示す図である。
【図6】タイムスロットデータA,B,Cの待ち行列について、図5の次の状態を示す図である。
【図7】タイムスロットデータA,B,Cの待ち行列について、図6の次の状態を示す図である。
【図8】タイムスロットデータA,B,Cの待ち行列について、図7の次の状態を示す図である。
【図9】タイムスロットデータA,B,Cの待ち行列について、図8の次の状態を示す図である。
【図10】タイムスロットデータA,B,Cの待ち行列について、図9の次の状態を示す図である。
【図11】タイムスロットデータA,B,Cの待ち行列について、図10の次の状態を示す図である。
【図12】図12及び図13は、待ち行列が17番目にまで達した場合の待ち行列の遷移を順に示す図であり、図12は17番目に待ち行列にタイムスロットデータAが並んでいる状態を示す図である。
【図13】タイムスロットデータA,B,Cの待ち行列について、図12の次の状態を示す図である。
【図14】図14乃至図23は優先度の継承が行われる場合の待ち行列の遷移を順に示す図であり、図14は1番目の待ち行列にタイムスロットデータA,B,Cが並んでいる状態を示す図である。
【図15】タイムスロットデータA,B,Cの待ち行列について、図14の次の状態を示す図である。
【図16】タイムスロットデータA,B,Cの待ち行列について、図15の次の状態を示す図である。
【図17】タイムスロットデータA,B,Cの待ち行列について、図16の次の状態を示す図である。
【図18】タイムスロットデータA,B,Cの待ち行列について、図17の次の状態を示す図である。
【図19】タイムスロットデータA,B,Cの待ち行列について、図18の次の状態を示す図である。
【図20】タイムスロットデータA,B,Cの待ち行列について、図19の次の状態を示す図である。
【図21】タイムスロットデータA,B,Cの待ち行列について、図20の次の状態を示す図である。
【図22】タイムスロットデータA,B,Cの待ち行列について、図21の次の状態を示す図である。
【図23】タイムスロットデータA,B,Cの待ち行列について、図22の次の状態を示す図である。
【図24】本発明に係る実施例として示すテレビジョン受信装置の概略構成図である。
【図25】本発明に係るオペレーティングシステムの概略を説明するための図である。
【図26】優先度逆転の問題を説明するための図である。
【図27】従来の優先度継承機構を説明するための図である。
【符号の説明】
1 テレビジョン受信装置、 2 バス/IOブリッジ、 3 バス、 4 テレビ機能部、 5 バス/メモリブリッジ、 6 プロセッサ、 7 ROM(Read Only Memory)、 8 RAM(Random Access Memory)、 9 操作パネル、 10 外部記憶装置、 11 通信装置[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a scheduling apparatus and scheduling method in an operating system capable of time-sharing a plurality of execution subjects, and a recording medium on which an operating system capable of time-sharing a plurality of execution subjects is recorded. .
[0002]
[Prior art]
In a system in which an execution entity in an operating system and an application program running on the operating system can be operated in parallel in a time-sharing manner, the execution subject is based on the priority set for each execution subject. Scheduled. Specifically, each execution entity is normally queued based on priority so that the execution entity with higher priority is executed earlier, and the execution entity in the queue is associated with the queue. Are sequentially executed by a CPU (Central Processing Unit) in this order. Here, the execution subject is generally referred to as a process, a task, a thread, and the like. A system in which a thread is an execution subject is referred to as a multi-thread system.
[0003]
That is, in the multi-thread system, all threads are basically defined in the order relationship based on the priority set when each thread is generated. Note that this order relationship does not necessarily indicate only the relationship of execution order. For example, in so-called time slice scheduling, the order based on priority is used as the ratio of the CPU processing time allocated to each thread within a certain time. A relationship is defined. In some cases, the priority of each thread may be dynamically weighted according to the passage of time of the system, the processing time of each thread, or the like.
[0004]
By the way, in the scheduling algorithm based on priority, a problem called priority inversion may occur in exclusive control of access to a shared resource. Hereinafter, the priority inversion will be described with reference to FIG.
[0005]
FIG. 26 is a diagram showing a typical situation of priority inversion, and shows a situation that can occur when a thread A having a high priority tries to enter the critical section CS1. It is assumed that the critical section CS1 includes resources that are commonly used by the thread A and the thread C.
[0006]
As shown in FIG. 26, first, after the thread C enters the critical section CS1, it is assumed that the thread A having a higher priority becomes operable. Then, the execution of the thread C is interrupted and the execution of the thread A is started. However, since thread C has already entered critical section CS1 at this time, thread A must wait for processing until thread C exits critical section CS1. Therefore, the thread A enters a waiting state, and the execution of the thread C is started again.
[0007]
In such a situation, when thread B having an intermediate priority level between thread A and thread C becomes operable before thread C exits critical section A, Priority inversion occurs. That is, a situation occurs in which the execution of the thread B having a lower priority is started even though the thread A having a higher priority is in a waiting state. When the thread B having an intermediate priority is in an operable state, the execution of the thread C is interrupted according to the priority, and the execution of the thread B is started. At this time, thread A remains suspended. In addition, since the relationship between the thread A and the thread B is not defined other than the priority, in this situation, the thread A cannot estimate how long the process will be interrupted. It becomes possible.
[0008]
As described above, in the scheduling algorithm based on priority, there is a possibility that a problem called priority inversion occurs in which a higher priority thread waits for execution of a lower priority thread. Moreover, as described above, when priority inversion occurs, it is impossible to predict the interruption time of a higher priority thread. In this way, the interruption time of a high priority thread becomes unpredictable, especially in a real-time system (a system in which the system cannot be established if each process does not finish within a certain time). Problem.
[0009]
Therefore, conventionally, when it is necessary to avoid such a problem of priority inversion, a priority inheritance mechanism is introduced. (Lui Sha, Ragunathan Rajkumar, and John P.Lehoczky.Priority Inheritance Protocols: An Approach to Real-Time Synchronization.Technical report, Computer Science Department, Carnegie Mellon University.November 1987.Tech.Report CMU-CS-87-181. ) The priority inheritance mechanism means that when a thread with a high priority enters a wait state for a thread with a low priority, the priority of the thread with a high priority is changed to a thread with a low priority. It is a mechanism that inherits.
[0010]
FIG. 27 shows a scenario when the priority inheritance mechanism is introduced in the same situation as FIG. When the priority inheritance mechanism is introduced, the priority of the thread C is set to the same level as that of the thread A when the thread A enters the waiting state and the execution of the thread C is started again. . As a result, the execution of the thread C is not interrupted by a thread having a lower priority than the thread A (for example, the thread B in the figure) until the thread C leaves the critical section CS1.
[0011]
When the priority inheritance mechanism is introduced in this way, the thread C is scheduled with the priority of the thread A until it exits the critical section CS1. Therefore, the time that the thread A waits to access the critical section CS1 is limited to the time that the thread C needs the critical section CS1, and the interruption time of the thread A that is a high priority thread is reduced. Prediction becomes possible.
[0012]
Incidentally, in order to actually realize the priority inheritance mechanism as described above, specifically, the following processing is performed. Here, as described above, a case where the thread A having a high priority has to wait for processing until the thread C having a low priority exits the critical section CS1 will be described as an example.
[0013]
First, when it is determined that the thread A has to wait for processing until the thread C exits the critical section CS1, the state of the thread A is set to the wait state, and the thread A is removed from the queue. Next, the priority of thread C is temporarily changed to the priority of thread A, and thread C is re-queued based on the changed priority. The threads in the queue are sequentially executed by the CPU, and when the thread C is selected, the thread C is executed. In addition, when the fixed processing time allocated to the thread C is used up during the execution of the thread C, the thread C is re-queued based on the changed priority (that is, the priority of the thread A). Can be put.
[0014]
After that, when the waiting event of thread A is resolved (that is, when thread C exits the critical section CS1), the priority of thread C is returned to the original, and the thread is changed based on the restored priority. As C is re-queued, the state of thread A is made executable and thread A is queued.
[0015]
Through the above processing, the priority inheritance mechanism as shown in FIG. 27 is realized, and the thread having a lower priority than the thread A (for example, thread B in the figure) is used by the thread until the thread C leaves the critical section CS1. The execution of C is not interrupted.
[0016]
[Problems to be solved by the invention]
By the way, in the conventional scheduling mechanism, the position to enter the thread queue is determined according to the priority of each thread at that time. In the priority inheritance mechanism as described above, since the priority is dynamically changed frequently, it is necessary to frequently change the queue. Therefore, when the priority inheritance mechanism as described above is introduced, the overhead due to queue rescheduling accompanying the dynamic change of the priority is greatly increased.
[0017]
That is, the priority inheritance mechanism as described above is effective for avoiding the problem of priority inversion, but when the priority inheritance mechanism is introduced, the priority is frequently dynamically changed. There arises a problem that the overhead due to scheduling is greatly increased and the performance of the entire system is lowered.
[0018]
Also, if the priority does not indicate the mere execution order of threads but indicates the percentage of the CPU processing time, that is, if time-sharing scheduling is adopted, it causes a wait state. By simply setting the priority of threads (thread C in the above example) to the same level of priority as the waiting thread (thread A in the above example), the processing time allocated to these threads is reduced. It cannot be used effectively.
[0019]
That is, for example, when the priority of the thread C is set to the same level as that of the thread A as in the above example, the thread C is executed with the priority of the thread A. The CPU processing time assigned to the thread C is used, but the CPU processing time assigned to the thread C is no longer used. In order to avoid such a state and use the processing time of the CPU effectively, the processing time assigned to the thread A in the waiting state and the thread C causing the waiting state It is necessary to obtain the total of the processing time that has been assigned and to assign the processing time to the thread C anew. In other words, when time-sharing scheduling is adopted, the priority given to the total processing time of the processing time assigned to thread A and the processing time assigned to thread C is given. The priority should be determined and assigned to thread C.
[0020]
However, if the processing time allocated to the thread is recalculated and rescheduled in this way, the overhead associated with the processing increases significantly. Therefore, the conventional priority inheritance mechanism cannot effectively use the CPU processing time allocated to each thread.
[0021]
The present invention has been proposed in view of the conventional situation as described above, and an object thereof is to provide a scheduling apparatus and method capable of avoiding the priority inversion problem. By using the scheduling apparatus and method as in the present invention, it is possible to reduce the number of queue changes that cause an increase in overhead, and it is possible to effectively use the processing time of the allocated CPU. . Another object of the present invention is to provide a recording medium in which a data processing program of an operating system capable of time-sharing a plurality of execution subjects is recorded.
[0022]
[Means for Solving the Problems]
A scheduling apparatus according to the present invention is an operating system scheduling apparatus capable of time-sharing a plurality of execution subjects, and means for storing time slot data allocated as a scheduling target for each execution subject. The time slot data is assigned a processing time, the scheduler performs time division scheduling, the means for executing the execution subject corresponding to the time slot data to which the processing time is assigned, and the first execution subject having a high priority is given priority. When it is necessary to wait for the processing of the second execution entity having a low degree, the means for assigning the time slot data corresponding to the first execution entity to the second execution entity and the processing of the second execution entity include When finished, the time slot data assigned by the first execution subject And characterized by comprising a means for assigning again to the first execution subject.
[0023]
In the scheduling apparatus according to the present invention as described above, it is necessary for an execution entity having a high priority to wait for processing of an execution entity having a low priority by making time slot data independent of the execution entity an object of scheduling. Sometimes, priority inheritance can be performed by a low-cost process of transferring time slot data.
[0026]
The scheduling method according to the present invention is an operating system scheduling method capable of time-sharing a plurality of execution subjects, and processing time is assigned to time slot data assigned as a scheduling target for each execution subject. And executing a time-sharing scheduling, executing an execution subject corresponding to the time slot data to which the processing time is assigned, and a first execution subject having a high priority in a second execution having a low priority. When it is necessary to wait for the processing of the subject, the step of assigning the time slot data corresponding to the first execution subject to the second execution subject, and when the processing of the second execution subject is completed, The time slot data assigned by one executing entity is re-sent to the first executing entity. Characterized by comprising a step of assigning.
[0027]
In the scheduling method according to the present invention as described above, it is necessary for an execution entity having a high priority to wait for a process of an execution entity having a low priority by targeting time slot data independent of the execution entity. Sometimes, priority inheritance can be performed by a low-cost process of transferring time slot data.
[0030]
  The recording medium according to the present invention is a recording medium on which a data processing program of an operating system capable of time-sharing a plurality of execution subjects is recorded, and is assigned as a scheduling target for each execution subject. Assigning processing time to the assigned time slot data and performing time-sharing scheduling, executing an execution subject corresponding to the time slot data to which the processing time is assigned, and a first execution subject having a high priority, When it is necessary to wait for processing of a second execution subject having a low priority, a step of assigning time slot data corresponding to the first execution subject to the second execution subject, and processing of the second execution subject Is completed, the time slot data assigned by the first execution subject is And assigning again mainlyA data processing program to be executed by a computer is recorded..
[0032]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
[0033]
In the present invention, in an operating system capable of time-sharing a plurality of execution subjects, time slots are assigned so as to correspond to each thread, and scheduling is performed in units of time slot data assigned to each thread. In other words, in the present invention, the time itself is not assigned to the thread itself, but time slot data is assigned to each thread, and the time slot data is set as the scheduling target. Then, when processing time is allocated to the time slot data, a thread corresponding to the time slot data is executed.
[0034]
Here, the time slot data is an indirect expression of the priority assigned to each thread. Each time slot data holds link information to a thread to be executed when the CPU processing time is given to the time slot data. The operating system does not perform scheduling in units of threads, but performs scheduling in units of time slot data. When the CPU processing time is allocated to the time slot data, the operating system corresponds to the time slot data at that time. Run the thread that is running.
[0035]
In the present invention, priority inheritance is realized by dynamically changing the correspondence between time slot data and threads. In other words, when a thread with a high priority needs to wait for processing of a thread with a low priority, the time slot data corresponding to the thread with a high priority is prioritized until the process is completed. When it is handled as time slot data corresponding to a thread with a low degree and processing time is assigned to the time slot data, a thread with a low priority is executed.
[0036]
The present invention can be applied not only to exclusive control of access to shared resources, but also to general waiting events having dependencies among multiple threads, such as synchronization-based message communication in an object-oriented operating system, and waiting for some event. Is possible.
[0037]
Hereinafter, the present invention will be described in detail with a specific example of a scheduling method to which the present invention is applied. Note that the scheduling method described below is executed, for example, in a scheduling device in an operating system capable of time-sharing a plurality of threads. A recording medium on which such an operating system is recorded corresponds to the recording medium according to the present invention.
[0038]
1. Data used for scheduling
First, data used in the scheduling method described below will be described.
[0039]
In the scheduling method shown below, time slot data is assigned to correspond to each thread, and scheduling is performed in units of time slot data assigned to each thread. That is, each time a thread is generated, time slot data corresponding to the thread is generated. At this time, for each thread, a data area in which data about the thread (hereinafter referred to as thread data) is stored is secured, for example, on the external storage device 10 in FIG. Thread data is stored in. Also, a data area for storing time slot data is secured on the external storage device 10 in FIG. 24, for example.
[0040]
[Table 1]
Figure 0004048638
[0041]
As shown in Table 1, the thread data includes a “ThreadState” type variable “state” that is a data type for indicating a thread state and a “Thread *” type that is a data type for specifying thread data. Variable “depend”, “ThreadList” type variable “inherit” that indicates the entry to the thread data list, and “TimeSlot *” type variable “timeSlot” that specifies the time slot Is included.
[0042]
In the variable “state”, a value indicating the state of the thread is set. The thread is in a state where the thread is stopped (hereinafter referred to as “sleep state”), in a state where the thread is suspended waiting for some event (hereinafter referred to as “wait state”), and There are three possible states: an executable state (hereinafter referred to as “executable state”). The variable “state” indicates which of these states the thread is in. Note that the thread is executed only when the thread is in an executable state. In other words, in scheduling, the CPU processing time is given to a time slot only when the thread corresponding to the time slot is in an executable state.
[0043]
The variable “depend” is set to a value indicating the thread that is the cause of the wait state when the thread is in a wait state waiting for an event caused by another thread. In other cases, a NULL value is set in the variable “depend”.
[0044]
The variable “inherit” is set to a value indicating the thread from which the priority is inherited when the thread inherits the priority from another thread. In other words, the variable “inherit” is set to a value indicating a thread waiting for an event that this thread causes. When the priority is not inherited, a NULL value is set in the variable “inherit”.
[0045]
There may be a plurality of threads waiting for an event caused by the thread, and these threads are registered in the thread list. The variable “inherit” is an entry to such a thread list. That is, the variable “inherit” is not set to a value indicating the priority inheritance source thread itself, but is set to a value indicating the thread list in which such a thread is registered.
[0046]
In the variable “timeSlot”, a value indicating time slot data assigned to the thread since the initialization of the thread is set. In other words, the variable “timeSlot” is link data indicating the time slot data assigned to the thread.
[0047]
In the thread data as described above, the variables “depend” and “inherit” are the link information of the priority inheritance relationship. That is, for example, when the thread A waits for an event caused by the thread B, the thread data variable “depend” of the thread A and the thread data variable “inherit” of the thread B are displayed. As a pair, a bidirectional link is formed. In the following description, a thread data variable of a thread is simply referred to as a thread variable. The thread data is simply called a thread.
[0048]
[Table 2]
Figure 0004048638
[0049]
As shown in Table 2, the time slot data includes a variable “owner” of “Thread *” type that is a data type for specifying a thread, and a “Priority” type that is a data type for specifying a priority. Variable “prio” and “TimeSlot *” type variable “next”, which is a data type for specifying time slot data.
[0050]
The variable “owner” is set to a value indicating a thread to be executed when the CPU processing time is assigned to the time slot data. In other words, the variable “owner” is link data indicating a thread corresponding to the time slot data.
[0051]
In the scheduling method described below, the thread to which the processing time of the CPU is assigned is changed by changing the thread indicated by the variable “owner”, thereby substantially inheriting the priority. That is, when the CPU processing time is allocated to the time slot data, the thread indicated by the variable “owner” of the time slot data is executed. The inheritance of the priority is not performed by changing the queue, but by changing the variable “owner”.
[0052]
A variable indicating a priority is set in the variable “prio”. In the scheduling method described below, the processing time of the CPU allocated to each time slot data is determined based on this variable “prio”. Note that the variable “prio” is not changed even when the thread indicated by the variable “owner” is changed. That is, the variable “prio” retains the value indicating the priority of the thread originally corresponding to the time slot data even if the thread indicated by the variable “owner” is changed.
[0053]
In the variable “next”, a value indicating the time slot data to which the CPU processing time is assigned next is set. That is, when the CPU processing time assigned to certain time slot data is used up, the CPU processing time is assigned to the time slot data indicated by the variable “next” of the time slot data.
[0054]
2. Processing when a thread enters a wait state
Next, a description will be given of the flow of processing performed when a high priority thread waits for an event caused by a low priority thread.
[0055]
When a high-priority thread waits for an event caused by a low-priority thread, the function “makeWait (Thread * target, Thread * depend)” is called. Here, the first argument “target” of the function “makeWait (Thread * target, Thread * depend)” is an argument of “Thread *” type, and this argument “target” includes a low-priority thread. A value is set that points to a thread that waits for an event to occur. The second argument “depend” is an argument of “Thread *” type, and this argument “depend” has a value indicating a low priority thread that causes a high priority thread to wait. Is set.
[0056]
Hereinafter, processing when the function “makeWait (Thread * target, Thread * depend)” is called will be described with reference to the flowchart of FIG. In the flowchart of FIG. 1, the process at each step is represented by an expression according to the notation in C language.
[0057]
When the function “makeWait (Thread * target, Thread * depend)” is called, first, in step ST1-1, the variable “timeSlot” of the “TimeSlot *” type is changed to the variable of the thread indicated by the argument “target”. Set the value of “timeSlot”.
[0058]
Next, in step ST1-2, a value “WAIT” indicating that the thread is in a waiting state is set in the variable “state” of the thread indicated by the argument “target”.
[0059]
Next, in step ST1-3, the value of the argument “depend” is set in the variable “depend” of the thread indicated by the argument “target”. In other words, the thread that caused the wait state of the high priority thread can be referred to by the variable “depend”.
[0060]
Next, in step ST1-4, the thread indicated by the argument “target” is added to the end of the thread list indicated by the variable “inherit” of the thread indicated by the argument “depend”. Note that “AddLast (target)” in FIG. 1 indicates a function for performing processing for adding a thread to the end of the thread list. In other words, a list of high priority threads from which time slot data is inherited can be referred to by the thread variable “inherit”.
[0061]
Next, in step ST1-5, the value of the variable “depend” of the thread that has been pointed to by the argument “target” is set in the argument “target”. That is, a thread that may be an execution target can be referred to by an argument “target”.
[0062]
Next, in step ST1-6, it is determined whether or not the value “WAIT” indicating that the thread is in a waiting state is set in the variable “state” of the thread data indicated by the argument “target”. . If the value “WAIT” indicating that the thread is in a waiting state is set, the process returns to step ST1-5 to repeat the process. If not set, the process proceeds to step ST1-7. That is, the operations of steps ST1-5 and ST1-6 are repeated until a thread that is not in a waiting state is found.
[0063]
In step ST1-7, the value of the current argument “target” is set in the variable “owner” of the time slot indicated by the variable “timeSlot”. That is, by this processing, the priority indirectly expressed by the time slot data is inherited from the thread having the higher priority to the thread having the lower priority.
[0064]
Finally, in step ST1-8, execution of the thread indicated by the current argument “target” is started.
[0065]
Through the above processing, a thread with a high priority is put in a waiting state, and a thread with a low priority is executed. At this time, a mutual link of the execution waiting relationship is formed by the variable “depend” of the thread having a high priority and the variable “inherit” of the thread having a low priority.
[0066]
When a low priority thread that causes a high priority thread wait state is in a wait state waiting for an event caused by a lower priority thread, step ST1-5 and step ST1- By repeating the process of No. 6, a value indicating a lower priority thread is set in the argument “target”, and as a result, a lower priority thread is executed. In other words, by executing the function “makeWait (Thread * target, Thread * depend)”, the variable “owner” of the time slot data assigned to the high priority thread corresponds to the only executable thread. To be changed.
[0067]
In the scheduling method according to this example, when the CPU processing time is allocated to the time slot data, the thread indicated by the variable “owner” of the time slot data is executed. Therefore, by changing the variable “owner” by the process as described above, the CPU processing time assigned to the high priority thread according to the variable “prio” of the time slot data should be executed first. It will be assigned to a low priority thread. As a result, the priority is substantially inherited from the high priority thread to the low priority thread.
[0068]
3. Processing when the thread wait state is resolved
Next, when a high-priority thread waits for an event caused by a low-priority thread, the processing in the low-priority thread is completed and the high-priority thread waits. Processing when the state is resolved will be described.
[0069]
When a high-priority thread waits for an event caused by a low-priority thread, processing in the low-priority thread is completed and the wait state of the high-priority thread is resolved If so, the function “makeReady (Thread * target)” is called. Here, the argument “target” of the function “makeReady (Thread * target)” is an argument of the “Thread *” type, and this argument “target” is set to a value indicating the thread whose wait state has been canceled. The
[0070]
Hereinafter, processing when the function “makeReady (Thread * target)” is called will be described with reference to the flowchart of FIG. In the flowchart of FIG. 2, the processing at each step is shown in an expression according to the notation in C language.
[0071]
When the function “makeReady (Thread * target)” is called, first, in step ST2-1, the variable “state” of the thread indicated by the argument “target” indicates that the thread is in an executable state. Set the value “RUNNING”.
[0072]
Next, in step ST2-2, from the list to the inheritance source thread connected to the variable “inherit” of the thread that inherits the time slot data of the thread indicated by the argument “target”, the function “Remove (target)” To delete the link to the thread indicated by the argument “target”. In other words, the time slot data return procedure is performed for the inherited thread.
[0073]
Next, in step ST2-3, a NULL value is set in the variable “depend” of the thread indicated by the argument “target”. In other words, it is ensured that waiting is no longer necessary by completing the processing of the thread that has caused the waiting state of the thread.
[0074]
Next, in step ST2-4, the value of the argument “target” passed to the function “makeReady (Thread * target)” is set in both the first argument and the second argument, and the function “changeOwner” is set. (Thread * target, Thread * depend) ”. That is, the process of moving the time slot data originally assigned to the thread from the inheritance destination thread to the thread is performed. As a result, the thread can use the time slot data. In the function “changeOwner (Thread * target, Thread * depend)”, the process of changing the variable “owner” of the time slot data is performed. This process will be described in detail later. When the processing with the function “changeOwner (Thread * target, Thread * depend)” is completed, the process proceeds to step ST2-5.
[0075]
Finally, in step ST2-5, execution of the thread indicated by the argument “target” is started.
[0076]
Through the processing by the function “makeReady (Thread * target)” as described above, the high priority thread is returned from the wait state to the executable state, and the high priority thread is executed.
[0077]
Next, processing when the function “changeOwner (Thread * target, Thread * depend)” is called will be described with reference to the flowchart of FIG. In the flowchart of FIG. 3, the processing at each step is shown in an expression according to the notation in C language.
[0078]
The first argument “target” and the second argument “depend” of the function “changeOwner (Thread * target, Thread * depend)” are arguments of the “Thread *” type, and the function “changeOwner (Thread * target) , Thread * depend) ”changes the variable“ owner ”of the time slot data of the argument“ target ”to the value of the argument“ depend ”.
[0079]
When the function “changeOwner (Thread * target, Thread * depend)” is called, first, in step ST 3-1, the variable “timeSlot” of the “TimeSlot *” type is changed to the thread variable indicated by the argument “target”. Set the value of “timeSlot”.
[0080]
Next, in step ST <b> 3-2, the value of the argument “depend” is set in the variable “owner” of the time slot indicated by the variable “timeSlot”. That is, this inherits the ownership of the time slot to the thread indicated by the argument “depend”.
[0081]
Next, in step ST3-3, the value indicating the first thread in the thread list indicated by the variable “inherit” of the thread indicated by the argument “target” is set in the variable “inherit” of the “Thread *” type. When the thread list is empty, a NULL value is set in the variable “inherit”.
[0082]
Note that “Snoop ()” in FIG. 3 indicates a function for performing processing for extracting the first thread in the thread list. The function “Snoop ()” returns a value indicating the head thread as a return value.
[0083]
Next, in step ST3-4, it is determined whether or not a NULL value is set in the variable “inherit”. If a NULL value is set in the variable “inherit”, the processing of this function “changeOwner (Thread * target, Thread * depend)” is terminated. If no NULL value is set for the variable “inherit”, the process proceeds to step ST3-5.
[0084]
In step ST3-5, the value of the current variable “inherit” is set as the first argument, the value of the current argument “depend” is set as the second argument, and the function “changeOwner (Thread * inherit) is changed. , Thread * depend) ". When the processing by the function “changeOwner (Thread * inherit, Thread * depend)” is completed, the process proceeds to step ST3-6.
[0085]
In step ST3-6, a value indicating the next thread indicated by the argument “inherit” is set in the variable “inherit”. When there is no next thread, a NULL value is set in the variable “inherit”. When the process in step ST3-6 is completed, the process returns to step ST3-4 to repeat the process.
[0086]
By the processing with the function “changeOwner (Thread * target, Thread * depend)” as described above, the variable “owner” of the time slot data is changed, and the variable “depend” of the high priority thread and the priority are changed. The link of execution waiting relation formed by the variable “inherit” of the low thread is canceled.
[0087]
There may be a plurality of threads waiting for an event caused by a low priority thread, and these threads are registered in the thread list. Therefore, in the function “changeOwner (Thread * target, Thread * depend)”, by repeating the processing of step ST3-4 to step ST3-6, all threads registered in the thread list correspond to those threads. The variable “owner” of the time slot data to be changed is changed.
[0088]
4). Specific examples of scheduling
Next, a specific example of scheduling will be described with reference to FIGS.
[0089]
Note that in the example described below, so-called time slice scheduling is applied, and the priority of the thread indicates the ratio of the CPU processing time allocated to each thread. The following example is based on a round robin scheduling algorithm weighted by priority.
[0090]
In performing the scheduling described below, first, time slot data corresponding to the priority is assigned to each thread. In this example, the priority is assumed to take a value of 15-0. That is, a value of 15 to 0 is set in the variable “prio” of each time slot data according to the priority of the thread corresponding to the time slot. Here, the values of 15 to 0 correspond to the ratio of CPU usage rate 1: 1/2: 1/3:.
[0091]
Each time slot data corresponding to each thread is put in a ring buffer consisting of a total of 17 queues, and the time slot data is selected in order for each queue. Then, the CPU processing time is assigned to the selected time slot data, and a thread corresponding to the time slot data is executed.
[0092]
The time slot data to which the processing time of the CPU is assigned is determined according to the priority set in the variable “prio” of the time slot data when the corresponding thread uses up the processing time assigned to the time slot. It will be connected to the queue ahead. Here, by adjusting the queue in the ring buffer to which the time slot data is connected next in accordance with the priority, the allocation of the CPU usage rate according to the priority is realized.
[0093]
Here, a scheduling method based on a round robin scheduling algorithm is taken as an example, but the present invention is not limited to this. That is, the present invention can be applied to a scheduling method that performs FCFS (First Come First Serve) based on priority, for example. Here, as a scheduling method for performing FCFS based on priority, for example, “Rate Monotonic” (John Lehoczky, Lui Sha, and Ye Ding. The Rate Monotonic Scheduling Algorithm. Scheduling methods using algorithms such as “Earliest Deadline First” and “Average Average Behavior. Thchnical report, Department Of Statistics, Carnegie Mellon University, 1987)”.
[0094]
4-1 When priority is not inherited
FIG. 4 shows a case where a thread A having a priority of 15, a thread B having a priority of 13, and a thread C having a priority of 3 are processed in a time-sharing manner, and priority is not inherited. This will be described with reference to FIG. In FIGS. 4 to 13 and FIGS. 14 to 23 to be described later, numerals 1 to 17 indicate queue numbers. The circles attached to these numbers indicate that the queue with that number is currently subject to processing.
[0095]
When time-sharing the threads A, B, and C, first, as shown in FIG. 4, time slot data A, B, and C are arranged in the first queue. That is, the variable “next” of the time slot data A indicates the time slot data B, and the variable “next” of the time slot data B indicates the time slot data C. Here, the time slot data assigned to thread A is time slot data A, the time slot data assigned to thread B is time slot data B, and the time slot data assigned to thread C is time slot data C. Yes.
[0096]
First, the CPU processing time is assigned to the time slot data A that is the first time slot data of the first queue, and the thread A that is a thread corresponding to the time slot data A is executed. Note that the thread corresponding to the time slot data A is a thread indicated by the variable “owner” of the time slot data A.
[0097]
Then, when the thread A uses up the processing time allocated to the time slot data A, the time slot data A is connected to the previous queue in the ring buffer by the amount corresponding to the priority. Specifically, since the priority of the thread A is 15, as shown in FIG. 5, the time slot data A is connected to the next queue, that is, the second queue by (16-15) = 1. It is.
[0098]
Next, the CPU processing time is allocated to time slot data B, which is the next time slot data in the first queue, and thread B, which is a thread corresponding to time slot data B, is executed. Note that the thread corresponding to the time slot data B is a thread indicated by the variable “owner” of the time slot data B.
[0099]
Then, when the thread B uses up the processing time allocated to the time slot data B, the time slot data B is linked to the previous queue in the ring buffer by the amount corresponding to the priority. Specifically, since the priority of the thread B is 13, as shown in FIG. 6, the time slot data B is connected to the queue ahead by (16-13) = 3, that is, the fourth queue. It is.
[0100]
Next, the CPU processing time is allocated to time slot data C that is the next time slot data of the first queue, and thread C that is a thread corresponding to time slot data C is executed. The thread corresponding to the time slot data C is a thread indicated by the variable “owner” of the time slot data C.
[0101]
When the time slice assigned to the time slot data C is used up, the time slot data C is linked to the previous queue in the ring buffer by the amount corresponding to the priority. Specifically, since the priority of the thread C is 3, as shown in FIG. 7, the time slot data C is connected to the queue ahead (ie, the 14th queue) by (16-3) = 13. It is.
[0102]
This completes the processing of the time slot data arranged in the first queue, and then the processing of the time slot data arranged in the second queue is performed. At this time, since the head of the second queue is time slot data A, the CPU processing time is allocated to the time slot data A, and the thread A that is a thread corresponding to the time slot data A is executed. Is done. Then, when the processing time assigned to the time slot data A is used up, the time slot data A is connected to the queue ahead by the amount corresponding to the priority. Specifically, since the priority of the thread A is 15, as shown in FIG. 8, the time slot data A is connected to the next queue, that is, the third queue by (16-15) = 1. It is.
[0103]
This completes the processing of the time slot data arranged in the second queue, and then the processing of the time slot data arranged in the third queue is performed. At this time, since the head of the third queue is the time slot data A, the CPU processing time is allocated to the time slot data A, and the thread A that is a thread corresponding to the time slot data A is executed. Is done. Then, when the processing time assigned to the time slot data A is used up, the time slot data A is connected to the queue ahead by the amount corresponding to the priority. Specifically, since the priority of the thread A is 15, as shown in FIG. 9, the time slot data A is connected to the queue ahead by (16-15) = 1, that is, the fourth queue. It is. Here, since the time slot data B is already arranged in the fourth queue, the time slot data A is connected after the time slot data B.
[0104]
This completes the processing of the time slot data arranged in the third queue, and then the processing of the time slot data arranged in the fourth queue is performed. At this time, since the head of the fourth queue is the time slot data B, first, the CPU processing time is assigned to the time slot data B, and the thread B that is a thread corresponding to the time slot data B Is executed. When the processing time allocated to the time slot data B is used up, the time slot data B is connected to the queue ahead by the amount corresponding to the priority. Specifically, since the priority of the thread B is 13, as shown in FIG. 10, the time slot data B is connected to a queue ahead by (16-13) = 3, that is, the seventh queue. It is.
[0105]
Next, the CPU processing time is allocated to time slot data A, which is the next time slot data in the fourth queue, and thread A, which is a thread corresponding to time slot data A, is executed. Then, when the processing time assigned to the time slot data A is used up, the time slot data A is connected to the queue ahead by the amount corresponding to the priority. Specifically, since the priority of the thread A is 15, as shown in FIG. 11, the time slot data A is connected to the next queue, that is, the fifth queue by (16-15) = 1. It is.
[0106]
Similarly, the CPU processing time is assigned to the time slot data for each queue, the thread corresponding to the time slot data is executed, and the time slot data that has used up the processing time corresponds to the priority. The process connected to the queue ahead is carried out by the minute. It should be noted that by proceeding as described above, if the queue reaches the 17th position, then the process returns to the first queue.
[0107]
For example, as shown in FIG. 12, the time slot data A is connected to the 17th queue, the processing time of the CPU is assigned to the time slot data A, and the thread is a thread corresponding to the time slot data A When A is executed, if the processing time assigned to the time slot data A is used up, the time slot data A is connected to the previous queue by the amount corresponding to the priority. Specifically, since the priority of the thread A is 15, it is connected to the queue ahead by (16−15) = 1. Since the current queue is 17th at this time, the queue ahead by (16-15) = 1 is the first queue. That is, the time slot data A is connected to the first queue as shown in FIG.
[0108]
By sequentially performing the processes as described above, the ratio of the CPU usage rate of the thread A, the CPU usage rate of the thread B, and the CPU usage rate of the thread C is 1: 1/3: 1/13. Become. That is, the processing time of the CPU is allocated to each thread according to the priority of the corresponding time slot data of the thread, and the time division processing of a plurality of threads is executed.
[0109]
By the way, in many conventional time slice schedulings, processing such as sorting queues according to the ratio of the CPU usage rate is necessary. On the other hand, in the above method, the time slice scheduling can be realized simply by switching the time slot data. That is, by using the above method, time slice scheduling can be realized with a very small amount of calculation.
[0110]
Note that when the above method is applied to a real-time system in which the system cannot be established unless each process is completed within a certain period of time, the amount of time slot data placed in the scheduling queue is limited. do it. By limiting the amount of time slot data to be placed in the scheduling queue, it is possible to guarantee the CPU usage rate, thereby enabling application to a real-time system.
[0111]
For example, assume that thread A is the highest priority thread. Here, it is assumed that two units of CPU processing time are required to complete the execution of the thread A. Further, it is assumed that the thread A must be terminated within 5 CPU unit processing time. In this case, it is assumed that the thread A is in the state shown in FIG. 8 and the state shown in FIG. At this time, it is necessary to wait for one CPU unit processing time (that is, the processing time executed by the thread B) until at least the next processing time is assigned to the thread A (that is, the processing time executed by the thread B). be able to. However, assuming that five threads are connected to the queue to which thread B is currently connected in the state shown in FIG. Will wait for time. In this case, the execution limit time of the thread A will be exceeded by this alone. In such a case, for example, the number of threads that can be connected to one queue may be limited to a number that indicates that the thread A will not exceed the time limit by queue theory or the like. Conceivable.
[0112]
4-2 When priority is inherited
FIG. 14 to FIG. 14 show the case where the thread A having the priority 15, the thread B having the priority 13, and the thread C having the priority 3 are processed in a time-sharing manner and the inheritance of the priority is performed. This will be described with reference to FIG.
[0113]
14 to 23, the reference numerals in parentheses indicate the thread indicated by the variable “owner” of the time slot data. That is, for example, A (A) represents that the variable “owner” of the time slot data A indicates the thread A, and for example, A (B) represents the variable “owner” of the time slot data A. It represents that “owner” indicates the thread B.
[0114]
Also in this example, as in the example shown in FIGS. 4 to 13, first, as shown in FIG. 14, time slot data A, B, and C are arranged in the first queue. First, the CPU processing time is assigned to the time slot data A, which is the first time slot data of the first queue, and the thread A corresponding to the time slot data A is executed. Then, at this time, it is assumed that thread A must wait for an event that thread B causes. Then, the thread A is not executed here, and processing is performed according to the flowchart shown in FIG. As a result, the thread A is put in a waiting state, and as shown in FIG. 15, the variable “owner” of the time slot data A is changed to point to the thread B, and the thread B is executed. That is, the link from the time slot data A is changed from the thread A to the thread B, and the CPU processing time originally assigned to the thread A is assigned to the thread B.
[0115]
Then, when the processing time assigned to the time slot data A is used up, the time slot data A is connected to the queue ahead by the amount corresponding to the priority. Specifically, since the priority of the thread A is 15, as shown in FIG. 16, the time slot data A is connected to the next queue, that is, the second queue by (16-15) = 1. It is.
[0116]
Next, the CPU processing time is allocated to time slot data B, which is the next time slot data in the first queue, and thread B, which is a thread corresponding to time slot data B, is executed. The thread corresponding to the time slot data B is a thread indicated by the variable “owner” of the time slot data B, and is the thread B here.
[0117]
When the processing time allocated to the time slot data B is used up, the time slot data B is connected to the queue ahead by the amount corresponding to the priority. Specifically, since the priority of the thread B is 13, as shown in FIG. 17, the time slot data B is connected to the queue ahead by the amount of (16-13) = 3, that is, the fourth queue. It is.
[0118]
Next, the CPU processing time is allocated to time slot data C that is the next time slot data of the first queue, and thread C that is a thread corresponding to time slot data C is executed. The thread corresponding to the time slot data C is a thread indicated by the variable “owner” of the time slot data C, and is the thread C here.
[0119]
Then, when the processing time assigned to the time slot data C is used up, the time slot data C is connected to the queue ahead by the amount corresponding to the priority. Specifically, since the priority of the thread C is 3, as shown in FIG. 18, the time slot data C is connected to the queue ahead by (16-3) = 3, that is, the 14th queue. It is.
[0120]
This completes the processing of the time slot data arranged in the first queue, and then the processing of the time slot data arranged in the second queue is performed. At this time, since the head of the second queue is the time slot data A, the thread indicated by the variable “owner” of the time slot data A, that is, the thread B is executed. Then, when the processing time assigned to the time slot data A is used up, the time slot data A is connected to the queue ahead by the amount corresponding to the priority. Specifically, since the priority of the thread A is 15, as shown in FIG. 19, the time slot data A is connected to the next queue, that is, the third queue by (16-15) = 1. It is.
[0121]
This completes the processing of the time slot data arranged in the second queue, and then the processing of the time slot data arranged in the third queue is performed. At this time, since the head of the third queue is the time slot data A, the thread indicated by the variable “owner” of the time slot data A, that is, the thread B is executed. Then, when the processing time assigned to the time slot data A is used up, the time slot data A is connected to the queue ahead by the amount corresponding to the priority. Specifically, since the priority of the thread A is 15, as shown in FIG. 20, the time slot data A is connected to the queue ahead (ie, the fourth queue) by (16-15) = 1. It is. Here, since the time slot data B is already arranged in the fourth queue, the time slot data A is connected after the time slot data B.
[0122]
This completes the processing of the time slot data arranged in the third queue, and then the processing of the time slot data arranged in the fourth queue is performed. At this time, since the head of the fourth queue is the time slot data B, first, the thread indicated by the variable “owner” of the time slot data B, that is, the thread B is executed.
[0123]
At this time, it is assumed that the cause of the waiting state of the thread A is eliminated by the execution of the thread B. Then, the processing is performed according to the flowcharts shown in FIGS. 2 and 3, and as a result, the thread A is made executable and the variable “owner” of the time slot data A is changed to the thread A as shown in FIG. Is changed to point to That is, the link from the time slot data A is returned to the thread A.
[0124]
Thereafter, when the processing time allocated to the time slot data B is used up, the time slot data B is connected to the queue ahead by the amount corresponding to the priority. Specifically, since the priority of the thread B is 13, as shown in FIG. 22, the time slot data B is connected to a queue ahead by (16−13) = 3, that is, the seventh queue. It is.
[0125]
Next, the CPU processing time is allocated to time slot data A, which is the next time slot data in the fourth queue, and thread A, which is a thread corresponding to time slot data A, is executed. Note that the thread corresponding to the time slot data A is a thread indicated by the variable “owner” of the time slot data A, and is the thread A here.
[0126]
Then, when the processing time assigned to the time slot data A is used up, the time slot data A is connected to the queue ahead by the amount corresponding to the priority. Specifically, since the priority of the thread A is 15, as shown in FIG. 23, the time slot data A is connected to the next queue, that is, the fifth queue by (16-15) = 1. It is.
[0127]
Similarly, the time slot data is executed for each queue, and the processing for connecting the time slot data that has used up the processing time to the previous queue by the amount corresponding to the priority is performed.
[0128]
5. Summary
In the scheduling method described above, when a high priority thread needs to wait for processing of a low priority thread, the high priority thread is placed in a wait state and is assigned to a high priority thread. The thread indicated by the variable “owner” of the time slot data is changed from a thread having a high priority to a thread having a low priority. That is, the link from the time slot data assigned to the thread having a high priority to the thread is temporarily switched to a thread having a low priority.
[0129]
In other words, the scheduling method avoids the priority inversion problem by increasing the priority of the low priority thread when the high priority thread needs to wait for the processing of the low priority thread. Instead, the priority inversion problem is avoided by running a low priority thread instead of a high priority thread.
[0130]
According to this scheduling method, when a high priority thread needs to wait for processing of a low priority thread, it recalculates processing and priority that change the queue for priority inheritance. The same result as when the priority is inherited from the high priority thread to the low priority thread can be obtained without performing such processing. Therefore, according to the scheduling method, it is possible to avoid the priority inversion problem which is a fatal problem particularly in a real-time system. In addition, the scheduling method does not require any processing such as changing the queue for inheriting the priority or recalculating the priority, so that the priority can be increased without increasing the scheduling cost. The reversal problem can be avoided. Furthermore, in the scheduling method described above, the CPU processing time allocated to the waiting thread is allocated to the thread causing the waiting state, so the CPU processing time can be used effectively without waste. Is done.
[0131]
In the scheduling method described above, even when waiting events are connected (for example, when thread A waits for thread B and thread B waits for thread C), all the time slot data is the thread at the leading end of the connection. Will be linked to. Therefore, all the processing time of the CPU is used effectively. In other words, the scheduling method enables so-called multiple thread waiting, which was impossible with the conventional priority inheritance method.
[0132]
Finally, an example of a hardware configuration and an operating system configuration to which the present invention is applied will be described with reference to FIGS. In FIG. 24, the television receiver 1 to which the present invention is applied is taken as an example, but it goes without saying that the present invention can be applied to other various information processing apparatuses. That is, the present invention can be widely applied to information processing apparatuses equipped with an operating system (hereinafter referred to as OS) employing a multi-thread system that performs time-sharing processing. For example, various audio / visual devices ( The present invention can be applied to information processing apparatuses such as so-called AV equipment), office information processing equipment, and computer equipment.
[0133]
In FIG. 24, the television receiver 1 receives a signal transmitted from a broadcasting station via an antenna or a cable, displays video on an image display device and outputs sound from a speaker based on the received signal. Device.
[0134]
The television receiver 1 not only has a general television reception function, but can receive a program, data, and the like from the outside. As shown in FIG. The TV function unit 4 connected to the bus 3 via the bus, the processor 6 connected to the bus 3 via the bus / memory bridge 5, and the ROM (Read that is connected to the bus 3 via the bus / memory bridge 5) And a RAM (Random Access Memory) 8, an operation panel 9 connected to the bus 3, an external storage device 10, and a communication device 11.
[0135]
The TV function unit 4 has a function of reproducing video and audio based on a signal received by an antenna or a cable. The television function unit 4 is connected to the bus 3 via the bus / IO bridge 2, thereby enabling signal exchange with other units.
[0136]
The processor 6 controls each part of the television receiver 1 and is connected to the bus 3 via the bus / memory bridge 5. A ROM 7 and a RAM 8 are connected to the processor 6 via a bus / memory bridge 5. The ROM 7 holds, for example, invariant information regarding the television receiver 1. The RAM 8 provides a memory space used as a work area for the processor 6. That is, the processor 6 executes the OS (including the scheduling apparatus and method of the present invention) and application programs recorded in the external storage device 10 as described later while using the RAM 8 as a work area. Each part which comprises the television receiver 1 is controlled.
[0137]
The operation panel 9 is an input device for receiving an operation input from a user. The television receiver 1 receives a signal for instructing switching of, for example, a channel and a volume from the operation panel 9. Specifically, the operation panel 9 includes an input device having a plurality of buttons for inputting various signals, a pointing device represented by a so-called mouse, and the like. A signal input from the operation panel 9 is input to the processor 6 via the bus 3 and the bus / memory bridge 5. Then, the processor 6 performs predetermined arithmetic processing based on the signal input from the operation panel 9 and controls each part constituting the television receiver 1.
[0138]
The external storage device 10 is composed of a storage device such as a hard disk device, for example, and records an OS (including the scheduling device and method of the present invention) and application programs for performing various controls by the processor 6. The external storage device 10 stores image data and control data, a program downloaded from the outside via the communication device 11, and the like. The communication device 11 is an input / output unit for performing data communication with the outside, and is configured by a communication device such as a modem or a terminal adapter.
[0139]
Further, the television receiver 1 executes the OS stored in the external storage device 10 by the processor 6 and records the information in the external storage device 10 using the control information recorded in the ROM 7 on the OS. Each part is controlled by executing the prepared application program. That is, the television receiving device 1 includes an external storage device 10 as a program providing medium that provides various data processing programs (including the scheduling device and method of the present invention) constituting the OS.
[0140]
The OS including the scheduling apparatus and method of the present invention may be recorded in the ROM 7 or RAM 8. In this case, the ROM 7 and the RAM 8 are program providing media. However, in order to perform an OS rewrite operation such as version upgrade, it is desirable to provide an OS including the scheduling apparatus and method of the present invention on a rewritable recording medium. Further, the program providing medium may be, for example, a magnetic recording medium or an optical recording medium that is used detachably with respect to the television receiver 1, or the television receiver 1 and other various information. It may be a network line or the like connecting the processing device.
[0141]
The OS installed in the television receiver 1 is a pure object-oriented OS. On the OS, for example, an application program for displaying a moving image on the TV function unit 4 and an application program for realizing a graphical user interface (GUI) for controlling the operation panel 9 are executed. .
[0142]
Next, an example of the OS will be described with reference to FIG. This OS is composed of a MetaCore 20 that is a basic part and other object groups. Here, the metacore 20 is a part that cannot be defined as an object, and includes a processing unit that switches execution control between objects, that is, a processing unit that executes a thread to which processing time according to the present invention is assigned. .
[0143]
This OS is a pure object-oriented OS, and an object that constitutes an application program executed on the OS and an object that constitutes the OS have the same execution mechanism. In this OS, all objects each have one thread and can operate in parallel with each other. Each object can communicate with each other by sending messages. However, only a specific object called a system object can be communicated without passing through a message, and further, it is guaranteed to operate outside the scheduling target as in the present invention. In addition, system objects are allowed to directly operate on specific data structures. Such a specific data structure includes thread data, time slot data, and the like as in the present invention.
[0144]
In FIG. 25, in addition to the metacore 20, a timer object 21 and a scheduler 22 which are system objects, and other object groups, a first message handler 23, a second message handler 24, a first execution environment manager 25, A second execution environment manager 26 is shown. In FIG. 25, it goes without saying that there are many objects (including system objects) that are included in the actual system but omitted.
[0145]
In this OS, each application can be operated on different execution environments. In this embodiment, an example in which two applications use different execution environments is shown. Specifically, the first application 32 operates on the first execution environment 30, and the first execution environment 30 includes the timer object 21, the scheduler 22, the first message handler 23, and the first execution. An environment manager 25 is included. The second application 33 operates on the second execution environment 31, and the second execution environment 31 includes the timer object 21, the scheduler 22, the second message handler 24, and the second execution environment manager 26. Is included. Further, the first application 32 and the second application 33 are also configured by object groups. Further, it is assumed that the first application includes a first object 34 and a second object 35, and the priority of the first object 34 is lower than the priority of the second object 35.
[0146]
First, a procedure for switching threads in the present invention will be described. It is assumed that the first object 34 constituting the first application 32 sends a processing request message to the second object 35. In this case, the message is sent to the second object 35 via the first message handler 23. At this time, the first message handler 23 compares the priority of the first object 34 that is the sender with the priority of the second object 35 that is the receiver, so that the priority inversion occurs. To detect. Upon receiving this detection, the first message handler 23 calls the function “makeWait (Thread * target, Thread * depend)”. Here, the argument “target” indicates the thread of the first object 34, and the argument “depend” indicates the thread of the second object 35. As a result, the time slot data corresponding to the thread of the first object 34 is inherited from the thread of the second object 35.
[0147]
Next, the second object 35 ends the processing requested by the processing request message from the first object 34 and returns a response message to the first object 34. This reply message is sent again via the first message handler 23. At this time, the first message handler 23 detects that the first object 34 is in a waiting state depending on the second object 35. Upon receiving this detection, the first message handler 23 calls the function “makeReady (Thread * target)”. Here, the argument “target” is a thread of the first object 34. As a result, the time slot data inherited for the thread of the second object 35 is returned to the thread of the first object 34.
[0148]
Next, time division scheduling will be described. In time-sharing scheduling, the timer object 21 generates a timer interrupt at regular intervals and calls the scheduler 22. The scheduler 22 selects the time slot data of the thread to be executed next by the method as described above, and activates the thread of the selected object.
[0149]
【The invention's effect】
As described above in detail, in the present invention, the time slot data corresponding to the thread having a high priority is handled as the time slot data corresponding to the thread having a low priority, so that the priority is high. Priority inheritance from a thread to a lower priority thread is realized. Therefore, according to the present invention, the problem of priority inversion can be avoided.
[0150]
Moreover, in the present invention, priority inheritance is realized only by treating the time slot data corresponding to the high priority thread as time slot data corresponding to the low priority thread. There is no need to change queues frequently in order to inherit priority. Therefore, according to the present invention, priority inheritance can be realized without frequently changing a queue that causes an increase in overhead.
[0151]
Furthermore, in the present invention, when priority is inherited from a thread with a high priority to a thread with a low priority, the thread with a low priority has a processing time allocated to the thread with a high priority and a priority. Both the processing time originally assigned to the lesser thread will be used. Therefore, according to the present invention, it is possible to effectively use the processing time allocated to each thread.
[Brief description of the drawings]
FIG. 1 is a flowchart showing a flow of processing of a function “makeWait (Thread * target, Thread * depend)” called when a thread enters a wait state.
FIG. 2 is a flowchart showing a processing flow of a function “makeReady (Thread * target)” that is called when a thread wait state is resolved;
FIG. 3 is a flowchart showing a processing flow of a function “changeOwner (Thread * target, Thread * depend)” called in a function “makeReady (Thread * target)”;
FIGS. 4 to 11 are diagrams sequentially illustrating queue transition when priority is not inherited. FIG. 4 is a diagram illustrating time slot data A, B, and C arranged in the first queue. It is a figure which shows the state which has come out.
5 is a diagram showing the next state of FIG. 4 for the queue of time slot data A, B, and C. FIG.
6 is a diagram showing the next state of FIG. 5 with respect to the queue of time slot data A, B, and C. FIG.
7 is a diagram showing the next state of FIG. 6 for the queue of time slot data A, B, and C. FIG.
8 is a diagram showing the next state of FIG. 7 with respect to the queue of time slot data A, B, and C. FIG.
9 is a diagram showing the next state of FIG. 8 for the queue of time slot data A, B, and C. FIG.
10 is a diagram showing the next state of FIG. 9 for the queue of time slot data A, B, C. FIG.
11 is a diagram showing the next state of FIG. 10 for the queue of time slot data A, B, and C. FIG.
FIGS. 12 and 13 are diagrams sequentially illustrating the transition of the queue when the queue reaches the 17th, and FIG. 12 shows time slot data A arranged in the 17th queue. It is a figure which shows a state.
13 is a diagram showing the next state of FIG. 12 for the queue of time slot data A, B, and C. FIG.
FIG. 14 to FIG. 23 are diagrams sequentially showing the transition of the queue when priority is inherited, and FIG. 14 shows time slot data A, B, and C arranged in the first queue. FIG.
15 is a diagram showing the next state of FIG. 14 for the queue of time slot data A, B, C. FIG.
16 is a diagram showing the next state of FIG. 15 for the queue of time slot data A, B, and C. FIG.
FIG. 17 is a diagram showing the next state of FIG. 16 with respect to the queue of time slot data A, B, and C.
18 is a diagram showing the next state of FIG. 17 for the queue of time slot data A, B, and C. FIG.
FIG. 19 is a diagram showing the next state of FIG. 18 for the queue of time slot data A, B, and C.
20 shows the next state of FIG. 19 for the queue of time slot data A, B, and C. FIG.
21 shows the next state of FIG. 20 for the queue of time slot data A, B, and C. FIG.
22 shows the next state of FIG. 21 for the queue of time slot data A, B, and C. FIG.
23 shows the next state of FIG. 22 for the queue of time slot data A, B, and C. FIG.
FIG. 24 is a schematic configuration diagram of a television receiver shown as an embodiment of the present invention.
FIG. 25 is a diagram for explaining the outline of an operating system according to the present invention;
FIG. 26 is a diagram for explaining a problem of priority inversion;
FIG. 27 is a diagram for explaining a conventional priority inheritance mechanism.
[Explanation of symbols]
DESCRIPTION OF SYMBOLS 1 Television receiver, 2 Bus / IO bridge, 3 Bus, 4 Television function part, 5 Bus / memory bridge, 6 Processor, 7 ROM (Read Only Memory), 8 RAM (Random Access Memory), 9 Operation panel, 10 External storage device, 11 Communication device

Claims (6)

複数の実行主体を時分割処理することが可能なオペレーティングシステムのスケジューリング装置において、
各実行主体毎に、スケジューリングの対象として割り当てられたタイムスロットデータを記憶する手段と、
タイムスロットデータに処理時間を割り当て、時分割スケジューリングを行うスケジューラと、
処理時間が割り当てられたタイムスロットデータに対応する実行主体を実行する手段と、優先度の高い第一の実行主体が、優先度の低い第二の実行主体の処理を待つ必要があるときには、当該第一の実行主体に対応するタイムスロットデータを当該第二の実行主体に割り当てる手段と、当該第二の実行主体の処理が終了したときに、当該第一の実行主体から割り当てられたタイムスロットデータを、当該第一の実行主体に再度割り当てる手段と、
を具備することを特徴とするスケジューリング装置。
In an operating system scheduling apparatus capable of time-sharing a plurality of execution subjects,
Means for storing time slot data assigned as a scheduling target for each execution subject;
A scheduler that allocates processing time to time slot data and performs time division scheduling;
When the execution entity corresponding to the time slot data to which the processing time is allocated and the first execution entity having a high priority need to wait for the processing of the second execution entity having a low priority, Means for assigning time slot data corresponding to the first execution subject to the second execution subject, and time slot data assigned by the first execution subject when the processing of the second execution subject is completed Means for reassigning to the first execution subject,
A scheduling apparatus comprising:
前記タイムスロットデータは、各タイムスロットデータの対応する実行主体を指し示すリンクデータを格納するデータ領域を具備し、前記スケジューリング装置は、
優先度の高い実行主体に対応していたタイムスロットデータを、優先度の低い実行主体に対応したタイムスロットデータとして扱うようにするときには、当該タイムスロットデータのリンクデータが指し示す実行主体を、優先度の高い実行主体から優先度の低い実行主体に変更する手段を具備する、
ことを特徴とする請求項1記載のスケジューリング装置。
The time slot data includes a data area for storing link data indicating a corresponding execution subject of each time slot data, and the scheduling device includes:
When handling time slot data corresponding to an execution subject having a high priority as time slot data corresponding to an execution subject having a low priority, the execution subject indicated by the link data of the time slot data is assigned the priority. A means for changing from a high execution subject to a low priority execution subject,
The scheduling apparatus according to claim 1, wherein:
複数の実行主体を時分割処理することが可能なオペレーティングシステムのスケジューリング方法において、  In an operating system scheduling method capable of time-sharing a plurality of execution subjects,
各実行主体毎に、スケジューリングの対象として割り当てられたタイムスロットデータに処理時間を割り当て、時分割スケジューリングを行うステップと、  For each execution subject, assigning processing time to time slot data assigned as a scheduling target, and performing time division scheduling;
処理時間が割り当てられたタイムスロットデータに対応する実行主体を実行するステップと、  Executing the execution subject corresponding to the time slot data to which the processing time is allocated;
優先度の高い第一の実行主体が、優先度の低い第二の実行主体の処理を待つ必要があるときには、当該第一の実行主体に対応するタイムスロットデータを当該第二の実行主体に割り当てるステップと、当該第二の実行主体の処理が終了したときに、当該第一の実行主体から割り当てられたタイムスロットデータを、当該第一の実行主体に再度割り当てるステップと、  When the first execution entity with high priority needs to wait for the processing of the second execution entity with low priority, time slot data corresponding to the first execution entity is allocated to the second execution entity. Re-assigning the time slot data allocated from the first execution entity to the first execution entity when the processing of the second execution entity is completed;
を具備することを特徴とするスケジューリング方法。  A scheduling method comprising:
前記タイムスロットデータ毎に、対応する実行主体を指し示すリンクデータが格納されるデータ領域を確保しておき、優先度の高い実行主体に対応していたタイムスロットデータを、優先度の低い実行主体に対応したタイムスロットデータとして扱うようにするときには、当該タイムスロットデータに対応したリンクデータが指し示す実行主体を、優先度の高い実行主体から優先度の低い実行主体に変更する、  For each time slot data, a data area for storing link data indicating the corresponding execution subject is secured, and the time slot data corresponding to the execution subject having a high priority is assigned to the execution subject having a low priority. When handling as corresponding time slot data, the execution subject indicated by the link data corresponding to the time slot data is changed from an execution subject having a high priority to an execution subject having a low priority.
ことを特徴とする請求項3記載のスケジューリング方法。  The scheduling method according to claim 3, wherein:
複数の実行主体を時分割処理することが可能なオペレーティングシステムのデータ処理プログラムが記録された記録媒体であって、  A recording medium on which a data processing program of an operating system capable of time-sharing a plurality of execution subjects is recorded,
各実行主体毎に、スケジューリングの対象として割り当てられたタイムスロットデータに処理時間を割り当て、時分割スケジューリングを行うステップと、処理時間が割り当てられたタイムスロットデータに対応する実行主体を実行するステップと、  For each execution subject, assigning processing time to time slot data assigned as a target for scheduling and performing time-sharing scheduling; executing an execution subject corresponding to time slot data to which processing time is assigned;
優先度の高い第一の実行主体が、優先度の低い第二の実行主体の処理を待つ必要がある  The first execution entity with the higher priority needs to wait for the processing of the second execution entity with the lower priority. ときには、当該第一の実行主体に対応するタイムスロットデータを当該第二の実行主体に割り当てるステップと、Sometimes assigning time slot data corresponding to the first execution entity to the second execution entity;
当該第二の実行主体の処理が終了したときに、当該第一の実行主体から割り当てられたタイムスロットデータを、当該第一の実行主体に再度割り当てるステップと、  Reassigning the time slot data allocated from the first execution entity to the first execution entity when the processing of the second execution entity is completed;
をコンピュータに実行させるためのデータ処理プログラムが記録された記録媒体。  A recording medium on which a data processing program for causing a computer to execute is recorded.
上記データ処理プログラムは、前記タイムスロットデータ毎に、対応する実行主体を指し示すリンクデータが格納されるデータ領域を確保しておき、優先度の高い実行主体に対応していたタイムスロットデータを、優先度の低い実行主体に対応したタイムスロットデータとして扱うようにするときには、当該タイムスロットデータに対応したリンクデータが指し示す実行主体を、優先度の高い実行主体から優先度の低い実行主体に変更する、  The data processing program reserves, for each time slot data, a data area in which link data indicating the corresponding execution subject is stored, and prioritizes the time slot data corresponding to the execution subject having a high priority. When handling as time slot data corresponding to a low execution subject, the execution subject indicated by the link data corresponding to the time slot data is changed from a high priority execution subject to a low priority execution subject.
ことをコンピュータに実行させることを特徴とする請求項5記載の記録媒体。  6. The recording medium according to claim 5, wherein the recording medium is made to execute this.
JP06895899A 1998-04-27 1999-03-15 Scheduling apparatus and method, and recording medium Expired - Lifetime JP4048638B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP06895899A JP4048638B2 (en) 1998-04-27 1999-03-15 Scheduling apparatus and method, and recording medium

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
JP10-117504 1998-04-27
JP11750498 1998-04-27
JP06895899A JP4048638B2 (en) 1998-04-27 1999-03-15 Scheduling apparatus and method, and recording medium

Publications (2)

Publication Number Publication Date
JP2000020323A JP2000020323A (en) 2000-01-21
JP4048638B2 true JP4048638B2 (en) 2008-02-20

Family

ID=26410145

Family Applications (1)

Application Number Title Priority Date Filing Date
JP06895899A Expired - Lifetime JP4048638B2 (en) 1998-04-27 1999-03-15 Scheduling apparatus and method, and recording medium

Country Status (1)

Country Link
JP (1) JP4048638B2 (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3813930B2 (en) 2002-01-09 2006-08-23 松下電器産業株式会社 Processor and program execution method
JP4750350B2 (en) 2003-03-13 2011-08-17 パナソニック株式会社 Task switching device, method and program
US7401208B2 (en) 2003-04-25 2008-07-15 International Business Machines Corporation Method and apparatus for randomizing instruction thread interleaving in a multi-thread processor
US7360062B2 (en) 2003-04-25 2008-04-15 International Business Machines Corporation Method and apparatus for selecting an instruction thread for processing in a multi-thread processor
US7401207B2 (en) 2003-04-25 2008-07-15 International Business Machines Corporation Apparatus and method for adjusting instruction thread priority in a multi-thread processor
US7409520B2 (en) 2005-01-25 2008-08-05 International Business Machines Corporation Systems and methods for time division multiplex multithreading
KR20080064608A (en) * 2007-01-05 2008-07-09 삼성전자주식회사 Method and embedded system for multi-tasking according to spi scheme
CN111666136A (en) * 2020-04-24 2020-09-15 北京奇艺世纪科技有限公司 Thread processing method and device, electronic equipment and storage medium
CN112181614B (en) * 2020-09-14 2024-04-19 中国银联股份有限公司 Task timeout monitoring method, device, equipment, system and storage medium

Also Published As

Publication number Publication date
JP2000020323A (en) 2000-01-21

Similar Documents

Publication Publication Date Title
US8612986B2 (en) Computer program product for scheduling ready threads in a multiprocessor computer based on an interrupt mask flag value associated with a thread and a current processor priority register value
US6560628B1 (en) Apparatus, method, and recording medium for scheduling execution using time slot data
US8615765B2 (en) Dividing a computer job into micro-jobs
US9588809B2 (en) Resource-based scheduler
EP3008594B1 (en) Assigning and scheduling threads for multiple prioritized queues
JP5722327B2 (en) Hardware based scheduling of GPU work
US5247671A (en) Scalable schedules for serial communications controller in data processing systems
EP2885707B1 (en) Latency sensitive software interrupt and thread scheduling
CN111897637B (en) Job scheduling method, device, host and storage medium
JP2013218744A (en) Resource-based scheduler
JP4048638B2 (en) Scheduling apparatus and method, and recording medium
JP2000056992A (en) Task scheduling system, its method and recording medium
JP5299869B2 (en) Computer micro job
JP2005092780A (en) Real time processor system and control method
JP2008225641A (en) Computer system, interrupt control method and program
JP2000259430A (en) Processing method for computer system
Schaffer et al. The joy of scheduling
JPH0822396A (en) Device and method for managing task execution
JPS62235646A (en) Resource managing system

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20060105

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20070727

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20070814

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20071015

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20071106

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20071119

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20101207

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20101207

Year of fee payment: 3

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313113

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20101207

Year of fee payment: 3

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20101207

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111207

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121207

Year of fee payment: 5

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121207

Year of fee payment: 5

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20131207

Year of fee payment: 6

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

EXPY Cancellation because of completion of term