JP2001236236A - Task controller and its task scheduling method - Google Patents

Task controller and its task scheduling method

Info

Publication number
JP2001236236A
JP2001236236A JP2000049125A JP2000049125A JP2001236236A JP 2001236236 A JP2001236236 A JP 2001236236A JP 2000049125 A JP2000049125 A JP 2000049125A JP 2000049125 A JP2000049125 A JP 2000049125A JP 2001236236 A JP2001236236 A JP 2001236236A
Authority
JP
Japan
Prior art keywords
task
execution
time
switching
cycle time
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2000049125A
Other languages
Japanese (ja)
Inventor
Yuji Fujiwara
雄治 藤原
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.)
Renesas Micro Systems Co Ltd
Original Assignee
Renesas Micro Systems Co Ltd
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 Renesas Micro Systems Co Ltd filed Critical Renesas Micro Systems Co Ltd
Priority to JP2000049125A priority Critical patent/JP2001236236A/en
Publication of JP2001236236A publication Critical patent/JP2001236236A/en
Pending legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To reduce task switching frequency, and to reduce the generation of dead line violation in a real time OS for scheduling a fixed cycle task to be repeatedly executed in each fixed time interval. SOLUTION: A start task deciding part 11 is newly provided with a task start excess time comparing means 16. Whether or not the start of the execution of a task whose execution priority index is large can be delayed is judged by the task start excess time comparing means 16 without unconditionally switching a task even when a task whose priority index is large is requested, and when it is possible, the execution of the task whose execution priority index is small which is being executed at present is continued, and the early end of the task whose priority index is small is realized. Thus, it is possible to reduce the number of times of task switching being the factor of the generation of the overhead of the executing time, and to reduce dead line violation which is likely to be generated in the task whose priority index is small.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、タスク制御装置お
よびそのタスクスケジューリング方法に関し、特に、リ
アルタイムOSにおいて周期的に実行される定周期タス
クを効率よく実行できるタスク制御装置およびそのタス
クスケジューリング方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a task control device and a task scheduling method thereof, and more particularly, to a task control device and a task scheduling method capable of efficiently executing a periodic task periodically executed in a real-time OS.

【0002】[0002]

【従来の技術】近年、CPU処理能力の向上とともに、
リアルタイムOSで複数のタスクを同時に実行させると
いう要求が強まってきた。複数のタスクを同時に実行し
ようとした場合、すべてのタスクを限られた時間内で処
理する必要がある。時間内に処理できなかったときには
デッドライン違反となり、例えば音声再生のタスクの場
合ではノイズの発生として現れる。デッドライン違反が
発生する要因として、第1には、タスクの実行順序が効
率的でないために処理が間に合わなくなることが上げら
れ、第2には、タスク切り替えに伴うオーバヘッド時間
は大きいためにタスク切り替えの発生回数が多くなるほ
どオーバヘッド時間が大きくなってタスクに割り当てら
れる実行時間が少なくなってしまうことが上げられる。
2. Description of the Related Art In recent years, with the improvement of CPU processing capability,
There has been an increasing demand for real-time OS to execute a plurality of tasks simultaneously. When trying to execute a plurality of tasks at the same time, all the tasks need to be processed within a limited time. If the processing cannot be performed within the time, the deadline is violated. For example, in the case of a task of sound reproduction, it appears as generation of noise. The first cause of the deadline violation is that processing cannot be performed in time due to the inefficient execution order of tasks, and secondly, task switching occurs because the overhead time involved in task switching is large. As the number of occurrences of the task increases, the overhead time increases and the execution time assigned to the task decreases.

【0003】図8は、従来のタスク制御装置の構成図で
ある。タスク制御装置80は、所定の時間毎に発生する
割り込み毎に起動タスクの決定を制御する起動タスク決
定部81とタスクの実行を制御するタスク実行部82と
周期的に実行するタスクの情報を保持するタスク情報テ
ーブル83とを有している。起動タスク決定部81は、
新たなタスクの実行要求があるかを調べる実行要求確認
手段84と優先度指標であるタスクの周期時間を比較し
て最も短いタスクを最優先とするタスク優先度比較手段
85とを備えている。タスク実行部82は、実行中のタ
スクがない場合に新たに実行要求のあったタスクを実行
する新タスク実行手段87と、実行中のタスクを中断し
別タスクを実行するタスク切替手段88と、中断中のタ
スクの実行を再開する中断タスク再開手段89とを備え
ている。実行要求確認手段86からの指示により、タス
ク実行部82のどの手段が起動するかが決定される。
FIG. 8 is a configuration diagram of a conventional task control device. The task control device 80 holds information on a task to be periodically executed, and a task execution unit 82 for controlling the execution of a task and a task execution unit 82 for controlling the execution of a task for each interrupt generated at a predetermined time interval. And a task information table 83. The activation task determining unit 81
An execution request confirmation unit 84 for checking whether there is a new task execution request and a task priority comparison unit 85 for comparing the cycle time of a task as a priority index and giving the shortest task the highest priority are provided. The task execution unit 82 includes a new task execution unit 87 that executes a task that has been newly requested to execute when there is no task being executed, a task switching unit 88 that interrupts the task being executed and executes another task, A suspended task resuming means 89 for resuming the execution of the suspended task. An instruction from the execution request confirmation unit 86 determines which unit of the task execution unit 82 is activated.

【0004】図9は、タスク情報テーブルの格納データ
を示す図である。タスクTID1〜TIDnに対して周
期時間T1〜Tn、カウンタのカウント値C1〜Cnの
それぞれが格納される。
FIG. 9 shows data stored in a task information table. The cycle times T1 to Tn and the count values C1 to Cn of the counter are stored for the tasks TID1 to TIDn, respectively.

【0005】図10は、従来のタスク制御装置における
起動タスク決定処理のフロー図である。所定の時間毎に
発生する割り込みを受けてステップ101でタスク情報
テーブル83のカウンタのカウント値Cを“1”減算
し、ステップ102でカウント値が“0”未満のカウン
タがあるかを調べ、ステップ103で“0”未満のカウ
ンタをもつタスクのうちで最も周期時間が短いタスクを
切替実行候補タスクTSKとする。ステップ104で現
在タスクを実行継続中である場合には、ステップ105
で実行中のタスクの周期時間と切替実行候補タスクTS
Kの周期時間とを比較する。TSKの周期時間の方が小
さいときには、ステップ106でそれまで実行中のタス
クに換えて切替実行候補タスクTSKを実行する。
FIG. 10 is a flow chart of a start task determination process in a conventional task control device. Upon receiving an interrupt generated at predetermined time intervals, the count value C of the counter in the task information table 83 is decremented by "1" in step 101, and it is checked in step 102 whether there is a counter whose count value is less than "0". The task having the shortest cycle time among the tasks having the counter less than “0” in 103 is set as the switching execution candidate task TSK. If the task is currently being executed in step 104, step 105
Cycle time of the task being executed by the switch and the switching execution candidate task TS
Compare with the cycle time of K. When the cycle time of the TSK is shorter, the switching execution candidate task TSK is executed in step 106 in place of the task that has been executed.

【0006】図11(a)〜(d)は、図8、図10の
従来例による二つの定周期タスクのスケジューリング過
程を示す図である。割り込み発生の周期が1msであ
り、タスクTID1、タスクTID2の周期時間T1、
T2が図9のタスク情報テーブル83に表される値であ
るとすれば、タスクTID1が先行して実行される(図
11(a))。時刻2msにタスクTID1の実行が終
了した後にタスクTID2の実行が開始される(図11
(b))。時刻5msに再度タスクTID1の実行要求
を受けると、切替実行候補タスクTSKをタスクTID
1としてその周期時間T1とタスクTID2の周期時間
T2とを比較した結果タスクTID1が優先と判断され
るので、タスクTID2の実行は中断され、タスクTI
D1が切替実行される。ところが、時刻7msにタスク
TID1の実行が終了し、中断していたタスクTID2
を再実行しようとすると、タスクTID2すでに実行要
求から7msの時間が経過しており、タスクTID2に
デッドライン違反が発生してしまう。この例では、時刻
35msまで追跡した図11(d)において、タスク切
替が16回実行され、デッドライン違反が1回発生して
いる。
FIGS. 11 (a) to 11 (d) are diagrams showing a scheduling process of two fixed-period tasks according to the conventional example of FIGS. 8 and 10. FIG. The cycle of the interrupt occurrence is 1 ms, and the cycle time T1 of the task TID1 and the task TID2,
Assuming that T2 is a value represented in the task information table 83 of FIG. 9, the task TID1 is executed in advance (FIG. 11A). After the execution of task TID1 ends at time 2 ms, the execution of task TID2 starts (FIG. 11).
(B)). When the execution request of the task TID1 is received again at time 5 ms, the switching execution candidate task TSK is set to the task TID.
As a result of comparing the cycle time T1 with the cycle time T2 of the task TID2 as 1, the task TID1 is determined to have priority, so the execution of the task TID2 is interrupted and the task TI
D1 is switched. However, the execution of the task TID1 ends at time 7 ms, and the suspended task TID2
When the task TID2 is re-executed, the task TID2 has already passed for 7 ms from the execution request, and a deadline violation occurs in the task TID2. In this example, in FIG. 11D traced until time 35 ms, the task switching is performed 16 times, and the deadline violation occurs once.

