JP3870730B2 - Task management system - Google Patents

Task management system Download PDF

Info

Publication number
JP3870730B2
JP3870730B2 JP2001206814A JP2001206814A JP3870730B2 JP 3870730 B2 JP3870730 B2 JP 3870730B2 JP 2001206814 A JP2001206814 A JP 2001206814A JP 2001206814 A JP2001206814 A JP 2001206814A JP 3870730 B2 JP3870730 B2 JP 3870730B2
Authority
JP
Japan
Prior art keywords
task
service
activity
context
server
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 - Fee Related
Application number
JP2001206814A
Other languages
Japanese (ja)
Other versions
JP2003022193A (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 JP2001206814A priority Critical patent/JP3870730B2/en
Priority to US10/190,203 priority patent/US7302686B2/en
Publication of JP2003022193A publication Critical patent/JP2003022193A/en
Application granted granted Critical
Publication of JP3870730B2 publication Critical patent/JP3870730B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Description

【0001】
【発明の属する技術分野】
本発明は、例えば、オペレーティング・システム(OS)に適用して好適なタスク管理システムに関するものである。
【0002】
【従来の技術】
従来から、タスクの応答時間の上限がデッドラインとなる規定値以下となることを保証しつつ、タスクの実行によって占有可能なプロセッサの時間の有効利用を高めることは、リアルタイムOSの重要な設計目標の一つであった。この設計目標を達成するために、より優れたディスパッチポリシを採用することが考えられる。
【0003】
このようなディスパッチポリシの一つとして、EDF(Earlist Deadline First)ポリシ(参照文献:C.L.Liu and J.W.Layland,“Scheduling alogorithms for multiprogramming in a hard real time environment,”Journal of ACM,Vol.20,No.1,pp.46−61,1973.)が知られている。EDFポリシは、デッドラインと周期が等しい周期タスクのスケジューリングを行う手法の中で、もっとも高いプロセッサ利用率を達成可能であることが知られている。ただし、タスク間の干渉がないことや、プロセッサ数が1であることなどの前提条件がある。
【0004】
一方、システムの安定した動作を実現するために、システムを複数のモジュールに分割し、それぞれを異なるアドレス空間内で実行することによって、互いに他のモジュールのデータを誤って破壊することがないようシステムを構成することが行われている。
【0005】
また、一般的には、各タスクは個々のモジュールの境界を超えることはできない。このように構成されたシステムにおいて、あるモジュールから他のモジュールの機能を利用することを可能とするために、異なるアドレス空間中の手続きを呼び出すための機構が提供されることが多い。
【0006】
ところが、この場合、サービスを利用しようとするたびにクライアントタスクとサーバタスクを停止または起動する処理が必要となる。サービスの提供に要する時間にもよるが、しばしば、この停止または起動に要する時間は全サービス時間に対して無視できない割合を占める。さらに、EDFポリシを採用したスケジューラは、従来のスケジューラに比べてオーバーヘッドが増大する傾向があるため、この問題がさらに悪化することが考えられる。
【0007】
さらに、サーバタスクの優先度変更に伴うオーバーヘッドの増大も考慮する必要がある。一般に、クライアントタスクの緊急性は様々であるため、サーバタスクはクライアントタスクと同一の優先度で依頼を処理することが望ましい。
【0008】
そこで、サービス依頼時にサーバタスクの優先度をクライアントタスクの優先度に合わせて変更することがしばしば行われている。この優先度変更または停止に伴うオーバーヘッドの発生が、サーバタスクおよびクライアントタスクの起動または停止に伴うオーバーヘッドに加わることになる。
【0009】
【発明が解決しようとする課題】
しかし、上述した従来のEDFポリシを採用したスケジューラは、従来のOSで広く使われている固定した優先度を用いる静的優先度スケジューラに比べ、オーバーヘッドが大きくなるという不都合があった。
【0010】
また、サービス依頼時にサーバタスクの優先度をクライアントタスクの優先度に合わせて変更する際に、この優先度変更または停止に伴うオーバーヘッドの発生が、サーバタスクおよびクライアントタスクの起動または停止に伴うオーバーヘッドに加わるため、一層オーバーヘッドが増大するという不都合があった。
【0011】
そこで、本発明は、かかる点に鑑みてなされたものであり、オーバーヘッドを減少させるために、ディスパッチキューを操作することなく、サーバタスクの起動または停止を行うことができ、また、ディスパッチキューを操作することなく、優先度を継承することができるタスク管理システムを提供することを課題とする。
【0012】
【課題を解決するための手段】
本発明のタスク管理システムは、単一のプロセッサによりタスクの管理を行うタスク管理システムにおいて、任意のタスクに関する情報のうち、タスクのスケジューリングに関係する情報を保持する第1のデータブロックと、第1のデータブロックに記録されていない情報を保持する第2のデータブロックと、実行可能なタスクの中から、もっとも優先度が高いものを選択するために設けられた第3のデータブロックと、他のモジュール内で動作しているタスクからのサービス依頼によって起動され、サービス依頼を処理するサーバタスクと、サーバタスクにサービス依頼を発行するクライアントタスクとを備えるものである。
【0013】
本発明のタスク管理システムは、特に、一つのタスクに関する情報を、第1のデータブロックと第2のデータブロックに分割して管理し、第1のデータブロックを第3のデータブロックへの挿入または削除の対象としており、サーバタスクは、それ自身の第1のデータブロックを持たない特別のタスクであり、サーバタスクとクライアントタスクの起動または終了、およびあるタスクの優先度を他のタスクが継承する際には、第1のデータブロックと第2のデータブロックの対応関係だけを変化させるようにしたものである。
【0014】
優先度継承プロトコルを採用した同時に二つのタスクの実行をできないようにするミューテックス(Mutex:MutualExclusion(相互排除))が、通常のミューテックスに比べ、オーバーヘッドが大きくなる理由の一つとして、優先度継承による優先度の変化が挙げられる。一般的に、タスクの優先度が変化した際には、ディスパッチキューに対して何らかの操作を行う必要がある。これは、操作に要するコストが大きいEDFスケジューラの場合に特に問題となる。
【0015】
この分割によって、両者の対応関係を変化させるだけでサーバタスクとクライアントタスクの起動または終了、優先度を継承させることが可能となる。これにより、クライアントタスクが停止したにも関わらず、第1のデータブロックのデータ構造内の位置関係は変化しておらず、第1のデータブロックの関係だけが変化する。
【0016】
また、起動前における第1のデータブロックから第2のデータブロックに対して、一つのポインタを示す現在有効な対応づけから、起動後における第1のデータブロックから第2のデータブロックに対して、一つのポインタを示す現在有効な対応づけに更新する操作だけで、移動と同等の処理が行われる。
【0017】
【発明の実施の形態】
本発明の実施の形態を以下に説明する。
本実施の形態のタスク管理システムは、例えば、クライアントタスクがサーバタスクにサービス依頼を行う際に、優先度の継承を効率的に実現するものである。
【0018】
【課題を解決するための手段】
本発明のタスク管理システムは、一つのプロセッサにより複数のタスクの管理を行うタスク管理システムにおいて、実行可能なタスクの中から、もっとも優先度が高いものを選択するために設けられたディスパッチキューと、他のモジュール内で動作しているタスクからのサービス依頼によって起動され、上記サービス依頼を処理するサーバタスクと、上記サーバタスクにサービス依頼を発行するクライアントタスクと、処理を待っているサービス依頼を記録するデータ構造であるサービス待ちキューとを備え、一つのタスクに関する情報を、少なくとも上記タスクの優先度情報を含む上記タスクのスケジューリングに関係する情報を保持するアクティビティ上記アクティビティに記録されていない情報を保持するコンテキストに分割して管理し、上記アクティビティを上記ディスパッチキューへの挿入または削除の対象としており、上記サーバタスクは、それ自身の上記アクティビティを持た、上記サーバタスクと上記クライアントタスクの起動または終了、およびあるタスクの優先度を他のタスクが継承する際には、上記ディスパッチキューおよび上記サービス待ちキューを用いて、上記アクティビティと上記コンテキストの対応関係だけを変化させることにより処理を行うようにしたものである。
【0019】
また、本発明のタスク管理方法は、一つのプロセッサにより複数のタスクの管理を行うタスク管理方法において、一つのタスクに関する情報を、少なくとも上記タスクの優先度情報を含む上記タスクのスケジューリングに関係する情報を保持するアクティビティと上記アクティビティに記録されていない情報を保持するコンテキストに分割して管理し、上記アクティビティを実行可能なタスクの中から、もっとも優先度が高いものを選択するために設けられたディスパッチキューへの挿入または削除の対象としており、他のモジュール内で動作しているタスクからのサービス依頼によって起動され、上記サービス依頼を処理するサーバタスクは、それ自身の上記アクティビティを持たず、上記サーバタスクと上記サーバタスクにサービス依頼を発行するクライアントタスクの起動または終了、およびあるタスクの優先度を他のタスクが継承する際には、上記ディスパッチキューおよび処理を待っているサービス依頼を記録するデータ構造であるサービス待ちキューを用いて、上記アクティビティと上記コンテキストの対応関係だけを変化させることにより処理を行うようにしたものである。
【0020】
この分割によって、コンテキスト(context)4とアクティビティ(activity)2の対応関係を変化させるだけで、サーバタスクの起動または終了、および優先度の継承が可能となる。
【0021】
図1において、ディスパッチキュー(dispatch_queue)1は、アクティビティ(activity)2に対して、優先度に基づくもっとも緊急な対応づけ(the_most_urgent_activity)D1を行っている。
【0022】
アクティビティ(activity)2は、自身に対して列の後者の対応づけ(successor)D2を行っている。優先度(priority)3はアクティビティ(activity)2に対して、列の前者の対応づけ(predecessor)D3を行っている。
【0023】
コンテキスト(context)4はアクティビティ(activity)2に対して、優先度(priority)3に関係しない本来の対応づけ(base_activity)D4を行っている。アクティビティ(activity)2はコンテキスト(context)4に対して、現在有効な対応づけ(effective_context)D5を行っている。
【0024】
コンテキスト(context)4はアクティビティ(activity)2に対して、現在有効な対応づけ(effective_activity)D6を行っている。
【0025】
サーバタスクが起動される前後で対応関係が変化する様子を図2に示す。
図2は、サーバ起動によるコンテキストおよびアクティビティの関係の変化を示す図である。図2は、図2Aに示す起動前から図2Bに示す起動後におけるサーバが起動される前後で、コンテキストおよびアクティビティの対応関係が変化する様子を表している。ここでは、キューイングの対象がアクティビティ(activity)であることと、後述するように実行可能でないアクティビティ(activity)もキューイングされることから、このデータ構造をディスパッチキュー(the dispatch_queue)と呼ぶ。
【0026】
図2から分かるように、クライアントタスク(client task)12が停止したにも関わらず、アクティビティ(activity)C14はディスパッチキュー(the dispatch_queue)11内の同一位置にとどまっており、アクティビティ(activity)C14とコンテキスト(context)S16、コンテキスト(context)C13の関係だけが変化している。
【0027】
複数のクライアント(client)がサービス(a_service)15を要求した場合も、サーバタスクの実行が中断されない限り、優先度継承によって常にサーバタスクの優先度が高くなることが保証される。そのため、ディスパッチャがそれらクライアントに対応するコンテキスト(context)をディスパッチ対象として選択する可能性はない。ゆえに、クライアントタスク(client task)12に対応づけられていたアクティビティ(activity)C14をディスパッチキュー(the_dispatch_queue)11から除去する必要はない。
【0028】
また、図2Aに示す起動前におけるアクティビティ(activity)C14からコンテキスト(context)C13に対して、一つのポインタを示す現在有効な対応づけ(effective_context)D1から、図2Bに示す起動後におけるアクティビティ(activity)C14からコンテキスト(context)S16に対して、現在有効な対応づけを示すポインタ(effective_context)D4に更新する操作だけで、移動と同等の処理が行われている。
【0029】
さらに、従来の技術に示した手法では、アクティビティ(activity)C14がディスパッチキュー(the_dispatch_queue)11から除去されていたのに対して、本実施の形態による手法では、アクティビティ(activity)C14はそのままディスパッチキュー(the_dispatch_queue)11に残される。この処理は、後述する遅延デキューイングによって、この省略が可能となる。
【0030】
ここで、両者の対応関係の変化の判断は、サービス(a_service)15のサーバーコンテキスト(server_context)に対応づけられるコンテキスト(context)S16が行い、この対応関係の変化を認識する。
【0031】
図2Aにおいて、アクティビティ(activity)C14はコンテキスト(context)C13に対して、現在有効な対応づけ(effective_context)D1を行っている。
【0032】
サービス(a_service)15はコンテキスト(context)S16に対して、サーバーコンテキスト(server_context)の対応づけD2を行っている。
【0033】
図2Bにおいて、アクティビティ(activity)14はコンテキスト(context)S16に対して、現在有効な対応づけ(effective_context)D4を行っている。
【0034】
サービス(a_service)15はコンテキスト(context)C13に対して、現在のサービスを記録する(in_service)対応づけD3を行っている。
【0035】
サービス(a_service)15はコンテキスト(context)S16に対して、サーバーコンテキスト(server_context)の対応づけD2を行っている。
【0036】
ここで、問題となるのは、サーバタスクの実行が中断されない限りという条件が満たせなくなる場合である。例えば、サーバタスクが入力処理(I/O)待ちなどによって停止した場合などがこれに該当する。
【0037】
この場合、このタスクに対応づけられていたクライアントタスク(client task)12のアクティビティ(activity)C14がディスパッチキュー(the dispatch_queue)11から除去される。
【0038】
その結果、後述する図3に示すように、本来ならばサービス完了を待って停止しているはずのクライアントタスク(client task)25のアクティビティ(activity)C2(27)がディスパッチ対象として選択される可能性がある。
【0039】
この問題を解決するために、サービス完了を待っているクライアントタスク(client task)12は、ディスパッチされた後に、サービス(a_service)15の実行が完了しているかどうかを検査する。もし、もし完了していなかったならば、自身に対応するアクティビティ(activity)C14をディスパッチキュー(the dispatch_queue)11から除去する。ここでは、このように、ディスパッチキュー(the dispatch_queue)11からアクティビティ(activity)C14を除去する処理を延期することを、遅延デキューイングと呼ぶ。
【0040】
図3は、サーバタスクの休眠による不適切なアクティビティの実行を示す図である。
図3において、サーバタスクが、サービス中に停止した場合、アクティビティ(activity)C1(24)がディスパッチキュー(the dispatch_queue)21から除去される。
【0041】
これによって、より低い優先度をもち、本来ならば実行されないはずの、アクティビティ(activity)C1(24)が選択される可能性がある。
【0042】
このとき、コンテキスト(context)C2(26)は、サービス終了後の処理を継続する状態になっている。
【0043】
したがって、サービスが終了していないにも関わらず、あたかもサービスが終了したかのように動作してしまうことになる。
【0044】
図3において、クライアントタスク(client task)22のコンテキスト(context)C1(23)は、サービス(a_service)31に対して、現在のサービスを記録する(in_service)対応づけD11を行っている。
【0045】
サービス(a_service)31は、コンテキスト(context)S32に対して、サーバーコンテキスト(server_context)の対応づけD12を行っている。
【0046】
クライアントタスク(client task)22のアクティビティ(activity)C1(24)は、コンテキスト(context)S32に対して、現在有効な対応づけ(effective_context)D13を行っている。
【0047】
サービス(a_service)31は、クライアントタスク(clienttask)25のコンテキスト(context)C2(26)に対して、並んで順番を待つ対応づけ(is_queued)D14を行っている。
【0048】
クライアントタスク(client task)25のアクティビティ(activity)C2(27)は、コンテキスト(context)C2(26)に対して、現在有効な対応づけ(effective_context)D15を行っている。
【0049】
サービス(a_service)31は、クライアントタスク(clienttask)28のコンテキスト(context)C3(29)に対して、並んで順番を待つ対応づけ(is_queued)D16を行っている。
【0050】
クライアントタスク(client task)28のアクティビティ(activity)C3(30)は、コンテキスト(context)C3(29)に対して、現在有効な対応づけ(effective_context)D17を行っている。
【0051】
図4は、サービス依頼機構の実現に関連するクラスとそれらの間の関連を示す図である。
図中のディスパッチキュー(dispatch_queue)31、アクティビティ(activity)32およびコンテキスト(context)34は上述した通りである。
【0052】
ここでは、その他の二つのクラスについて説明する。この二つのクラスは、それぞれ、以下の機能を有している。
【0053】
第1に、サービス(service)クラス37について説明する。
サービス(service)クラス37は、あるサービス(service)、一般的には、異なるアドレス空間から呼び出し可能な手続きを表現するクラスである。各サービス(service)には、一つのサーバタスクが対応づけられている。このサービス(service)クラス37のコンテキスト(context)34はサーバーコンテキスト(server_context)の対応づけD33によるポインタを介して参照可能である。このサービス(service)クラス37は、アプリケーションプログラムにより生成される。
【0054】
第2に、サービスリクエスト(service_request)クラス35について説明する。
サービスリクエスト(service_request)クラス35は、あるタスクによるサービス要求を表現するクラスである。クライアントタスク(client task)がサービスを要求してから、サーバタスクがサービスを提供を完了するまでの間、存在し続ける。
【0055】
属性のインヘリッティング(inheriting)36は、このサービス(service)要求の処理中に、サーバタスクへの優先度の継承が発生したときにツゥルー(true)、それ以外の場合にフォールス(false)となる。
【0056】
このサービスリクエスト(service_request)クラス35は、クライアントタスク(client task)のコンテキスト(context)により生成される。
【0057】
次に、オブジェクト間の関係を説明する。
これらのクラスは、それぞれ独立に動作するのではなく、図4に示されているように他のクラスのオブジェクトへの参照の対応づけとして、例えば、the_first_requestを保持している。これらの参照は、以下に挙げるデータ構造を構成するために必要とされている。
【0058】
第1に、サービス(service)待ちキューについて説明する。
サービス(service)依頼時にサーバタスクが依頼を処理中(in_service)、つまり、るサービスリクエスト(service_request)オブジェクトへのポインタが格納されている状態だった場合は、サーバタスクの実行が完了するまで待つことになる。サービス(service)待ちキューは、このようにして待つことになったサービス(service)要求を記録するデータ構造である。サービス(service)待ちキューは、サービスリクエスト(service_request)オブジェクト35を要素とする双方向リンクリストとして構成されている。
【0059】
サービス(service)オブジェクト37のファーストリクエストの対応づけ(the_first_request)D29が先頭の要素を指している。
【0060】
サービスリクエスト(service_request)オブジェクト35の列の後者の対応づけ(successor)D27は後続する要素35−1,35−2・・・へのポインタであり、列の前者の対応づけ(predecessor)D30は先行する要素35−1,35−2・・・へのポインタである。先頭の要素35の(predecessor)D30と末尾の要素35−nの(successor)D27は、それぞれ、どのオブジェクトも指さない特別なポインタ値を保持している。なお、C,C++言語で実装する際にはヌル(NULL)ポインタをこのために用いることが可能である。
【0061】
図4において、ディスパッチキュー(dispatch_queue)31は、アクティビティ(activity)32に対して、優先度に基づくもっとも緊急な対応づけ(the_most_urgent_activity)D21を行っている。
【0062】
アクティビティ(activity)32は、自身に対して列の後者の対応づけ(successor)D22を行っている。優先度(priority)33はアクティビティ(activity)32に対して、列の前者の対応づけ(predecessor)D23を行っている。
【0063】
コンテキスト(context)34はアクティビティ(activity)32に対して、優先度(priority)33に関係しない本来の対応づけ(base_activity)D24を行っている。アクティビティ(activity)32はコンテキスト(context)34に対して、現在有効な対応づけ(effective_context)D25を行っている。
【0064】
サービスリクエスト(service_request)クラス35は、コンテキスト(context)34に対して、コンテキストの対応づけ(the_context)D26を行っている。
【0065】
サービス(service)クラス37は、サービスリクエスト(service_request)クラス35に対して、ファーストリクエストの対応づけ(the_first_request)D29を行っている。
【0066】
サービスリクエスト(service_request)クラス35は、サービス(service)クラス37に対して、ウエイティングフォーの対応づけ(waiting_for)D28を行っている。
【0067】
サービスリクエスト(service_request)クラス35は、35−1,35−2・・・に対して、列の後者の対応づけ(successor)D27を行っている。サービスリクエスト(service_request)クラス35は、35−1,35−2・・・に対して、列の前者の対応づけ(predecessor)D30を行っている。
【0068】
サービスリクエスト(service_request)クラス35は、アクティビティ(activity)32に対して、リクエスティングアクティビティ(requesting_actibity)の対応づけD31を行っている。
【0069】
サービス(service)クラス37は、サービスリクエスト(service_request)クラス35に対して、サービス処理中(in_service)対応づけD32を行っている。
【0070】
サービス(service)クラス37は、コンテキスト(context)34に対して、サーバーコンテキスト(server_context)の対応づけD33を行っている。
【0071】
次に、サービス要求操作、サーバ処理手順を以下に説明する。
図5は、サービス要求手順の動作を示すフローチャートである。図5に示すサービス要求手順は、サービス(service)クラス37の動作を示すものである。各処理は、上述した図4に対応している。
【0072】
図5において、ステップS1で、サービスリクエスト(service_request)オブジェクト35を生成する。ステップS2で、サーバタスクはビジーであるか否かを判断する。ステップS2でサーバタスクがビジーであるときはステップS3へ進み、ステップS3で、サービス処理中(in_service)対応づけD32による、属性のインヘリッティング(inheriting)36により、このサービス(service)要求の処理中に、サーバタスクへの優先度の継承が発生したか否かを判断する。
【0073】
ステップS3でサーバタスクへの優先度の継承がされているときはステップS4へ進み、ステップS4で、ファーストリクエスト(the_first_request)D29に対応づけられたサービスリクエスト35からリクエスティングアクティビティ(requesting_actibity)D31でアクティビティ32に対応づけ、さらに、ファーストリクエスト(the_first_request)D29に対応づけられたサービスリクエスト35からコンテキスト(the_context)の対応づけD26でコンテキスト34に対応づけることにより、アクティビティ32とコンテキスト34の対応づけを行う。
【0074】
ステップS5でサービス(service)待ちキューの先頭に、生成したサービスリクエスト(service_request)オブジェクト35を挿入する。
【0075】
ステップS2でサーバタスクがビジーでないときはステップS6へ進み、ステップS6で、サービス処理中(in_service)対応づけD32により、生成したサービスリクエスト(service_request)オブジェクト35を参照するよう設定する。
【0076】
ステップS3でサーバタスクへの優先度の継承がされていないときはステップS7へ進み、ステップS7で、サービス処理中(in_service)D32に対応づけられたサービスリクエスト35からリクエスティングアクティビティ(requesting_actibity)D31でアクティビティ32に対応づけ、さらに、サービス処理中(in_service)D32に対応づけられたサービスリクエスト35からコンテキスト(the_context)の対応づけD26でコンテキスト34に対応づけることにより、アクティビティ32とコンテキスト34の対応づけを行う。
【0077】
具体的には、サービス要求時のアクティビティ(activity)を現在サービス中のクライアントコンテキストに対応づけする。
【0078】
ステップS8で、サービス処理中(in_service)対応づけD32による、属性のインヘリッティング(inheriting)36において、このサービス(service)要求の処理中に、サーバタスクへの優先度の継承が発生したことを示すツゥルー(true)にする。
【0079】
ステップS9で、現行アクティビティ(activity)32とサーバーコンテキスト(server_context)の対応づけD33を対応づける。具体的には、先頭クライアントのアクティビティ(activity)とサーバーコンテキスト(server_context)を対応づけする。
【0080】
ステップS10で、サーバーコンテキスト(server_context)の対応づけD33をディスパッチする。このとき、クライアントのコンテキストは保持されている。
【0081】
ステップS11で、サービス完了か否かを判断する。ステップS11でサービス完了のときは、直ちにサービス要求に成功する。
【0082】
ステップS11でサービス完了でないときは、ステップS12へ進み、ステップS12で、現行アクティビティ(activity)32を、ディスパッチキュー(dispatch_queue)31から除去する。具体的には、間違ったディスパッチの修正処理を行う。この処理は、図3に示したクライアントタスク(client task)25のアクティビティ(activity)C2(27)の除去に対応する。
【0083】
ステップS13で、再スケジューリングを行って、ステップS11へ戻って、ステップS11〜ステップS13までの判断および処理を繰り返す。具体的には、本来ディスパッチすべき相手をディスパッチするように処理する。
【0084】
図6は、サーバ処理手順の動作を示すフローチャートである。図6は、サーバコンテキストの動作を示すものである。
図6において、ステップS21で、サービスを実行する。
【0085】
ステップS22で、サービス処理中(in_service)対応づけD32による、属性のインヘリッティング(inheriting)36により、このサービス(service)要求の処理中に、サーバタスクへの優先度の継承が発生したか否かを判断する。
【0086】
ステップS22でサーバタスクへの優先度の継承が発生していないときは、ステップS23へ進み、ステップS23で、cをサービス処理中(in_service)対応づけD32によるコンテキストの対応づけ(the_context)D26とする。具体的には、現在サービスを提供しているクライアントのコンテキストに対応付けする。ステップS24で、待ちキューは空か否かを判断する。
【0087】
ステップS24で待ちキューが空でないときは、ステップS25へ進み、ステップS25で、サービス処理中(in_service)対応づけD32に待ちキューの先頭要素を代入する。
【0088】
ステップS26で、待ちキューの先頭要素を除去する。ステップS27で、サービス処理中(in_service)対応づけD32によるリクエスティングアクティビティ(requesting_actibity)の対応づけD31をされたアクティビティ(actibity)32は遅延デキューイング済みであるか否かを判断する。具体的には、待ちキューに並んでいる間に遅延デキューイングされているときの処理である。
【0089】
ステップS27で遅延デキューイング済みであるときはステップS28へ進み、ステップS27で遅延デキューイング済みでないときはステップS29へ進む。
【0090】
ステップS28で、サービス処理中(in_service)対応づけD32によるリクエスティングアクティビティ(requesting_actibity)の対応づけD31をされたアクティビティ(actibity)32を、ディスパッチキュー(dispatch_queue)31に挿入する。
【0091】
ステップS29で、サービス処理中(in_service)対応づけD32によるリクエスティングアクティビティ(requesting_actibity)の対応づけD31をされたアクティビティ(actibity)32を、サーバーコンテキスト(server_context)の対応づけD33に対応づける。
【0092】
ステップS30で、cをディスパッチして、ステップS21へ戻って、ステップS21〜ステップS30までの処理および判断を繰り返す。具体的には、以前サービス処理中(in_service)対応づけD32されていたクライアントをディスパッチする。このとき、以前のアクティビティに対応づけられたコンテキストをディスパッチする必要はない。
【0093】
ステップS22でサーバタスクへの優先度の継承が発生しているときは、ステップS31へ進み、ステップS31で、サービス処理中(in_service)対応づけD32によるリクエスティングアクティビティ(requesting_actibity)の対応づけD31をされたアクティビティ(actibity)32は遅延デキューイング済みであるか否かを判断する。
【0094】
ステップS31で遅延デキューイング済みであるときはステップS32へ進み、ステップS31で遅延デキューイング済みでないときはステップS33へ進む。
【0095】
ステップS32で、サービス処理中(in_service)対応づけD32によるリクエスティングアクティビティ(requesting_actibity)の対応づけD31をされたアクティビティ(actibity)32を、ディスパッチキュー(dispatch_queue)31に挿入する。
【0096】
具体的には、以前のアクティビティは、現行アクティビティよりも優先度の低いもので、サーバーコンテキストに対応づけされるものであるため、以前のアクティビティに対応づけられたコンテキストをディスパッチする必要はない。
【0097】
ステップS33で、サービス処理中(in_service)対応づけD32に待ちキューの先頭要素を代入する。このとき、現在のサービスを記録する(in_service)対応づけD32が先頭のサービスリクエストを指すようにする。
【0098】
ステップS34で、待ちキューの先頭要素を除去して、ステップS21へ戻って、ステップS21〜ステップS30までの処理および判断を繰り返す。このとき、サーバコンテキストは、先頭のサービスリクエストに対応づけられたアクティビティで動いていたことになる。
【0099】
ステップS24で待ちキューが空でのときは、ステップS35へ進み、ステップS35で、サービス処理中(in_service)対応づけD32にNULLを代入する。このとき、サーバはアイドリング中である。
【0100】
ステップS36で、cをディスパッチして、ステップS21へ戻って、ステップS21〜ステップS30までの処理および判断を繰り返す。図5に示したステップS10でサーバーコンテキスト(server_context)の対応づけD33をディスパッチしたときは、ステップS36でcをディスパッチしたところで、停止する。
【0101】
上述したように、システムの安定性を向上させるためには、システムを複数のモジュールに分割し、それぞれを異なるアドレス空間中で実行することが効果的である。
【0102】
また、異なるアドレス空間に存在しているモジュールにサービスを依頼するために、クライアントタスクのサービス依頼を受けてサーバタスクがサービスを実行する機構を提供することが行われている。
【0103】
また、このとき、クライアントタスクの緊急性に応じた処理が行えるよう、サーバタスクがクライアントタスクの優先度を継承するよう実装されることがしばしばある。
【0104】
一方、より高いプロセッサ利用率を達成するためには、EDFポリシを採用したスケジューラの利用が効果的である。ところが、EDFポリシを採用したスケジューラを用いた場合、タスクの起動または終了や、優先度の変更に伴うオーバーヘッドが従来手法に比べて増加する傾向がある。このため、サービス依頼機構の効率が低下するという問題があった。
【0105】
そこで、本実施の形態で提案した手法によれば、以下の最適化を可能とすることによって、EDFスケジューリングがもつディスパッチキュー(dispatch_queue)操作による高いオーバーヘッドという問題を回避することができる効果がある。
【0106】
第1に、ディスパッチキュー(dispatch_queue)を表現するデータ構造を操作することなく、サーバタスクを起動または終了する。これによって、EDFスケジューリングがもつディスパッチキュー(dispatch_queue)の操作による高いオーバーヘッドという問題を回避することができる。
【0107】
第2に、ディスパッチキュー(dispatch_queue)を表現するデータ構造を操作することなく、サーバタスクがクライアントタスクの優先度を継承することを可能とする。この結果、EDFスケジューリングと優先度継承を伴うサーバタスク起動に付随するオーバーヘッドの増加を抑えつつ、安定性の高いシステム構築と、より高いプロセッサ利用率の達成が可能となる。
【0108】
また、この手法を省電力リアルタイムスケジューリング手法と組み合わせることによって、より高い消費電力削減効果を得ることができる。
【0109】
【発明の効果】
この発明のタスク管理システムは、単一のプロセッサによりタスクの管理を行うタスク管理システムにおいて、任意のタスクに関する情報のうち、タスクのスケジューリングに関係する情報を保持する第1のデータブロックと、第1のデータブロックに記録されていない情報を保持する第2のデータブロックと、実行可能なタスクの中から、もっとも優先度が高いものを選択するために設けられた第3のデータブロックと、他のモジュール内で動作しているタスクからのサービス依頼によって起動され、サービス依頼を処理するサーバタスクと、サーバタスクにサービス依頼を発行するクライアントタスクとを備え、一つのタスクに関する情報を、第1のデータブロックと第2のデータブロックに分割して管理し、第1のデータブロックを第3のデータブロックへの挿入または削除の対象としており、サーバタスクは、それ自身の第1のデータブロックを持たない特別のタスクであり、サーバタスクとクライアントタスクの起動または終了、およびあるタスクの優先度を他のタスクが継承する際には、第1のデータブロックと第2のデータブロックの対応関係だけを変化させるようにしたので、第1に、第3のデータブロックを操作することなく、サーバタスクを起動または終了することによって、EFDスケジューリングがもつ第3のデータブロックの操作による高いオーバーヘッドという問題を回避することができる。
【0110】
第2に、第3のデータブロックを操作することなく、サーバタスクがクライアントタスクの優先度を継承することを可能とする。この結果、EDFスケジューリングと優先度継承を伴うサーバタスク起動に付随するオーバーヘッドの増加を抑えつつ、安定性の高いシステム構築と、より高いプロセッサ利用率を達成することができるという効果を奏する。
【0111】
また、この発明のタスク管理システムは、上述において、サーバタスクからのサービス依頼待ちのためにクライアントタスクが停止しても、即座に第3のデータブロックからクライアントタスクを削除することなく、誤って第3のデータブロックから選択されることがわかるまで、第3のデータブロックに対する操作を延期するので、クライアントタスクの停止・起動に伴う第3のデータブロックへの操作回数を低減させることができるという効果を奏する。
【図面の簡単な説明】
【図1】本実施の形態に適用されるコンテキストとアクティビティを示す図である。
【図2】サーバ起動によるコンテキストとアクティビティの関係の変化を示す図であり、図2Aは起動前、図2Bは起動後である。
【図3】サーバタスクの休眠による不適切なアクティビティの実行を示す図である。
【図4】サービス依頼機構の実現に関連するクラスとそれらの間の関連を示す図である。
【図5】サービス要求手順の動作を示すフローチャートである。
【図6】サーバ処理手順の動作を示すフローチャートである。
【符号の説明】
1……ディスパッチキュー(dispatch_queue)、2……アクティビティ(activity)、3……コンテキスト(context)、11……ディスパッチキュー(dispatch_queue)、12……クライアントタスク(client task)、13……コンテキスト(context)C、14……アクティビティ(activity)C、15……サービス(a_service)、16……コンテキスト(context)S、21……ディスパッチキュー(dispatch_queue)、22……クライアントタスク(client task)、23……コンテキスト(context)C1、24……アクティビティ(activity)C1、25……クライアントタスク(client task)、26……コンテキスト(context)C2、27……アクティビティ(activity)C2、28……クライアントタスク(client task)、29……コンテキスト(context)C3、30……アクティビティ(activity)C3、31……サービス(a_service)、32……コンテキスト(context)S、31……ディスパッチキュー(dispatch_queue)、32……アクティビティ(activity)、33……優先度(priority)、34……コンテキスト(context)、35……サービスリクエスト(service_request)クラス、36……インヘリッティング(inheriting)属性、37……サービス(service)クラス
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a task management system suitable for application to an operating system (OS), for example.
[0002]
[Prior art]
Conventionally, it has been an important design goal of a real-time OS to increase the effective use of processor time that can be occupied by task execution while ensuring that the upper limit of the response time of a task is below a specified value that becomes a deadline. It was one of. In order to achieve this design goal, it is conceivable to employ a better dispatch policy.
[0003]
As one of such dispatch policies, an EDF (Earlist Deadline First) policy (reference documents: CL Liu and JW Layland, “Scheduling algorithms in multi-programming in a harden- rent realtime,” Vol. 20, No. 1, pp. 46-61, 1973.) is known. The EDF policy is known to be able to achieve the highest processor utilization rate among the methods for scheduling periodic tasks having the same period as the deadline. However, there are preconditions such as no interference between tasks and the number of processors being one.
[0004]
On the other hand, in order to realize stable operation of the system, the system is divided into a plurality of modules, and each is executed in a different address space, so that the data of other modules is not accidentally destroyed. Has been made up.
[0005]
Also, in general, each task cannot cross individual module boundaries. In a system configured as described above, a mechanism for calling a procedure in a different address space is often provided in order to make it possible to use a function of another module from one module.
[0006]
However, in this case, it is necessary to stop or start the client task and the server task every time the service is used. Depending on the time it takes to provide the service, often the time taken to stop or start is a non-negligible percentage of the total service time. Furthermore, since the scheduler employing the EDF policy tends to increase overhead as compared with the conventional scheduler, this problem can be further exacerbated.
[0007]
Furthermore, it is necessary to consider an increase in overhead accompanying a change in server task priority. In general, since the urgency of client tasks varies, it is desirable that the server task processes requests with the same priority as the client task.
[0008]
Therefore, the server task priority is often changed in accordance with the client task priority at the time of service request. The occurrence of overhead associated with the priority change or stop adds to the overhead associated with the start or stop of the server task and the client task.
[0009]
[Problems to be solved by the invention]
However, the above-described scheduler employing the conventional EDF policy has a disadvantage that the overhead becomes larger than the static priority scheduler using a fixed priority widely used in the conventional OS.
[0010]
In addition, when changing the priority of a server task according to the priority of a client task at the time of a service request, the overhead that accompanies the change or stop of the priority becomes the overhead associated with the start or stop of the server task and the client task. In addition, there is a disadvantage that the overhead is further increased.
[0011]
Therefore, the present invention has been made in view of the above points, and in order to reduce overhead, it is possible to start or stop a server task without operating the dispatch queue, and to operate the dispatch queue. It is an object of the present invention to provide a task management system that can inherit the priority without having to do so.
[0012]
[Means for Solving the Problems]
The task management system of the present invention is a task management system that manages tasks by a single processor, and includes a first data block that holds information related to task scheduling among information related to an arbitrary task, A second data block for holding information not recorded in the data block, a third data block provided for selecting the highest priority among the executable tasks, and other data blocks. It is activated by a service request from a task operating in the module, and includes a server task that processes the service request and a client task that issues a service request to the server task.
[0013]
In particular, the task management system of the present invention divides and manages information related to one task into a first data block and a second data block, and inserts the first data block into the third data block or The server task is a special task that is subject to deletion and does not have its own first data block, and other tasks inherit the start or end of the server task and the client task, and the priority of a certain task. In this case, only the correspondence between the first data block and the second data block is changed.
[0014]
  Mutex: Mutual Exclusion (Mutex: Mutual Exclusion) that uses the priority inheritance protocol to prevent the execution of two tasks at the same time is due to priority inheritance as one of the reasons why the overhead is larger than a normal mutex. A change in priority can be mentioned. Generally, when the priority of a task changes, it is necessary to perform some operation on the dispatch queue. This is expensive to operateEDFThis is especially a problem for the scheduler.
[0015]
With this division, it is possible to inherit the activation or termination of the server task and the client task and the priority only by changing the correspondence between the two. Thereby, although the client task is stopped, the positional relationship in the data structure of the first data block is not changed, and only the relationship of the first data block is changed.
[0016]
Also, from the current effective association indicating one pointer to the second data block from the first data block before activation, from the first data block to the second data block after activation, A process equivalent to movement is performed only by an operation for updating to a currently valid association indicating one pointer.
[0017]
DETAILED DESCRIPTION OF THE INVENTION
Embodiments of the present invention will be described below.
The task management system of the present embodiment efficiently realizes priority inheritance when a client task makes a service request to a server task, for example.
[0018]
[Means for Solving the Problems]
  The task management system of the present inventionOneDepending on the processorpluralIn the task management system that manages tasks, it is provided to select the highest priority task that can be executed.Dispatch queueAnd a server task that is activated by a service request from a task operating in another module and processes the service request, a client task that issues a service request to the server task,Service wait queue, which is a data structure that records service requests waiting to be processedWith information about one task,Activity that holds information related to scheduling of the task including at least priority information of the taskWhenContext holding information not recorded in the above activityDivided and managed as aboveactivityThe aboveDispatch queueThe above server task is subject to its own insertion or deletion.Activity aboveHaveZWhen other tasks inherit the start or end of the server task and the client task and the priority of a task,Using the dispatch queue and the service waiting queue,the aboveactivityAnd abovecontextChange only the correspondence ofProcess byIt is what I did.
[0019]
  In addition, the present inventionTask management methodIsIn a task management method for managing a plurality of tasks by a single processor, information relating to one task is recorded in an activity holding at least information related to scheduling of the task including priority information of the task and the activity. It is divided into contexts that hold information that is not managed, and the above activities are subject to insertion or deletion to the dispatch queue provided to select the highest priority task that can be executed. A server task that is started by a service request from a task running in another module and processes the service request does not have its own activity, and issues a service request to the server task and the server task. A client task Alternatively, when another task inherits the termination and priority of a task, the activity and the context are used by using the dispatch queue and a service wait queue that is a data structure for recording a service request waiting for processing. The processing is done by changing only the correspondence ofIs.
[0020]
By this division, the server task can be started or terminated and the priority can be inherited only by changing the correspondence relationship between the context 4 and the activity 2.
[0021]
In FIG. 1, the dispatch queue (dispatch_queue) 1 performs the most urgent association (the_most_urgent_activity) D1 based on the priority with respect to the activity (activity) 2.
[0022]
Activity 2 is performing the latter successor D2 of the column to itself. The priority (priority) 3 performs the former predecessor D3 of the column for the activity (activity) 2.
[0023]
The context 4 performs an original association (base_activity) D4 that is not related to the priority 3 with respect to the activity 2. The activity 2 performs a currently valid association (effective_context) D5 with respect to the context 4.
[0024]
The context 4 performs an association (effective_activity) D <b> 6 that is currently valid for the activity 2.
[0025]
FIG. 2 shows how the correspondence changes before and after the server task is activated.
FIG. 2 is a diagram illustrating changes in the relationship between contexts and activities due to server activation. FIG. 2 shows a state in which the correspondence between contexts and activities changes before and after the activation of the server shown in FIG. 2B from before activation shown in FIG. 2A. Here, since the object of queuing is an activity, and an activity that cannot be executed is queued as will be described later, this data structure is called a dispatch queue (the dispatch_queue).
[0026]
As can be seen from FIG. 2, the activity C14 remains in the same position in the dispatch queue 11 even though the client task 12 is stopped, and the activity C14 is the same as the activity C14. Only the relationship between the context S16 and the context C13 has changed.
[0027]
Even when a plurality of clients (clients) request the service (a_service) 15, it is guaranteed that the priority of the server task is always increased by priority inheritance unless the execution of the server task is interrupted. Therefore, there is no possibility that the dispatcher selects a context corresponding to these clients as a dispatch target. Therefore, it is not necessary to remove the activity C14 associated with the client task 12 from the dispatch queue 11 (the_dispatch_queue) 11.
[0028]
  Also, from the activity (activity) C14 before activation shown in FIG. 2A to the context (context) C13, from the current effective association (effective_context) D1 indicating one pointer, the activity (activity) after activation shown in FIG. 2B is displayed. ) From C14 to context S16,Pointer to the currently valid mapping(Effective_context) Processing equivalent to movement is performed only by an operation of updating to D4.
