JP3783553B2 - Information processing device - Google Patents

Information processing device Download PDF

Info

Publication number
JP3783553B2
JP3783553B2 JP2000348121A JP2000348121A JP3783553B2 JP 3783553 B2 JP3783553 B2 JP 3783553B2 JP 2000348121 A JP2000348121 A JP 2000348121A JP 2000348121 A JP2000348121 A JP 2000348121A JP 3783553 B2 JP3783553 B2 JP 3783553B2
Authority
JP
Japan
Prior art keywords
area
program
global variable
priority
task
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP2000348121A
Other languages
Japanese (ja)
Other versions
JP2002149421A (en
Inventor
義貴 植松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Denso Corp
Original Assignee
Denso Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Denso Corp filed Critical Denso Corp
Priority to JP2000348121A priority Critical patent/JP3783553B2/en
Publication of JP2002149421A publication Critical patent/JP2002149421A/en
Application granted granted Critical
Publication of JP3783553B2 publication Critical patent/JP3783553B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Description

【0001】
【発明の属する技術分野】
本発明は、割込処理が実行される処理プログラムにおいて、割込処理のリアルタイム性を確保する技術に関する。
【0002】
【従来の技術】
例えば車両に搭載される電子制御装置(以下「ECU」という。)に用いられる制御プログラムでは、制御応答性や安全性の確保等から所定の処理をリアルタイムに実行する必要性がある。そのため、このようなリアルタイム性を必要とする処理(リアルタイム処理)は、メインルーチンとは別の割込ルーチンとして用意されるのが一般的である。割り込みルーチンは、例えばイベントの発生等をトリガとしてメインルーチンの実行中に優先して実行される。優先して実行されるとは、割込ルーチンの実行により一時的にメインルーチンの実行が中断され、割込ルーチン終了後に、再びその中断位置からメインルーチンが実行されることをいう。
【0003】
近年では、上述したECUの制御プログラムもOS(オペレーティング・システム)上で動作するようになっており、メインルーチンや割込ルーチン等の実行単位がタスクと呼ばれ、OSにより管理されている。
このタスクには実行の優先度を示すレベル(タスクレベル)が設定されており、このタスクレベルに基づいて上述したような割込処理を実現している。つまり、OSの管理の下、相対的にレベルの高いタスクである上位タスクは、相対的にレベルの低いタスクである下位タスクに優先する(割り込む)。上述した例で言えば、メインルーチンによる処理が下位タスクに相当し、割込ルーチンによる処理が上位タスクに相当する。
【0004】
このようなタスク概念の導入は、タスクレベルを設定するという極めて簡単な情報記述だけで何等プログラム間の実行タイミング等を記述する必要をなくし、割込処理の設計を容易にした。
一方、イベント発生というような、下位タスクの処理タイミングに関係しないタイミングで、上位タスクが割り込む。そのため、下位タスクに不具合が生じる可能性がある。ここで本発明で前提とする、上位タスクの割り込みによって生じる不具合について説明する。
【0005】
上位タスクと下位タスクとで共通の変数を操作する場合を考える。この共通の変数は、例えばプログラム全体が複数の関数にて構成されているとき、これら関数間で共通にアクセスできる記憶領域に記憶されるものであり、グローバル変数(大域変数)と呼ばれる。
【0006】
例えば、下位タスクにて2つのグローバル変数a,bを参照し、上位タスクにて同一のグローバル変数a,bを更新する場合を考える。このとき、下位タスクにて変数aが参照された後、変数bが参照される前に上位タスクが割り込むと、グローバル変数a,bが共に更新されてしまい、その後、下位タスクで参照されるグローバル変数bは上位タスクによる更新後のものになってしまう。つまり、一方のグローバル変数aについては時間的に古いものが参照され、他方のグローバル変数bについては時間的に新しいものが参照されるのである。このような状態は、グローバル変数の同時性(一貫性、無矛盾性などと呼ばれることもある)が失われた状態と表現され、この同時性が必要とされる場合、例えば時間的な相関関係が変数間に存在するような場合には、制御上の問題を招く事態となる。
【0007】
また例えば、下位タスクにて2つのグローバル変数a,bを更新し、上位タスクにて同一のグローバル変数a,bを参照する場合も同様である。このとき、下位タスクにて変数aが更新された後、変数bが更新される前に、上位タスクによってグローバル変数a,bが参照される可能性がある。このような上位タスクの割り込みがあると、一方のグローバル変数aについては時間的に新しいものが参照され、他方のグローバル変数bについては時間的に古いものが参照されてしまう。つまり、この場合も、グローバル変数の同時性が失われてしまう。
【0008】
なお、上述した例では2つのグローバル変数を処理対象としていたが、同時性を必要とする3つ以上のグローバル変数を処理対象とする場合も、同様の問題が発生する。また、1つのグローバル変数を処理対象とする場合であっても、同様の問題が発生する。例えば下位タスクで2回連続して同一のグローバル変数を読み出す場合が一例として挙げられる。このときは、下位タスクによる1回目の変数の参照後に上位タスクでその変数が更新されると、2回目に読み出された変数は、1回目に読み出された変数と異なるものとなってしまい、同時性が失われることになる。
【0009】
従来、このような同時性を確保するため、下位タスクのプログラム中には、必要に応じて割込禁止/許可命令を記述していた。割込禁止命令は、上位タスクの割り込みを禁止するものであり、割込許可命令は上位タスクの割り込みを許可するものである。つまり、割込禁止命令と割込許可命令で挟まれた処理ステップの途中では、上位タスクは割り込めない。したがって、同時性を必要とするグローバル変数に係る処理の前後にそれぞれ割込禁止命令、割込許可命令を記述しておけば、上位タスクによる参照・更新がなされないため、グローバル変数の同時性が確保できることになる。
【0010】
【発明が解決しようとする課題】
上述したような割込処理は、リアルタイム処理の実行には不可欠の技術であり、OSによるタスク管理といったコンピュータ技術の発達によって容易に設計されるに至った。しかしながら一方で、割込処理が増えると、それに応じて割込禁止/許可命令の記述が増えることにより、リアルタイム性が確保できなくなってしまうことが問題になる。これについて説明する。
【0011】
上述したように、下位タスクのプログラム中に割込禁止/許可命令が記述されると、割込禁止命令と割込許可命令で挟まれた処理ステップの途中では、上位タスクは割り込めない。すなわち、上位タスクは下位タスクで割込許可がなされるまで実行を待つことになり、この期間は、実行の優先度が実質的に逆転することになる。そのため、割込処理が増えてこのような期間が多くなればなるほど、リアルタイム処理である上位タスクの実行が遅れる可能性が高くなり、制御応答性や安全性の確保等が実現が困難になるなど、制御性能に影響を及ぼす結果を招いてしまう。
【0012】
本発明は、このような問題を解決するためになされたものであり、相対的に優先度の高い上位プログラムによる割込処理を遅らせることなく、しかも、相対的に優先度の低い下位プログラムとの間で共通に使用されるグローバル変数の参照時の同時性を確保することを目的とする。
【0013】
【課題を解決するための手段及び発明の効果】
上述した目的を達成するためになされた請求項1に記載の情報処理装置は、実行単位となる複数の処理プログラムを当該処理プログラム毎に設定される優先度に基づき実行することによって、一連の機能を実現する。例えばOS上でタスク管理されるプログラムであれば、この処理プログラム毎にタスクが生成されることになり、タスク毎に設定されるタスクレベルがここでいう優先度に相当する。なお、以下では各機能の実現において処理プログラムを主体とした表現を便宜上用いることがあるが、実際には情報処理装置の備えるいわゆるCPUが主体となって処理プログラムを実行することによって各機能が実現されることは言うまでもない。
【0014】
本発明では、グローバル変数を2つの領域に重複させて記憶させる。グローバル変数は、優先度の相対的に低い下位プログラムと優先度の相対的に高い上位プログラムとの間で共通に使用される変数である。ここで「2つの領域に重複させて記憶させる」というのは、各グローバル変数をそれぞれ、一方の領域(以下「領域1」という。)と他方の領域(以下「領域2」という。)の両方に記憶することをいう。そして、例えば領域1を公開領域として設定し、領域2を作業領域として設定する。
【0015】
そして、本発明では、下位プログラムによるグローバル変数の参照途中で、上位プログラムによってグローバル変数が更新される可能性のある第1のケースに対し、次のような構成を採用した。
すなわち、上位プログラムでは、上位更新処理を実行することによって、作業領域を使用してグローバル変数を更新し、一方、下位プログラムでは、下位参照処理を実行することによって、公開領域を使用してグローバル変数を参照するようにした。つまり、グローバル変数の参照と更新を別々の領域で行うようにし、下位プログラムによるグローバル変数の参照時における同時性を確保したのである。
【0016】
具体的に、下位プログラムにて2つのグローバル変数a,bを参照し、上位プログラムにて同一のグローバル変数a,bを更新する場合を考える。このとき、下位プログラムでは、公開領域に記憶されたグローバル変数a,bを参照する。一方、上位プログラムは、作業領域に記憶されたグローバル変数a,bを更新する。したがって、例えば下位プログラムによる参照途中で上位プログラムが割り込んでも、作業領域に記憶されたグローバル変数a,bが更新されるだけであり、下位プログラムの参照する公開領域に記憶されたグローバル変数a,bは更新されない。すなわち、下位プログラムで参照されるグローバル変数a,bの同時性が確保される。
【0017】
そして、下位プログラムではさらに、下位参照処理によるグローバル変数の参照を完了すると、領域切換処理を実行することによって、作業領域を新たに公開領域として設定しなおすと共に公開領域を新たに作業領域として設定しなおす。
「グローバル変数の参照を完了する」とは、同時性を必要とするグローバル変数の一連の参照処理が完了することをいう。例えば同時性を必要とする複数のグローバル変数の参照処理を全て完了した場合であることが考えられる。また、同時性を必要とする1つのグローバル変数の複数回の参照処理を全て完了した場合であることが考えられる。
【0018】
参照を完了した時点では、それ以前の上位プログラムの割り込みによって作業領域のグローバル変数が更新されている可能性がある。したがって、作業領域と公開領域とを切り換えることにより、次の参照処理において、更新されたグローバル変数が参照されるようにする。
【0019】
このようにすれば、上位プログラムによる割込処理を遅らせることなく、しかも、下位プログラムで参照されるグローバル変数の同時性を確保することができる。
ところで、上述した構成は、下位プログラムによるグローバル変数の参照途中で、上位プログラムによってグローバル変数が更新される可能性のある第1のケースに対するものであった。これに対し、さらに、下位プログラムによるグローバル変数の更新途中で、上位プログラムによってグローバル変数が参照される可能性のある第2のケースも考えられる。上述した第1及び第2のそれぞれのケースに対し、下位プログラム及び上位プログラムにおけるグローバル変数参照時の同時性を確保するために、請求項2に示す構成を採用することが考えられる。
【0020】
すなわち、上位プログラムでは、上位参照処理を実行することによって、公開領域を使用してグローバル変数を参照し、一方、下位プログラムでは、下位更新処理を実行することによって、作業領域を使用してグローバル変数を更新することを特徴とするものである。
【0021】
この場合も、グローバル変数の参照と更新を別々の領域で行うようにしたことによって、このときは、上位プログラムによる参照時におけるグローバル変数の同時性を確保した。
具体的に、下位プログラムにて2つのグローバル変数a,bを更新し、上位プログラムにて同一のグローバル変数a,bを参照する場合を考える。このとき、下位プログラムでは、作業領域に記憶されたグローバル変数a,bを更新する。一方、上位プログラムは、公開領域に記憶されたグローバル変数a,bを参照する。したがって、例えば下位プログラムによる更新途中で上位プログラムが割り込んでも、公開領域に記憶されたグローバル変数a,bが参照されることになり、更新途中の作業領域に記憶されたグローバル変数a,bが参照されることはない。すなわち、上位プログラムで参照されるグローバル変数a,bの同時性が確保される。
【0022】
そして、この場合も下位プログラムでは、下位更新処理によるグローバル変数の更新を完了すると、領域切換処理を実行することによって、作業領域と公開領域とを切り換える。次の参照処理において、更新されたグローバル変数が参照されるようにするためである。なお、「グローバル変数の更新を完了する」とは、参照の場合と同様、同時性を必要とするグローバル変数の一連の更新処理が完了することをいう。
【0023】
のようにすれば、上位プログラムによる割込処理を遅らせることなく、しかも上位プログラムあるいは下位プログラムで参照されるグローバル変数の同時性を確保することができる。
【0024】
ところで、本発明は、上述したような第1又は第2のケースにおけるグローバル変数参照時の同時性の確保を目的としてなされたものである。したがって、このいずれかのケースに該当することを前提に、各処理プログラムは、他の処理プログラムとの関係において、自らを、上位プログラム又は下位プログラムとして判断するようにしてもよい。
【0025】
例えば、ある処理プログラムがグローバル変数を参照する場合、別の処理プログラムによってグローバル変数が更新される可能性があることが予め分かっているという前提の下で、その別の処理プログラムに対して、上位プログラムとなるのか下位プログラムとなるのかを判断することが考えられる。同様に、ある処理プログラムがグローバル変数を更新する場合、別の処理プログラムによってグローバル変数が参照される可能性があることが予め分かっているという前提の下でその別の処理プログラムに対して、上位プログラムとなるのか下位プログラムとなるのかを判断することが考えられる。
【0026】
そこで、請求項に示すように、各処理プログラムでは、グローバル変数の参照又は更新を行う他の処理プログラムの優先度に基づき、下位処理プログラム又は上位処理プログラムのいずれに該当するかを判断する判断処理を実行し、当該判断処理による判断結果に基づいて、該当する処理を実行するようにしてもよい。具体的には、例えば請求項に示すように、グローバル変数の参照又は更新を行う処理プログラムの優先度の中で最も高いものを優先度記憶手段に記憶しておき、この記憶された優先度と処理プログラムに設定される優先度とを比較することによって、判断することが考えられる。このようにすれば、各処理プログラムをより汎用的なものとすることができる点で有利である。
【0027】
なお、定義されたグローバル変数の全てが各処理プログラムの処理対象となるわけではない。したがって、他の処理プログラムにて更新又は参照されるグローバル変数が、処理対象のグローバル変数以外である可能性も考えられる。このような場合は、割り込みによる干渉は発生しない。
【0028】
そこで、請求項に示すように、上述した判断処理を、判断対象の処理プログラムにて処理対象となるグローバル変数についての参照又は更新を行う他の処理プログラムの優先度に基づき判断するものにするとよい。この場合、具体的には、請求項に示すように、グローバル変数毎に、当該グローバル変数の参照又は更新を行う処理プログラムの優先度の中で最も高いものを優先度記憶手段に記憶しておくことが考えられる。このとき判断処理は、優先度記憶手段に記憶された、処理対象となるグローバル変数に対応する優先度と、判断対象の処理プログラムに設定された優先度とを比較することによって判断するものとする。
【0029】
ところで、本発明では、2つの領域の一方を公開領域とし、他方を作業領域として設定し、領域切換処理によって、公開領域と作業領域を切り換える。このような領域設定は、例えば請求項に示すように、領域情報記憶手段を備える構成とし、この領域情報記憶手段に設定情報を記憶することで実現することが考えられる。例えば設定情報として「1」又は「2」が記憶されるようにしておき、設定情報が「1」の場合は領域1が公開領域として、領域2が作業領域として設定され、一方「2」の場合は逆に、領域1が作業領域として、領域2が公開領域として設定されるという具合である。
【0030】
この場合、請求項に示すように、領域切換処理は、領域情報記憶手段に記憶された設定情報を更新することによって、作業領域を新たに公開領域として設定しなおすと共に公開領域を新たに作業領域として設定しなおすものとすることが考えられる。このような設定情報の更新は、CPUの一命令で実現できるため、このようにすれば領域切換の途中に割り込みがかかることもない。その結果、上位プログラムあるいは下位プログラムで参照されるグローバル変数の同時性を確実に確保できる。
【0031】
【発明の実施の形態】
以下、本発明を具体化した実施例を図面を参照して説明する。
[実施例]
図1は、本発明の「情報処理装置」を具体化したエンジン制御装置(以下「ECU」という。)1の構成を表すブロック図である。ECU1は、車両に搭載された内燃機関型エンジンの制御を行う。
【0032】
ECU1は、エンジンのクランク軸が所定角度回転する毎にパルス状の信号を出力する回転角センサ、エンジンの特定の気筒のピストンが所定位置(例えば上死点:TDC)にくる度にパルス状の信号を出力する基準位置センサ、エンジンの冷却水の温度を検出する水温センサ、及び酸素濃度を計測する酸素濃度センサ等、エンジンの運転状態を検出する様々なセンサ30からの信号を入力して波形整形やA/D変換を行う入力回路21と、入力回路21からのセンサ信号に基づき、エンジンを制御するための様々な処理を実行するマイクロコンピュータ(以下「マイコン」という。)10と、マイコン10からの制御データに応じて、エンジンに取付けられたインジェクタ(燃料噴射装置)及びイグナイタ(点火装置)等のアクチュエータ40を駆動する出力回路22とを、備えている。
【0033】
そして、マイコン10には、プログラムを実行する周知のCPU(中央演算処理装置)11と、CPU11によって実行されるプログラムを記憶するROM12と、CPU11による演算結果等を記憶するためのRAM13と、入力回路21及び出力回路22との間で信号をやり取りするためのI/O14と、各種レジスタやフリーランカウンタ等(図示省略)とが備えられている。
【0034】
このように構成されたECU1は、各種センサ30から入力回路21を介して入力される信号に基づき、出力回路22に接続されたアクチュエータ40を駆動する、エンジン制御処理を行う。
このエンジン制御を実現するためのエンジン制御プログラムは、上述したようにマイコン10の備えるROM12に記憶されている。そして、このエンジン制御プログラムは実行単位毎に細分化されて記述されている。実行単位となる各処理プログラムは、設定される優先度(タスクレベル)に基づき実行される。具体的には、優先度の相対的に高い処理プログラムである上位プログラムは、相対的に低い処理プログラムである下位プログラムに優先して実行される。これら処理プログラムの実行単位がタスクと呼ばれ、OSによって管理される。以下では、上位プログラムの実行単位を上位タスクと記述し、下位プログラムの実行単位を下位タスクと記述する。このようにして各タスクは、優先度に基づく割込処理によって、上述したエンジン制御処理に係る制御データを算出して更新したり、算出された制御データを参照して新たな制御データを算出したりする。
【0035】
制御データを各タスクで共通に処理するために、グローバル変数が用いられる。グローバル変数は、例えばプログラム全体が複数の関数にて構成されているとき、これら関数間で共通にアクセスできる記憶領域に記憶される。
このようなグローバル変数の上位タスク及び下位タスクによる参照・更新を考えた場合、上述した割込処理によってグローバル変数の参照時の同時性が失われてしまうことがある。
【0036】
従来は、このような不具合を回避するために、割込禁止/許可命令を下位タスクで実行することによって、同時性を必要とするグローバル変数の処理の途中で、上位タスクが割り込んでグローバル変数を処理できないようにしていた。
ところが、このような手法で上位タスクの割り込みを禁止してしまうと、下位タスクによって割込許可がなされるまで上位タスクは実行を待つことになり、この期間は、実質的に優先度が逆転してしまうことになる。そしてこのような割込処理が増えれば、それに伴って割込禁止の期間が多くなるため、上位タスクのリアルタイム性が確保できなくなって、制御性能に問題が生じる。
【0037】
そこで本実施例では、次のようにした。
まず、グローバル変数を重複させて2つの領域に記憶させるようにした。図1に示すように、RAM13に、このグローバル変数の記憶領域13bが設けられている。本実施例では、グローバル変数としての3つの制御データA,B,Cを処理対象としている。この場合、図2に示すように、制御データを領域1に格納すると共に他方の領域2にも格納する。ここでは、領域1に格納された制御データA,B,CをそれぞれA1,B1,C1と示し、領域2に格納された制御データA,B,CをそれぞれA2,B2,C2と示した。そして、RAM13には領域設定情報Sの記憶領域13aが設けられており、ここに記憶される領域設定情報Sの値によって、2つの領域1,2の一方を公開領域として、他方を作業領域として設定するようにした。具体的には、領域設定情報Sが「1」であれば、領域1が公開領域として設定され、領域2が作業領域として設定される。一方、領域設定情報Sが「2」であれば、領域1が作業領域として設定され、領域2が公開領域として設定される。
【0038】
そして、本実施例は、下位タスクの制御データの参照処理の途中で上位タスクの割り込みによって制御データが更新される可能性のある第1のケースに対応するものであり、本実施例では、下位タスク処理及び上位タスク処理を以下に示すようなものとした。
【0039】
まず下位タスク処理について、図3のフローチャートに基づき説明する。なお、図3に示すフローチャートは、制御データA,B,Cを参照して、これら制御データA,B,Cに基づき、新たな制御データUを算出することを特徴とするものであり、これらの特徴的な処理に関係しないその他の処理については、フローチャート中に破線で示して省略した。
【0040】
まずステップ(以下、ステップを単に記号Sで示す。)100では、RAM13の記憶領域13bに記憶された制御データAを参照する。同様に、続くS110では制御データBを参照し、さらに次のS120では、制御データCを参照する。制御データA,B,Cの参照は、参照処理のサブルーチンをコールすることによってなされる。
【0041】
ここで制御データA,B,Cの参照処理を、図4のフローチャートに基づき説明する。
処理が開始されると、最初に領域設定情報Sが「1」であるか否かを判断する(S200)。領域設定情報Sは、上述したようにRAM13の記憶領域13aに記憶されている。ここで領域設定情報Sが「1」であれば(S200:YES)、領域1から制御データを読み出し(S210)、その後、本参照処理を終了する。一方、領域設定情報Sが「1」でない場合、すなわち領域設定情報Sが「2」であれば(S200:NO)、領域2から制御データを読み出し(S220)、その後、本参照処理を終了する。
【0042】
このような参照処理は、3つの制御データA,B,Cのそれぞれに対し、個別に用意してもよい。つまり、制御データAを参照するための参照処理、制御データBを参照するための参照処理、制御データCを参照するための参照処理という具合に別個のサブルーチンにすることが考えられる。例えば制御データAを参照するための参照処理では、領域1又は2の最初の記憶領域から制御データA1又はA2が読み出されるという具合である。また、3つの制御データA,B,Cのいずれかを指定して、共通の参照処理をコールするようにしてもよい。この場合、例えば制御データBを指定すれば、領域1又は2の2番目の記憶領域から制御データB1又はB2が読み出されるという具合である。
【0043】
いずれにしても、この場合、公開領域として設定された領域から制御データA,B,Cが読み出されることになる。領域設定情報Sが「1」であれば、領域1が公開領域となっているからであり、領域設定情報Sが「2」であれば、領域2が公開領域となっているからである。
【0044】
図3のS120に続くS130では、領域設定情報Sが「1」であるか否かを判断する。ここで領域設定情報Sが「1」である場合(S130:YES)、S140にて領域設定情報Sを「2」として更新する。一方、領域設定情報Sが「1」でない場合(S130:NO)、すなわち領域設定情報Sが「2」である場合には、S150にて領域設定情報Sを「1」として更新する。
【0045】
S140又はS150から移行するS160では、S100〜S120で参照した制御データA,B,Cに基づき、新たな制御データUを算出する。その後、本下位タスク処理を終了する。
続けて上位タスク処理について、図5のフローチャートに基づき説明する。なお、図5に示すフローチャートは、制御データA,B,Cを算出して、これら制御データA,B,Cを更新することを特徴とするものである。図3に示した下位タスク処理と同様、これらの特徴的な処理に関係しないその他の処理については、フローチャート中に破線で示して省略した。
【0046】
まず最初のS300において、3つの制御データA,B,Cを算出する。
続くS310では、RAM13の記憶領域13bに記憶された制御データAを更新する。同様に、次のS320では制御データBを更新し、さらにS330では、制御データCを更新する。その後、本上位タスク処理を終了する。
【0047】
上述した制御データA,B,Cの更新は、更新処理のサブルーチンをコールすることによってなされる。
ここで制御データA,B,Cの更新処理を、図6のフローチャートに基づき説明する。
【0048】
処理が開始されると、最初に領域設定情報Sが「1」であるか否かを判断する(S400)。ここで領域設定情報Sが「1」であれば(S400:YES)、領域2へ制御データを書き込む(S410)、その後、本更新処理を終了する。一方、領域設定情報Sが「1」でない場合、すなわち領域設定情報Sが「2」であれば(S400:NO)、領域1へ制御データを書き込む(S420)、その後、本更新処理を終了する。
【0049】
このような更新処理も、参照処理と同様、3つの制御データA,B,Cのそれぞれに対し、個別に用意してもよい。また、3つの制御データA,B,Cのいずれかを指定して、共通の更新処理をコールするようにしてもよい。
いずれにしても、この場合、作業領域として設定された領域へ制御データA,B,Cが書き込まれることになる。領域設定情報Sが「1」であれば、領域2が作業領域となっているからであり、領域設定情報Sが「2」であれば、領域1が作業領域となっているからである。
【0050】
以上説明したように、本実施例のECU1では、グローバル変数としての制御データA,B,Cの参照と更新を別々の領域で行うようにし、下位タスクによる制御データA,B,Cの参照時における同時性を確保した。
例えば領域設定情報Sが「1」であるものとして、具体的に説明する。
【0051】
領域設定情報Sが「1」であれば領域1が公開領域となっている。したがって、下位タスクでは、公開領域である領域1に記憶された制御データA1,B1,C1を参照する(図3中のS100〜S120、図4参照)。一方、上位タスクは、作業領域である領域2に記憶された制御データA2,B2,C2を更新する(図5中のS310〜S330、図6参照)。したがって、例えば下位タスクによる参照途中で上位タスクが割り込んでも、領域2に格納された制御データA2,B2,C2が更新されるだけであり、下位タスクの参照する領域1に格納された制御データA1,B1,C1は更新されない。すなわち、下位タスクで参照される制御データA1,B1,C1の同時性が確保される。
【0052】
また、同時性を必要とする制御データA1,B1,C1の参照が完了した時点(図3中のS120終了時点)では、それ以前の上位タスクの割り込みによって領域2の制御データA2,B2,C2が更新されている可能性がある。したがって、領域設定情報Sを「1」→「2」と更新することによって(S130:YES、S140)、作業領域と公開領域とを切り換える。すなわち、領域1を作業領域として設定しなおすと共に、領域2を公開領域として設定しなおす。これによって、次の参照処理において、更新された制御データA2,B2,C2が参照されることになる。
【0053】
その結果、上位タスクの割込処理を遅らせることなく、しかも、下位タスクで参照される制御データの同時性を確保することができる。
さらに、本実施例では、RAM13の記憶領域13aに記憶した領域設定情報Sによって領域1,2の一方を公開領域、他方を作業領域として設定し、この領域設定情報Sを更新することによって(図3中のS130〜S150)、領域1,2を切り換えるようにした。このような領域設定情報Sの更新は、CPUの一命令で実現できるため、領域切換の途中に割り込みがかかることもない。その結果、下位タスクで参照される制御データの同時性を確実に確保できる。
【0054】
なお、本実施例におけるRAM13が「領域情報記憶手段」に相当する。そして、図3中に一点鎖線で示した、S100〜S120の処理が「下位参照処理」に相当し、S130〜S150の処理が「領域切換処理」に相当する。また、図5中に一点鎖線で示したS310〜S330の処理が「上位更新処理」に相当する。
参考例]
記実施例は、下位タスクの制御データの参照処理の途中で上位タスクの割り込みによって制御データが更新される可能性のある第1のケースに対応するものであった。
【0055】
これに対して参考例は、下位タスクの制御データの更新処理の途中で上位タスクの割り込みによって制御データが参照される可能性のある第2のケースに対応するものである。なお、ハードウェア構成をはじめ、グローバル変数としての制御データをRAM13の記憶領域13bに重複させて記憶させ、さらに、領域設定情報Sによって、一方を公開領域、他方を作業領域として設定することは、上記実施例と同様である。したがって、以下では、上記実施例と異なる下位タスク処理及び上位タスク処理についてのみ説明する。
【0056】
参考例では、下位タスク処理及び上位タスク処理を以下に示すようなものとした。
まず下位タスク処理について、図7のフローチャートに基づき説明する。なお、図7に示すフローチャートは、制御データA,B,Cを算出して、これら制御データA,B,Cを更新することを特徴とするものである。これらの特徴的な処理に関係しないその他の処理については、上記実施例のフローチャートと同様に、フローチャート中に破線で示して省略した。
【0057】
まずステップS500では、3つの制御データA,B,Cを算出する。
続くS510では、RAM13の記憶領域13bに記憶された制御データAを更新する。同様に、次のS520では制御データBを更新し、さらに続くS530では、制御データCを更新する。
【0058】
制御データA,B,Cの更新は、上記実施例で図6を用いて説明した更新処理のサブルーチンをコールすることによってなされる。すなわち、領域設定情報Sが「1」であれば(S400:YES)、領域2へ制御データを書き込み(S410)、一方、領域設定情報Sが「1」でない場合、すなわち領域設定情報Sが「2」であれば(S400:NO)、領域1へ制御データを書き込む(S420)。もちろん、上記実施例と同様、このような更新処理を、3つの制御データA,B,Cのそれぞれに対し個別に用意してもよいし、3つの制御データA,B,Cのいずれかを指定して、共通の更新処理をコールするようにしてもよい。
【0059】
いずれにしても、この場合、作業領域として設定された領域へ制御データA,B,Cが書き込まれることになる。
図7中のS530に続くS540では、領域設定情報Sが「1」であるか否かを判断する。ここで領域設定情報Sが「1」である場合(S540:YES)、S550にて領域設定情報Sを「2」として更新する。一方、領域設定情報Sが「1」でない場合(S540:NO)、すなわち領域設定情報Sが「2」である場合には、S560にて領域設定情報Sを「1」として更新する。
【0060】
そしてその後、本下位タスク処理を終了する。
続けて上位タスク処理について、図8のフローチャートに基づき説明する。なお、図8に示すフローチャートは、制御データA,B,Cを参照して、これら制御データA,B,Cに基づき、新たな制御データUを算出することを特徴とするものである。図7に示した下位タスク処理と同様、これらの特徴的な処理に関係しないその他の処理については、フローチャート中に破線で示して省略した。
【0061】
まず最初のS600において、RAM13の記憶領域13bに記憶された制御データAを参照する。同様に、次のS610では制御データBを参照し、さらにS620では、制御データCを参照する。
そして、続くS630では、S600〜S620にて参照した制御データA,B,Cに基づき、新たな制御データUを算出し、その後、本上位タスク処理を終了する。
【0062】
上述した制御データA,B,Cの参照は、上記実施例で図4を用いて説明した参照処理のサブルーチンをコールすることによってなされる。すなわち、領域設定情報Sが「1」であれば(S200:YES)、領域1から制御データを読み出し(S210)、一方、領域設定情報Sが「1」でない場合、すなわち領域設定情報Sが「2」であれば(S200:NO)、領域2から制御データを読み出す(S220)。もちろん、上記実施例と同様、このような参照処理を、3つの制御データA,B,Cのそれぞれに対し、個別に用意してもよいし、3つの制御データA,B,Cのいずれかを指定して、共通の参照処理をコールするようにしてもよい。
【0063】
いずれにしても、この場合、公開領域として設定された領域から制御データA,B,Cが読み出されることになる。
以上説明したように、本参考例でも、上記実施例と同様に、グローバル変数としての制御データA,B,Cの参照と更新を別々の領域で行うようにしたことによって、このときは、上位タスクによる制御データA,B,Cの参照時における同時性を確保した。
【0064】
例えば領域設定情報Sが「1」であるものとして、具体的に説明する。
領域設定情報Sが「1」であれば領域1が公開領域となっている。したがって、下位タスクでは、作業領域である領域2に記憶された制御データA2,B2,C2を更新する(図7中のS510〜S530、図6参照)。一方、上位タスクは、公開領域である領域1に記憶された制御データA1,B1,C1を参照する(図8中のS600〜S620、図4参照)。したがって、例えば下位タスクによる更新途中で上位タスクが割り込んでも、領域1に格納された制御データA1,B1,C1が参照されることになり、更新途中の領域2に記憶された制御データA2,B2,C2が参照されることはない。すなわち、上位タスクで参照される制御データA1,B1,C1の同時性が確保される。
【0065】
また、同時性を必要とする制御データA2,B2,C2の更新が完了した時点(図7中のS530終了時点)では、領域設定情報Sを「1」→「2」と更新することによって(S540:YES、S550)、作業領域と公開領域とを切り換える。これによって、次の参照処理において、更新された制御データA2,B2,C2が参照される。
【0066】
その結果、上位タスクの割込処理を遅らせることなく、しかも、上位タスクで参照される制御データの同時性を確保することができる。
さらに、本参考例おいても、上記実施例と同様、RAM13の記憶領域13aに記憶した領域設定情報Sによって領域1,2の一方を公開領域、他方を作業領域として設定し、この領域設定情報Sを更新することによって(図7中のS540〜S560)、領域1,2を切り換えるようにした。このような領域設定情報Sの更新は、CPUの一命令で実現できるため、領域切換の途中に割り込みがかかることもない。その結果、上位タスクで参照される制御データの同時性を確実に確保できる。
【0067】
なお、本参考例におけるRAM13が「領域情報記憶手段」に相当する。そして、図7中に一点鎖線で示した、S510〜S530の処理が「下位更新処理」に相当し、S540〜S560の処理が「領域切換処理」に相当する。また、図8中に一点鎖線で示したS600〜S620の処理が「上位参照処理」に相当する。
[その他]
なお、上記実施例は、下位タスクの制御データの参照処理の途中で上位タスクの割り込みによって制御データが更新される可能性のある第1のケースに対応するものであり、一方、上記参考例は、下位タスクの制御データの更新処理の途中で上位タスクの割り込みによって制御データが参照される可能性のある第2のケースに対応するものであった。
【0068】
記では説明を簡単にするため、実施例は第1のケースに対応するものとして、一方、参考例は第2のケースに対応するものとして説明したが、もちろん、エンジン制御処理において、第1及び第2の両方のケースが発生することが考えられる。したがって通常は、第1のケースに対応させて下位及び上位の処理プログラムを設計し、第2のケースに対応させて下位及び上位の処理プログラムを設計する。つまり、一つのエンジン制御処理の中で、ある下位タスク処理は図3に示す如くとなり、別の下位タスク処理は図7に示す如くとなる。同様に、ある上位タスク処理は図5に示す如くとなり、別の上位タスク処理は図8に示す如くとなる。
【0069】
このように第1及び第2の両方のケースに対応させることを考えると、あるタスクが制御データを参照する場合、別のタスクによって制御データが更新される可能性があることが予め分かっているという前提の下で、その別のタスクに対して、自らが上位タスクとなるのか下位タスクとなるのかを判断することが考えられる。同様に、あるタスクが制御データを更新する場合、別のタスクによってグローバル変数が参照される可能性があることが予め分かっているという前提の下で、その別のタスクに対して、自らが上位タスクとなるのか下位タスクとなるのかを判断することが考えられる。
【0070】
具体的には、図1中に破線で示す如く優先度に関する情報を記憶する記憶領域13cをRAM13に設け、ここに制御データA,B,C毎に、制御データA,B,Cの参照又は更新を行うタスクの優先度の中で最も高いものを記憶しておく。例えば図9に示す如くである。図9では、3つの制御データA,B,Cをそれぞれ処理対象とする各タスクの優先度の中で最も高い優先度がPA,PB,PCとして記憶された様子を示している。
【0071】
そして、処理対象となる制御データに対応する優先度PA,PB,PCと、判断対象の処理プログラムに設定された優先度Pとを比較することによって、下位タスク又は上位タスクのいずれに相当するかを判断する。
この判断処理を図10のフローチャートに示した。これについて説明する。
【0072】
処理が開始されると、判断対象のタスクの優先度Pを取得する(S700)。判断対象のタスクとは現在実行中のタスクである。設定された優先度Pは、OSのサブルーチンコールによって取得することが考えられる。
次に処理対象の制御データA,B,Cに対応する優先度PA,PB,PCを取得する(S710)。これは、上述した記憶領域13cに記憶されたものである。このとき、3つの優先度PA,PB,PCの中で最も高いものを取得することが考えられる。また、3つの優先度PA,PB,PCの全てを取得するようにしてもよい。
【0073】
そして、S700及びS710にて取得した優先度を比較して、優先度Pが相対的に低いか否かを判断する(S720)。3つの優先度PA,PB,PCの中で1つでも優先度Pを上回るものがあれば、ここで肯定判断される。優先度Pが相対的に低い場合(S720:YES)、実行中のタスクを下位タスクと判断し(S730)、一方、優先度Pが相対的に低くない場合(S720:NO)、実行中のタスクを上位タスクと判断する(S740)。
【0074】
これによって、あるタスクにて制御データA,B,Cを参照して制御データUを算出する際、他のタスクにて制御データA,B,Cが更新される可能性があれば、上述した判断処理を予め実行することによって、図3に示す下位タスク処理、又は、図8に示す上位タスク処理を選択的に実行するようにできる。
【0075】
同様に、あるタスクにて制御データA,B,Cを算出して制御データA,B,Cを更新する際、他のタスクにて制御データA,B,Cが参照される可能性があれば、上述した判断処理を予め実行することによって、図7に示す下位タスク処理、又は、図5に示す上位タスク処理を選択的に実行するようにできる。
【0076】
このようにすれば、各タスクがより汎用的なものとなる点で有利である。
なお、このような構成において、マイコン10の備えるRAM13が「優先度記憶手段」に相当し、図10に示した判断処理が「判断処理」に相当する。
また、ここでは図9に示すように、優先度に関する情報を、3つの制御データA,B,C毎に記憶した。これに対して、同時性が必要な制御データといったグローバル変数全体を一まとめにし、グローバル変数を参照・更新する可能性のあるタスクに設定された優先度の中で最も高いものを一つだけ記憶するようにしてもよい。このようにしても、図10と同様の判断処理を予め実行することによって、下位あるいは上位のタスク処理を選択的に実行することができる。
【0077】
ところで、上記実施例ではエンジン制御処理を行うECU1として本発明を具体化したが、このような車両のエンジン制御に限られず、リアルタイム性を確保すべき割込処理を行うような情報処理装置全般に本発明が適用できることは言うまでもない。
【図面の簡単な説明】
【図1】実施例のECUの構成を表すブロック図である。
【図2】領域設定情報及び制御データの記憶領域を示す説明図である。
【図3】実施例の下位タスク処理を示すフローチャートである。
【図4】参照処理を示すフローチャートである。
【図5】実施例の上位タスク処理を示すフローチャートである。
【図6】更新処理を示すフローチャートである。
【図7】参考例の下位タスク処理を示すフローチャートである。
【図8】参考例の上位タスク処理を示すフローチャートである。
【図9】優先度の記録領域を示す説明図である。
【図10】判断処理を示すフローチャートである。
【符号の説明】
1…ECU 10…マイコン
11…CPU 12…ROM
13…RAM 13a…記憶領域
13b…記憶領域 13c…記憶領域
14…I/O 21…入力回路
22…出力回路 30…センサ
40…アクチュエータ
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a technique for ensuring real-time interrupt processing in a processing program in which interrupt processing is executed.
[0002]
[Prior art]
For example, in a control program used in an electronic control device (hereinafter referred to as “ECU”) mounted on a vehicle, it is necessary to execute predetermined processing in real time in order to ensure control responsiveness and safety. For this reason, such processing requiring real-time properties (real-time processing) is generally prepared as an interrupt routine different from the main routine. The interrupt routine is executed preferentially during execution of the main routine, for example, triggered by the occurrence of an event. The preferential execution means that the execution of the main routine is temporarily interrupted by the execution of the interrupt routine, and the main routine is executed again from the interruption position after the interruption routine ends.
[0003]
In recent years, the ECU control program described above also operates on an OS (operating system), and execution units such as a main routine and an interrupt routine are called tasks and are managed by the OS.
A level indicating the priority of execution (task level) is set for this task, and the interrupt processing as described above is realized based on this task level. In other words, under the management of the OS, a higher-order task that is a relatively high-level task has priority (interrupts) over a lower-order task that is a relatively low-level task. In the example described above, the processing by the main routine corresponds to the lower task, and the processing by the interrupt routine corresponds to the upper task.
[0004]
The introduction of such a task concept makes it easy to design an interrupt process by eliminating the need to describe the execution timing between programs with only a very simple information description of setting a task level.
On the other hand, the upper task interrupts at a timing not related to the processing timing of the lower task, such as the occurrence of an event. For this reason, there is a possibility that a problem occurs in the lower task. Here, a problem caused by an interrupt of a higher-level task, which is assumed in the present invention, will be described.
[0005]
Consider a case in which a common variable is manipulated between the upper task and the lower task. For example, when the entire program is composed of a plurality of functions, this common variable is stored in a storage area that can be accessed in common among these functions, and is called a global variable (global variable).
[0006]
For example, consider a case where two global variables a and b are referenced in a lower task and the same global variables a and b are updated in an upper task. At this time, if the upper task interrupts before the variable b is referenced after the variable a is referenced in the lower task, both the global variables a and b are updated, and then the global referenced by the lower task. The variable b becomes the one after the update by the upper task. That is, one global variable a is referred to the old one in time, and the other global variable b is referred to the new one in time. Such a state is expressed as a state in which simultaneity of global variables (sometimes called consistency, consistency, etc.) is lost, and when this simultaneity is required, for example, temporal correlation If it exists between variables, it will cause a problem in control.
[0007]
Further, for example, the same applies when two global variables a and b are updated in a lower task and the same global variables a and b are referred to in an upper task. At this time, after the variable a is updated in the lower task, the global variables a and b may be referred to by the upper task before the variable b is updated. When there is such an interrupt of a higher-level task, one global variable a is referred to in time, and the other global variable b is referred to in time. In other words, the simultaneity of global variables is lost in this case as well.
[0008]
In the above-described example, two global variables are processed, but the same problem occurs when three or more global variables that require simultaneity are processed. The same problem occurs even when one global variable is a processing target. For example, a case where the same global variable is read twice consecutively in the lower task is cited as an example. In this case, if the upper task updates the variable after the lower-level task references the first variable, the variable read the second time is different from the variable read the first time. , Simultaneity will be lost.
[0009]
Conventionally, in order to ensure such simultaneity, an interrupt disable / permit instruction has been described in the lower task program as necessary. The interrupt prohibition instruction is for prohibiting an upper task interrupt, and the interrupt permission instruction is for permitting an upper task interrupt. In other words, the upper task cannot interrupt during the processing step between the interrupt prohibition instruction and the interrupt permission instruction. Therefore, if an interrupt disable instruction and an interrupt enable instruction are described before and after the processing related to a global variable that requires simultaneity, referencing and updating by a higher-level task is not performed, the simultaneity of global variables can be reduced. It can be secured.
[0010]
[Problems to be solved by the invention]
Interrupt processing as described above is an indispensable technique for executing real-time processing, and has been easily designed by the development of computer technology such as task management by the OS. On the other hand, however, if the number of interrupt processes increases, the description of interrupt prohibition / permission instructions increases accordingly, which makes it impossible to secure real-time performance. This will be described.
[0011]
As described above, if an interrupt disable / enable instruction is described in the lower task program, the upper task cannot be interrupted in the middle of the processing step between the interrupt disable instruction and the interrupt enable instruction. In other words, the upper task waits for execution until the lower task is permitted to interrupt, and during this period, the execution priority is substantially reversed. Therefore, as the number of interrupt processes increases and the number of such periods increases, there is a higher possibility that execution of higher-level tasks that are real-time processes will be delayed, making it difficult to ensure control responsiveness and safety, etc. As a result, the control performance is affected.
[0012]
The present invention has been made to solve such a problem, and does not delay interrupt processing by a higher-priority higher-level program, and it can be compared with a lower-level lower-level program. The purpose is to ensure simultaneity when referring to global variables used in common.
[0013]
[Means for Solving the Problems and Effects of the Invention]
The information processing apparatus according to claim 1, which is made to achieve the above-described object, performs a series of functions by executing a plurality of processing programs as execution units based on a priority set for each processing program. To realize. For example, in the case of a program that manages tasks on the OS, a task is generated for each processing program, and the task level set for each task corresponds to the priority mentioned here. In the following, the expression based on the processing program may be used for convenience in realizing each function, but in actuality, each function is realized by executing the processing program mainly by the so-called CPU of the information processing apparatus. It goes without saying that it is done.
[0014]
In the present invention, global variables are stored in duplicate in two areas. A global variable is a variable used in common between a lower-level program having a relatively low priority and a higher-level program having a relatively high priority. Here, “store overlapping two areas” means that each global variable has both one area (hereinafter referred to as “area 1”) and the other area (hereinafter referred to as “area 2”). It means to memorize. Then, for example, the area 1 is set as a public area and the area 2 is set as a work area.
[0015]
In the present invention, the following configuration is adopted for the first case where the global variable may be updated by the upper program while the global variable is being referenced by the lower program.
That is, the upper program updates the global variable using the work area by executing the upper update process, while the lower program uses the public area by executing the lower reference process. It was made to refer to. In other words, global variables are referenced and updated in different areas, ensuring simultaneity when referring to global variables by lower-level programs.
[0016]
Specifically, a case is considered where two global variables a and b are referred to in the lower program and the same global variables a and b are updated in the upper program. At this time, the lower-level program refers to the global variables a and b stored in the public area. On the other hand, the upper program updates the global variables a and b stored in the work area. Therefore, for example, even if the upper program interrupts during the reference by the lower program, only the global variables a and b stored in the work area are updated, and the global variables a and b stored in the public area referred to by the lower program are updated. Will not be updated. That is, the simultaneity of the global variables a and b referred to in the lower program is ensured.
[0017]
When the lower-level program further completes the reference of the global variable by the lower-level reference processing, by executing the area switching process, the work area is newly set as the public area and the public area is newly set as the work area. fix.
“Completing the reference of a global variable” means that a series of reference processing of a global variable that requires simultaneity is completed. For example, it can be considered that all the reference processing of a plurality of global variables that require simultaneity is completed. In addition, it can be considered that all the reference processing of a single global variable that requires simultaneity is completed.
[0018]
When the reference is completed, there is a possibility that the global variable in the work area has been updated by the interruption of the previous upper program. Therefore, by switching between the work area and the public area, the updated global variable is referred to in the next reference process.
[0019]
In this way, it is possible to ensure the simultaneity of global variables referenced in the lower program without delaying the interrupt process by the upper program.
By the way, the configuration described above is for the first case in which a global variable may be updated by a higher-level program in the middle of referring to a global variable by a lower-level program. In contrast, further, A second case in which the global variable may be referred to by the upper program during the update of the global variable by the lower program is also conceivable. To ensure simultaneity when referring to global variables in the lower and upper programs for the first and second cases described above It is conceivable to adopt the configuration shown in claim 2.
[0020]
That is, the upper program executes the upper reference process to reference the global variable using the public area, while the lower program executes the lower update process to execute the global variable using the work area. Is updated.
[0021]
In this case as well, the global variables are referenced and updated in different areas, and at this time, the simultaneity of the global variables at the time of reference by the upper program is ensured.
Specifically, consider a case where two global variables a and b are updated in a lower program and the same global variables a and b are referenced in an upper program. At this time, the lower-level program updates the global variables a and b stored in the work area. On the other hand, the upper program refers to the global variables a and b stored in the public area. Therefore, for example, even when the upper program interrupts during the update by the lower program, the global variables a and b stored in the public area are referred to, and the global variables a and b stored in the work area being updated are referred to. Will never be done. That is, the simultaneity of the global variables a and b referred to in the upper program is ensured.
[0022]
In this case as well, when the update of the global variable by the lower update process is completed, the lower program switches the work area and the public area by executing the area switching process. This is because the updated global variable is referred to in the next reference process. “Completing the update of the global variable” means that, as in the case of the reference, a series of update processing of the global variable that requires simultaneity is completed.
[0023]
This By doing so, it is possible to ensure the simultaneity of the global variables referenced in the upper program or the lower program without delaying the interrupt processing by the upper program.
[0024]
By the way, the present invention has been made for the purpose of ensuring simultaneity when referring to global variables in the first or second case as described above. Therefore, on the assumption that any one of these cases is applicable, each processing program may determine itself as a higher-level program or a lower-level program in relation to other processing programs.
[0025]
For example, when a processing program references a global variable, it is assumed that it is known in advance that the global variable may be updated by another processing program. It can be considered to determine whether the program is a program or a subordinate program. Similarly, when a certain processing program updates a global variable, it is assumed that it is known in advance that there is a possibility that the global variable may be referenced by another processing program. It can be considered to determine whether the program is a program or a subordinate program.
[0026]
Therefore, the claim 3 As shown in FIG. 4, in each processing program, based on the priority of another processing program that references or updates the global variable, a determination process is performed to determine whether the processing program corresponds to the lower processing program or the upper processing program. The corresponding process may be executed based on the determination result of the determination process. Specifically, for example, claims 4 As shown in FIG. 5, the highest priority among the processing programs that reference or update the global variable is stored in the priority storage means, and the stored priority and the priority set in the processing program It can be considered to make a judgment by comparing. This is advantageous in that each processing program can be made more versatile.
[0027]
Note that not all defined global variables are processed by each processing program. Therefore, there is a possibility that a global variable updated or referred to by another processing program is other than the global variable to be processed. In such a case, interference due to interruption does not occur.
[0028]
Therefore, the claim 5 As described above, the determination processing described above may be determined based on the priority of another processing program that performs reference or update on the global variable to be processed in the processing program to be determined. In this case, specifically, the claim 6 As shown in FIG. 6, for each global variable, it is conceivable to store in the priority storage means the highest priority among the processing programs that refer to or update the global variable. At this time, the determination process is determined by comparing the priority corresponding to the global variable to be processed, stored in the priority storage unit, and the priority set in the determination target processing program. .
[0029]
By the way, in the present invention, one of the two areas is set as a public area and the other is set as a work area, and the public area and the work area are switched by area switching processing. Such a region setting is, for example, a claim 7 As shown in FIG. 5, it is possible to realize the configuration by providing the area information storage means and storing the setting information in the area information storage means. For example, “1” or “2” is stored as the setting information. When the setting information is “1”, the area 1 is set as the public area, the area 2 is set as the work area, and the “2” is set. In the opposite case, the area 1 is set as a work area and the area 2 is set as a public area.
[0030]
In this case, the claim 8 As shown in FIG. 4, the area switching process is to newly set the work area as a public area and re-set the public area as a new work area by updating the setting information stored in the area information storage means. It can be considered. Such updating of the setting information can be realized by a single instruction of the CPU. Thus, no interruption is caused during the area switching. As a result, it is possible to ensure the simultaneity of global variables referenced in the upper program or the lower program.
[0031]
DETAILED DESCRIPTION OF THE INVENTION
Embodiments of the present invention will be described below with reference to the drawings.
[Actual Example]
FIG. 1 is a block diagram showing a configuration of an engine control apparatus (hereinafter referred to as “ECU”) 1 that embodies an “information processing apparatus” of the present invention. The ECU 1 controls an internal combustion engine type engine mounted on the vehicle.
[0032]
The ECU 1 is a rotation angle sensor that outputs a pulsed signal every time the crankshaft of the engine rotates by a predetermined angle. Each time the piston of a specific cylinder of the engine comes to a predetermined position (for example, top dead center: TDC), the ECU1 Signals from various sensors 30 that detect the operating state of the engine, such as a reference position sensor that outputs a signal, a water temperature sensor that detects the temperature of the engine coolant, and an oxygen concentration sensor that measures the oxygen concentration, are used to input waveforms. An input circuit 21 that performs shaping and A / D conversion, a microcomputer (hereinafter referred to as a “microcomputer”) 10 that executes various processes for controlling the engine based on sensor signals from the input circuit 21, and a microcomputer 10 Actuators such as injectors (fuel injection devices) and igniters (ignition devices) attached to the engine according to control data from And an output circuit 22 for driving the 0 includes.
[0033]
The microcomputer 10 includes a well-known CPU (central processing unit) 11 that executes programs, a ROM 12 that stores programs executed by the CPU 11, a RAM 13 that stores calculation results and the like by the CPU 11, and an input circuit. 21 and I / O 14 for exchanging signals between the output circuit 22 and various registers and free-run counters (not shown).
[0034]
The ECU 1 configured as described above performs an engine control process for driving the actuator 40 connected to the output circuit 22 based on signals input from the various sensors 30 via the input circuit 21.
The engine control program for realizing this engine control is stored in the ROM 12 provided in the microcomputer 10 as described above. This engine control program is subdivided and described for each execution unit. Each processing program as an execution unit is executed based on a set priority (task level). Specifically, a higher-order program that is a processing program with a relatively high priority is executed in preference to a lower-order program that is a relatively low processing program. The execution unit of these processing programs is called a task and is managed by the OS. Hereinafter, the execution unit of the upper program is described as an upper task, and the execution unit of the lower program is described as a lower task. In this way, each task calculates and updates the control data related to the engine control process described above by the interrupt process based on the priority, or calculates new control data by referring to the calculated control data. Or
[0035]
Global variables are used to process control data in common for each task. For example, when the entire program is composed of a plurality of functions, the global variable is stored in a storage area that can be commonly accessed among these functions.
When considering the reference / update by the higher-order task and the lower-order task of such a global variable, the simultaneity at the time of referring to the global variable may be lost by the above-described interrupt processing.
[0036]
Conventionally, in order to avoid such problems, by executing the interrupt disable / permit instruction in the lower task, the upper task interrupts the global variable in the middle of processing the global variable that requires simultaneity. I couldn't handle it.
However, if the interrupt of the upper task is prohibited by such a method, the upper task waits for execution until the interrupt is permitted by the lower task, and the priority is substantially reversed during this period. Will end up. If the number of interrupt processes increases, the interrupt prohibition period increases accordingly, and the real-time property of the higher-level task cannot be secured, causing a problem in control performance.
[0037]
Therefore Real In the examples, the following was performed.
First, global variables are duplicated and stored in two areas. As shown in FIG. 1, the RAM 13 is provided with a global variable storage area 13b. Real In the embodiment, three control data A, B, and C as global variables are processed. In this case, as shown in FIG. 2, the control data is stored in the area 1 and also in the other area 2. Here, the control data A, B, and C stored in the area 1 are indicated as A1, B1, and C1, respectively, and the control data A, B, and C stored in the area 2 are indicated as A2, B2, and C2, respectively. The RAM 13 is provided with a storage area 13a for area setting information S. Depending on the value of the area setting information S stored therein, one of the two areas 1 and 2 is set as a public area and the other is set as a work area. I set it. Specifically, if the area setting information S is “1”, the area 1 is set as a public area and the area 2 is set as a work area. On the other hand, if the area setting information S is “2”, the area 1 is set as a work area and the area 2 is set as a public area.
[0038]
And Real The example corresponds to the first case where the control data may be updated by the interrupt of the upper task during the reference processing of the control data of the lower task, Real In the embodiment, the lower task processing and the upper task processing are as shown below.
[0039]
First, the lower task processing will be described with reference to the flowchart of FIG. The flowchart shown in FIG. 3 is characterized in that new control data U is calculated based on the control data A, B, C with reference to the control data A, B, C. Other processes that are not related to the characteristic process are indicated by broken lines in the flowchart and omitted.
[0040]
First, in step (hereinafter, the step is simply indicated by symbol S) 100, the control data A stored in the storage area 13b of the RAM 13 is referred to. Similarly, the control data B is referred to in the subsequent S110, and the control data C is referred to in the next S120. The control data A, B, and C are referred to by calling a reference processing subroutine.
[0041]
Here, the reference processing of the control data A, B, C will be described based on the flowchart of FIG.
When the process is started, it is first determined whether or not the region setting information S is “1” (S200). The area setting information S is stored in the storage area 13a of the RAM 13 as described above. If the area setting information S is “1” (S200: YES), the control data is read out from the area 1 (S210), and then this reference process is terminated. On the other hand, if the area setting information S is not “1”, that is, if the area setting information S is “2” (S200: NO), the control data is read from the area 2 (S220), and then this reference process is terminated. .
[0042]
Such a reference process may be prepared individually for each of the three control data A, B, and C. That is, it can be considered that separate subroutines are used, such as a reference process for referring to the control data A, a reference process for referring to the control data B, and a reference process for referring to the control data C. For example, in the reference process for referring to the control data A, the control data A1 or A2 is read from the first storage area of the area 1 or 2. Further, any one of the three control data A, B, and C may be designated to call a common reference process. In this case, for example, if the control data B is designated, the control data B1 or B2 is read from the second storage area of the area 1 or 2.
[0043]
In any case, in this case, the control data A, B, and C are read from the area set as the public area. This is because if the area setting information S is “1”, the area 1 is a public area, and if the area setting information S is “2”, the area 2 is a public area.
[0044]
In S130 following S120 in FIG. 3, it is determined whether or not the region setting information S is “1”. If the area setting information S is “1” (S130: YES), the area setting information S is updated to “2” in S140. On the other hand, if the area setting information S is not “1” (S130: NO), that is, if the area setting information S is “2”, the area setting information S is updated to “1” in S150.
[0045]
In S160 that moves from S140 or S150, new control data U is calculated based on the control data A, B, and C referenced in S100 to S120. Thereafter, the lower task processing is terminated.
Next, the upper task processing will be described based on the flowchart of FIG. The flowchart shown in FIG. 5 is characterized in that the control data A, B, and C are calculated and the control data A, B, and C are updated. Similar to the lower-level task process shown in FIG. 3, other processes not related to these characteristic processes are indicated by broken lines in the flowchart and omitted.
[0046]
First, in the first S300, three control data A, B, and C are calculated.
In subsequent S310, the control data A stored in the storage area 13b of the RAM 13 is updated. Similarly, in the next S320, the control data B is updated, and in S330, the control data C is updated. Thereafter, the upper task processing is terminated.
[0047]
The control data A, B, and C are updated by calling a subroutine for update processing.
Here, the update processing of the control data A, B, C will be described based on the flowchart of FIG.
[0048]
When the process is started, it is first determined whether or not the region setting information S is “1” (S400). If the area setting information S is “1” (S400: YES), the control data is written to the area 2 (S410), and then this update process is terminated. On the other hand, if the area setting information S is not “1”, that is, if the area setting information S is “2” (S400: NO), the control data is written in the area 1 (S420), and then this update process is terminated. .
[0049]
Such an update process may be prepared individually for each of the three control data A, B, and C as in the reference process. Alternatively, any one of the three control data A, B, and C may be designated to call a common update process.
In any case, in this case, control data A, B, and C are written in the area set as the work area. This is because if the area setting information S is “1”, the area 2 is a work area, and if the area setting information S is “2”, the area 1 is a work area.
[0050]
As explained above, Real In the ECU 1 of the embodiment, reference and update of the control data A, B, and C as the global variables are performed in different areas, and synchronization at the time of referring to the control data A, B, and C by the lower task is ensured.
For example, a specific description will be given assuming that the area setting information S is “1”.
[0051]
If the area setting information S is “1”, the area 1 is a public area. Therefore, in the lower task, the control data A1, B1, and C1 stored in the area 1 that is the public area are referred to (S100 to S120 in FIG. 3, see FIG. 4). On the other hand, the higher-order task updates the control data A2, B2, C2 stored in the work area 2 (see S310 to S330 in FIG. 5 and FIG. 6). Therefore, for example, even if a higher-level task interrupts during reference by a lower-level task, only the control data A2, B2, and C2 stored in the area 2 are updated, and the control data A1 stored in the area 1 referenced by the lower-level task. , B1, C1 are not updated. That is, the simultaneity of the control data A1, B1, C1 referred to in the lower task is ensured.
[0052]
Further, when the reference of the control data A1, B1, and C1 that require simultaneity is completed (at the end of S120 in FIG. 3), the control data A2, B2, and C2 in the area 2 are interrupted by the previous upper-level task interrupt. May have been updated. Therefore, by updating the area setting information S from “1” to “2” (S130: YES, S140), the work area and the public area are switched. That is, the area 1 is reset as a work area and the area 2 is reset as a public area. As a result, the updated control data A2, B2, and C2 are referred to in the next reference process.
[0053]
As a result, it is possible to ensure the simultaneity of the control data referred to by the lower task without delaying the interrupt process of the upper task.
further, Real In the embodiment, one of the areas 1 and 2 is set as a public area and the other as a work area by the area setting information S stored in the storage area 13a of the RAM 13, and the area setting information S is updated (see FIG. 3). S130 to S150), the regions 1 and 2 are switched. Such updating of the area setting information S can be realized by one instruction of the CPU, so that no interruption occurs during the area switching. As a result, the simultaneity of the control data referred to by the lower task can be ensured.
[0054]
In addition, Real The RAM 13 in the embodiment corresponds to “region information storage means”. And the process of S100-S120 shown with the dashed-dotted line in FIG. 3 is equivalent to a "lower-order reference process", and the process of S130-S150 is equivalent to a "area | region switching process." Further, the processing of S310 to S330 indicated by the alternate long and short dash line in FIG. 5 corresponds to “upper update processing”.
[ reference Example]
Up Real The embodiment corresponds to a first case in which control data may be updated by an interrupt of a higher-level task in the middle of reference processing of control data of a lower-level task.
[0055]
On the contrary reference The example corresponds to a second case in which control data may be referred to by a higher-level task interrupt during the process of updating control data of a lower-level task. It is to be noted that, including hardware configuration, control data as a global variable is stored in the storage area 13b of the RAM 13 in an overlapping manner, and further, setting one as a public area and the other as a work area by the area setting information S Up Real This is the same as the example. Therefore, in the following, Real Only the lower task processing and the upper task processing different from the embodiment will be described.
[0056]
Book reference In the example, the lower task processing and the upper task processing are as shown below.
First, the lower task processing will be described with reference to the flowchart of FIG. The flowchart shown in FIG. 7 is characterized in that the control data A, B, and C are calculated and the control data A, B, and C are updated. For other processes not related to these characteristic processes, Real Similar to the flowchart of the embodiment, it is indicated by a broken line in the flowchart and omitted.
[0057]
First, in step S500, three control data A, B, and C are calculated.
In subsequent S510, the control data A stored in the storage area 13b of the RAM 13 is updated. Similarly, the control data B is updated in the next S520, and the control data C is updated in the subsequent S530.
[0058]
Update of control data A, B, C Real This is done by calling the update processing subroutine described in the embodiment with reference to FIG. That is, if the area setting information S is “1” (S400: YES), control data is written to the area 2 (S410). On the other hand, if the area setting information S is not “1”, that is, the area setting information S is “1”. If “2” (S400: NO), the control data is written to the area 1 (S420). Of course, on Real Similar to the embodiment, such update processing may be prepared individually for each of the three control data A, B, and C, and any one of the three control data A, B, and C may be designated. A common update process may be called.
[0059]
In any case, in this case, control data A, B, and C are written in the area set as the work area.
In S540 following S530 in FIG. 7, it is determined whether or not the region setting information S is “1”. If the area setting information S is “1” (S540: YES), the area setting information S is updated to “2” in S550. On the other hand, if the area setting information S is not “1” (S540: NO), that is, if the area setting information S is “2”, the area setting information S is updated to “1” in S560.
[0060]
Thereafter, the lower task processing is terminated.
Next, the upper task processing will be described with reference to the flowchart of FIG. The flowchart shown in FIG. 8 is characterized in that new control data U is calculated based on the control data A, B, and C with reference to the control data A, B, and C. Similar to the lower-level task process shown in FIG. 7, other processes not related to these characteristic processes are indicated by broken lines in the flowchart and omitted.
[0061]
First, in the first S600, the control data A stored in the storage area 13b of the RAM 13 is referred to. Similarly, control data B is referred to in the next S610, and control data C is referred to in S620.
In subsequent S630, new control data U is calculated based on the control data A, B, and C referred to in S600 to S620, and then the upper task processing is terminated.
[0062]
Refer to the control data A, B and C above. Real This is done by calling the subroutine of the reference process described with reference to FIG. 4 in the embodiment. That is, if the area setting information S is “1” (S200: YES), the control data is read from the area 1 (S210). On the other hand, if the area setting information S is not “1”, that is, the area setting information S is “1”. If “2” (S200: NO), the control data is read out from the area 2 (S220). Of course, on Real Similar to the embodiment, such reference processing may be prepared individually for each of the three control data A, B, and C, or any one of the three control data A, B, and C is designated. Thus, a common reference process may be called.
[0063]
In any case, in this case, the control data A, B, and C are read from the area set as the public area.
As explained above, the book reference Even on the example Real As in the embodiment, reference and update of the control data A, B, and C as the global variables are performed in different areas. At this time, when the control data A, B, and C are referred to by the upper task Ensured simultaneity.
[0064]
For example, a specific description will be given assuming that the area setting information S is “1”.
If the area setting information S is “1”, the area 1 is a public area. Accordingly, in the lower task, the control data A2, B2, and C2 stored in the area 2 that is the work area are updated (S510 to S530 in FIG. 7, see FIG. 6). On the other hand, the higher-level task refers to the control data A1, B1, and C1 stored in the area 1 that is a public area (see S600 to S620 in FIG. 8 and FIG. 4). Therefore, for example, even if the upper task interrupts during the update by the lower task, the control data A1, B1, C1 stored in the area 1 will be referred to, and the control data A2, B2 stored in the area 2 during the update will be referred to. , C2 is never referenced. That is, the simultaneity of the control data A1, B1, C1 referred to by the upper task is ensured.
[0065]
Further, when the update of the control data A2, B2, and C2 that require simultaneity is completed (at the end of S530 in FIG. 7), the area setting information S is updated from “1” to “2” ( S540: YES, S550), the work area and the public area are switched. Thereby, the updated control data A2, B2, and C2 are referred to in the next reference process.
[0066]
As a result, it is possible to ensure the simultaneity of the control data referred to by the upper task without delaying the interrupt processing of the upper task.
In addition, book reference For example, above Real As in the embodiment, by setting one of the areas 1 and 2 as a public area and the other as a work area by the area setting information S stored in the storage area 13a of the RAM 13, the area setting information S is updated (in FIG. 7). S540 to S560), the regions 1 and 2 are switched. Such updating of the area setting information S can be realized by one instruction of the CPU, so that no interruption occurs during the area switching. As a result, the simultaneity of the control data referred to by the upper task can be ensured.
[0067]
Book reference The RAM 13 in the example corresponds to “region information storage means”. And the process of S510-S530 shown with the dashed-dotted line in FIG. 7 is equivalent to a "lower update process", and the process of S540-S560 is equivalent to an "area | region switching process." Further, the processing of S600 to S620 indicated by the alternate long and short dash line in FIG. 8 corresponds to “upper reference processing”.
[Others]
The above Real The embodiment corresponds to the first case where the control data may be updated by the interrupt of the upper task in the middle of the reference processing of the control data of the lower task. reference The example corresponds to the second case in which the control data may be referred to by the interrupt of the upper task during the process of updating the control data of the lower task.
[0068]
Up With For ease of explanation , Real While the example corresponds to the first case, reference Although the example has been described as corresponding to the second case, of course, it is conceivable that both the first and second cases occur in the engine control process. Therefore, usually, lower and upper processing programs are designed in correspondence with the first case, and lower and upper processing programs are designed in correspondence with the second case. That is, in one engine control process, one lower task process is as shown in FIG. 3, and another lower task process is as shown in FIG. Similarly, one upper task process is as shown in FIG. 5, and another upper task process is as shown in FIG.
[0069]
Considering that both the first and second cases are handled in this way, it is known in advance that when one task refers to the control data, the control data may be updated by another task. Under this assumption, it can be determined whether or not the other task is a higher-order task or a lower-order task. Similarly, if a task updates control data, it knows in advance that there is a possibility that a global variable may be referenced by another task. It can be considered to determine whether it is a task or a subordinate task.
[0070]
Specifically, as shown by a broken line in FIG. 1, a storage area 13c for storing information on priority is provided in the RAM 13, and the control data A, B, C is referred to for each control data A, B, C. The highest priority among the tasks to be updated is stored. For example, as shown in FIG. FIG. 9 shows a state in which the highest priority among the priorities of the tasks for which the three control data A, B, and C are processed is stored as PA, PB, and PC.
[0071]
Then, by comparing the priorities PA, PB, PC corresponding to the control data to be processed with the priority P set in the processing program to be determined, it corresponds to the lower task or the upper task. Judging.
This determination process is shown in the flowchart of FIG. This will be described.
[0072]
When the process is started, the priority P of the determination target task is acquired (S700). The task to be determined is a task that is currently being executed. It is conceivable that the set priority P is acquired by an OS subroutine call.
Next, priorities PA, PB, and PC corresponding to the control data A, B, and C to be processed are acquired (S710). This is stored in the storage area 13c described above. At this time, it is conceivable to obtain the highest priority among the three priorities PA, PB, and PC. Further, all of the three priorities PA, PB, and PC may be acquired.
[0073]
Then, the priorities acquired in S700 and S710 are compared to determine whether the priority P is relatively low (S720). If any of the three priorities PA, PB, PC exceeds the priority P, an affirmative determination is made here. If the priority P is relatively low (S720: YES), the task being executed is determined as a lower task (S730). On the other hand, if the priority P is not relatively low (S720: NO), it is being executed. The task is determined as an upper task (S740).
[0074]
As a result, when calculating the control data U with reference to the control data A, B, C in a certain task, if there is a possibility that the control data A, B, C is updated in another task, the above-mentioned By executing the determination process in advance, the lower task process shown in FIG. 3 or the upper task process shown in FIG. 8 can be selectively executed.
[0075]
Similarly, when the control data A, B, and C are calculated by a certain task and the control data A, B, and C are updated, the control data A, B, and C may be referred to by another task. For example, by executing the above-described determination process in advance, the lower task process shown in FIG. 7 or the upper task process shown in FIG. 5 can be selectively executed.
[0076]
This is advantageous in that each task becomes more versatile.
In such a configuration, the RAM 13 included in the microcomputer 10 corresponds to the “priority storage unit”, and the determination process illustrated in FIG. 10 corresponds to the “determination process”.
Here, as shown in FIG. 9, information on the priority is stored for each of the three control data A, B, and C. On the other hand, global variables such as control data that require concurrency are grouped together, and only the highest priority set for tasks that may reference or update global variables is stored. You may make it do. Even in this case, the lower or upper task process can be selectively executed by executing the same determination process as in FIG.
[0077]
In the above embodiment, the present invention is embodied as the ECU 1 that performs the engine control process. However, the present invention is not limited to the engine control of the vehicle, and the information processing apparatus generally performs an interrupt process that should ensure real-time performance. Needless to say, the present invention is applicable.
[Brief description of the drawings]
FIG. 1 is a block diagram illustrating a configuration of an ECU according to an embodiment.
FIG. 2 is an explanatory diagram showing a storage area for area setting information and control data;
[Fig. 3] ] Real It is a flowchart which shows the low-order task process of an Example.
FIG. 4 is a flowchart showing a reference process.
FIG. ] Real It is a flowchart which shows the high-order task process of an Example.
FIG. 6 is a flowchart showing an update process.
[Fig. 7] reference It is a flowchart which shows the low-order task process of an example.
[Fig. 8] reference It is a flowchart which shows the high-order task process of an example.
FIG. 9 is an explanatory diagram showing a priority recording area;
FIG. 10 is a flowchart showing a determination process.
[Explanation of symbols]
1 ... ECU 10 ... Microcomputer
11 ... CPU 12 ... ROM
13 ... RAM 13a ... storage area
13b: Storage area 13c: Storage area
14 ... I / O 21 ... Input circuit
22 ... Output circuit 30 ... Sensor
40 ... Actuator