【0007】[0007]

【発明が解決しようとする課題】このように、従来は、
周期時間による優先順位のみにしたがって実行するタス
クを決定していたので、タスクの切替が多く発生すると
ともに、効率的ではないタスク切替も発生してしまうた
めに、デッドライン違反が生じやすいという問題点があ
った。いかにデッドライン違反を起こさないようにタス
クを実行するかということと、リアルタイムOSのオー
バヘッド時間を削減するかということがタスクスケジュ
ーリングの重要課題となっている。タスク切替頻度が大
であると切替に要するオーバーヘッド時間がタスクの実
行時間を圧迫し、予想した実行時間では実際にはタスク
が終了せずに予期しないデッドライン違反を引き起こ
す。
As described above, conventionally,
Since the tasks to be executed are determined only according to the priority based on the cycle time, the task switching frequently occurs, and the inefficient task switching occurs, so that a deadline violation is likely to occur. was there. How to execute a task so as not to cause a deadline violation and how to reduce the overhead time of a real-time OS are important tasks in task scheduling. If the task switching frequency is high, the overhead time required for the switching reduces the execution time of the task, and the expected execution time does not actually end the task, causing an unexpected deadline violation.

【0008】本発明の目的は、以上の問題点を解決し
て、タスクの切替を効率的に行い、切替頻度も低減でき
るので、デッドライン違反の発生を抑制することのでき
るリアルタイムOSのタスク制御装置およびタスクスケ
ジューリング方法を提供することである。
SUMMARY OF THE INVENTION An object of the present invention is to solve the above problems, efficiently switch tasks, and reduce the switching frequency, so that the task control of a real-time OS capable of suppressing the occurrence of a deadline violation can be achieved. An apparatus and a task scheduling method are provided.

【0009】[0009]

【課題を解決するための手段】本発明のタスク制御装置
は、周期的に実行要求される複数の定周期タスクの実行
順序を制御するタスク制御装置において、所定の割り込
み周期時間毎に発生する割り込みに応答して動作し、実
行要求があり実行待ちのタスクのうち最も優先度指標が
大きいタスクである切替実行候補タスクの優先度指標が
現在実行中のタスクの優先度指標よりも大きいときには
前記切替実行候補タスクの実行開始を次の割り込み発生
予定時刻まで遅延させた場合に周期時間内でタスクが終
了しないデッドライン違反が発生するかを前記切替実行
候補タスクの実行要求の周期時間と実行要求が発生して
からの経過時間を示すカウント値とタスクの実行に必要
な実行時間または実行要求発生時刻から実行開始を遅ら
せうる限度時刻までの時間を表す起動余裕時間のいずれ
か一方とに基づいて判定し、デッドライン違反が発生す
ると判定したときには前記現在実行中のタスクの実行を
中断して前記切替実行候補タスクの実行を開始し、デッ
ドライン違反が発生しないと判定したときには前記現在
実行中のタスクの実行を継続するものである。
An object of the present invention is to provide a task control device for controlling the execution order of a plurality of fixed-period tasks periodically requested to be executed. The switching is performed when the priority index of the switching execution candidate task, which is the task having the highest priority index among tasks waiting for execution and having an execution request, is greater than the priority index of the currently executing task. If the execution start of the execution candidate task is delayed until the next interrupt occurrence scheduled time, whether the deadline violation in which the task does not end within the cycle time occurs or not is determined by the cycle time of the execution request of the switching execution candidate task and the execution request. From the count value indicating the elapsed time since the occurrence and the execution time required to execute the task or the execution request generation time to the limit time that can delay the execution start Determined based on any one of the start allowance time representing the time of, when it is determined that a deadline violation occurs, interrupt the execution of the currently executing task and start execution of the switching execution candidate task, When it is determined that the deadline violation does not occur, the execution of the currently executed task is continued.

【0010】本発明の制御装置のタスクスケジューリン
グ方法は、周期的に実行要求される複数の定周期タスク
の実行順序をこれら複数のタスクの情報を保持するタス
ク情報テーブルを参照しながらスケジューリングするタ
スク制御装置のタスクスケジューリング方法において、
タスクスケジューリング開始に先立って予め前記タスク
情報テーブルに前記複数のタスクそれぞれの実行要求の
周期時間と実行要求が発生してからの経過時間を示すカ
ウンタのカウント値と実行要求発生時刻から実行開始を
遅らせうる限度時刻までを表す起動余裕時間とを登録す
る初期設定処理と、所定の割り込み周期時間毎に発生す
る割り込みを受けて前記タスク情報テーブル登録されて
いる各タスクのカウント値を1だけ減算して更新する第
1のステップと、カウント値が0未満のタスクが存在す
るか否かを調べカウント値が0未満のタスクが存在しな
いときには現在時刻で実行すべきタスクは無いと判定し
て処理を終了し、前記カウント値が0未満のタスクが存
在した場合には次ステップに進む第2のステップと、カ
ウント値が0未満のタスクのうち最も周期時間の短いタ
スクを切替実行候補タスクとして選択し格納する第3の
ステップと、実行中のタスクがあるかを判定し実行中の
タスクが存在した場合には次ステップに進む第4のステ
ップと、現在実行中のタスクの周期時間と前記切替実行
候補タスクの周期時間とを比較し前記現在実行中のタス
クの周期時間が短いときには前記現在実行中のタスクを
継続実行することとして処理を終了し、前記現在実行中
のタスクの周期時間が長いときには次ステップに進む第
5のステップと、前記切替実行候補タスクのカウント値
に(−1)を乗じて得られる第1の値が前記切替実行候
補タスクの起動余裕時間を前記割り込み周期時間で除し
て得られる第2の値と等しいかまたはこれより小さいと
きには処理を終了し、前記第1の値が前記第2の値より
も大きいときには次ステップへ進む第6のステップと、
前記現在実行中のタスクを中断し前記切替実行候補タス
クへ切り替えて実行開始し終了する第7のステップと、
前記第4のステップで実行中のタスクがない場合に前記
切替実行候補タスクの実行を開始して終了する第8のス
テップとを含む起動タスク決定処理とを有している。第
6のステップを、切替実行候補タスクの周期時間を割り
込み周期時間で除して得られる値に前記切替実行候補タ
スクのカウント値を加えて得られる第3の値が切替実行
候補タスクの実行時間を前記割り込み周期時間で除して
得られる第4の値と等しいかまたはこれより大きいとき
には処理を終了し、前記第3の値が前記第4の値よりも
小さいときには次ステップへ進むとしてもよい。
In the task scheduling method of the control device according to the present invention, the task control for scheduling the execution order of a plurality of fixed-period tasks periodically requested by referring to a task information table holding information of the plurality of tasks. In the apparatus task scheduling method,
Prior to the start of task scheduling, the start of execution is delayed from the count value of a counter indicating the cycle time of the execution request of each of the plurality of tasks and the elapsed time since the execution request was generated and the execution request generation time in the task information table in advance. An initial setting process for registering a start allowance time indicating up to a time limit, and an interrupt generated at every predetermined interrupt cycle time, and subtracting one from the count value of each task registered in the task information table. The first step to be updated and whether or not there is a task whose count value is less than 0 is checked, and if there is no task whose count value is less than 0, it is determined that there is no task to be executed at the current time, and the processing ends. If there is a task whose count value is less than 0, the second step proceeds to the next step, and the count value is less than 0. A third step of selecting and storing a task having the shortest cycle time as a switching execution candidate task among tasks, and a step of determining whether there is a task being executed and proceeding to the next step if there is a task being executed. Step 4 and comparing the cycle time of the currently executing task with the cycle time of the switching execution candidate task, and when the cycle time of the currently executing task is short, continue executing the currently executing task. When the process is completed and the cycle time of the currently executing task is long, the fifth step proceeds to the next step, and the first value obtained by multiplying the count value of the switching execution candidate task by (−1) is: The processing is terminated when the activation margin time of the switching execution candidate task is equal to or smaller than a second value obtained by dividing by the interruption cycle time, and the first value A sixth step proceeds to the next step when greater than said second value,
A seventh step of interrupting the currently executing task, switching to the switching execution candidate task, starting execution and ending,
An activation task determination process including an eighth step of starting and ending the execution of the switching execution candidate task when there is no task being executed in the fourth step. In the sixth step, a third value obtained by adding a count value of the switching execution candidate task to a value obtained by dividing a cycle time of the switching execution candidate task by an interruption cycle time is an execution time of the switching execution candidate task. May be terminated when the value is equal to or greater than a fourth value obtained by dividing by the interrupt cycle time, and when the third value is smaller than the fourth value, the process may proceed to the next step. .

【0011】[0011]