[0029]
  Further, in the technique shown in the conventional technique, the activity C14 is sent to the dispatch queue (the)._In the method according to the present embodiment, the activity C14 is not changed from the dispatch queue (the)._(dispatch_queue) 11 is left. This process can be omitted by delay dequeuing described later.
[0030]
Here, the change in the correspondence between the two is determined by the context S16 associated with the server context (server_context) of the service (a_service) 15, and the change in the correspondence is recognized.
[0031]
In FIG. 2A, an activity C14 performs a currently valid association (effective_context) D1 with respect to a context C13.
[0032]
The service (a_service) 15 performs an association D2 of the server context (server_context) with respect to the context (context) S16.
[0033]
In FIG. 2B, the activity 14 performs an effective association (effective_context) D4 for the context S16.
[0034]
The service (a_service) 15 performs an association D3 that records the current service (in_service) for the context C13.
[0035]
The service (a_service) 15 performs an association D2 of the server context (server_context) with respect to the context (context) S16.
[0036]
Here, a problem arises when the condition that the execution of the server task is not interrupted cannot be satisfied. For example, this is the case when the server task is stopped due to waiting for input processing (I / O) or the like.
[0037]
In this case, the activity C14 of the client task (client task) 12 associated with this task is removed from the dispatch queue (the dispatch_queue) 11.
[0038]
As a result, as shown in FIG. 3 to be described later, the activity (activity) C2 (27) of the client task (client task) 25 that should have stopped after waiting for service completion can be selected as a dispatch target. There is sex.
[0039]
In order to solve this problem, the client task (client task) 12 waiting for service completion checks whether the execution of the service (a_service) 15 is completed after being dispatched. If it has not been completed, the activity C14 corresponding to itself is removed from the dispatch queue (the dispatch_queue) 11. Here, postponing the process of removing the activity C14 from the dispatch queue (the dispatch_queue) 11 in this way is referred to as delay dequeuing.
[0040]
FIG. 3 is a diagram illustrating the execution of an inappropriate activity due to the sleep of the server task.
In FIG. 3, when the server task is stopped during service, the activity C 1 (24) is removed from the dispatch queue (the dispatch_queue) 21.
[0041]
This may select an activity C1 (24) that has a lower priority and would otherwise not be executed.
[0042]
At this time, the context C2 (26) is in a state of continuing the processing after the service ends.
[0043]
Therefore, even if the service has not ended, it behaves as if the service has ended.
[0044]
In FIG. 3, a context (context) C1 (23) of a client task (client task) 22 performs an association D11 that records the current service (in_service) for the service (a_service) 31.
[0045]
The service (a_service) 31 performs an association D12 of the server context (server_context) to the context (context) S32.
[0046]
The activity (activity) C1 (24) of the client task (client task) 22 performs a currently valid association (effective_context) D13 with respect to the context (context) S32.
[0047]
The service (a_service) 31 performs a correspondence (is_queued) D14 that waits in line for the context (context) C2 (26) of the client task (clienttask) 25.
[0048]
The activity (activity) C2 (27) of the client task (client task) 25 performs a currently valid association (effective_context) D15 with respect to the context (context) C2 (26).
[0049]
The service (a_service) 31 performs a correspondence (is_queued) D16 that waits in turn for the context (context) C3 (29) of the client task (clienttask) 28.
[0050]
The activity (activity) C3 (30) of the client task (client task) 28 performs an association (effective_context) D17 that is currently valid for the context (context) C3 (29).
[0051]
FIG. 4 is a diagram showing classes related to the realization of the service request mechanism and the relationship between them.
The dispatch queue (dispatch_queue) 31, the activity (activity) 32, and the context (context) 34 in the figure are as described above.
[0052]
Here, the other two classes will be described. Each of these two classes has the following functions.
[0053]
First, the service class 37 will be described.
The service class 37 is a class that represents a certain service, generally a procedure that can be called from different address spaces. Each service (service) is associated with one server task. The context 34 of the service class 37 can be referred to via a pointer by the association D33 of the server context (server_context). The service class 37 is generated by an application program.
[0054]
Second, the service request (service_request) class 35 will be described.
The service request (service_request) class 35 represents a service request by a certain task. The client task (client task) continues to exist from when the service is requested until the server task completes providing the service.
[0055]
The attribute inheriting 36 is set to true when inheritance of priority to the server task occurs during processing of the service request, and false otherwise. Become.
[0056]
The service request (service_request) class 35 is generated by the context of the client task (client task).
[0057]
Next, the relationship between objects will be described.
These classes do not operate independently, but hold the_first_request, for example, as an association of references to objects of other classes as shown in FIG. These references are needed to construct the data structures listed below.
[0058]
  First, the service waiting queue will be described.
  A server task requests a serviceProcessing (in_service)That is,AhIf a pointer to the service request (service_request) object is stored, the server task waits until the execution of the server task is completed. The service wait queue is a data structure that records a service request that has been waited in this way. The service waiting queue is configured as a bidirectional link list having a service request (service_request) object 35 as an element.