Claims (8)

実行単位となる複数の処理プログラムを当該処理プログラム毎に設定される優先度に基づき実行することによって、一連の機能を実現する情報処理装置において、
前記優先度の相対的に低い下位プログラムと前記優先度の相対的に高い上位プログラムとの間で共通に使用されるグローバル変数を2つの領域に重複させて記憶させ、当該領域の一方を公開領域、他方を作業領域として設定しておき、
前記下位プログラムによる前記グローバル変数の参照途中で前記上位プログラムによって前記グローバル変数が更新される可能性のある第1のケースに対し、
前記上位プログラムでは、前記作業領域を使用して前記グローバル変数を更新する上位更新処理を実行するようにし、
一方、前記下位プログラムでは、前記公開領域を使用して前記グローバル変数を参照する下位参照処理及び、当該下位参照処理による前記グローバル変数の参照を完了すると、前記作業領域を新たに公開領域として設定しなおすと共に前記公開領域を新たに作業領域として設定しなおす領域切換処理を実行するようにしたこと
を特徴とする情報処理装置。
In an information processing apparatus that realizes a series of functions by executing a plurality of processing programs as execution units based on a priority set for each processing program,
A global variable used in common between the lower program having a relatively low priority and the higher program having a relatively high priority is stored in two areas overlappingly, and one of the areas is a public area Set the other as the work area,
For the first case in which the global variable may be updated by the upper program in the middle of referring to the global variable by the lower program,
In the upper program, the upper update process for updating the global variable using the work area is executed,
On the other hand, in the lower program, when the lower reference process that refers to the global variable using the public area and the reference of the global variable by the lower reference process is completed, the work area is newly set as the public area. An information processing apparatus characterized in that an area switching process for newly setting the public area as a work area is executed.
実行単位となる複数の処理プログラムを当該処理プログラム毎に設定される優先度に基づき実行することによって、一連の機能を実現する情報処理装置において、
前記優先度の相対的に低い下位プログラムと前記優先度の相対的に高い上位プログラムとの間で共通に使用されるグローバル変数を2つの領域に重複させて記憶させ、当該領域の一方を公開領域、他方を作業領域として設定しておき、
前記下位プログラムによる前記グローバル変数の参照途中で前記上位プログラムによって前記グローバル変数が更新される可能性のある第1のケースに対し、
前記上位プログラムでは、前記作業領域を使用して前記グローバル変数を更新する上位更新処理を実行するようにし、
一方、前記下位プログラムでは、前記公開領域を使用して前記グローバル変数を参照する下位参照処理及び、当該下位参照処理による前記グローバル変数の参照を完了すると、前記作業領域を新たに公開領域として設定しなおすと共に前記公開領域を新たに作業領域として設定しなおす領域切換処理を実行するようにしており、
さらに、前記下位プログラムによる前記グローバル変数の更新途中で前記上位プログラムによって前記グローバル変数が参照される可能性のある第2のケースに対し、
前記上位プログラムでは、前記公開領域を使用して前記グローバル変数を参照する上位参照処理を実行するようにし、
一方、前記下位プログラムでは、前記作業領域を使用して前記グローバル変数を更新する下位更新処理及び、当該下位更新処理による前記グローバル変数の更新を完了すると、前記作業領域を新たに公開領域として設定しなおすと共に前記公開領域を新たに作業領域として設定しなおす領域切換処理を実行するようにしたこと
を特徴とする情報処理装置。
In an information processing apparatus that realizes a series of functions by executing a plurality of processing programs as execution units based on a priority set for each processing program,
A global variable used in common between the lower program having a relatively low priority and the higher program having a relatively high priority is stored in two areas overlappingly, and one of the areas is a public area Set the other as the work area,
For the first case in which the global variable may be updated by the upper program in the middle of referring to the global variable by the lower program,
In the upper program, the upper update process for updating the global variable using the work area is executed,
On the other hand, in the lower program, when the lower reference process that refers to the global variable using the public area and the reference of the global variable by the lower reference process is completed, the work area is newly set as the public area. At the same time, an area switching process for newly setting the public area as a work area is executed.
Furthermore, for the second case in which the global variable may be referred to by the upper program during the update of the global variable by the lower program,
In the upper program, an upper reference process that refers to the global variable using the public area is executed,
On the other hand, in the subordinate program, when the subordinate update process for updating the global variable using the work area and the update of the global variable by the subordinate update process are completed, the work area is newly set as a public area. An information processing apparatus characterized in that an area switching process for newly setting the public area as a work area is executed.
請求項に記載の情報処理装置において、
前記各処理プログラムでは、前記グローバル変数の参照又は更新を行う他の処理プログラムの優先度に基づき、前記下位処理プログラム又は前記上位処理プログラムのいずれに該当するかを判断する判断処理を実行し、当該判断処理による判断結果に基づいて、前記該当する処理を実行するようにしたこと
を特徴とする情報処理装置。
The information processing apparatus according to claim 2 ,
In each processing program, based on the priority of another processing program that performs reference or update of the global variable, a determination process is performed to determine which of the lower processing program and the upper processing program corresponds, An information processing apparatus characterized in that the corresponding process is executed based on a determination result of the determination process.
請求項に記載の情報処理装置において、
前記グローバル変数の参照又は更新を行う処理プログラムの優先度の中で最も高い優先度を記憶するための優先度記憶手段を備え、
前記判断処理は、前記優先度記憶手段に記憶された優先度と、判断対象の処理プログラムに設定された優先度とを比較することによって判断するものであること
を特徴とする情報処理装置。
The information processing apparatus according to claim 3 .
A priority storage means for storing the highest priority among the priorities of the processing program for referring to or updating the global variable;
The information processing apparatus according to claim 1, wherein the determination process is performed by comparing a priority stored in the priority storage unit with a priority set in a processing program to be determined.
請求項に記載の情報処理装置において、
前記判断処理は、判断対象の処理プログラムにて処理対象となるグローバル変数についての参照又は更新を行う他の処理プログラムの優先度に基づき判断するものであること
を特徴とする情報処理装置。
The information processing apparatus according to claim 3 .
The information processing apparatus according to claim 1, wherein the determination processing is based on a priority of another processing program that performs reference or update for a global variable to be processed in the processing program to be determined.
請求項に記載の情報処理装置において、
前記グローバル変数毎に、当該グローバル変数の参照又は更新を行う処理プログラムの優先度の中で最も高い優先度を記憶するための優先度記憶手段を備え、
前記判断処理は、前記優先度記憶手段に記憶された、前記処理対象となるグローバル変数に対応する優先度と、判断対象の処理プログラムに設定された優先度とを比較することによって判断するものであること
を特徴とする情報処理装置。
The information processing apparatus according to claim 5 ,
For each global variable, comprising a priority storage means for storing the highest priority among the priorities of the processing program for referring to or updating the global variable,
The determination process is performed by comparing the priority corresponding to the global variable to be processed stored in the priority storage unit and the priority set in the processing program to be determined. An information processing apparatus characterized by being.
請求項1〜のいずれかに記載の情報処理装置において、
さらに、前記公開領域又は前記作業領域として領域を設定する設定情報を記憶するための領域情報記憶手段を備えていること
を特徴とする情報処理装置。
In the information processing apparatus according to any one of claims 1 to 6 ,
The information processing apparatus further comprises an area information storage unit for storing setting information for setting an area as the public area or the work area.
請求項に記載の情報処理装置において、
前記領域切換処理は、前記領域情報記憶手段に記憶された前記設定情報を更新することによって、前記作業領域を新たに公開領域として設定しなおすと共に前記公開領域を新たに作業領域として設定しなおすものであること
を特徴とする情報処理装置。
The information processing apparatus according to claim 7 ,
In the area switching process, the work area is newly set as a public area and the public area is newly set as a work area by updating the setting information stored in the area information storage unit. An information processing apparatus characterized by
JP2000348121A 2000-11-15 2000-11-15 Information processing device Expired - Fee Related JP3783553B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2000348121A JP3783553B2 (en) 2000-11-15 2000-11-15 Information processing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2000348121A JP3783553B2 (en) 2000-11-15 2000-11-15 Information processing device