【発明の実施の形態】本発明のタスク制御装置は、所定
の割り込み周期時間毎に発生する割り込みに応答して動
作する。タスクの実行要求があると、実行待ちのタスク
のうちで最も優先度指標の大きいタスクを切替実行候補
タスクとして選択する。切替実行候補タスクの優先度指
標が現在実行中のタスクの優先度指標よりも大きいとき
には、切替実行候補タスクの実行開始を次の割り込み発
生予定時刻まで遅延させた場合に周期時間内でタスクが
終了しないデッドライン違反が発生するか否かを、切替
実行候補タスクの実行要求の周期時間と実行要求が発生
してからの経過時間を示すカウント値とタスクの実行に
必要な実行時間または実行要求発生時刻から実行開始を
遅らせうる限度時刻までの時間を表す起動余裕時間のい
ずれか一方とに基づいて判定する。デッドライン違反が
発生すると判定したときには、前記現在実行中のタスク
の実行を中断して切替実行候補タスクの実行を開始し、
デッドライン違反が発生しないと判定したときには、現
在実行中のタスクの実行を継続する。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS A task control device according to the present invention operates in response to an interrupt generated every predetermined interrupt cycle time. When there is a task execution request, a task having the highest priority index among tasks waiting to be executed is selected as a switching execution candidate task. When the priority index of the switch execution candidate task is higher than the priority index of the currently executing task, the task ends within the cycle time if the execution start of the switch execution candidate task is delayed until the next interrupt occurrence scheduled time Whether or not a deadline violation occurs is determined by the cycle time of the execution request of the switching execution candidate task and the count value indicating the elapsed time since the execution request was generated, and the execution time or execution request required to execute the task The determination is made based on any one of the activation allowance times indicating the time from the time to the limit time at which the execution start can be delayed. When it is determined that a deadline violation occurs, the execution of the currently executing task is interrupted and the execution of the switching execution candidate task is started,
When it is determined that the deadline violation does not occur, the execution of the currently executing task is continued.

【0012】本発明では、優先度指標の大きいタスク要
求に対して従来例のように無条件なタスク切り替えを行
うことはなく、優先度指標の大きいタスクの実行開始を
次の割り込み発生時まで遅延させることが可能な場合に
は、現在実行中のタスクの実行を継続することにより、
タスク切替の回数を低減し、優先度指標の小さいタスク
で発生しやすいデッドライン違反を低減する。
According to the present invention, unconditional task switching is not performed for a task request having a large priority index as in the prior art, and execution of a task having a large priority index is delayed until the next interrupt occurs. Where possible, by continuing to execute the currently running task,
The number of times of task switching is reduced, and the deadline violation that is likely to occur in a task with a small priority index is reduced.

【0013】次に、本発明の実施の形態について詳細に
説明する。図1は、本発明のタスク制御装置の構成図で
ある。
Next, an embodiment of the present invention will be described in detail. FIG. 1 is a configuration diagram of the task control device of the present invention.

【0014】リアルタイムOSにおける定周期タスクス
ケジューリングの制御を行う本発明のタスク制御装置1
0は、割り込みが発生する毎に起動すべきタスクの決定
を制御する起動タスク決定部11と、起動タスク決定部
11で決定された起動タスクを実行するタスク実行部1
2と、周期的に実行するタスクの情報を保持するタスク
情報テーブル13とを有している。
The task control device 1 of the present invention for controlling the periodic task scheduling in the real-time OS
0 is a start task determining unit 11 that controls the determination of a task to be started every time an interrupt occurs, and a task executing unit 1 that executes the start task determined by the start task determining unit 11
2 and a task information table 13 for holding information on tasks to be executed periodically.

【0015】タスク情報テーブル13には、複数のタス
クそれぞれの実行要求の周期時間Tと所定割り込み周期
時間毎に発生する割り込み毎に1減算しタスクの実行が
終了したときに周期時間Tを前記所定時間で除した値を
加算するカウンタのカウント値Cとタスクの実行に必要
な実行時間Eまたは実行要求発生時刻から実行開始を遅
らせうる限度時刻までの時間を表す起動余裕時間Sの少
なくとも一方とを保持する。
In the task information table 13, the cycle time T of the execution request of each of the plurality of tasks and one for each interrupt generated at every predetermined interrupt cycle time are decremented. The count value C of the counter for adding the value divided by the time and at least one of the execution time E necessary for executing the task or the activation allowance time S representing the time from the execution request generation time to the limit time at which the execution start can be delayed. Hold.

【0016】起動タスク決定部11は、新たなタスクの
実行要求があるか否かを調べる実行要求確認手段14
と、複数タスクの実行要求があるときにタスク情報テー
ブルを参照してそれぞれのタスクの優先度指標を比較し
最も優先度指標の大きいタスクを切替実行候補タスクT
SKとして選択するタスク優先度比較手段15と、切替
実行候補タスクTSKの優先度指標が現在実行中のタス
クの優先度指標よりも大きいときには切替実行候補タス
クTSKの実行開始を次の割り込み発生予定時刻まで遅
延させた場合に周期時間内でタスクが終了しないデッド
ライン違反が発生するか否かをタスク情報テーブル13
内の切替実行候補タスクTSKに指定されたタスクのデ
ータに基づいて判定するタスク起動余裕時間比較手段1
6とを備えている。
The start task determining unit 11 checks whether there is a new task execution request or not.
And when there is a request for execution of a plurality of tasks, the task information table is referred to and the priority indices of the respective tasks are compared, and the task having the highest priority index is selected as the switching execution candidate task T
The task priority comparing means 15 to be selected as the SK, and when the priority index of the switching execution candidate task TSK is larger than the priority index of the currently executing task, the execution start of the switching execution candidate task TSK is set to the next interrupt occurrence scheduled time. The task information table 13 determines whether or not a deadline violation in which the task does not end within the periodic time when the delay is
Task start margin comparing means 1 for determining based on the data of the task designated as the switching execution candidate task TSK
6 is provided.

【0017】優先度指標として従来例と同様に実行要求
の周期時間Tの短さを規定する場合には、タスク優先度
比較手段15は、タスク情報テーブルを参照して複数の
タスクのそれぞれの周期時間を比較し最も周期時間の短
いタスクを優先順位が最も高い切替実行候補タスクTS
Kとして選択する。
In the case where the shortage of the cycle time T of the execution request is defined as the priority index as in the conventional example, the task priority comparing means 15 refers to the task information table and sets the respective cycles of the plurality of tasks. Comparing the times, the task with the shortest cycle time is the switching execution candidate task TS with the highest priority
Select as K.

【0018】タスク実行部12は、実行中のタスクがな
いときには新たに実行要求のあったタスクを新規に実行
する新タスク実行手段17と、起動余裕時間比較手段1
6で切替実行候補タスクTSKの実行開始を遅延させた
場合にはデッドライン違反が発生すると判定されたとき
に現在実行中のタスクを中断して切替実行候補タスクT
SKを実行するタスク切替手段18と、起動タスク決定
部11での起動タスク決定処理または現在実行タスクの
実行終了待ちにより中断中であったタスクの実行を再開
する中断タスク再開手段19とを備えている。
The task execution unit 12 includes a new task execution unit 17 for newly executing a task requested to be newly executed when there is no task being executed, and a start margin time comparison unit 1.
In the case where the execution start of the switching execution candidate task TSK is delayed in step 6, when it is determined that a deadline violation occurs, the currently executing task is interrupted and the switching execution candidate task T
A task switching unit for executing the SK; and an interrupted task resuming unit for resuming the execution of the task that has been interrupted by the activation task determination process in the activation task determination unit or waiting for the end of the execution of the currently executed task. I have.

【0019】図2は、本発明のタスク制御装置の一実施
例におけるタスク情報テーブル13のデータ構造図であ
り、タスク毎にタスクの識別名であるタスクTID、周
期時間T、カウンタのカウンタ値C、起動余裕時間Sが
対応して格納される。
FIG. 2 is a data structure diagram of the task information table 13 in one embodiment of the task control device of the present invention. The task TID, which is the identification name of the task, the period time T, and the counter value C , The start allowance time S is stored correspondingly.

【0020】図3は、本発明の一実施例における起動タ
スク決定処理のフロー図である。以下に図1,図2を参
照しながら図3にしたがって本実施例の動作について詳
細に説明する。
FIG. 3 is a flowchart of the activation task determination processing in one embodiment of the present invention. Hereinafter, the operation of the present embodiment will be described in detail with reference to FIG. 3 while referring to FIGS.

【0021】タスクスケジューリング開始に先立って予
めタスク情報テーブル13に複数のタスクそれぞれの実
行要求の周期時間Tと実行要求が発生してからの経過時
間を示すカウンタのカウント値Cと実行要求発生時刻か
ら実行開始を遅らせうる限度時刻までを表す起動余裕時
間Sとを登録する初期設定しておく。また割り込みは1
ms毎に発生するように設定されているものとして説明
する。
Prior to the start of task scheduling, the task information table 13 previously stores the execution request cycle time T, the counter value C indicating the elapsed time since the execution request was generated, and the execution request generation time. Initial setting for registering a start allowance time S indicating up to a limit time at which the start of execution can be delayed. The interrupt is 1
Description will be made assuming that the setting is made every ms.