[0059]
The first request association (the_first_request) D29 of the service object 37 indicates the top element.
[0060]
The latter association (successor) D27 of the column of the service request (service_request) object 35 is a pointer to the subsequent elements 35-1, 35-2,..., And the former association (predecessor) D30 of the column is the preceding. Is a pointer to the elements 35-1, 35-2,. The (predecessor) D30 of the first element 35 and the (successor) D27 of the last element 35-n respectively hold special pointer values that do not point to any object. Note that a null pointer can be used for this purpose when implemented in the C, C ++ language.
[0061]
In FIG. 4, the dispatch queue (dispatch_queue) 31 performs the most urgent association (the_most_urgent_activity) D21 based on the priority with respect to the activity (activity) 32.
[0062]
The activity 32 performs the latter successor D22 of the column to itself. The priority 33 performs the former predecessor D23 in the column for the activity 32.
[0063]
The context 34 performs an original association (base_activity) D24 that is not related to the priority 33 with respect to the activity 32. The activity 32 performs an association (effective_context) D <b> 25 that is currently valid for the context 34.
[0064]
The service request (service_request) class 35 associates a context (the_text) D26 with the context (context) 34.
[0065]
The service class 37 performs first request association (the_first_request) D29 with respect to the service request (service_request) class 35.
[0066]
The service request (service_request) class 35 performs a waiting-for association (waiting_for) D28 with respect to the service (service) class 37.
[0067]
The service request (service_request) class 35 performs the latter successor D27 in the column for 35-1, 35-2,. The service request (service_request) class 35 performs the former predecessor D30 of the column for 35-1, 35-2.
[0068]
The service request (service_request) class 35 performs an association D31 of a requesting activity (requesting_activity) to the activity (activity) 32.
[0069]
  The service class 37 is in response to the service request (service_request) class 35.Processing service(In_service) Correlation D32 is performed.