Publications (2)

Publication Number Publication Date
JP2002149421A JP2002149421A (en) 2002-05-24
JP3783553B2 true JP3783553B2 (en) 2006-06-07

Family

ID=18821750

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2000348121A Expired - Fee Related JP3783553B2 (en) 2000-11-15 2000-11-15 Information processing device

Country Status (1)

Country Link
JP (1) JP3783553B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE102011055205A1 (en) 2010-11-15 2012-05-16 Denso Corporation Electronic control unit for use in electrical servo steering device of steering wheel system of vehicle, has microcomputer comprising CPU for storing global variable, where task of low order executes duplication method

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5596320B2 (en) * 2009-09-07 2014-09-24 任天堂株式会社 Information processing program and information processing apparatus
JP5406072B2 (en) * 2010-02-18 2014-02-05 株式会社日立製作所 Embedded control device
JP4957853B1 (en) * 2011-03-15 2012-06-20 オムロン株式会社 PLC CPU unit, PLC system program, and recording medium storing PLC system program
KR102492399B1 (en) * 2016-07-27 2023-01-26 엘에스일렉트릭(주) Apparatus for monitoring and controlling
JP6452924B1 (en) 2018-05-11 2019-01-16 三菱電機株式会社 Compiler and programming support device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE102011055205A1 (en) 2010-11-15 2012-05-16 Denso Corporation Electronic control unit for use in electrical servo steering device of steering wheel system of vehicle, has microcomputer comprising CPU for storing global variable, where task of low order executes duplication method