【0022】1ms毎に発生する割り込みを受けて、ま
ずステップ31で、タスク情報テーブル13に登録され
ている各タスクTID1〜TIDnのそれぞれのカウン
タのカウント値C1〜Cnを“1”減算して更新する。
In response to an interrupt generated every 1 ms, first, in step 31, the count values C1 to Cn of the counters of the tasks TID1 to TIDn registered in the task information table 13 are updated by subtracting "1" from the count values. I do.

【0023】次に、ステップ32で、カウント値が
“0”未満のタスクが存在するか否かを調べる。カウン
ト値が“0”未満のタスクが存在しないときには、現在
時刻で実行すべきタスクは無いと判定し、タスク実行に
関する処理は行わずに処理を終了する。存在した場合に
はステップ33に進む。
Next, in step 32, it is checked whether or not there is a task whose count value is less than "0". When there is no task whose count value is less than “0”, it is determined that there is no task to be executed at the current time, and the process ends without performing the process related to the task execution. If there is, go to step 33.

【0024】ステップ33では、“0”未満のカウント
値を持つタスクのうち優先度指数のもっとも高いタスク
すなわち最も周期時間の短いタスクを切替実行候補タス
クTSKとして選択し格納する。
In step 33, the task having the highest priority index, that is, the task having the shortest cycle time, among the tasks having the count value less than "0" is selected and stored as the switching execution candidate task TSK.

【0025】次に、ステップ34で、現在時刻にタスク
を実行中であるか否かを調べる。実行中のタスクがない
場合には、ステップ38に進む。実行中のタスクが存在
した場合には、ステップ35に進む。
Next, at step 34, it is checked whether or not the task is being executed at the current time. If there is no task being executed, the process proceeds to step 38. If there is a task being executed, the process proceeds to step 35.

【0026】ステップ35では、実行中のタスクの周期
時間と切替実行候補タスクTSKとして格納されている
タスクの周期時間とを比較する。実行中のタスクの周期
時間が短いときすなわち優先度指標が大きいときには、
無条件に実行中のタスクを継続実行することとし、タス
クの切り替え処理を行わずに処理を終了する。実行中の
タスクの周期時間が長いときすなわち優先度指標が小さ
いときには、ステップ36に進む。
In step 35, the cycle time of the task being executed is compared with the cycle time of the task stored as the switching execution candidate task TSK. When the cycle time of the running task is short, that is, when the priority index is large,
The task being executed is unconditionally continued, and the process ends without performing the task switching process. When the cycle time of the task being executed is long, that is, when the priority index is small, the process proceeds to step S36.

【0027】ステップ36では、切替実行候補タスクT
SKとして格納されているタスクの実行開始を次の割り
込み予定時刻まで遅延させることができるか否かを調べ
る。具体的には、切替実行候補タスクTSKとして格納
されているタスクについて、起動余裕時間Sと(−1)
×(カウント値C)とを比較する。起動余裕時間が大き
いかまたは等しい場合には、切替実行候補タスクTSK
として格納されているタスクの実行開始を次の割り込み
予定時刻まで遅延させることが可能と判断して切り替え
処理を行わずに処理は終了する。起動余裕時間が小さい
場合には、遅延不可能と判断してステップ37へ進む。
In step 36, the switching execution candidate task T
It is determined whether the execution of the task stored as SK can be delayed until the next scheduled interrupt time. Specifically, for the task stored as the switching execution candidate task TSK, the activation margin time S and (−1)
× (count value C). If the starting margin time is large or equal, the switching execution candidate task TSK
It is determined that it is possible to delay the execution start of the task stored as "" until the next scheduled interrupt time, and the process ends without performing the switching process. If the start-up margin time is short, it is determined that delay is impossible, and the process proceeds to step S37.

【0028】ステップ37では、現在実行中のタスクを
中断し、切替実行候補タスクTSKとして格納されてい
るタスクへの切り替え処理を行って終了する。
In step 37, the currently executing task is interrupted, the process is switched to the task stored as the switch execution candidate task TSK, and the process ends.

【0029】ステップ34で実行中のタスクがなくステ
ップ38に進んだ場合には、ステップ38で、切替実行
候補タスクTSKとして登録されたタスクの実行を開始
して終了する。
If there is no task being executed in step 34 and the process proceeds to step 38, in step 38 the execution of the task registered as the switching execution candidate task TSK is started and ended.

【0030】なお、実行中のタスクが全処理の実行を終
了したときには、タスク情報テーブル103内の実行が
終了したタスクのカウンタのカウント値に周期時間の値
を加算してカウント値を更新する。
When the task being executed has completed execution of all processes, the count value is updated by adding the value of the period time to the count value of the counter of the task in the task information table 103 for which execution has been completed.

【0031】割り込み発生が1ms毎であるとして説明
したが、割り込み発生の周期時間がmのときには、ステ
ップ36で起動余裕時間に代えて((起動余裕時間)/
m)を用いて判定すればよい。
Although it has been described that the interrupt is generated every 1 ms, if the cycle time of the interrupt is m, in step 36, instead of the start allowance, ((start allowance)) /
m) may be used for the determination.

【0032】以上説明したステップ31〜ステップ38
の処理フローをタスクスケジューリング中に所定の時間
間隔で発生する割り込み毎に行うことにより、現在実行
中のタスクより優先順位の高いタスクの実行要求がある
場合でも、無条件にタスク切り替え処理を行わず、タス
ク実行要求のあったタスクの実行開始時間を次の割り込
み開始予定時刻まで遅延可能なときには切り替えを行わ
ずに現在実行中のタスクの実行を継続させるので、非効
率的な切替を抑制して切替回数を低減することができ、
デッドライン違反の発生を低減することができる。
Steps 31 to 38 described above
Is performed for each interrupt that occurs at a predetermined time interval during task scheduling, so that even if there is an execution request for a task with a higher priority than the currently executing task, task switching processing is not performed unconditionally. When the execution start time of the task requested to be executed can be delayed until the next scheduled interrupt start time, the execution of the currently executing task is continued without switching, so that inefficient switching is suppressed. Switching frequency can be reduced,
The occurrence of deadline violation can be reduced.

【0033】次に、具体例を用いて本実施例の動作を説
明する。図4(A1)〜(F2)は、スケジューリング
過程でのタスク情報テーブルの状態を示す図であり、図
5(a)〜(g)は、周期時間5msのタスクTID1
と周期時間7msのタスクTID2との二つのタスクの
スケジューリング過程を示す図である。
Next, the operation of this embodiment will be described using a specific example. 4 (A1) to 4 (F2) are diagrams showing states of the task information table in the scheduling process. FIGS. 5 (a) to 5 (g) show tasks TID1 having a cycle time of 5 ms.
FIG. 9 is a diagram showing a scheduling process of two tasks, and a task TID2 having a cycle time of 7 ms.

【0034】タスクTID1は、周期時間5ms、タス
クの実行に要する実行時間2ms、起動余裕時間すなわ
ち(周期時間−実行時間)=3msのタスクであり、デ
ッドラインが5msの倍数時間毎に訪れる。タスクTI
D2は、周期時間7ms、実行時間4ms、起動余裕時
間3msのタスクであり、デッドラインが7msの倍数
時間毎に訪れる。割り込みは1ms毎に発生し、その度
に起動タスクを決定するものとする。
The task TID1 is a task having a cycle time of 5 ms, an execution time required for executing the task of 2 ms, and a start allowance time, ie, (cycle time−execution time) = 3 ms, and a deadline comes every multiple of 5 ms. Task TI
D2 is a task having a cycle time of 7 ms, an execution time of 4 ms, and a start allowance time of 3 ms, and a deadline comes every multiple of 7 ms. An interrupt occurs every 1 ms, and the activation task is determined each time.

【0035】図4(A1)の状態で割り込みが発生する
と、図3のステップ31に従いタスク情報テーブル10
3のタスクTID1,TID2のそれぞれのカウンタの
カウント値C1,C2を“1”減算する。その結果、カ
ウント値C1,C2はいずれも“−1”となる(A
2)。タスクTID1,TID2のカウント値C1,C
2がいずれも“0”未満となったので、図3のステップ
33に従って、“0”未満のカウント値を持つタスクの
うち最も周期時間の短いタスクであるタスクTID1を
切替実行候補タスクTSKとして選択し格納する。ステ
ップ34で現在実行中のタスクはないので、ステップ3
8に進んで切替実行候補タスクTSKとして選択し格納
されているタスクTID1を実行する。図5で斜線で示
すように時刻0からはTID1が実行される。
When an interrupt occurs in the state of FIG. 4 (A1), the task information table 10 is stored in accordance with step 31 of FIG.
The count values C1 and C2 of the counters of the tasks TID1 and TID2 of No. 3 are decremented by "1". As a result, the count values C1 and C2 are both "-1" (A
2). Count values C1, C of tasks TID1, TID2
2 are all less than "0", so that task TID1, which is the task with the shortest cycle time among the tasks having the count value less than "0", is selected as the switching execution candidate task TSK in accordance with step 33 of FIG. And store. Since no task is currently being executed in step 34, step 3
In step 8, the task TID1 selected and stored as the switching execution candidate task TSK is executed. As shown by hatching in FIG. 5, TID1 is executed from time 0.