[0070]
The service class 37 performs an association D33 of a server context (server_context) with a context (context) 34.
[0071]
Next, service request operations and server processing procedures will be described below.
FIG. 5 is a flowchart showing the operation of the service request procedure. The service request procedure shown in FIG. 5 shows the operation of the service class 37. Each process corresponds to FIG. 4 described above.
[0072]
  In FIG. 5, in step S1, a service request (service_request) object 35 is generated. In step S2, it is determined whether the server task is busy. When the server task is busy in step S2, the process proceeds to step S3. In step S3,Processing serviceBased on the attribute inheriting 36 by the (in_service) association D32, it is determined whether or not the inheritance of the priority to the server task has occurred during the processing of the service request.
[0073]
  If the priority is inherited to the server task in step S3, the process proceeds to step S4. In step S4, the first request(The_first_request) From the service request 35 associated with D29Requesting activity (requesting_activity) D31In association with activity 32,First request(The_first_request) From the service request 35 associated with D29contextThe activity 32 and the context 34 are associated with each other by associating the context 34 with the correspondence D26 of (the_context).
[0074]
In step S5, the generated service request (service_request) object 35 is inserted at the head of the service waiting queue.
[0075]
  If the server task is not busy in step S2, the process proceeds to step S6. In step S6,Processing service(In_service) The association D32 is set to refer to the generated service request (service_request) object 35.
