JP2008276674A - Electronic computer capable of specifying execution time of task, and program for electronic computer - Google Patents
Electronic computer capable of specifying execution time of task, and program for electronic computer Download PDFInfo
- Publication number
- JP2008276674A JP2008276674A JP2007122195A JP2007122195A JP2008276674A JP 2008276674 A JP2008276674 A JP 2008276674A JP 2007122195 A JP2007122195 A JP 2007122195A JP 2007122195 A JP2007122195 A JP 2007122195A JP 2008276674 A JP2008276674 A JP 2008276674A
- Authority
- JP
- Japan
- Prior art keywords
- task
- execution
- time
- storage medium
- cpu
- 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.)
- Withdrawn
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/34—Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
- G06F11/3466—Performance evaluation by tracing or monitoring
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/34—Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
- G06F11/3409—Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
- G06F11/3419—Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment by assessing time
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2201/00—Indexing scheme relating to error detection, to error correction, and to monitoring
- G06F2201/865—Monitoring of software
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
Description
本発明は、複数のタスクのうちからCPUが実行する対象のタスクを切り替えることができると共に、タスクの実行時間を特定することのできる電子計算装置、および当該電子計算装置用のプログラムに関する。 The present invention relates to an electronic computing device that can switch a task to be executed by a CPU from among a plurality of tasks and that can specify an execution time of the task, and a program for the electronic computing device.
従来、複数のタスクのうちから実行する対象のタスクを切り替えるCPUにおける、タスクの実行時間を特定する技術が種々知られている。タスクの実行時間を特定する方法としては、例えば、タスクの実行開始時にRAMの所定のフラグを1にし、タスクの実行終了時に当該フラグを0にする処理を、タスクの実行がある度に繰り返し、そのフラグの変化を、外部の装置であるRAMモニタで定期的にチェックする方法がある。このような方法を用いれば、ある期間におけるRAMが1であった期間の割合から、CPUのタスク実行率、すなわちCPUの利用率を特定することができる。 Conventionally, various techniques for specifying task execution time in a CPU that switches a target task to be executed from among a plurality of tasks are known. As a method for specifying the task execution time, for example, a process of setting a predetermined flag in the RAM at the start of task execution and setting the flag to 0 at the end of task execution is repeated each time the task is executed, There is a method of periodically checking the change of the flag with a RAM monitor which is an external device. By using such a method, the task execution rate of the CPU, that is, the usage rate of the CPU can be specified from the ratio of the period in which the RAM is 1 in a certain period.
また、タスクの実行時間を特定する方法として、特許文献1、2に記載されているようなものがある。この方法では、CPUが、通常のタスクが実行されていない時間にアイドルタスクを実行し、そのアイドルタスク中で定期的にカウンタ値を増加させるようになっている。これによって、ある期間内におけるカウンタの増加量から、当該期間において通常のタスクが実行されていない時間の比率を算出することができ、さらにこれに基づいて、通常のタスクが実行されている時間の比率を算出することができる。
しかし、上述のようなRAMモニタを用いる方法では、タスクの実行開始から実行終了までの時間が、RAMモニタのチェック間隔よりも短くなると、そのタスクの実行があったことを検出できなくなり、結果として、タスクの実行時間の算出結果が不正確なものになってしまう。 However, in the method using the RAM monitor as described above, if the time from the start of execution of the task to the end of execution becomes shorter than the check interval of the RAM monitor, it cannot be detected that the task has been executed, and as a result The calculation result of the task execution time will be inaccurate.
また、アイドルタスク中にカウンタ値を増加させる方法では、アイドルタスク中に他の処理(例えば記憶媒体の診断処理)を行うと、その処理によってカウンタ値を増加させる処理の実行タイミングに影響が及び、結果としてカウンタ値の増加レートが一定でなくなってしまう可能性がある。カウンタ値の増加レートが一定でなくなれば、タスクの実行時間の算出結果が不正確なものになってしまう。 Further, in the method of increasing the counter value during the idle task, if other processing (for example, storage medium diagnosis processing) is performed during the idle task, the execution timing of the processing for increasing the counter value is affected by the processing, As a result, the increment rate of the counter value may not be constant. If the increment rate of the counter value is not constant, the calculation result of the task execution time becomes inaccurate.
本発明は上記点に鑑み、複数のタスクのうちから実行する対象のタスクを切り替えるCPUにおける、タスクの実行時間を特定する技術において、タスクの実行時間が非常に短い場合でも確実に当該タスクの実行時間を特定することができるようにし、また、上述したようなしくみで他の処理によって実行時間の計算に狂いが生じることがないようにすることを目的とする。 In view of the above points, the present invention is a technology for specifying a task execution time in a CPU that switches a target task to be executed from among a plurality of tasks. Even when the task execution time is very short, the task is reliably executed. The purpose is to allow the time to be specified, and to prevent the execution time from being distorted by other processes in the above-described manner.
上記目的を達成するための本発明の第1の特徴は、記憶媒体およびCPUを備え、記憶媒体に記録されている複数のタスクのうちからCPUが実行する対象のタスクを切り替える電子計算装置についてのものである。この本発明の第1の特徴において、CPUは、複数のタスクのうち1つのタスク(以下、実行タスクという)の実行を開始するとき、実行タスクが記憶媒体に記録された指定タスクであるか否かを判定し、その判定結果が肯定的であることに基づいて、当該実行タスクの実行開始時に、その開始時の時刻を、当該実行タスクの実行開始時刻として、記憶媒体に記録する。さらに、当該実行タスクの実行終了時に、その終了時の時刻と、記憶媒体に記録された当該実行タスクの実行開始時刻との差を、当該実行タスクの実行時間として記憶媒体に記録する。 In order to achieve the above object, a first feature of the present invention relates to an electronic computer that includes a storage medium and a CPU and switches a task to be executed by the CPU from a plurality of tasks recorded in the storage medium. Is. In the first feature of the present invention, when the CPU starts execution of one of a plurality of tasks (hereinafter referred to as an execution task), whether or not the execution task is a designated task recorded in the storage medium. When the execution result of the execution task is started, the time at the start is recorded in the storage medium as the execution start time of the execution task. Further, at the end of execution of the execution task, the difference between the end time and the execution start time of the execution task recorded in the storage medium is recorded in the storage medium as the execution time of the execution task.
このように、あらかじめ指定されたタスクと、実行を開始するタスクとを照合し、それらが合致したときに、当該実行タスクの開始時刻と終了時刻との差を実行時間として記録することで、所望のタスクの実行時間を特定することができる。そして、このような方法を用いることで、タスクの実行時間が非常に短い場合であっても、確実にその実行時間を特定することができ、また、上述したようなしくみで他の処理によって実行時間の計算に狂いが生じることがない。 In this way, a task specified in advance and a task to start execution are collated, and when they match, the difference between the start time and end time of the execution task is recorded as an execution time. The execution time of the task can be specified. By using such a method, even when the task execution time is very short, the execution time can be reliably specified, and the execution can be performed by other processes with the above-described mechanism. There is no error in the calculation of time.
また、本発明の第2の特徴は、記憶媒体およびCPUを備え、記憶媒体に記録されている、第1のグループに属する複数の第1グループタスクおよび第2のグループに属する複数の第2グループタスクのうちから、CPUが実行する対象のタスクを切り替える電子計算装置についてのものである。そして、このCPUは、第1グループタスクのどれも実行していないときは必ず第2グループタスクのいずれかを実行している。 The second feature of the present invention is that a storage medium and a CPU are provided, and a plurality of first group tasks belonging to the first group and a plurality of second groups belonging to the second group are recorded on the storage medium. The present invention relates to an electronic computing device that switches a task to be executed by a CPU from among tasks. The CPU always executes one of the second group tasks when none of the first group tasks are executed.
さらにこのCPUは、所定の計測期間内における第2グループタスクの実行のそれぞれにおいて、実行対象となる第2グループタスク(以下、実行タスクという)の実行開始時に、その開始時の時刻を、当該実行タスクの実行開始時刻として、記憶媒体に記録し、また、当該実行タスクの実行終了時に、その終了時の時刻と、記憶媒体に記録された当該実行タスクの実行開始時刻との差を、当該実行タスクの実行時間として算出する。また、CPUは、計測期間内において算出した当該実行タスクの実行時間の総和を計測期間から減算した結果を、複数の第1グループタスクの実行時間として、記憶媒体に記録する。 Further, the CPU executes the execution time of the second group task to be executed (hereinafter referred to as an execution task) in the execution of the second group task within a predetermined measurement period. The task execution start time is recorded on the storage medium, and at the end of execution of the execution task, the difference between the end time and the execution start time of the execution task recorded on the storage medium is Calculated as task execution time. Further, the CPU records the result of subtracting the total execution time of the execution tasks calculated within the measurement period from the measurement period as the execution times of the plurality of first group tasks in the storage medium.
このように、CPUの実行対象となるタスクが、第1のグループと第2のグループに分けられており、かつ、第1のグループのタスクが実行されていない間は、必ず第2のグループのタスクが実行されているようになっている場合、ある計測期間内において、第2のグループに属するタスクのそれぞれについて実行時間を計測し、それら計測結果の総和を計測期間から減算した値を、第1グループタスクの実行時間として特定することができる。 As described above, the tasks to be executed by the CPU are divided into the first group and the second group, and the task of the second group is always performed while the task of the first group is not executed. When a task is being executed, the execution time is measured for each task belonging to the second group within a certain measurement period, and the value obtained by subtracting the sum of the measurement results from the measurement period is It can be specified as the execution time of one group task.
また、個々の第2グループタスクについては、当該実行タスクの開始時刻と終了時刻との差を実行時間として特定することで、当該タスクの実行時間を特定することができる。このような方法を用いることで、タスクの実行時間が非常に短い場合であっても、確実にその実行時間を特定することができ、また、上述したようなしくみで他の処理によって実行時間の計算に狂いが生じることがない。 For each second group task, the execution time of the task can be specified by specifying the difference between the start time and the end time of the execution task as the execution time. By using such a method, even if the task execution time is very short, the execution time can be specified reliably, and the execution time of the task can be determined by other processes with the above-described mechanism. There will be no error in the calculation.
また、本発明の第2の特徴においては、第2のグループに属するタスクのそれぞれは、当該電子計算装置のハードウェアおよびオペレーティングシステムを直接制御するプラットフォームタスクであって、第1のグループに属するタスクのそれぞれは、当該電子計算装置のハードウェアおよびオペレーティングシステムを、プラットフォームタスクを介して利用するアプリケーションタスクであってもよい。このようになっていることで、アプリケーションタスクによるCPU利用率を知りたいという一般的なニーズに対応することができる。 Further, in the second feature of the present invention, each of the tasks belonging to the second group is a platform task for directly controlling the hardware and operating system of the electronic computing device, and belongs to the first group. Each may be an application task that uses the hardware and operating system of the electronic computing device via a platform task. In this way, it is possible to meet the general need to know the CPU usage rate by the application task.
また、計測期間内において算出された実行タスクの実行時間の総和を計測期間から減算した結果を、アプリケーションタスクの実行時間として記憶媒体に記録する機能は、プラットフォームタスクとして実現されていてもよい。このようになっていることで、アプリケーションタスクの実行時間の計算機能をプラットフォームの一部として設計することができるので、アプリケーションタスクの設計者が、アプリケーションタスクの実行時間算出のためのプログラムを作成する必要がなくなる。 Further, the function of recording the result of subtracting the total execution time of execution tasks calculated within the measurement period from the measurement period in the storage medium as the execution time of the application task may be realized as a platform task. In this way, the application task execution time calculation function can be designed as part of the platform, so the application task designer creates a program for calculating the application task execution time. There is no need.
また、本発明の第1および第2の特徴は、プログラムとしても実現することができる。 The first and second features of the present invention can also be realized as a program.
以下、本発明の一実施形態について説明する。図1に、本実施形態に係るECU1の構成およびRAMモニタ2との接続関係を示す。ECU1は、車両に搭載され、車両の挙動等を制御するための電子制御装置である。例えば、ECU1は、エンジンECUであってもよい。
Hereinafter, an embodiment of the present invention will be described. FIG. 1 shows the configuration of the
ECU1は、タイマ10、RAM11、ROM12、CPU13等を有している。タイマ10は、時刻の経過を計測する。CPU13は、ROM12からプログラムを読み出して実行し、その実行の際にRAM11を作業領域として各種演算を行う。また、CPU13は、その演算の際に、図示しないセンサ(例えば車速センサ、アクセル開度センサ)から車両内の情報を取得してもよいし、図示しないアクチュエータ(例えばインジェクタ、アンチロックブレーキ装置)を制御するようになっていてもよい。RAMモニタ2は、必要なときにECU1に接続されることで、RAM11の記憶内容を読み取ることができる装置である。
The
ここで、CPU13が実行するプログラムについて説明する。ROM12に記録されているプログラムは、リアルタイムオペレーティングシステム(以下、RTOSという)用のプログラム、プラットフォーム用のプログラム、およびアプリケーション用のプログラムを含んでいる。図2に、アプリケーション31、プラットフォーム32、RTOS33の階層構造を、ハードウェア34との関係で概念的に示す。RTOS33は、ECU1のハードウェア(RAM、ROM、図示しないI/O等)34を直接制御するシステムである。RTOS33としては、例えば、OSEK(登録商標)仕様のものを用いてもよい。プラットフォーム32は、当該ハードウェア34およびRTOS33を直接制御するシステムである。
Here, a program executed by the
アプリケーション31は、ECU1の各種機能(例えばエンジン制御、オートクルーズ制御、レーンキープ制御等)を実現するためのシステムであり、この目的のために、プラットフォーム32を介して当該ハードウェア34およびRTOS33を利用する。このような階層構造の存在により、アプリケーションは、RTOS33およびハードウェア34の機能を直接利用する必要がなくなる。したがって、プラットフォーム32とアプリケーション31との間のインターフェースを共通化しておけば、プラットフォーム32がECU毎のRTOS33およびハードウェア34の違いを吸収するので、異なる種類のECUに同じアプリケーション31を使用することができる。すなわち、アプリケーション31の再配置が可能となる。
The
また、ROM中のプログラムは、タスクというプログラム単位に分かれており、CPU13は、それら複数のタスクのうち一時期に1つのタスクの実行を行うようになっている。そしてCPU13は、あらかじめ定められたタスク間の優先順等に基づいて、実行する対象のタスクを順次切り替えていく。この実行タスクの切り替え機能を、タスクスケジューリング機能という。タスクスケジューリング機能は、RTOS33によって実現される。
The programs in the ROM are divided into program units called tasks, and the
図3に、CPU13が実行する各種タスクの実行順序の一例を示す。この例においては、計測タスク、PFタスク1、APタスク1、2、…n、PFタスク2等を、CPU13が実行している。そして、これら各タスクには、この順に高い優先度が割り当てられている。例えば、他に実行するプログラムがないときに実行されるアイドルタスクであるPFタスク2の実行タイミング53中に、APタスク2の実行タイミング63が来ると、CPU13はPFタスク2の実行を終了し、APタスク2の実行を開始する。
FIG. 3 shows an example of the execution order of various tasks executed by the
なお、APタスク(第1のグループに属する第1グループタスクの一例に相当する)とは、アプリケーションのプログラムの単位となるタスクをいい、PFタスク(第2のグループに属する第2グループタスクの一例に相当する)は、プラットフォームのプログラムの単位となるタスクをいう。どのAPタスクよりもどのPFタスクよりも優先度の高い計測タスクは、タイマ割り込みによって所定の周期Tc(例えば1ms)で実行される。 The AP task (corresponding to an example of a first group task belonging to the first group) refers to a task that is a unit of an application program, and is a PF task (an example of a second group task belonging to the second group). Corresponds to a task that is a unit of the platform program. A measurement task having a higher priority than any PF task over any AP task is executed at a predetermined cycle Tc (for example, 1 ms) by a timer interrupt.
なお、RTOSの提供する機能によって、CPU13は、各タスクの実行開始時にタスク開始フック関数を実行し、各タスクの終了時にタスク終了フック関数を実行するようになっている。図4および図5に、それぞれタスク開始フック関数100およびタスク終了フック関数200の処理内容を、フローチャートで示す。
Note that the function provided by the RTOS allows the
タスク開始フック関数100の実行において、CPU13は、まずステップ110で、開始するタスクのタスクIDを取得する。タスクIDとは、各タスクを識別するために、各タスクにあらかじめ(設計時に)割り当てられたコードである。このタスクIDの内容によって、対応するタスクがAPタスクであるかPFタスクであるかを判別することができるようになっている。タスクIDの取得方法は周知であるので、ここではその詳細についての説明は行わない。
In the execution of the task start
続いてステップ120で、取得したタスクIDがPFタスクを示しているかAPタスクを示しているかを判定する。PFタスクを示していると判定した場合、続いてステップ130で、タイマ10からの出力信号に基づいて現在時刻を取得し、その現在時刻を変数Spfとして、RAM11に記録し、その後タスク開始フック関数100の実行を終了する。
In
ステップ120でAPタスクを示していると判定した場合、続いてステップ140で、実行開始したタスク(以下、実行タスクという)が、実行時間計測対象のタスク(以下、指定タスクという)として指定されているか否かを判定する。この判定は、具体的には、ステップ110で取得したタスクIDが、あらかじめRAM11、ROM12、図示しない不揮発性書き込み可能記憶媒体等に記録されている1つまたは複数の指定タスクIDの1つに一致しているか否かによって決まる。指定タスクIDは、RAMモニタ2等の外部の装置を用いて作業者が随時RAM11に記録できるようになっていてもよい。
If it is determined in
実行タスクが指定タスクの1つでない場合、タスク開始フック関数100の実行を終了し、指定タスクの1つである場合、続いてステップ150で、タイマ10からの出力信号に基づいて現在時刻を取得し、その現在時刻を変数Sappとして、RAM11に記録し、その後タスク開始フック関数100の実行を終了する。
If the execution task is not one of the designated tasks, the execution of the task start
このように、CPU13は、タスクの実行開始時に、当該タスクがPFタスクであるか指定タスクであれば、その開始時の時刻を、APタスクの実行開始時刻またはPFタスクの実行開始時刻として、RAM11に記録する。
As described above, when the task is started, if the task is a PF task or a designated task, the
タスク終了フック関数200の実行において、CPU13は、まずステップ210で、終了するタスクのタスクIDを取得する。続いてステップ220で、取得したタスクIDがPFタスクを示しているかAPタスクを示しているかを判定し、PFタスクを示していると判定した場合続いてステップ230を実行し、APタスクを示していると判定した場合続いてステップ250を実行する。
In executing the task
ステップ230では、現在時刻Eをタイマ10から取得し、続いてステップ240で、変数Tpfの値に、現在時刻Eから変数Spfの値を減算した結果を加算する。現在時刻Eから変数Spfの値を減算した結果は、実行を終了しようとしているタスクの開始時から現在(すなわち実行終了時)までの時間である。換言すれば、この減算値は、今回の実行タスクの実行時間である。変数Tpfは、後述するように、計測タスクの実行時にゼロにリセットされる。したがって、変数Tpfは、最後に計測タスクが実行されてから現在までのPFタスクの総実行時間を表している。ステップ240の後、タスク終了フック関数200の実行は終了する。
In
ステップ250では、終了しようとしているタスクが指定タスクの1つであるか否かを判定し、指定タスクの1つでなければタスク終了フック関数200の実行を終了し、指定タスクの1つであれば続いてステップ260を実行する。ステップ260では、現在時刻Eをタイマ10から取得し、続いてステップ270で、変数Tappの値に、現在時刻Eから変数Sappの値を減算した結果を加算する。現在時刻Eから変数Sappの値を減算した結果は、実行を終了しようとしているタスクの開始時から現在(すなわち実行終了時)までの時間である。換言すれば、この減算値は、今回の実行タスクの実行時間である。変数Tappは、後述するように、計測タスクの実行時にゼロにリセットされる。したがって、変数Tappは、最後に計測タスクが実行されてから現在までのすべての指定タスクの総実行時間を表している。ステップ270の後、タスク終了フック関数200の実行は終了する。
In
このように、CPU13は、タスクの実行終了時に、当該タスクがPFタスクであるか指定タスクであれば、その終了時の時刻と、RAM11に記録された当該タスクの実行開始時刻との差を、当該タスクの今回の実行時間として特定し、特定した実行時間を、変数Tpfまたは変数Tappに加算する。その結果、次の計測タスクの実行タイミングの直前には、変数Tpfには、期間Tcの間に実行されたすべてのPFタスクの総実行時間が記録されており、また、変数Tappには、期間Tcの間に実行されたすべての指定APタスクの総実行時間が記録されていることになる。例えば、図3において、APタスク1およびAPタスクnが指定タスクになっている場合、実行時間61、65、66の総和が、計測タスクの実行タイミング41から42までの期間Tcにおける指定タスクの総実行時間Tappとなり、また、実行時間62、67の総和が、計測タスクの実行タイミング42から43までの期間Tcにおける指定タスクの総実行時間Tappとなる。
In this way, at the end of execution of the task, if the task is a PF task or a designated task, the
ここで、計測タスクの詳細について説明する。図6に、計測タスク300のフローチャートを示す。CPU13は、この計測タスク300の実行において、まずステップ310で、指定APタスクによるCPU利用時間を計算するか、あるいは、全APタスクによるCPU利用時間を計算するかについての判定を行う。
Here, the details of the measurement task will be described. FIG. 6 shows a flowchart of the
この判定は、あらかじめRAM11、ROM12、または図示しない書き込み可能不揮発性記憶媒体に記録された設定値に基づいて実行する。ここで、設定値は、ECU1の製造時に決定されていてもよいし、RAMモニタ2等の外部の装置を用いて作業者が随時RAM11に記録できるようになっていてもよい。
This determination is executed based on a setting value recorded in advance in the
全APタスクによるCPU利用時間を計算する場合、続いてステップ320で、変数Tpf_aveに、変数Tpfと変数Tpf´の平均値を代入する。ここで、Tpf´は、後述する通り、前々回から前回の計測タスク300の実行タイミングまでの間に実行されたPFタスクの総実行時間である。変数Tpfは、今回から前回の計測タスク300の実行タイミングまでの間に実行されたPFタスクの総実行時間であるので、変数Tpf_aveは、直近の連続する2つの期間TcにおけるPFタスクの総実行時間の平均値である。この処理は、期間Tc毎に変化する総実行時間に対するフィルタリング処理の一種である。
When calculating the CPU usage time by all AP tasks, subsequently, in
さらにステップ330で、期間Tcから変数Tpf_aveを減算した結果を、変数Upfに代入する。この変数Upfの値は、期間Tc内で、PFタスクが実行されていない時間である。本実施形態においては、他のタスクが実行されていないときには必ずPF2タスクが実行されるので、PFタスクが実行されていない時間とは、PFタスク以外のタスクが実行されている時間と同じである。したがって、変数Upfは、実質的にすべてのAPタスクの期間Tc内における総実行時間である。
In
続いて、次の期間Tcのための処理として、ステップ340で変数Tpf´に現在のTpfの値を代入し、さらにステップ350で、Tpfをゼロにリセットする。このようになっていることで、次回の計測タスク300において、変数Tpf´が、当該計測タスク300の実行時から見て直前となる期間TcにおけるPFタスクの総実行時間として用いられる。ステップ350の後、計測タスク300の実行が終了する。このようなステップ320〜350の処理によって、直近の2つの期間TcにおけるすべてのAPタスクの実行時間の平均を算出することができる。そして、この実行時間を期間Tcで除算すれば、直近の2つの期間TcにおけるすべてのAPタスクによるCPU利用率を特定することができる。
Subsequently, as a process for the next period Tc, the current Tpf value is substituted into the variable Tpf ′ at
指定APタスクのみによるCPU利用時間を計算する場合、続いてステップ360で、変数Tapp_aveに、変数Tappと変数Tapp´の平均値を代入する。ここで、Tapp´は、後述する通り、前々回から前回の計測タスク300の実行タイミングまでの間に実行された指定APタスクの総実行時間である。変数Tappは、今回から前回の計測タスク300の実行タイミングまでの間に実行された指定APタスクの総実行時間であるので、変数Tapp_aveは、直近の連続する2つの期間Tcにおける指定APタスクの総実行時間である。この処理は、期間Tc毎に変化する総実行時間に対するフィルタリング処理の一種である。
When calculating the CPU usage time by only the designated AP task, in step 360, the average value of the variable Tapp and the variable Tap 'is substituted for the variable Tap_ave. Here, Tap 'is the total execution time of the designated AP task executed between the previous time and the execution timing of the
続いて、次の期間Tcのための処理として、ステップ370で変数Tapp´に現在の変数Tappの値を代入し、さらにステップ380で、変数Tappをゼロにリセットする。このようになっていることで、次回の計測タスク300において、変数Tapp´が、当該計測タスク300の実行時から見て直前となる期間TcにおけるPFタスクの総実行時間として用いられる。ステップ380の後、計測タスク300の実行が終了する。このようなステップ360〜380の処理によって、直近の2つの期間TcにおけるすべてのAPタスクの実行時間の平均を算出することができる。そして、この実行時間を期間Tcで除算すれば、直近の2つの期間Tcにおけるすべての指定APタスクによるCPU利用率を特定することができる。
Subsequently, as a process for the next period Tc, the value of the current variable Tapp is substituted into the variable Tapp ′ at Step 370, and the variable Tapp is reset to zero at
以上のように、個々のタスクについて、当該タスクの開始時刻と終了時刻との差を実行時間として特定することで、当該タスクの実行時間を特定することができる。このような方法を用いることで、タスクの実行時間が非常に短い場合であっても、確実にその実行時間を特定することができ、また、アイドルタスクの一部として実行される他の処理によって実行時間の計算に狂いが生じることがない。 As described above, for each task, the execution time of the task can be specified by specifying the difference between the start time and the end time of the task as the execution time. By using such a method, even if the task execution time is very short, the execution time can be reliably specified, and it can be determined by other processes executed as part of the idle task. There is no error in the calculation of execution time.
このように、あらかじめ指定されたAPタスクのタスクIDと、実行を開始するAPタスクのタスクIDとを照合し、それらが合致したときに、当該APタスクの開始時刻と終了時刻との差を実行時間として記録することで、所望のタスクの実行時間を特定することができる。 In this way, the task ID of the AP task designated in advance is collated with the task ID of the AP task to start execution, and when they match, the difference between the start time and end time of the AP task is executed. By recording the time, the execution time of the desired task can be specified.
また、各期間Tcについて算出された全APタスクまたは全指定APタスクの総実行時間には、それより過去の複数の期間Tcにおける算出結果を用いたフィルタリング処理が施される。フィルタリング処理が施されない場合には、図7に示すように、算出値71〜76の値の、異なる期間Tc間のばらつきが大きいので、それら算出値71〜76に基づいて作成される波形77の形状も変化が激しい。
Further, the total execution time of all AP tasks or all designated AP tasks calculated for each period Tc is subjected to a filtering process using calculation results in a plurality of periods Tc in the past. When the filtering process is not performed, as shown in FIG. 7, since the variation of the calculated
しかし、フィルタリングが施されると、図8に示すように、算出値81〜86の値の、異なる期間Tc間のばらつきが抑えられるので、それら算出値81〜86に基づいて作成される波形77の形状も変化が緩やかである。したがって、作業者は、フィルタリングを施した結果のデータをRAMモニタ2を用いて取得した場合は、改めて算出結果の平均化等の作業を行う必要がなくなる。
However, when filtering is performed, as shown in FIG. 8, variations in the calculated
また、計測タスクがプラットフォームタスクとして実現されているので、アプリケーションタスクの設計者が、アプリケーションタスクの実行時間算出のためのプログラムを作成する必要がなくなる。したがって、アプリケーションの設計内容によらず、タスクの処理負荷の計測が可能となる。 Further, since the measurement task is realized as a platform task, the designer of the application task does not need to create a program for calculating the execution time of the application task. Therefore, the task processing load can be measured regardless of the design contents of the application.
なお、上記実施形態においては、ECU1が電子計算装置の一例に相当し、RAM11、ROM12、およびCPU13中のレジスタが記憶媒体の一例に相当する。また、CPU13が、タスク開始フック関数100のステップ140を実行することで判定手段の一例として機能し、ステップ150を実行することで開始時記録手段の一例として機能し、タスク終了フック関数200のステップ270を実行することで終了時記録手段の一例として機能し、また、タスク開始フック関数100のステップ130およびタスク終了フック関数200のステップ240を実行することで開始終了時算出手段の一例として機能し、計測タスク300のステップ320、33、340、350を実行することで計測結果記録手段の一例として機能する。
In the above embodiment, the
(他の実施形態)
以上、本発明の実施形態について説明したが、本発明の範囲は、上記実施形態のみに限定されるものではなく、本発明の各発明特定事項の機能を実現し得る種々の形態を包含するものである。
(Other embodiments)
As mentioned above, although embodiment of this invention was described, the scope of the present invention is not limited only to the said embodiment, The various form which can implement | achieve the function of each invention specific matter of this invention is included. It is.
例えば、上記の実施形態においては、ECU1は車両に搭載されるECUとなっているが、本発明の電子計算装置は、車両に搭載されるものでなくともよい。
For example, in the above-described embodiment, the
また、上記の実施形態においては、PFタスクの総実行時間に、計測タスクの実行時間を含めるようになっていてもよいし、含めないようになっていてもよい。期間TCにおける計測タスクの実行時間は、期間TCに比べて十分短いので、どちらの場合においても、アプリケーションタスクの実行時間の計測には大きな影響を及ぼさない。 In the embodiment described above, the execution time of the measurement task may be included in the total execution time of the PF task, or may not be included. Since the execution time of the measurement task in the period TC is sufficiently shorter than that in the period TC, in either case, the measurement of the execution time of the application task is not greatly affected.
また、APタスクとPFタスクの間の優先度の関係は、図3のようなものに限らず、どのようになっていてもよい。 Further, the priority relationship between the AP task and the PF task is not limited to that shown in FIG. 3 and may be any method.
1…ECU、2…RAMモニタ、10…タイマ、11…RAM、12…ROM、
13…CPU、31…アプリケーション、32…プラットフォーム、33…RTOS、
34…ハードウェア、41〜43…計測タスク、51〜55…PFタスク、
61〜67…APタスク、71〜76、81〜86…算出値、77、87…波形、
100…タスク開始フック関数、200…タスク終了フック関数、
300…計測タスク。
1 ... ECU, 2 ... RAM monitor, 10 ... timer, 11 ... RAM, 12 ... ROM,
13 ... CPU, 31 ... application, 32 ... platform, 33 ... RTOS,
34 ... Hardware, 41-43 ... Measurement task, 51-55 ... PF task,
61-67 ... AP task, 71-76, 81-86 ... calculated value, 77, 87 ... waveform,
100: Task start hook function, 200: Task end hook function,
300: Measurement task.
Claims (6)
前記CPUは:
前記複数のタスクのうち1つのタスク(以下、実行タスクという)の実行を開始するとき、前記実行タスクが前記記憶媒体に記録された指定タスクであるか否かを判定する判定手段(140)と、
前記第1判定手段の判定結果が肯定的であることに基づいて、前記実行タスクの実行開始時に、その開始時の時刻を、前記実行タスクの実行開始時刻として、前記記憶媒体に記録する開始時記録手段(150)と、
前記実行タスクの実行終了時に、その終了時の時刻と、前記記憶媒体に記録された前記実行タスクの実行開始時刻との差を、前記実行タスクの実行時間として前記記憶媒体に記録する終了時記録手段(270)と、
を有していることを特徴とする電子計算装置。 An electronic computing device comprising a storage medium and a CPU, and switching a task to be executed by the CPU from a plurality of tasks recorded in the storage medium,
The CPU is:
Determining means (140) for determining whether or not the execution task is a designated task recorded in the storage medium when starting execution of one of the plurality of tasks (hereinafter referred to as an execution task); ,
When the execution result of the execution task is started based on the determination result of the first determination means being positive, the start time is recorded in the storage medium as the execution start time of the execution task. Recording means (150);
At the end of execution of the execution task, a recording at the end of recording the difference between the time at the end of the execution task and the execution start time of the execution task recorded on the storage medium as the execution time of the execution task Means (270);
An electronic computing device characterized by comprising:
前記CPUは、前記複数の第1グループタスクのどれも実行していないときは必ず前記複数の第2グループタスクのいずれかを実行しており、
前記CPUは:
所定の計測期間内における前記第2グループタスクの実行のそれぞれにおいて、実行対象となる第2グループタスク(以下、実行タスクという)の実行開始時に、その開始時の時刻を、前記実行タスクの実行開始時刻として、前記記憶媒体に記録し、また、前記実行タスクの実行終了時に、その終了時の時刻と、前記記憶媒体に記録された前記実行タスクの実行開始時刻との差を、前記実行タスクの実行時間として算出する開始終了時算出手段と、
前記計測期間内において前記開始終了時算出手段が算出した前記実行タスクの実行時間の総和を前記計測期間から減算した結果を、前記複数の第1グループタスクの実行時間として、前記記憶媒体に記録する計測結果記録手段と、
を有することを特徴とする電子計算装置。 A CPU having a storage medium and a CPU, and executed by the CPU from among a plurality of first group tasks belonging to a first group and a plurality of second group tasks belonging to a second group recorded in the storage medium An electronic computing device for switching a target task,
The CPU always executes one of the plurality of second group tasks when none of the plurality of first group tasks is executed,
The CPU is:
In each execution of the second group task within a predetermined measurement period, when the execution of the second group task (hereinafter referred to as an execution task) to be executed starts, the time at the start is used to start the execution of the execution task. The time is recorded in the storage medium, and at the end of execution of the execution task, the difference between the end time and the execution start time of the execution task recorded in the storage medium is Start / end time calculating means for calculating as execution time;
The result obtained by subtracting the total execution time of the execution tasks calculated by the start / end time calculation means within the measurement period from the measurement period is recorded in the storage medium as the execution time of the plurality of first group tasks. A measurement result recording means;
An electronic computing device comprising:
前記複数のタスクのうち1つのタスク(以下、実行タスクという)の実行を開始するとき、前記実行タスクが前記記憶媒体に記録された指定タスクであるか否かを判定する判定手段、
前記第1判定手段の判定結果が肯定的であることに基づいて、前記実行タスクの実行開始時に、その開始時の時刻を、前記実行タスクの実行開始時刻として、前記記憶媒体に記録する開始時記録手段、および、
前記実行タスクの実行終了時に、その終了時の時刻と、前記記憶媒体に記録された前記実行タスクの実行開始時刻との差を、前記実行タスクの実行時間として前記記憶媒体に記録する終了時記録手段として、前記CPUを機能させるプログラム。 A program comprising a storage medium and a CPU, and used for an electronic computing device that switches a task to be executed by the CPU from a plurality of tasks recorded on the storage medium,
Determining means for determining whether or not the execution task is a designated task recorded in the storage medium when starting execution of one of the plurality of tasks (hereinafter referred to as an execution task);
When the execution result of the execution task starts based on the determination result of the first determination means being affirmative, the start time is recorded in the storage medium as the execution start time of the execution task. Recording means, and
At the end of execution of the execution task, a recording at the end of recording the difference between the time at the end of the execution task and the execution start time of the execution task recorded on the storage medium as the execution time of the execution task As a means, a program for causing the CPU to function.
所定の計測期間内における前記第2グループタスクの実行のそれぞれにおいて、実行対象となる第2グループタスク(以下、実行タスクという)の実行開始時に、その開始時の時刻を、前記実行タスクの実行開始時刻として、前記記憶媒体に記録し、また、前記実行タスクの実行終了時に、その終了時の時刻と、前記記憶媒体に記録された前記実行タスクの実行開始時刻との差を、前記実行タスクの実行時間として算出する開始終了時算出手段、および、
前記計測期間内において前記開始終了時算出手段が算出した前記実行タスクの実行時間の総和を前記計測期間から減算した結果を、前記複数の第1グループタスクの実行時間として、前記記憶媒体に記録する計測結果記録手段、として、前記CPUを機能させるプログラム。 A CPU having a storage medium and a CPU, and executed by the CPU from among a plurality of first group tasks belonging to a first group and a plurality of second group tasks belonging to a second group recorded in the storage medium A program used for an electronic computing device that switches a target task and causes the CPU to execute any one of the plurality of second group tasks whenever any of the plurality of first group tasks is not executed. ,
In each execution of the second group task within a predetermined measurement period, when the execution of the second group task (hereinafter referred to as an execution task) to be executed starts, the time at the start is used to start the execution of the execution task. The time is recorded in the storage medium, and at the end of execution of the execution task, the difference between the end time and the execution start time of the execution task recorded in the storage medium is Start / end time calculating means for calculating the execution time; and
The result obtained by subtracting the total execution time of the execution tasks calculated by the start / end time calculation means within the measurement period from the measurement period is recorded in the storage medium as the execution time of the plurality of first group tasks. A program that causes the CPU to function as measurement result recording means.
Priority Applications (3)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2007122195A JP2008276674A (en) | 2007-05-07 | 2007-05-07 | Electronic computer capable of specifying execution time of task, and program for electronic computer |
US12/149,685 US20080282248A1 (en) | 2007-05-07 | 2008-05-06 | Electronic computing device capable of specifying execution time of task, and program therefor |
DE102008022302A DE102008022302A1 (en) | 2007-05-07 | 2008-05-06 | Electronic computing device for determining an execution time of a task and program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2007122195A JP2008276674A (en) | 2007-05-07 | 2007-05-07 | Electronic computer capable of specifying execution time of task, and program for electronic computer |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2008276674A true JP2008276674A (en) | 2008-11-13 |
Family
ID=39829638
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2007122195A Withdrawn JP2008276674A (en) | 2007-05-07 | 2007-05-07 | Electronic computer capable of specifying execution time of task, and program for electronic computer |
Country Status (3)
Country | Link |
---|---|
US (1) | US20080282248A1 (en) |
JP (1) | JP2008276674A (en) |
DE (1) | DE102008022302A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10843704B2 (en) | 2017-03-20 | 2020-11-24 | Hyundai Motor Company | Vehicle and control method thereof |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010033436A (en) * | 2008-07-30 | 2010-02-12 | Autonetworks Technologies Ltd | Control apparatus, control method, and computer program |
US20160103708A1 (en) * | 2014-10-09 | 2016-04-14 | Profoundis Labs Pvt Ltd | System and method for task execution in data processing |
KR102085899B1 (en) * | 2018-12-10 | 2020-03-06 | 현대오트론 주식회사 | Operating Monitoring Method For CPU Of Vehicle ECU, And Monitoring Unit |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0540651A (en) | 1991-08-06 | 1993-02-19 | Nec Corp | Analyzer for computer system load |
JP3376096B2 (en) | 1994-05-30 | 2003-02-10 | 昭和電工株式会社 | Soft injection molded article of thermoplastic olefin resin composition |
-
2007
- 2007-05-07 JP JP2007122195A patent/JP2008276674A/en not_active Withdrawn
-
2008
- 2008-05-06 US US12/149,685 patent/US20080282248A1/en not_active Abandoned
- 2008-05-06 DE DE102008022302A patent/DE102008022302A1/en not_active Withdrawn
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10843704B2 (en) | 2017-03-20 | 2020-11-24 | Hyundai Motor Company | Vehicle and control method thereof |
Also Published As
Publication number | Publication date |
---|---|
DE102008022302A1 (en) | 2008-11-13 |
US20080282248A1 (en) | 2008-11-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP5069325B2 (en) | Task execution control device and program | |
JP4770602B2 (en) | Electronics | |
JP2793993B2 (en) | Program runaway detection method in microcomputer | |
US20040039935A1 (en) | Method and device for measuring the execution time of a real task in a real time system | |
JP2008513900A (en) | Method for processing a computer program on a computer system | |
JP2002278779A (en) | Processing performing device and program | |
JP7282195B2 (en) | Machine learning-based anomaly detection for embedded software applications | |
JP4515701B2 (en) | VEHICLE CONTROL PROGRAM AND VEHICLE CONTROL DEVICE | |
JP2008276674A (en) | Electronic computer capable of specifying execution time of task, and program for electronic computer | |
US10162324B2 (en) | Method for manipulating a control program of a control device | |
US20120246650A1 (en) | Method for processing information and activities in a control and/or regulating system with the aid of a multi-core processor | |
KR102410940B1 (en) | Method and system for ECU execution time monitoring and fault finding | |
JP3376906B2 (en) | Computer load factor measurement system | |
WO2022262786A1 (en) | Method and apparatus for correcting opening degree of accelerator pedal, device, program, medium, controller, and vehicle | |
JP2024005967A (en) | Fraudulent signal detection device, vehicle, and fraudulent signal detection method | |
JP7435182B2 (en) | electronic control unit | |
US20020152256A1 (en) | Method and device for reconstructing the process sequence of a control program | |
JP6522550B2 (en) | Electronic control unit | |
JP3389745B2 (en) | Apparatus and method for measuring program performance | |
JP2005100017A (en) | Processor simulator, interruption delay count program and simulation method of processor | |
JP2004318672A (en) | Processor | |
CN113312167B (en) | Service control method and device, electronic equipment and computer readable medium | |
CN111858272B (en) | Method and device for judging program execution delay and terminal equipment | |
JPH08137703A (en) | Task switching device | |
US7417571B2 (en) | Method for providing a correlation |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A300 | Application deemed to be withdrawn because no request for examination was validly filed |
Free format text: JAPANESE INTERMEDIATE CODE: A300 Effective date: 20100803 |