【0036】時刻1msに次の割り込みが発生し、図3
の処理フロー従ってタスク起動決定の処理が再び行われ
る。まず、カウンタが更新されるとカウント値C1,C
2はいずれも“−2”となる(図4(B1))が、
“0”未満のカウント値を持つタスクのうち最も周期時
間の短いタスクはタスクTID1であるから、ステップ
33では切替実行候補タスクTSKとしてタスクTID
1を選択する。また実行中のタスクもタスクTID1な
ので、ステップ35では、(実行中のタスクの周期時
間)=(切替実行候補タスクTSKの周期時間)となる
ので、タスクTID1の実行を継続する。
At time 1 ms, the next interrupt occurs, and FIG.
In accordance with the processing flow of the above, the task activation determination processing is performed again. First, when the counter is updated, the count values C1, C
2 is "-2" (FIG. 4 (B1)),
Since the task having the shortest cycle time among the tasks having the count value less than “0” is the task TID1, the task TID is set as the switching execution candidate task TSK in step 33.
Select 1. In addition, since the task being executed is also the task TID1, in step 35, (cycle time of the task being executed) = (cycle time of the switching execution candidate task TSK), and the execution of the task TID1 is continued.

【0037】タスクTID1の実行時間は2msである
ので、図5で時刻2msになるとタスクTID1の処理
は終了する(図5(b))。タスクの終了時には、終了
したタスクについてはカウンタのカウント値に周期時間
を加算するが、タスクTID1の終了時のカウント値
“−2”に周期時間“5”が加算され、カウント値は
“3”に更新される。(図4(B2))。
Since the execution time of the task TID1 is 2 ms, the processing of the task TID1 ends at time 2 ms in FIG. 5 (FIG. 5B). At the end of the task, the cycle time is added to the count value of the counter for the completed task, but the cycle time “5” is added to the count value “−2” at the end of the task TID1, and the count value is “3”. Will be updated to (FIG. 4 (B2)).

【0038】その後に時刻2msの割り込みが発生し、
図3の起動タスク決定の処理が行われる。タスクTID
1,TID2のカウント値は、“1”減算されてそれぞ
れ“2”,“−3”となる(図4(C))。カウント値
が“0”未満のタスクはタスクTID2のみであるた
め、ステップ33ではタスクTID2が切替実行候補タ
スクTSKとして格納される。実行中のタスクはないた
め、ステップ38でタスクTID2の実行を開始する
(図5(c))。
Thereafter, an interrupt at time 2 ms occurs,
The activation task determination process of FIG. 3 is performed. Task TID
The count values of TID1 and TID2 are decremented by "1" to become "2" and "-3", respectively (FIG. 4C). Since the task whose count value is less than “0” is only the task TID2, the task TID2 is stored as the switching execution candidate task TSK in Step 33. Since no task is being executed, execution of task TID2 is started in step 38 (FIG. 5C).

【0039】次に時刻3msの割り込みが発生すると、
図3の起動タスク決定の処理が行われる。タスクTID
1,TID2のカウンタのカウント値は、それぞれ
“1”,“−4”に更新される(図4(D))。“0”
未満のカウント値のタスクはタスクTID2のみであ
り、また、実行中のタスクもタスクTID2なので、タ
スクTID2の実行を継続する(図5(d))。
Next, when an interrupt at time 3 ms occurs,
The activation task determination process of FIG. 3 is performed. Task TID
The count values of the counters 1 and 2 are updated to "1" and "-4", respectively (FIG. 4D). “0”
Only the task TID2 has a count value less than the task TID2, and the task being executed is also the task TID2. Therefore, the task TID2 continues to be executed (FIG. 5D).

【0040】次に時刻4msの割り込みについても同様
で、タスクTID1,TID2のカウンタのカウント値
は、それぞれ“0”,“−5”に更新される(図4
(E))。“0”未満のカウント値のタスクはタスクT
ID2のみであり、また、実行中のタスクもタスクTI
D2なので、タスクTID2の実行を継続する(図5
(e))。
Next, the same applies to the interruption at time 4 ms, and the count values of the counters of the tasks TID1 and TID2 are updated to "0" and "-5", respectively (FIG. 4).
(E)). Tasks with a count value less than “0” are task T
ID2 only, and the running task is also a task TI
Since it is D2, execution of task TID2 is continued (FIG. 5).
(E)).

【0041】次に時刻5msで割り込みが発生すると、
タスクTID1,TID2のカウンタのカウント値は、
それぞれ“−1”,“−6”に更新される(図4(F
1))。タスクTID1,TID2ともにカウンタのカ
ウント値が“0”未満であるので、図3のステップ33
では周期時間の短いタスクTID1を切替実行候補タス
クTSKとして選択し格納する。次に、現在タスクとし
てタスクTID2を実行中なので、ステップ35で実行
中のタスクTID2の周期時間と切替実行候補タスクT
SKのタスクTID1の周期時間を比較する。切替実行
候補タスクTSKのタスクTID1の周期時間が短いの
で、ステップ36に進んで切替実行候補タスクTSKの
タスクTID1のカウント値に(−1)を乗じて得られ
る値“1”よりも起動余裕時間“3”が大であるので、
タスク切替は行わずにタスクTID2を継続して実行す
る(図5(f))。
Next, when an interrupt occurs at time 5 ms,
The count values of the counters of the tasks TID1 and TID2 are
These are updated to “−1” and “−6”, respectively (FIG. 4 (F
1)). Since the count value of the counter is less than "0" for both tasks TID1 and TID2, step 33 in FIG.
Then, the task TID1 having a short cycle time is selected and stored as the switching execution candidate task TSK. Next, since the task TID2 is currently being executed as a task, in step 35, the cycle time of the task TID2 being executed and the switching execution candidate task T
The cycle time of the SK task TID1 is compared. Since the cycle time of the task TID1 of the switching execution candidate task TSK is short, the process proceeds to step 36, and the start allowance time is longer than the value “1” obtained by multiplying the count value of the task TID1 of the switching execution candidate task TSK by (−1). Since “3” is large,
The task TID2 is continuously executed without performing the task switching (FIG. 5F).

【0042】タスクTID2の実行時間は4msである
ので、図5で時刻6msになるとタスクTID2の処理
は終了する(図5(g))。タスク終了時にタスクTI
D2の終了時のカウント値“−6”に周期時間“7”が
加算され、カウント値は“1”に更新される。(図4
(F2))。
Since the execution time of task TID2 is 4 ms, the processing of task TID2 ends at time 6 ms in FIG. 5 (FIG. 5 (g)). Task TI at task end
The cycle time “7” is added to the count value “−6” at the end of D2, and the count value is updated to “1”. (FIG. 4
(F2)).

【0043】このようにして処理が繰り返され、時刻3
5msまで図5(g)のタスクスケジューリング経過を
たどる。本実施例の効果は、図5(g)と従来例の図1
1(d)との比較から理解できるように、デッドライン
違反の発生が低減するとともにタスク切替回数も16回
から12回に低減されている。
The processing is repeated as described above, and at time 3
The task scheduling process shown in FIG. 5G is followed until 5 ms. The effect of the present embodiment is shown in FIG.
As can be understood from the comparison with 1 (d), the occurrence of the deadline violation is reduced and the number of task switching is also reduced from 16 to 12.

【0044】次に、本発明の他の実施例について図面を
参照して説明する。本発明のタスク制御装置の第2の実
施例の構成は、図1のタスク情報テーブル13に換えて
タスク情報テーブル13aを用いる他は図1の第1の実
施例と同一であるので省略する。
Next, another embodiment of the present invention will be described with reference to the drawings. The configuration of the second embodiment of the task control device of the present invention is the same as that of the first embodiment of FIG. 1 except that a task information table 13a is used instead of the task information table 13 of FIG.

【0045】図6は、第2の実施例のタスク情報テーブ
ル13aのデータ構造図であり、図2のタスク情報テー
ブル13の起動余裕時間Sに代わってタスクの実行時間
Eを格納している。本実施例では、実行要求のあったタ
スクの実行開始を次の割り込み発生まで遅延させること
ができるか否かは、((切替実行候補タスクTSKの周
期時間)/(割り込み周期時間)+切替実行候補タスク
TSKのカウント値)と切替実行候補タスクTSKの実
行時間とを比較して判定する。
FIG. 6 is a diagram showing the data structure of the task information table 13a of the second embodiment. The task information table 13 shown in FIG. In the present embodiment, it is determined whether or not the execution start of the task for which execution has been requested can be delayed until the next interrupt occurs, as follows: ((cycle time of switch execution candidate task TSK) / (interrupt cycle time) + switch execution) The determination is made by comparing the count value of the candidate task TSK) with the execution time of the switching execution candidate task TSK.