[0076]
  When the priority is not inherited to the server task in step S3, the process proceeds to step S7. In step S7,Processing service(In_service) D32From service request 35 associated withRequesting activity (requesting_activity) D31Is associated with activity 32, and service processing is in progress(In_service) D32From service request 35 associated withcontextThe activity 32 and the context 34 are associated with each other by associating the context 34 with the correspondence D26 of (the_context).
[0077]
Specifically, an activity at the time of service request is associated with a client context currently in service.
[0078]
  In step S8,Processing service(In_service) In the attribute inheriting 36 based on the association D32, a true indicating that the inheritance of the priority to the server task has occurred during the processing of the service request is made. .
[0079]
In step S9, the association D33 between the current activity (activity) 32 and the server context (server_context) is associated. Specifically, the activity (activity) of the head client is associated with the server context (server_context).
[0080]
In step S10, the server context (server_text) association D33 is dispatched. At this time, the client context is retained.
[0081]
In step S11, it is determined whether or not the service is completed. When the service is completed in step S11, the service request is immediately successful.
[0082]
If the service is not completed in step S11, the process proceeds to step S12. In step S12, the current activity 32 is removed from the dispatch queue (dispatch_queue) 31. Specifically, correct dispatch correction processing is performed. This processing corresponds to the removal of the activity C2 (27) of the client task (client task) 25 shown in FIG.
[0083]
In step S13, rescheduling is performed, the process returns to step S11, and the determination and processing from step S11 to step S13 are repeated. Specifically, processing is performed so as to dispatch the other party that should originally be dispatched.
[0084]
FIG. 6 is a flowchart showing the operation of the server processing procedure. FIG. 6 shows the operation of the server context.
In FIG. 6, the service is executed in step S21.
[0085]
  In step S22,Processing serviceBased on the attribute inheriting 36 by the (in_service) association D32, it is determined whether or not the inheritance of the priority to the server task has occurred during the processing of the service request.