Also Published As

Publication number Publication date
JP2002149421A (en) 2002-05-24

Similar Documents

Publication Publication Date Title
JP3610915B2 (en) Processing execution apparatus and program
JP3578082B2 (en) Processing execution device and recording medium
JP4728020B2 (en) Vehicle control software and vehicle control apparatus
JPH04169350A (en) Event drive type vehicle control computer
JP4241462B2 (en) Control unit and microcomputer
JP3783553B2 (en) Information processing device
JP2009245009A (en) Vehicle control device and multi-core processor
US5974346A (en) Method for controlling technical processes
US7930523B2 (en) Inter-CPU data transfer device
JP3879514B2 (en) Electronic control device and program
JP3755415B2 (en) Processing execution device, processing program mounted on the processing execution device, and recording medium
JP3617445B2 (en) Information processing device
JPH05240106A (en) Electronic control unit to be mounted on vehicle
JP6981512B2 (en) Electronic control device
US20180173559A1 (en) Electronic Control Device and Stack Usage Method
JPH03189337A (en) Control unit for automobile
JPH08505455A (en) Calculation mechanism
JP2021152338A (en) Controller
JP4921175B2 (en) Software creation method for automobile control device
GB2328299A (en) Data processing system for ensuring data consistency
JP2018072921A (en) On-vehicle electronic control device
JP2019135656A (en) Electronic control device and method of using stack
JP2002342077A (en) Interface program and processing execution device
JPH08106307A (en) Programmable controller
JP2021089531A (en) Electronic control device

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20051122

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20060123

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

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20060221

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20060306

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20100324

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20100324

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20110324

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20120324

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20120324

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20130324

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20140324

Year of fee payment: 8

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

LAPS Cancellation because of no payment of annual fees