【0046】図7は、割り込み周期時間を1msとした
ときの第2の実施例の起動決定処理のフロー図である。
図3のステップ36に換えてステップ36aとし、ステ
ップ36aでは、(切替実行候補タスクTSKの周期時
間+切替実行候補タスクTSKのカウント値)が切替実
行候補タスクTSKの実行時間と等しいかまたはこれよ
り大きいかを判定するように変更した点のみが図3の第
1の実施例の処理フローと異なり、他は同一である。図
3のステップ36と図7のステップ36aとは実質的に
同一内容であるので、第1の実施例と第2の実施例とは
同一の効果が得られる。
FIG. 7 is a flow chart of the start determination processing of the second embodiment when the interrupt cycle time is 1 ms.
Step 36a is replaced with step 36a. In step 36a, (cycle time of switching execution candidate task TSK + count value of switching execution candidate task TSK) is equal to or longer than execution time of switching execution candidate task TSK. The only difference from the processing flow of the first embodiment shown in FIG. Since step 36 in FIG. 3 and step 36a in FIG. 7 have substantially the same contents, the same effects can be obtained in the first embodiment and the second embodiment.

【0047】[0047]

【発明の効果】以上に説明したように、本発明を適用す
ることにより、一定時間間隔で繰り返し実行される定周
期タスクをスケジューリングする際に、優先度指標の大
きいタスク要求があるときにも無条件にタスク切り替え
を行うことをせず、実行優先度指標の大きいタスクの実
行開始を次のスケジューリング判定時まで遅延させるこ
とが可能な場合には現在実行中の実行優先度指標の小さ
いタスクの実行を継続して優先度指標の小さいタスクの
早期終了を図るので、実行時間のオーバーヘッドを発生
するタスク切替の回数を低減することができるととも
に、優先度指標の小さいタスクで発生しやすいデッドラ
イン違反をも低減することができるという顕著な効果を
生じる。
As described above, by applying the present invention, when scheduling a periodic task that is repeatedly executed at a fixed time interval, even if there is a task request with a large priority index, the present invention is not performed. If it is possible to delay the start of a task with a large execution priority index until the next scheduling decision without performing task switching on the condition, execute the task currently being executed with a small execution priority index To end tasks with low priority index early, it is possible to reduce the number of task switching that causes execution time overhead, and to reduce deadline violations that are likely to occur in tasks with low priority index. Has a remarkable effect that it can also be reduced.

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

【図1】本発明のタスク制御装置の構成図である。FIG. 1 is a configuration diagram of a task control device of the present invention.

【図2】本発明の一実施例におけるタスク情報テーブル
のデータ構造図である。
FIG. 2 is a data structure diagram of a task information table in one embodiment of the present invention.

【図3】本発明の一実施例における起動タスク決定処理
のフロー図である。
FIG. 3 is a flowchart of a startup task determination process in one embodiment of the present invention.

【図4】(A1)〜(F2)は、タスク情報テーブルの
状態を示す図である。
FIGS. 4A and 4B are diagrams showing states of a task information table.

【図5】(a)〜(g)は、二つのタスクのスケジュー
リング過程を示す図である。
FIGS. 5A to 5G are diagrams illustrating a scheduling process of two tasks.

【図6】第2の実施例のタスク情報テーブルのデータ構
造図である。
FIG. 6 is a data structure diagram of a task information table according to the second embodiment.

【図7】第2の実施例の起動決定処理のフロー図であ
る。
FIG. 7 is a flowchart of a startup determination process according to the second embodiment.

【図8】従来のタスク制御装置の構成図である。FIG. 8 is a configuration diagram of a conventional task control device.

【図9】従来例のタスク情報テーブルの格納データを示
す図である。
FIG. 9 is a diagram showing data stored in a task information table of a conventional example.

【図10】従来例による起動タスク決定処理のフロー図
である。
FIG. 10 is a flowchart of a startup task determination process according to a conventional example.

【図11】(a)〜(d)は、従来例による二つのタス
クのタスクスケジューリング過程を示す図である。
11A to 11D are diagrams showing a task scheduling process of two tasks according to a conventional example.

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

10,80 タスク制御装置 11,81 起動タスク決定部 12,82 タスク実行部 13,13a,83 タスク情報テーブル 14,84 実行要求確認手段 15,85 タスク優先度比較手段 16 タスク起動余裕時間比較手段 17,87 新タスク実行手段 18,88 タスク切替手段 19,89 中断タスク再開手段 10, 80 task control device 11, 81 activation task determination unit 12, 82 task execution unit 13, 13a, 83 task information table 14, 84 execution request confirmation unit 15, 85 task priority comparison unit 16 task activation margin time comparison unit 17 , 87 New task executing means 18,88 Task switching means 19,89 Interrupted task resuming means

Claims (8)