[0086]
  When the priority inheritance to the server task does not occur in step S22, the process proceeds to step S23, and c is set in step S23.Processing service(In_service) Associating the context with the association D32 (the_context) D26. Specifically, it is associated with the context of the client that currently provides the service. In step S24, it is determined whether the waiting queue is empty.
[0087]
  When the waiting queue is not empty in step S24, the process proceeds to step S25, and in step S25,Processing service(In_service) The head element of the waiting queue is assigned to the association D32.
[0088]
  In step S26, the head element of the waiting queue is removed. In step S27,Processing serviceCorrespondence D31 of requesting activity (requesting_activity) by (in_service) mapping D32Activity 32Determines whether it has been delayed dequeued. Specifically, this is processing when delayed dequeuing is performed while queued.
[0089]
If the delay dequeue has been completed in step S27, the process proceeds to step S28. If the delay dequeue has not been completed in step S27, the process proceeds to step S29.
[0090]
  In step S28,Processing serviceCorrespondence D31 of requesting activity (requesting_activity) by (in_service) mapping D32Activity 32Is inserted into the dispatch queue (dispatch_queue) 31.
[0091]
  In step S29,Processing serviceCorrespondence D31 of requesting activity (requesting_activity) by (in_service) mapping D32Activity 32Is associated with the association D33 of the server context (server_context).