【特許請求の範囲】[Claims] 【請求項1】 周期的に実行要求される複数の定周期タ
スクの実行順序を制御するタスク制御装置において、 所定の割り込み周期時間毎に発生する割り込みに応答し
て動作し、実行要求があり実行待ちのタスクのうち最も
優先度指標が大きいタスクである切替実行候補タスクの
優先度指標が現在実行中のタスクの優先度指標よりも大
きいときには前記切替実行候補タスクの実行開始を次の
割り込み発生予定時刻まで遅延させた場合に周期時間内
でタスクが終了しないデッドライン違反が発生するかを
前記切替実行候補タスクの実行要求の周期時間と実行要
求が発生してからの経過時間を示すカウント値とタスク
の実行に必要な実行時間または実行要求発生時刻から実
行開始を遅らせうる限度時刻までの時間を表す起動余裕
時間のいずれか一方とに基づいて判定し、デッドライン
違反が発生すると判定したときには前記現在実行中のタ
スクの実行を中断して前記切替実行候補タスクの実行を
開始し、デッドライン違反が発生しないと判定したとき
には前記現在実行中のタスクの実行を継続することを特
徴とするタスク制御装置。
1. A task control device for controlling an execution order of a plurality of fixed-period tasks periodically requested to be executed, wherein the task control device operates in response to an interrupt generated at a predetermined interrupt cycle time, and executes when there is an execution request. When the priority index of the switching execution candidate task, which is the task with the highest priority index among the waiting tasks, is larger than the priority index of the currently executing task, the execution of the switching execution candidate task is scheduled to occur next interrupt. Whether the deadline violation in which the task is not completed within the cycle time when delayed until the time occurs, a count value indicating the cycle time of the execution request of the switching execution candidate task and the elapsed time since the execution request was generated Either the execution time required to execute the task or the start allowance time indicating the time from the execution request occurrence time to the limit time that can delay the execution start When it is determined that a deadline violation occurs, the execution of the currently executing task is interrupted to start the execution of the switching execution candidate task, and when it is determined that no deadline violation occurs, the current A task control device for continuing execution of a task being executed.
【請求項2】 周期的に実行要求される複数の定周期タ
スクの実行順序を制御するタスク制御装置において、 前記複数のタスクそれぞれの実行要求の周期時間と実行
要求が発生してからの経過時間を示すカウント値とタス
クの実行に必要な実行時間または実行要求発生時刻から
実行開始を遅らせうる限度時刻までの時間を表す起動余
裕時間の少なくとも一方とを保持するタスク情報テーブ
ルと、 所定の割り込み周期時間毎に発生する割り込みに応答し
て動作し、実行要求があり実行待ちのタスクのうち最も
優先度指標が大きいタスクである切替実行候補タスクの
優先度指標が現在実行中のタスクの優先度指標よりも大
きいときには前記切替実行候補タスクの実行開始を次の
割り込み発生予定時刻まで遅延させた場合に周期時間内
でタスクが終了しないデッドライン違反が発生するかを
前記タスク情報テーブルの前記切替実行候補タスクのデ
ータに基づいて判定する起動タスク決定部と、 前記起動タスク決定部でデッドライン違反が発生すると
判定したときには前記現在実行中のタスクの実行を中断
して前記切替実行候補タスクの実行を開始し、デッドラ
イン違反が発生しないと判定したときには前記現在実行
中のタスクの実行を継続するタスク実行部とを有するこ
とを特徴とするタスク制御装置。
2. A task control device for controlling an execution order of a plurality of fixed-period tasks that are periodically requested to be executed, wherein a period time of the execution request of each of the plurality of tasks and an elapsed time since the execution request is generated. A task information table which holds a count value indicating the execution time and at least one of an execution time required for executing the task or a start allowance time indicating a time from an execution request generation time to a limit time at which execution can be delayed, and a predetermined interrupt cycle The priority index of the switching execution candidate task, which operates in response to an interrupt generated every time and has the highest priority index among tasks waiting to be executed and waiting to be executed, is the priority index of the currently executing task If the task execution time is greater than the time limit, the task is terminated within the cycle time if the execution start of the switching execution candidate task is delayed until the next scheduled interrupt occurrence time. An activation task determination unit that determines whether a deadline violation does not occur based on the data of the switching execution candidate task in the task information table; and the current execution when the activation task determination unit determines that a deadline violation occurs. A task execution unit that interrupts the execution of the currently executing task, starts execution of the switching execution candidate task, and continues execution of the currently executed task when it is determined that a deadline violation does not occur. Task control device.
【請求項3】 周期的に実行要求される複数の定周期タ
スクの実行順序を制御するタスク制御装置において、 前記複数のタスクそれぞれの実行要求の周期時間と所定
割り込み周期時間毎に発生する割り込み毎に1減算しタ
スクの実行が終了したときに前記周期時間を前記所定時
間で除した値を加算するカウンタのカウント値とタスク
の実行に必要な実行時間または実行要求発生時刻から実
行開始を遅らせうる限度時刻までの時間を表す起動余裕
時間の少なくとも一方とを保持するタスク情報テーブル
と、 新たなタスクの実行要求があるか否かを調べる実行要求
確認手段と、複数タスクの実行要求があるときにタスク
情報テーブルを参照してそれぞれのタスクの優先度指標
を比較し最も優先度指標の大きいタスクを切替実行候補
タスクとして選択し格納するタスク優先度比較手段と、
前記切替実行候補タスクの優先度指標が現在実行中のタ
スクの優先度指標よりも大きいときには前記切替実行候
補タスクの実行開始を次の割り込み発生予定時刻まで遅
延させた場合に周期時間内でタスクが終了しないデッド
ライン違反が発生するかを前記タスク情報テーブル内の
前記切替実行候補タスクに指定されたタスクのデータに
基づいて判定するタスク起動余裕時間比較手段とを備え
た起動タスク決定部と、 実行中のタスクがないときには新たに実行要求のあった
タスクを新規に実行する新タスク実行手段と、前記起動
余裕時間比較手段で前記切替実行候補タスクの実行開始
を遅延させた場合にはデッドライン違反が発生すると判
定されたときに前記現在実行中のタスクを中断し前記切
替実行候補タスクを実行するタスク切替手段と、前記起
動タスク決定部での起動タスク決定処理または現在実行
タスクの実行終了待ちにより中断中であったタスクの実
行を再開する中断タスク再開手段とを備えるタスク実行
部とを有することを特徴とするタスク制御装置。
3. A task control device for controlling an execution order of a plurality of fixed-period tasks periodically requested to be executed, wherein each of the plurality of tasks has an execution request and an interrupt generated at a predetermined interrupt cycle time. The execution start can be delayed from the count value of a counter for adding a value obtained by dividing the cycle time by the predetermined time when the execution of the task is completed and the execution time required for the execution of the task or the execution request generation time. A task information table that holds at least one of a start-up margin time indicating a time until a time limit, an execution request confirmation unit that checks whether there is a new task execution request, and a case where there are multiple task execution requests. Referring to the task information table, the priority indices of the respective tasks are compared, and the task having the highest priority index is selected as a switching execution candidate task. And the task priority comparing means for storing,
When the priority index of the switching execution candidate task is larger than the priority index of the currently executing task, the task is started within the cycle time when the execution start of the switching execution candidate task is delayed until the next interrupt occurrence scheduled time. A start task determining unit including: a task start allowance time comparing unit that determines whether a deadline violation that does not end occurs based on data of a task designated as the switching execution candidate task in the task information table; If there is no task in progress, a new task execution means for newly executing a task for which execution has been newly requested, and a deadline violation if the start execution time of the switching execution candidate task is delayed by the activation margin time comparison means A task switching means for interrupting the currently executing task and executing the switching execution candidate task when it is determined that A task execution unit comprising: an interrupted task resuming unit that resumes execution of a task that has been suspended due to activation task determination processing in the activation task determination unit or waiting for execution of a currently executed task. Control device.
【請求項4】 前記タスク優先度比較手段が、タスクの
実行要求周期時間の短さを優先度指標として判定する請
求項3記載のタスク制御装置。
4. The task control device according to claim 3, wherein the task priority comparing means determines a shortness of a task execution request cycle time as a priority index.
【請求項5】 前記タスク起動余裕時間比較手段が、前
記切替実行候補タスクのカウント値に(−1)を乗じて
得られる第1の値が前記切替実行候補タスクの起動余裕
時間を割り込み周期時間で除して得られる第2の値より
も大きいときにデッドライン違反が発生すると判定する
請求項3記載のタスク制御装置。
5. The task activation allowance time comparison means sets a first value obtained by multiplying the count value of the switching execution candidate task by (−1) as an activation cycle time of the switching execution candidate task. 4. The task control device according to claim 3, wherein it is determined that a deadline violation occurs when the value is larger than a second value obtained by dividing the deadline.
【請求項6】 前記タスク起動余裕時間比較手段が、前
記切替実行候補タスクの周期時間を前記割り込み周期時
間で除して得られる値に前記切替実行候補タスクのカウ
ント値を加えて得られる第1の値が前記切替実行候補タ
スクの実行時間を前記割り込み周期時間で除して得られ
る第2の値よりも小さいときにデッドライン違反が発生
すると判定する請求項3記載のタスク制御装置。
6. A first task execution time comparing means for adding a count value of the switching execution candidate task to a value obtained by dividing a cycle time of the switching execution candidate task by the interruption cycle time. 4. The task control device according to claim 3, wherein it is determined that a deadline violation occurs when a value of the switching execution candidate task is smaller than a second value obtained by dividing an execution time of the switching execution candidate task by the interrupt cycle time.
【請求項7】 周期的に実行要求される複数の定周期タ
スクの実行順序をこれら複数のタスクの情報を保持する
タスク情報テーブルを参照しながらスケジューリングす
るタスク制御装置のタスクスケジューリング方法におい
て、 タスクスケジューリング開始に先立って予め前記タスク
情報テーブルに前記複数のタスクそれぞれの実行要求の
周期時間と実行要求が発生してからの経過時間を示すカ
ウンタのカウント値と実行要求発生時刻から実行開始を
遅らせうる限度時刻までを表す起動余裕時間とを登録す
る初期設定処理と、 所定の割り込み周期時間毎に発生する割り込みを受けて
前記タスク情報テーブル登録されている各タスクのカウ
ント値を1だけ減算して更新する第1のステップと、 カウント値が0未満のタスクが存在するか否かを調べカ
ウント値が0未満のタスクが存在しないときには現在時
刻で実行すべきタスクは無いと判定して処理を終了し、
前記カウント値が0未満のタスクが存在した場合には次
ステップに進む第2のステップと、 カウント値が0未満のタスクのうち最も周期時間の短い
タスクを切替実行候補タスクとして選択し格納する第3
のステップと、 実行中のタスクがあるかを判定し実行中のタスクが存在
した場合には次ステップに進む第4のステップと、 現在実行中のタスクの周期時間と前記切替実行候補タス
クの周期時間とを比較し前記現在実行中のタスクの周期
時間が短いときには前記現在実行中のタスクを継続実行
することとして処理を終了し、前記現在実行中のタスク
の周期時間が長いときには次ステップに進む第5のステ
ップと、 前記切替実行候補タスクのカウント値に(−1)を乗じ
て得られる第1の値が前記切替実行候補タスクの起動余
裕時間を前記割り込み周期時間で除して得られる第2の
値と等しいかまたはこれより小さいときには処理を終了
し、前記第1の値が前記第2の値よりも大きいときには
次ステップへ進む第6のステップと、 前記現在実行中のタスクを中断し前記切替実行候補タス
クへ切り替えて実行開始し終了する第7のステップと、 前記第4のステップで実行中のタスクがない場合に前記
切替実行候補タスクの実行を開始して終了する第8のス
テップとを含む起動タスク決定処理とを有することを特
徴とするタスク制御装置のタスクスケジューリング方
法。
7. A task scheduling method for a task control device, which schedules the execution order of a plurality of fixed-period tasks periodically requested to be executed with reference to a task information table holding information on the plurality of tasks. Prior to the start, the task information table has a cycle time of the execution request of each of the plurality of tasks and a count value of a counter indicating an elapsed time since the execution request is generated and a limit that can delay the execution start from the execution request generation time. Initial setting processing for registering a start allowance time indicating up to a time, and receiving an interrupt generated at every predetermined interrupt cycle time, subtracting and updating the count value of each task registered in the task information table by one. The first step is to check whether there is a task whose count value is less than 0. When there is no task with the count value less than 0, it is determined that there is no task to be executed at the current time, and the processing ends.
A second step for proceeding to the next step when there is a task whose count value is less than 0; and selecting and storing a task having the shortest cycle time among tasks having a count value of less than 0 as a switching execution candidate task. 3
A fourth step of determining whether there is a task being executed and proceeding to the next step if there is a task being executed; and a cycle time of the currently executing task and a cycle of the switching execution candidate task. When the cycle time of the currently executing task is short, the process is terminated by continuously executing the currently executing task, and when the cycle time of the currently executing task is long, the process proceeds to the next step. A fifth step, wherein a first value obtained by multiplying the count value of the switching execution candidate task by (−1) is obtained by dividing the activation margin time of the switching execution candidate task by the interrupt cycle time. A sixth step in which the processing is terminated when the value is equal to or smaller than 2; and a sixth step proceeds to the next step when the first value is larger than the second value; A seventh step of interrupting the running task, switching to the switching execution candidate task, starting execution and ending, and starting the execution of the switching execution candidate task when there is no task being executed in the fourth step. A task scheduling method for a task control device, comprising: an activation task determination process including an eighth step to end.
【請求項8】 周期的に実行要求される複数の定周期タ
スクの実行順序をこれら複数のタスクの情報を保持する
タスク情報テーブルを参照しながらスケジューリングす
るタスク制御装置のタスクスケジューリング方法におい
て、 タスクスケジューリング開始に先立って予め前記タスク
情報テーブルに前記複数のタスクそれぞれの実行要求の
周期時間と実行要求が発生してからの経過時間を示すカ
ウンタのカウント値とタスクの実行に要する実行時間と
を登録する初期設定処理と、 所定の割り込み周期時間毎に発生する割り込みを受けて
前記タスク情報テーブル登録されている各タスクのカウ
ント値を1だけ減算して更新する第1のステップと、 カウント値が0未満のタスクが存在するか否かを調べカ
ウント値が0未満のタスクが存在しないときには、現在
時刻で実行すべきタスクは無いと判定して処理を終了し
カウント値が0未満のタスクが存在した場合には次ステ
ップに進む第2のステップと、 カウント値が0未満のタスクのうち最も周期時間の短い
タスクを切替実行候補タスクとして選択し格納する第3
のステップと、 実行中のタスクがあるかを判定し実行中のタスクが存在
した場合には次ステップに進む第4のステップと、 現在実行中のタスクの周期時間と前記切替実行候補タス
クの周期時間とを比較し前記現在実行中のタスクの周期
時間が短いときには前記現在実行中のタスクを継続実行
することとして処理を終了し、前記現在実行中のタスク
の周期時間が長いときには次ステップに進む第5のステ
ップと、 前記切替実行候補タスクの周期時間を前記割り込み周期
時間で除して得られる値に前記切替実行候補タスクのカ
ウント値を加えて得られる第1の値が前記切替実行候補
タスクの実行時間を前記割り込み周期時間で除して得ら
れる第2の値と等しいかまたはこれより大きいときには
処理を終了し、前記第1の値が前記第2の値よりも小さ
いときには次ステップへ進む第6のステップと、 前記現在実行中のタスクを中断し前記切替実行候補タス
クへ切り替えて実行開始し終了する第7のステップと、 前記第4のステップで実行中のタスクがない場合に前記
切替実行候補タスクの実行を開始して終了する第8のス
テップとを含む起動タスク決定処理とを有することを特
徴とするタスク制御装置のタスクスケジューリング方
法。
8. A task scheduling method for a task control device, which schedules the execution order of a plurality of fixed-period tasks periodically requested to be executed with reference to a task information table holding information of the plurality of tasks. Prior to the start, the cycle time of the execution request of each of the plurality of tasks, the count value of a counter indicating the elapsed time since the generation of the execution request, and the execution time required for executing the task are registered in the task information table in advance. An initial setting process, a first step of receiving an interrupt generated at every predetermined interrupt cycle time and updating the count value of each task registered in the task information table by subtracting 1 from the count value, and a count value less than 0 Check if there are any tasks, and if there are no tasks whose count value is less than 0 In this case, when there is no task to be executed at the current time, the process is terminated, and when there is a task with a count value of less than 0, a second step proceeds to the next step; A task in which the task having the shortest cycle time is selected and stored as a switching execution candidate task among tasks.
A fourth step of determining whether there is a task being executed and proceeding to the next step if there is a task being executed; and a cycle time of the currently executing task and a cycle of the switching execution candidate task. When the cycle time of the currently executing task is short, the process is terminated by continuously executing the currently executing task, and when the cycle time of the currently executing task is long, the process proceeds to the next step. A fifth step, wherein a first value obtained by adding a count value of the switch execution candidate task to a value obtained by dividing a cycle time of the switch execution candidate task by the interrupt cycle time is the switch execution candidate task. When the execution time is equal to or greater than a second value obtained by dividing the execution time by the interrupt cycle time, the process is terminated, and the first value is smaller than the second value. A sixth step to proceed to the next step, a seventh step of interrupting the currently executing task, switching to the switching execution candidate task, starting and ending execution, and a task being executed in the fourth step An activation task determination process including: starting and ending the execution of the switching execution candidate task when there is no switching execution candidate task.
JP2000049125A 2000-02-25 2000-02-25 Task controller and its task scheduling method Pending JP2001236236A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2000049125A JP2001236236A (en) 2000-02-25 2000-02-25 Task controller and its task scheduling method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2000049125A JP2001236236A (en) 2000-02-25 2000-02-25 Task controller and its task scheduling method