[0092]
  In step S30, c is dispatched, the process returns to step S21, and the processes and determinations from step S21 to step S30 are repeated. Specifically, beforeProcessing service(In_service) The client that has been associated D32 is dispatched. At this time, the previous activityThe context associated withThere is no need to dispatch.
[0093]
  When the priority inheritance to the server task occurs in step S22, the process proceeds to step S31, and in step S31,Processing serviceCorrespondence D31 of requesting activity (requesting_activity) by (in_service) mapping D32Activity 32Determines whether it has been delayed dequeued.
[0094]
If the delay dequeue has been completed in step S31, the process proceeds to step S32. If the delay dequeue has not been completed in step S31, the process proceeds to step S33.
[0095]
  In step S32,Processing serviceCorrespondence D31 of requesting activity (requesting_activity) by (in_service) mapping D32Activity 32Is inserted into the dispatch queue (dispatch_queue) 31.
[0096]
  Specifically, the previous activity has a lower priority than the current activity and is associated with the server context, so the previous activityThe context associated withThere is no need to dispatch.
[0097]
  In step S33,Processing service(In_service) The head element of the waiting queue is assigned to the association D32. At this time, the association D32 that records the current service (in_service) is set to indicate the first service request.
[0098]
In step S34, the head element of the waiting queue is removed, the process returns to step S21, and the processes and determinations from step S21 to step S30 are repeated. At this time, the server context has been moved by the activity associated with the first service request.
[0099]
  When the waiting queue is empty in step S24, the process proceeds to step S35, and in step S35,Processing service(In_service) Assign NULL to the association D32. At this time, the server is idling.
[0100]
In step S36, c is dispatched, the process returns to step S21, and the processes and determinations from step S21 to step S30 are repeated. When the server context (server_context) mapping D33 is dispatched in step S10 shown in FIG. 5, it stops when c is dispatched in step S36.
[0101]
As described above, in order to improve the stability of the system, it is effective to divide the system into a plurality of modules and execute them in different address spaces.
[0102]
In addition, in order to request a service to a module existing in a different address space, a mechanism is provided in which a server task executes a service in response to a client task service request.
[0103]
At this time, the server task is often implemented so as to inherit the priority of the client task so that processing according to the urgency of the client task can be performed.
[0104]
On the other hand, in order to achieve a higher processor utilization rate, it is effective to use a scheduler that employs an EDF policy. However, when a scheduler that employs an EDF policy is used, the overhead associated with task activation or termination and priority change tends to increase compared to the conventional method. For this reason, there has been a problem that the efficiency of the service request mechanism decreases.
[0105]
Therefore, according to the technique proposed in the present embodiment, the following optimization can be performed, which has an effect of avoiding the problem of high overhead due to dispatch queue (dispatch_queue) operation of EDF scheduling.
[0106]
First, the server task is started or terminated without manipulating the data structure representing the dispatch queue (dispatch_queue). As a result, the problem of high overhead due to the dispatch queue (dispatch_queue) operation of EDF scheduling can be avoided.
[0107]
Second, the server task can inherit the priority of the client task without manipulating the data structure representing the dispatch queue (dispatch_queue). As a result, it is possible to construct a highly stable system and achieve a higher processor utilization rate while suppressing an increase in overhead associated with server task activation accompanying EDF scheduling and priority inheritance.
[0108]
Further, by combining this method with a power saving real-time scheduling method, a higher power consumption reduction effect can be obtained.
[0109]
【The invention's effect】
The task management system according to the present invention is a task management system that manages tasks by a single processor, and includes a first data block that holds information related to task scheduling out of information related to an arbitrary task; A second data block for holding information not recorded in the data block, a third data block provided for selecting the highest priority among the executable tasks, and other data blocks. A server task that is activated by a service request from a task operating in a module and processes the service request, and a client task that issues a service request to the server task. Divided into a block and a second data block and managed, and the first data block is The server task is a special task that does not have its own first data block, the start or end of the server task and the client task, and the priority of a certain task. When another task inherits, since only the correspondence between the first data block and the second data block is changed, first, the server is operated without operating the third data block. By starting or ending a task, it is possible to avoid the problem of high overhead due to the operation of the third data block of EFD scheduling.
[0110]
Second, it allows the server task to inherit the priority of the client task without manipulating the third data block. As a result, it is possible to achieve a highly stable system construction and a higher processor utilization rate while suppressing an increase in overhead associated with server task activation involving EDF scheduling and priority inheritance.
[0111]
In the task management system of the present invention, even if the client task is stopped due to waiting for a service request from the server task in the above, the client task is erroneously deleted without immediately deleting the client task from the third data block. Since the operation on the third data block is postponed until it is found that the data is selected from the three data blocks, the number of operations on the third data block associated with the stop / start of the client task can be reduced. Play.
[Brief description of the drawings]
FIG. 1 is a diagram showing contexts and activities applied to the present embodiment.
FIG. 2 is a diagram illustrating a change in a relationship between a context and an activity due to server activation. FIG. 2A is before activation, and FIG. 2B is after activation.
FIG. 3 is a diagram illustrating execution of an inappropriate activity due to a sleep of a server task.
FIG. 4 is a diagram showing classes related to the realization of the service request mechanism and the relationship between them.
FIG. 5 is a flowchart showing an operation of a service request procedure.
FIG. 6 is a flowchart showing an operation of a server processing procedure.
[Explanation of symbols]
DESCRIPTION OF SYMBOLS 1 ... Dispatch queue (dispatch_queue), 2 ... Activity (activity), 3 ... Context (context), 11 ... Dispatch queue (dispatch_queue), 12 ... Client task (client task), 13 ... Context (context) ) C, 14 ... activity C, 15 ... service (a_service), 16 ... context (context) S, 21 ... dispatch queue (dispatch_queue), 22 ... client task (client task), 23 ... ... Context C1, 24 ... Activity C1, 25 ... Client task (client) task), 26... Context C2, 27... Activity C2, 28... Client task (client task), 29... Context C3, 30. …… Service (a_service), 32 …… Context (context) S, 31 …… Dispatch queue (dispatch_queue), 32 …… Activity, 33 …… Priority (priority), 34 …… Context (context), 35 …… Service request class, 36 …… Inheriting attribute, 37 …… Service (service) e) Class