Publications (1)

Publication Number Publication Date
JP2001236236A true JP2001236236A (en) 2001-08-31

Family

ID=18571108

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2000049125A Pending JP2001236236A (en) 2000-02-25 2000-02-25 Task controller and its task scheduling method

Country Status (1)

Country Link
JP (1) JP2001236236A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007226587A (en) * 2006-02-24 2007-09-06 Mitsubishi Electric Corp Computer resource dynamic controller, computer resource dynamic control system and computer resource dynamic control method
US7322033B2 (en) 2002-03-29 2008-01-22 Denso Corporation Distributed control method and apparatus
JP2009079491A (en) * 2007-09-25 2009-04-16 Denso Corp Engine control device
JP2010205046A (en) * 2009-03-04 2010-09-16 Toyota Motor Corp Information processing apparatus
US7912623B2 (en) 2007-09-25 2011-03-22 Denso Corporation Engine control system designed to manage schedule of engine control tasks
US8418188B2 (en) 2010-03-11 2013-04-09 Toyota Jidosha Kabushiki Kaisha Task execution controller and recording medium on which task execution control program is recorded
US9058207B2 (en) 2010-10-05 2015-06-16 Socionext Inc. Simulation apparatus, method, and computer-readable recording medium
US9274833B2 (en) 2013-05-16 2016-03-01 Denso Corporation Task scheduler, microprocessor, and task scheduling method
CN111176815A (en) * 2019-12-30 2020-05-19 青岛海尔科技有限公司 Task scheduling method and device for operating system

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7322033B2 (en) 2002-03-29 2008-01-22 Denso Corporation Distributed control method and apparatus
JP2007226587A (en) * 2006-02-24 2007-09-06 Mitsubishi Electric Corp Computer resource dynamic controller, computer resource dynamic control system and computer resource dynamic control method
JP4523921B2 (en) * 2006-02-24 2010-08-11 三菱電機株式会社 Computer resource dynamic controller
JP2009079491A (en) * 2007-09-25 2009-04-16 Denso Corp Engine control device
JP4530015B2 (en) * 2007-09-25 2010-08-25 株式会社デンソー Engine control device
US7912623B2 (en) 2007-09-25 2011-03-22 Denso Corporation Engine control system designed to manage schedule of engine control tasks
JP2010205046A (en) * 2009-03-04 2010-09-16 Toyota Motor Corp Information processing apparatus
US8418188B2 (en) 2010-03-11 2013-04-09 Toyota Jidosha Kabushiki Kaisha Task execution controller and recording medium on which task execution control program is recorded
US9058207B2 (en) 2010-10-05 2015-06-16 Socionext Inc. Simulation apparatus, method, and computer-readable recording medium
US9274833B2 (en) 2013-05-16 2016-03-01 Denso Corporation Task scheduler, microprocessor, and task scheduling method
CN111176815A (en) * 2019-12-30 2020-05-19 青岛海尔科技有限公司 Task scheduling method and device for operating system
CN111176815B (en) * 2019-12-30 2023-09-19 青岛海尔科技有限公司 Task scheduling method and device of operating system

Similar Documents

Publication Publication Date Title
KR100864964B1 (en) Arithmetic Processing System and Arithmetic Processing Control Method, Task Management System and Task Management Method, and Storage Medium
JP3922070B2 (en) Distributed control method and apparatus
US7441240B2 (en) Process scheduling apparatus, process scheduling method, program for process scheduling, and storage medium recording a program for process scheduling
WO2010082244A1 (en) Information processing device and information processing method
JPH10301793A (en) Information processor and scheduling method
JP3952992B2 (en) Information processing apparatus, process control method, and computer program
JPWO2005106623A1 (en) CPU clock control device, CPU clock control method, CPU clock control program, recording medium, and transmission medium
WO2006009261A1 (en) Real time processing software control device and method
KR100959548B1 (en) A method of interrupt scheduling
US20030078954A1 (en) Method and system for executing multiple tasks in a task set
JP2001236236A (en) Task controller and its task scheduling method
US8555285B2 (en) Executing a general-purpose operating system as a task under the control of a real-time operating system
JP2002073354A (en) Task control device and task contol method
JP2005149312A (en) Task management system
JP3830133B2 (en) Power control apparatus and method, and power control program
JP3043748B1 (en) Task scheduling method and device
JP5480322B2 (en) Performance control method, system and program thereof
JPH10177489A (en) Task scheduling method
Thebe et al. Scheduling restartable jobs with short test runs
CN115981829B (en) Scheduling method and system in Internet of things
JP3169316B2 (en) Task scheduling method
CN110109743B (en) Real-time process scheduling method
JPH1040117A (en) System for changing task execution priority at the high load in on-line processing system
JP2003241978A (en) Load dispersion method and load dispersion system for device driver
JP2003050709A (en) Method and device for task scheduling

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20041005

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20041207

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20050405