Claims (4)

一つのプロセッサにより複数のタスクの管理を行うタスク管理システムにおいて、
実行可能なタスクの中から、もっとも優先度が高いものを選択するために設けられたディスパッチキューと、
他のモジュール内で動作しているタスクからのサービス依頼によって起動され、上記サービス依頼を処理するサーバタスクと、
上記サーバタスクにサービス依頼を発行するクライアントタスクと、
処理を待っているサービス依頼を記録するデータ構造であるサービス待ちキュー
を備え、
一つのタスクに関する情報を、少なくとも上記タスクの優先度情報を含む上記タスクのスケジューリングに関係する情報を保持するアクティビティ上記アクティビティに記録されていない情報を保持するコンテキストに分割して管理し、
上記アクティビティを上記ディスパッチキューへの挿入または削除の対象としており、
上記サーバタスクは、それ自身の上記アクティビティを持た
上記サーバタスクと上記クライアントタスクの起動または終了、およびあるタスクの優先度を他のタスクが継承する際には、上記ディスパッチキューおよび上記サービス待ちキューを用いて、上記アクティビティと上記コンテキストの対応関係だけを変化させることにより処理を行うようにしたことを特徴とするタスク管理システム。
In a task management system that manages multiple tasks with one processor,
A dispatch queue provided to select the highest priority task that can be executed;
A server task that is activated by a service request from a task operating in another module and processes the service request;
A client task that issues a service request to the server task, and
A service waiting queue that is a data structure for recording service requests waiting to be processed ;
Information related to one task is divided and managed into an activity holding information related to scheduling of the task including at least priority information of the task and a context holding information not recorded in the activity ,
The above activity is the target of insertion or deletion to the dispatch queue ,
The server task does not have its own activity ,
When other servers inherit the start or end of the server task and the client task, and the priority of a task, only the correspondence between the activity and the context using the dispatch queue and the service waiting queue A task management system characterized in that processing is performed by changing.
請求項1記載のタスク管理システムにおいて、
上記サーバタスクからのサービス依頼待ちのために上記クライアントタスクが停止しても、即座に上記ディスパッチキューから上記クライアントタスクを削除することなく、上記ディスパッチキューに対する操作を延期することを特徴とするタスク管理システム。
The task management system according to claim 1,
Even if the client task stopped for service request waiting from the server task immediately without deleting the client task from the dispatch queue, task management, characterized by postponing operations on the dispatch queue system.
一つのプロセッサにより複数のタスクの管理を行うタスク管理方法において、In a task management method for managing a plurality of tasks by one processor,
一つのタスクに関する情報を、少なくとも上記タスクの優先度情報を含む上記タスクのスケジューリングに関係する情報を保持するアクティビティと上記アクティビティに記録されていない情報を保持するコンテキストに分割して管理し、Information related to one task is divided into an activity holding information related to scheduling of the task including at least priority information of the task and a context holding information not recorded in the activity, and managed.
上記アクティビティを実行可能なタスクの中から、もっとも優先度が高いものを選択するために設けられたディスパッチキューへの挿入または削除の対象としており、Among the tasks that can execute the above activities, the task with the highest priority is selected for insertion or deletion into the dispatch queue.
他のモジュール内で動作しているタスクからのサービス依頼によって起動され、上記サービス依頼を処理するサーバタスクは、それ自身の上記アクティビティを持たず、A server task that is started by a service request from a task operating in another module and processes the service request does not have its own activity.
上記サーバタスクと上記サーバタスクにサービス依頼を発行するクライアントタスクの起動または終了、およびあるタスクの優先度を他のタスクが継承する際には、上記ディスパッチキューおよび処理を待っているサービス依頼を記録するデータ構造であるサービス待ちキューを用いて、上記アクティビティと上記コンテキストの対応関係だけを変化させることにより処理を行うようにしたことを特徴とするタスク管理方法。When starting or ending a client task that issues a service request to the server task and the server task, and when another task inherits the priority of a task, record the service request waiting for the dispatch queue and processing A task management method characterized in that processing is performed by changing only the correspondence between the activity and the context using a service waiting queue that is a data structure to be processed.
請求項3記載のタスク管理方法において、The task management method according to claim 3,
上記サーバタスクからのサービス依頼待ちのために上記クライアントタスクが停止しても、即座に上記ディスパッチキューから上記クライアントタスクを削除することなく、上記ディスパッチキューに対する操作を延期することを特徴とするタスク管理方法。Task management characterized in that even if the client task is stopped due to waiting for a service request from the server task, the operation on the dispatch queue is postponed without immediately deleting the client task from the dispatch queue. Method.
JP2001206814A 2001-07-04 2001-07-06 Task management system Expired - Fee Related JP3870730B2 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2001206814A JP3870730B2 (en) 2001-07-06 2001-07-06 Task management system
US10/190,203 US7302686B2 (en) 2001-07-04 2002-07-03 Task management system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2001206814A JP3870730B2 (en) 2001-07-06 2001-07-06 Task management system

Publications (2)

Publication Number Publication Date
JP2003022193A JP2003022193A (en) 2003-01-24
JP3870730B2 true JP3870730B2 (en) 2007-01-24

Family

ID=19042891

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2001206814A Expired - Fee Related JP3870730B2 (en) 2001-07-04 2001-07-06 Task management system

Country Status (1)

Country Link
JP (1) JP3870730B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113360260B (en) * 2021-06-01 2023-03-14 上海安吉星信息服务有限公司 Vehicle data acquisition method and system, storage medium and server

Also Published As

Publication number Publication date
JP2003022193A (en) 2003-01-24

Similar Documents

Publication Publication Date Title
US7302686B2 (en) Task management system
US7441240B2 (en) Process scheduling apparatus, process scheduling method, program for process scheduling, and storage medium recording a program for process scheduling
US8245207B1 (en) Technique for dynamically restricting thread concurrency without rewriting thread code
US7316017B1 (en) System and method for allocatiing communications to processors and rescheduling processes in a multiprocessor system
EP2097815B1 (en) Method and system for transaction resource control
JP3987384B2 (en) Run queue management
US20090165003A1 (en) System and method for allocating communications to processors and rescheduling processes in a multiprocessor system
US20140068624A1 (en) Quota-based resource management
US8881161B1 (en) Operating system with hardware-enabled task manager for offloading CPU task scheduling
JP2561801B2 (en) Method and system for managing process scheduling
US7681196B2 (en) Providing optimal number of threads to applications performing multi-tasking using threads
US20120054769A1 (en) Dividing a computer job into micro-jobs
JP2013500526A (en) Apparatus and method for handling events in a telecommunications network
CN113282395A (en) Redis-based job request scheduling method, device, equipment and medium
JP3034873B2 (en) Information processing device
JP3870730B2 (en) Task management system
JP2004030567A (en) Method and system for maintaining queue
JP3245500B2 (en) Event management method in multi-programming
US20160026504A1 (en) Asynchronous dispatcher for application framework
JP2001236236A (en) Task controller and its task scheduling method
JPS62284437A (en) Task control system
JP3601677B2 (en) Task processing system
JP3870729B2 (en) Task management system
JP2001022601A (en) Job execution control method and parallel computer system
JP5390947B2 (en) Job management system, job management apparatus and program thereof

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20060220

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20060307

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20060421

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: 20060926

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20061009

LAPS Cancellation because of no payment of annual fees