JP3124788B2 - Exception handling method of embedded multitasking operating system - Google Patents

Exception handling method of embedded multitasking operating system

Info

Publication number
JP3124788B2
JP3124788B2 JP03142671A JP14267191A JP3124788B2 JP 3124788 B2 JP3124788 B2 JP 3124788B2 JP 03142671 A JP03142671 A JP 03142671A JP 14267191 A JP14267191 A JP 14267191A JP 3124788 B2 JP3124788 B2 JP 3124788B2
Authority
JP
Japan
Prior art keywords
task
executed
state
user
processing
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
JP03142671A
Other languages
Japanese (ja)
Other versions
JPH04343148A (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.)
Ricoh Co Ltd
Original Assignee
Ricoh Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ricoh Co Ltd filed Critical Ricoh Co Ltd
Priority to JP03142671A priority Critical patent/JP3124788B2/en
Publication of JPH04343148A publication Critical patent/JPH04343148A/en
Application granted granted Critical
Publication of JP3124788B2 publication Critical patent/JP3124788B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、複数のユーザタスクを
並列して処理可能な組込型マルチタスクオペレーティン
グシステムの例外処理方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to an exception handling method for an embedded multitasking operating system capable of processing a plurality of user tasks in parallel.

【0002】[0002]

【従来の技術】例えば、ファクシミリ装置など、マイク
ロコンピュータシステムを利用して動作制御を行なって
いる装置で、複数のタスク(処理単位)を並列的に実行
する必要がある場合、その制御システムとして、マルチ
タスクオペレーティングシステムを使用している。
2. Description of the Related Art For example, when a plurality of tasks (processing units) need to be executed in parallel in a device such as a facsimile machine that performs operation control using a microcomputer system, the control system includes: You are using a multitasking operating system.

【0003】このようなマルチタスクオペレーティング
システムでは、装置の制御ソフトウェアが完成するま
で、何度か制御ソフトウェアの機能検査、いわゆる、デ
バッグ作業を行なう必要があり、その便宜のための種々
の機能を備えている。
In such a multitasking operating system, it is necessary to perform a function check of the control software several times until the control software of the apparatus is completed, that is, a so-called debugging work, and various functions for convenience are provided. ing.

【0004】例えば、ユーザタスクプログラム(以下、
単にプログラムという)の実行状況を1ステップずつ検
査できるトレース機能、プログラムを任意の時点で停止
できるブレーク機能、および、プログラムの不都合(以
下、バグという)によりシステムが暴走したときにハー
ド的にシステムを停止するウォッチドッグタイマ機能な
どである。
For example, a user task program (hereinafter, referred to as a user task program)
A trace function that can check the execution status of a program (step-by-step), a break function that can stop the program at any time, and a hardware system that runs out of control when a program runs out of control due to inconvenience (hereinafter referred to as a bug). For example, a watchdog timer function to stop.

【0005】[0005]

【発明が解決しようとする課題】しかしながら、このよ
うな従来装置では、デバッグ中にシステムが暴走したと
き、暴走を引き起こしたタスクのみならず、他のタスク
の実行状態を変化させることが有り、このような場合、
どのタスクがバグをもっているかオペレータが判断でき
ないという不都合を生じていた。
However, in such a conventional apparatus, when the system goes out of control during debugging, not only the task causing the runaway but also the execution state of other tasks may be changed. In such a case,
There has been a problem that the operator cannot determine which task has a bug.

【0006】また、完成した制御ソフトウェアを組込ん
だ装置を稼働中、その装置の動作環境によっては、シス
テム内部のバスにノイズが混入してバス上のデータが破
壊され、システムが暴走して制御不可能な状態になった
り、装置に組込まれている機器などを破壊するという不
都合を生じていた。
In addition, during operation of a device incorporating the completed control software, depending on the operating environment of the device, noise may be mixed into the bus inside the system and the data on the bus may be destroyed. There have been inconveniences such as being in an impossible state or destroying devices incorporated in the apparatus.

【0007】また、システム暴走のためのウォッチドッ
グタイマなどのハード要素を設ける必要があるために、
コストが大きくなるという不都合を生じていた。
Further, since it is necessary to provide a hardware element such as a watchdog timer for system runaway,
There has been an inconvenience that the cost increases.

【0008】本発明は、このような実情に鑑みてなされ
たものであり、デバッグ作業を効率よく行なえるととも
に、システム暴走時の影響を抑制でき、また、システム
暴走をソフト的に検出できるようにした組込型マルチタ
スクオペレーティングシステムの例外処理方法を提供す
ることを目的としている。
SUMMARY OF THE INVENTION The present invention has been made in view of the above circumstances, and has been made so that debugging can be performed efficiently, the influence of system runaway can be suppressed, and system runaway can be detected by software. It is an object of the present invention to provide an exception handling method for an embedded multitasking operating system.

【0009】[0009]

【課題を解決するための手段】本発明は、複数のユーザ
タスクを並列して処理可能な組込型マルチタスクオペレ
ーティングシステムの例外処理方法において、不当な命
令がフェッチされたことを検出可能なマイクロプロセッ
サを用いる一方、装置機能検査時、同一ユーザタスクか
ら所定回数連続して不当命令フェッチを検出すると、そ
のユーザタスクを強制待ち状態に遷移させるとともに、
他のユーザタスクを実行するようにしたものである。
SUMMARY OF THE INVENTION The present invention relates to an exception handling method for an embedded multitasking operating system capable of processing a plurality of user tasks in parallel. On the other hand, when the processor is used for device function inspection, if an illegal instruction fetch is detected a predetermined number of times in succession from the same user task, the user task is shifted to a forced wait state,
Another user task is executed.

【0010】また、複数のユーザタスクを並列して処理
可能な組込型マルチタスクオペレーティングシステムの
例外処理方法において、不当な命令がフェッチされたこ
とを検出可能なマイクロプロセッサを用いる一方、装置
稼働時、同一ユーザタスクから所定回数連続して不当命
令フェッチを検出すると、そのユーザタスクを強制的に
終了させるとともに、他のユーザタスクを実行するよう
にしたものである。
Also, in an exception handling method of an embedded multitasking operating system capable of processing a plurality of user tasks in parallel, a microprocessor capable of detecting that an illegal instruction has been fetched is used. When an illegal instruction fetch is detected a predetermined number of times in succession from the same user task, the user task is forcibly terminated and another user task is executed.

【0011】[0011]

【0012】[0012]

【作用】したがって、装置機能検査時、システム暴走し
たときの原因となったユーザタスクが強制待ち状態に遷
移されるので、そのシステム暴走が他のユーザタスクに
影響を及ぼすことが防止され、装置機能検査を効率よく
行うことができる。また、装置稼働時、システム暴走し
たときの原因となったユーザタスクが強制終了されるの
で、そのシステム暴走が他のユーザタスクに影響を及ぼ
すことが防止される。
Therefore, at the time of the device function test, the user task that caused the system runaway is shifted to the forced wait state, so that the system runaway is prevented from affecting other user tasks, and the device function is prevented. Inspection can be performed efficiently. Also, when the apparatus is operating, the user task that caused the system runaway is forcibly terminated, so that the system runaway is prevented from affecting other user tasks.

【0013】[0013]

【実施例】以下、添付図面を参照しながら、本発明の実
施例を詳細に説明する。
Embodiments of the present invention will be described below in detail with reference to the accompanying drawings.

【0014】図1は、本発明の一実施例にかかる装置モ
デルを示している。
FIG. 1 shows an apparatus model according to an embodiment of the present invention.

【0015】同図において、CPU(中央処理装置)1
は、この装置の動作制御を行なうものであり、ROM
(リード・オンリ・メモリ)2は、CPU1が実行する
処理プログラムおよびその処理プログラムを実行するた
めに必要な種々のデータを記憶するものであり、RAM
(ランダム・アクセス・メモリ)3は、CPU1が実行
する処理プログラムのワークエリアなどをなすものであ
る。また、CPU1は、不当な命令がフェッチされたこ
とを検出する不当命令検出機能を備えている。
In FIG. 1, a CPU (central processing unit) 1
Is used to control the operation of this device.
The (read only memory) 2 stores a processing program executed by the CPU 1 and various data necessary for executing the processing program.
The (random access memory) 3 forms a work area for a processing program executed by the CPU 1. Further, the CPU 1 has an illegal instruction detecting function for detecting that an illegal instruction has been fetched.

【0016】I/Oポート4は、周辺装置5,6とCP
U1を接続するためのものであり、周辺装置5,6は、
それぞれこの装置の機能を実現するためのものである。
例えば、ファクシミリ装置の場合、画像を読み取るため
のスキャナおよび画像を記録出力するためのプロッタな
どがこの周辺装置5,6に相当する。
The I / O port 4 is connected to the peripheral devices 5 and 6 and the CP
U1 is connected, and the peripheral devices 5 and 6 are
Each is for realizing the function of this device.
For example, in the case of a facsimile machine, the peripheral devices 5 and 6 correspond to a scanner for reading an image and a plotter for recording and outputting an image.

【0017】これらのCPU1、ROM2、RAM3、
I/Oポート4は、内部バス7に接続されており、これ
らの各要素間のデータのやりとりは、この内部バス7を
介して行われる。
These CPU1, ROM2, RAM3,
The I / O port 4 is connected to the internal bus 7, and data exchange between these elements is performed via the internal bus 7.

【0018】この装置モデルでは、図2に示すように、
システムが階層化されている。
In this device model, as shown in FIG.
The system is hierarchical.

【0019】同図において、システム資源は、CPU
1、RAM3のワークエリア、および、周辺装置5,6
などをあらわし、ユーザタスクは、この装置の処理機能
を実現するソフトウェアの処理単位をあらわし、マルチ
タスクオペレーティングシステム(以下、M_OSとい
う)は、ユーザタスクの実行を効率よく処理するための
システムソフトウェアをあらわす。
In FIG. 1, a system resource is a CPU.
1. Work area of RAM3 and peripheral devices 5, 6
The user task represents a processing unit of software for realizing the processing function of the device, and the multitask operating system (hereinafter, referred to as M_OS) represents system software for efficiently processing the execution of the user task. .

【0020】このM_OSは、複数のユーザタスクを並
列的に実行する機能を備えており、本実施例では、ユー
ザタスクからの処理の実行要求は、システムコールとい
う所定の形式のデータを発行するという形態で行なわれ
る。また、このシステムコールの発行は、所定のレジス
タに実行要求する処理機能をあらわす機能コードをセッ
トした状態で、ソフトウェア割り込みを発行することで
行なわれる。また、処理機能には、複数のユーザタスク
で共通に使用される汎用サブルーチンモジュールを含
む。
The M_OS has a function of executing a plurality of user tasks in parallel. In this embodiment, a request to execute a process from a user task issues data of a predetermined format called a system call. Performed in form. The system call is issued by issuing a software interrupt in a state where a function code representing a processing function for requesting execution is set in a predetermined register. The processing functions include a general-purpose subroutine module commonly used by a plurality of user tasks.

【0021】また、この装置モデルでは、図3(a)に
示すように、M_OSのプログラムが配置されるM_O
S領域、ユーザタスクのプログラムが配置されるユーザ
タスク領域、ワーク領域、および、データテーブル領域
に、CPU1のメモリ空間が分割されている。
Further, in this device model, as shown in FIG. 3A, M_O
The memory space of the CPU 1 is divided into an S area, a user task area in which a user task program is arranged, a work area, and a data table area.

【0022】ここで、ユーザタスク領域には、同図
(b)に示すように、複数のタスクが記憶されている。
Here, a plurality of tasks are stored in the user task area as shown in FIG.

【0023】さて、通常、CPU1が実行するプログラ
ムコードの1ステップは、命令コードと、この命令コー
ドの実行対象となる資源(メモリあるいはレジスタな
ど)を指定するオペランドコードから構成されており、
なんらかの理由でCPU1が暴走状態になったとき、オ
ペランドコードを命令コードと間違えてフェッチした
り、あるいは、次のステップの命令コードをオペランド
コードとして間違えてフェッチするような事態を生じ
る。
Normally, one step of the program code executed by the CPU 1 is composed of an instruction code and an operand code for specifying a resource (memory or register, etc.) to be executed by the instruction code.
When the CPU 1 goes out of control for any reason, a situation may occur in which the operand code is erroneously fetched as an instruction code or the instruction code of the next step is erroneously fetched as an operand code.

【0024】このような事態、すなわち、不当命令フェ
ッチ現象が発生すると、CPU1は不当命令割込状態と
なり、所定の処理を実行する。
When such a situation, that is, an illegal instruction fetch phenomenon occurs, the CPU 1 enters an illegal instruction interrupt state and executes a predetermined process.

【0025】図4は、この装置モデルのソフトウェアを
デバッグするときに、CPU1が実行する不当命令割込
処理の一例を示している。この不当命令割込処理は、M
_OSが実行する処理の1つである。
FIG. 4 shows an example of an illegal instruction interruption process executed by the CPU 1 when debugging the software of the device model. This illegal instruction interrupt processing is performed by M
This is one of the processes executed by the _OS.

【0026】まず、不当命令割込状態になると、M_O
Sは、その時点で実行中のタスクを待機状態(WAIT
状態)に遷移させるとともにそのときのCPU1のレジ
スタの内容を所定の領域に退避し(処理101)、不当
命令割込状態を検出したタスクを記憶するための変数T
_TCBが、そのときに実行しているタスクの識別情報
C_TCBに等しいかどうかを調べる(判断102)。
First, when an illegal instruction interrupt state occurs, M_O
S waits for the currently executing task (WAIT
State), the contents of the register of the CPU 1 at that time are saved in a predetermined area (process 101), and a variable T for storing the task in which the illegal instruction interrupt state is detected.
It is checked whether or not _TCB is equal to the identification information C_TCB of the task being executed at the time (decision 102).

【0027】判断102の結果がYESになるときに
は、同一タスクについて不当命令割込状態を連続して検
出した回数を記憶するためのカウンタT_CNTをデク
リメントし(処理103)、カウンタT_CNTの値が
0に等しいかどうかを調べる(判断104)。
When the result of the judgment 102 is YES, the counter T_CNT for storing the number of times the illegal instruction interrupt state is continuously detected for the same task is decremented (process 103), and the value of the counter T_CNT becomes 0. It is checked whether they are equal (decision 104).

【0028】判断104の結果がYESになるときに
は、同一タスクが不正なシステムコールをN(所定値)
回連続して発行した場合であり、そのタスクが異常な状
態なので、所定の例外処理ルーチン(図示略)を実行し
(処理105)、実行中のタスクを強制待ち状態(SU
SPEND状態)に遷移させて(処理106)、変数T
_TCBに所定値NULLをセットするとともに、カウ
ンタT_CNTに所定値Nをセットする(処理10
7)。
If the result of decision 104 is YES, the same task sends an invalid system call N (predetermined value)
In this case, the task is in an abnormal state. Therefore, a predetermined exception handling routine (not shown) is executed (processing 105), and the task being executed is forcibly waited (SU).
(SPEND state) (process 106), and the variable T
_TCB is set to a predetermined value NULL, and a counter T_CNT is set to a predetermined value N (Process 10
7).

【0029】次いで、実行可能な状態(READY状
態)に登録されている複数のタスクの中から、所定の実
行スケジュールにしたがって次に実行するタスクを選択
し(処理108)、その選択したタスクを実行するため
にレジスタの内容を選択タスクに対応した内容に更新し
て(処理109)、そのタスクを実行する状態に遷移す
る。
Next, a task to be executed next is selected from a plurality of tasks registered in an executable state (READY state) according to a predetermined execution schedule (step 108), and the selected task is executed. To do so, the contents of the register are updated to the contents corresponding to the selected task (process 109), and the state is shifted to a state in which the task is executed.

【0030】また、判断104の結果がNOになるとき
には、処理108に移行し、次に実行すべきタスクの実
行状態に移行する。
On the other hand, when the result of the determination 104 is NO, the process shifts to a process 108 to shift to an execution state of a task to be executed next.

【0031】また、判断102の結果がNOになるとき
には、変数T_TCBに識別情報C_TCBの内容をセ
ットし(処理110)、カウンタT_CNTに所定値N
をセットして(処理111)、この所定値Nが0に等し
いかどうかを判断する(判断112)。
When the result of the determination 102 is NO, the contents of the identification information C_TCB are set in a variable T_TCB (step 110), and a predetermined value N is set in a counter T_CNT.
Is set (process 111), and it is determined whether or not the predetermined value N is equal to 0 (determination 112).

【0032】判断112の結果がYESになるときに
は、処理105に移行して、例外処理状態に移行し、ま
た、判断112の結果がNOになるときには、処理10
8に移行して、次に実行すべきタスクの実行状態に移行
する。
When the result of the determination 112 is YES, the processing shifts to step 105 to shift to the exception processing state, and when the result of the determination 112 is NO, the processing 10
Then, the process shifts to the execution state of the task to be executed next.

【0033】このようにして、本実施例では、デバッグ
作業時に同一タスクを実行中に、不当命令割込状態が連
続してN回検出されたとき、その実行中のタスクが異常
であると判定し、そのタスクを異常状態のままSUSP
END状態に遷移させているので、このタスクの異常が
原因となって他のタスクの実行状態まで異常になるよう
な事態を防止できる。
As described above, in this embodiment, when an illegal instruction interrupt state is detected N times consecutively during execution of the same task during debugging, it is determined that the task being executed is abnormal. SUSP with the task in an abnormal state
Since the transition is made to the END state, it is possible to prevent a situation in which the abnormality of this task causes the execution state of another task to become abnormal.

【0034】また、適当なタイミングでブレークさせる
と、その異常状態のままSUSPEND状態に遷移させ
たタスクを適切にトレースすることができ、したがっ
て、効率的なデバッグ作業を行なうことができる。
Further, when a break is made at an appropriate timing, a task that has transited to the SUSPEND state in the abnormal state can be appropriately traced, and thus efficient debugging can be performed.

【0035】また、この装置モデルのソフトウェアのデ
バッグが完了して、この装置モデルを実際に稼働すると
きに、CPU1が実行する不当命令割込処理の一例を図
5に示す。この不当命令割込処理は、M_OSが実行す
る処理の1つである。
FIG. 5 shows an example of an illegal instruction interruption process executed by the CPU 1 when the debugging of the software of the device model is completed and the device model is actually operated. This illegal instruction interruption processing is one of the processing executed by the M_OS.

【0036】まず、不当命令割込状態になると、M_O
Sは、その時点で実行中のタスクを待機状態(WAIT
状態)に遷移させるとともにそのときのCPU1のレジ
スタの内容を所定の領域に退避し(処理201)、不当
命令割込状態を検出したタスクを記憶するための変数T
_TCBが、そのときに実行しているタスクの識別情報
C_TCBに等しいかどうかを調べる(判断202)。
First, when an illegal instruction interrupt state occurs, M_O
S waits for the currently executing task (WAIT
State), the contents of the register of the CPU 1 at that time are saved in a predetermined area (process 201), and a variable T for storing the task in which the illegal instruction interrupt state is detected.
It is checked whether or not _TCB is equal to the identification information C_TCB of the task being executed at the time (decision 202).

【0037】判断202の結果がYESになるときに
は、同一タスクについて不当命令割込状態を連続して検
出した回数を記憶するためのカウンタT_CNTをデク
リメントし(処理203)、カウンタT_CNTの値が
0に等しいかどうかを調べる(判断204)。
When the result of the determination 202 is YES, the counter T_CNT for storing the number of times the illegal instruction interrupt state is continuously detected for the same task is decremented (process 203), and the value of the counter T_CNT is set to 0. It is checked whether they are equal (decision 204).

【0038】判断204の結果がYESになるときに
は、同一タスクが不正なシステムコールをN(所定値)
回連続して発行した場合であり、そのタスクが異常な状
態なので、所定の例外処理ルーチン(図示略)を実行し
(処理205)、実行中のタスクに対応した終了ルーチ
ンを実行してそのタスクが使用しているシステム資源を
全て解放させ(処理206)、変数T_TCBに所定値
NULLをセットするとともに、カウンタT_CNTに
所定値Nをセットする(処理207)。
When the result of determination 204 is YES, the same task makes an illegal system call N (predetermined value)
In this case, the task is in an abnormal state, so that a predetermined exception handling routine (not shown) is executed (process 205), and an end routine corresponding to the task being executed is executed to execute the task. Release all the system resources used (process 206), set a predetermined value NULL to a variable T_TCB, and set a predetermined value N to a counter T_CNT (process 207).

【0039】次いで、実行可能な状態(READY状
態)に登録されている複数のタスクの中から、所定の実
行スケジュールにしたがって次に実行するタスクを選択
し(処理208)、その選択したタスクを実行するため
にレジスタの内容を選択タスクに対応した内容に更新し
て(処理209)、そのタスクを実行する状態に遷移す
る。
Next, a task to be executed next is selected from a plurality of tasks registered in an executable state (READY state) according to a predetermined execution schedule (step 208), and the selected task is executed. In order to execute the task, the content of the register is updated to the content corresponding to the selected task (process 209), and the state is shifted to the task execution.

【0040】また、判断204の結果がNOになるとき
には、処理208に移行し、次に実行すべきタスクの実
行状態に移行する。
On the other hand, when the result of the determination 204 is NO, the process shifts to a process 208 to shift to an execution state of a task to be executed next.

【0041】また、判断202の結果がNOになるとき
には、変数T_TCBに識別情報C_TCBの内容をセ
ットし(処理210)、カウンタT_CNTに所定値N
をセットして(処理211)、この所定値Nが0に等し
いかどうかを判断する(判断212)。
When the result of the determination 202 is NO, the contents of the identification information C_TCB are set to the variable T_TCB (step 210), and the predetermined value N is set to the counter T_CNT.
Is set (process 211), and it is determined whether or not the predetermined value N is equal to 0 (determination 212).

【0042】判断212の結果がYESになるときに
は、処理205に移行して、例外処理状態に移行し、ま
た、判断212の結果がNOになるときには、処理20
8に移行して、次に実行すべきタスクの実行状態に移行
する。
When the result of the determination 212 is YES, the process shifts to step 205 to shift to the exception processing state, and when the result of the determination 212 is NO, the process 20
Then, the process shifts to the execution state of the task to be executed next.

【0043】このようにして、本実施例では、装置稼働
時に同一タスクを実行中に、不当命令割込状態が連続し
てN回検出されたとき、その実行中のタスクが異常であ
ると判定し、そのタスクを強制的に終了させているの
で、このユーザタスクの異常が原因となって他のタスク
の実行状態まで異常になるような事態を防止できる。
As described above, in the present embodiment, when an illegal instruction interruption state is detected N times consecutively while the same task is being executed while the apparatus is operating, it is determined that the task being executed is abnormal. Since the task is forcibly terminated, it is possible to prevent a situation in which the abnormality of the user task causes the execution state of another task to become abnormal.

【0044】また、そのときに、異常なタスクに対応し
た終了ルーチンを実行させて、そのタスクが使用してい
たシステム資源を解放するとともに、そのタスクが他の
タスク(以下、子タスクという)を起床したり、生成し
た場合には、その子タスクを消滅させて、ワークエリア
を解放させるようにしている。
Further, at that time, a termination routine corresponding to the abnormal task is executed to release the system resources used by the task, and at the same time, the task replaces another task (hereinafter referred to as a child task). When the user wakes up or generates a task, the child task is deleted and the work area is released.

【0045】ところで、CPU1の動作が暴走状態にな
ったことをソフト的に検出するには、例えば、次のよう
にすればよい。なお、この動作は、M_OSにより実行
されるものであり、この場合、ユーザタスクが汎用のサ
ブルーチンモジュールを呼び出す、いわゆる、サブルー
チンコールを行なう前後で、CPU1の暴走状態を検出
している。
By the way, to detect that the operation of the CPU 1 has gone out of control by software, for example, the following may be performed. This operation is executed by the M_OS. In this case, the runaway state of the CPU 1 is detected before and after the user task calls a general-purpose subroutine module, that is, before and after performing a so-called subroutine call.

【0046】まず、ユーザタスクがサブルーチンコール
を行なう場合、呼び出すサブルーチンモジュールにそれ
ぞれ割り当てられている識別番号、例えば、01H(H
は16進数をあらわす;以下同じ)を共通スタックにプ
ッシュする(図6(a),(b)参照)。
First, when the user task makes a subroutine call, an identification number assigned to each subroutine module to be called, for example, 01H (H
Represents a hexadecimal number; the same applies hereinafter) onto the common stack (see FIGS. 6A and 6B).

【0047】そして、M_OSは、サブルーチンモジュ
ールが終了したあとにサブルーチンコールを発行したユ
ーザタスクに戻るための戻りアドレス(この場合、2バ
イト)を共通スタックにプッシュ(保存)して(図6
(c)参照)、実行要求されたサブルーチンモジュール
を実行する。この実行中の状態では、サブルーチンモジ
ュールに必要なワークエリアが共通スタックに確保され
る(図6(d)参照)。
Then, the M_OS pushes (stores) a return address (in this case, 2 bytes) for returning to the user task that issued the subroutine call after the subroutine module is completed (FIG. 6).
(Refer to (c)), execute the requested subroutine module. In this running state, a work area required for the subroutine module is secured on the common stack (see FIG. 6D).

【0048】サブルーチンモジュールの実行が終了する
と、M_OSは、そのときのスタックポインタSPに2
を加えた共通スタックのスタックアドレス領域位置に記
憶されている識別番号(この場合は、01H)を取り出
して、そのときに実行終了したサブルーチンモジュール
に設定されている識別番号の値と比較する(図6(e)
参照)。
When the execution of the subroutine module is completed, M_OS stores 2 in the stack pointer SP at that time.
The identification number (01H in this case) stored in the stack address area position of the common stack to which the subroutine module has been added is taken out, and is compared with the value of the identification number set in the subroutine module which has been executed at that time (FIG. 6 (e)
reference).

【0049】このとき、両者が等しければ、このサブル
ーチンモジュールの実行中にシステムが暴走状態になっ
ていないと判定することができ、その場合には、再度、
サブルーチンコールが発行されたときに対処できるよう
に、識別番号を記憶した共通スタック領域にデータ0を
セットする(図6(f)参照)。
At this time, if the two are equal, it can be determined that the system is not in a runaway state during the execution of this subroutine module.
Data 0 is set in the common stack area storing the identification number so as to cope with the issuance of the subroutine call (see FIG. 6F).

【0050】また、共通スタック領域に記憶されている
識別番号の値と、サブルーチンモジュールに設定されて
いる識別番号が不一致の場合には、システムが暴走状態
になっていると判定することができ、所定の例外処理、
例えば、システムリセット処理などを実行する。
When the value of the identification number stored in the common stack area does not match the identification number set in the subroutine module, it can be determined that the system is in a runaway state. Predetermined exception handling,
For example, a system reset process is performed.

【0051】このようにして、ユーザタスクがサブルー
チンコールを行なうたびに、システムが暴走状態である
か否かの判定動作が行われるので、システム暴走を検出
するためのウォッチドッグタイマなどの特別なハード的
機構が不要となる。
As described above, every time the user task makes a subroutine call, the operation of determining whether or not the system is in a runaway state is performed. Therefore, a special hardware such as a watchdog timer for detecting a system runaway is used. No mechanical mechanism is required.

【0052】通常、システム暴走状態になったときに
は、暴走してから最初に検出したサブルーチンからのリ
ターン命令により、そのサブルーチンコールを発行した
タスクとは全く関係のないタスクを起動したり、あるい
は、内部バス7に乗ったノイズにより、サブルーチンの
実行状態に制御が移行した場合などの事態が生じる。
Normally, when the system goes into a runaway state, a task that has nothing to do with the task that issued the subroutine call is activated by a return instruction from the subroutine detected first after the runaway, or A situation such as a case where the control is shifted to the execution state of the subroutine due to the noise on the bus 7 occurs.

【0053】したがって、上述したように、サブルーチ
ンコールの前後でそのサブルーチンに対応した識別番号
の検査処理を行なうようにすることで、システム暴走状
態を適切に検出することができる。
Therefore, as described above, the system runaway state can be appropriately detected by performing the inspection process of the identification number corresponding to the subroutine before and after the subroutine call.

【0054】図6は、ユーザタスクからサブルーチンコ
ールが発行されたときの処理例を示している。
FIG. 6 shows an example of processing when a subroutine call is issued from a user task.

【0055】まず、発行されたサブルーチンコールによ
り実行要求されたサブルーチンモジュールに設定されて
いる識別番号を、共通スタックにプッシュし(処理30
1)、その実行要求されたサブルーチンモジュールを実
行する(処理302)。
First, the identification number set in the subroutine module requested to be executed by the issued subroutine call is pushed onto the common stack (step 30).
1), the requested subroutine module is executed (process 302).

【0056】このサブルーチンモジュールの実行を終了
すると、共通スタックの先頭領域を示しているスタック
ポインタSPの値を1つ増やすことで、共通スタックに
プッシュした識別番号の次の領域にスタックポインタS
Pの値を移動し(処理303)、次の処理に移行する。
When the execution of the subroutine module is completed, the value of the stack pointer SP indicating the head area of the common stack is increased by one, so that the stack pointer S is moved to the area next to the identification number pushed onto the common stack.
The value of P is moved (process 303), and the process proceeds to the next process.

【0057】図7は、サブルーチンコール時の処理例を
示している。
FIG. 7 shows an example of processing at the time of a subroutine call.

【0058】まず、実行要求されたサブルーチンモジュ
ールを実行し(処理401)、その処理を終了すると、
そのときのスタックポインタSPの値は、戻りアドレス
の先頭のスタックアドレスを示しているので、スタック
ポインタSPの値に2を加えたスタックアドレスに記憶
されている識別番号を取り出す(処理402)。
First, the subroutine module requested to be executed is executed (process 401), and when the process is completed,
Since the value of the stack pointer SP at that time indicates the top stack address of the return address, the identification number stored in the stack address obtained by adding 2 to the value of the stack pointer SP is extracted (process 402).

【0059】そして、そのときに実行終了したサブルー
チンモジュールに設定されている識別番号と、その取り
出した識別番号が一致するかどうかを調べ(判断40
3)、判断403の結果がYESになるときには、その
識別番号を記憶していたスタック領域にデータ0をセッ
トして(処理404)、サブルーチンコールしたユーザ
タスクにリターンする。
Then, it is checked whether or not the identification number set in the subroutine module which has been executed at that time coincides with the extracted identification number (decision 40).
3) If the result of determination 403 is YES, data 0 is set in the stack area storing the identification number (process 404), and the process returns to the user task that called the subroutine.

【0060】また、判断403の結果がNOになるとき
には、システム暴走状態が発生したと判定し、所定の例
外処理を実行し(処理405)、エラー終了する。
When the result of determination 403 is NO, it is determined that a system runaway condition has occurred, a predetermined exception process is executed (process 405), and the process ends with an error.

【0061】なお、上述した実施例では、サブルーチン
コールを発行したときに、そのサブルーチンに対応する
識別番号をスタック領域に直接記録するようにしている
が、この識別番号の記録は、レジスタを介して行なうこ
ともできる。
In the above-described embodiment, when a subroutine call is issued, the identification number corresponding to the subroutine is recorded directly in the stack area. However, this identification number is recorded via a register. You can do it.

【0062】[0062]

【発明の効果】以上説明したように、本発明によれば、
装置機能検査時、システム暴走したときの原因となった
ユーザタスクが強制待ち状態に遷移されるので、そのシ
ステム暴走が他のユーザタスクに影響を及ぼすことが防
止され、装置機能検査を効率よく行うことができるとい
う効果を得る。また、装置稼働時、システム暴走したと
きの原因となったユーザタスクが強制終了されるので、
そのシステム暴走が他のユーザタスクに影響を及ぼすこ
とが防止されるという効果も得る。
As described above, according to the present invention,
During the device function test, the user task that caused the system runaway is transitioned to the forced wait state, so that the system runaway is prevented from affecting other user tasks, and the device function test is performed efficiently. The effect that can be obtained. Also, when the device is operating, the user task that caused the system runaway is forcibly terminated.
An effect is also obtained that the system runaway is prevented from affecting other user tasks.

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

【図1】本発明の一実施例にかかる装置モデルを示すブ
ロック図。
FIG. 1 is a block diagram showing an apparatus model according to one embodiment of the present invention.

【図2】図1の装置モデルのシステム構成の概略を示す
概略図。
FIG. 2 is a schematic diagram showing an outline of a system configuration of the device model of FIG. 1;

【図3】図1の装置モデルのメモリ空間の分割態様を例
示した概略図。
FIG. 3 is a schematic diagram illustrating a mode of dividing a memory space of the device model of FIG. 1;

【図4】図1の装置モデルのソフトウェアをデバッグす
るときに不当命令割込状態が検出されたときときにM_
OSが実行する処理例を示すフローチャート。
FIG. 4 is a diagram showing a state where an illegal instruction interrupt state is detected when debugging software of the device model of FIG. 1;
9 is a flowchart illustrating an example of processing executed by the OS.

【図5】図1の装置モデルの稼働時に不当命令割込状態
が検出されたときにM_OSが実行する処理例を示すフ
ローチャート。
FIG. 5 is a flowchart showing an example of processing executed by the M_OS when an illegal instruction interruption state is detected during operation of the device model of FIG. 1;

【図6】ソフト的にシステム暴走を検出する動作を説明
するための概略図。
FIG. 6 is a schematic diagram for explaining an operation of detecting system runaway by software.

【図7】図6の動作を実現するための処理例を示すフロ
ーチャート。
FIG. 7 is a flowchart showing a processing example for implementing the operation of FIG. 6;

【図8】図6の動作を実現するための他の処理例を示す
フローチャート。
FIG. 8 is a flowchart showing another processing example for realizing the operation of FIG. 6;

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

1 CPU(中央処理装置) 1 CPU (central processing unit)

Claims (2)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 複数のユーザタスクを並列して処理可能
な組込型マルチタスクオペレーティングシステムの例外
処理方法において、 不当な命令がフェッチされたことを検出可能なマイクロ
プロセッサを用いる一方、装置機能検査時、同一ユーザ
タスクから所定回数連続して不当命令フェッチを検出す
ると、そのユーザタスクを強制待ち状態に遷移させると
ともに、他のユーザタスクを実行することを特徴とする
組込型マルチタスクオペレーティングシステムの例外処
理方法。
1. An exception handling method for an embedded multitasking operating system capable of processing a plurality of user tasks in parallel, using a microprocessor capable of detecting that an illegal instruction has been fetched, When an illegal instruction fetch is detected a predetermined number of times in succession from the same user task, the user task is shifted to a forced wait state and another user task is executed. Exception handling method.
【請求項2】 複数のユーザタスクを並列して処理可能
な組込型マルチタスクオペレーティングシステムの例外
処理方法において、 不当な命令がフェッチされたことを検出可能なマイクロ
プロセッサを用いる一方、装置稼働時、同一ユーザタス
クから所定回数連続して不当命令フェッチを検出する
と、そのユーザタスクを強制終了させるとともに、他の
ユーザタスクを実行することを特徴とする組込型マルチ
タスクオペレーティングシステムの例外処理方法。
2. An exception handling method for an embedded multitasking operating system capable of processing a plurality of user tasks in parallel, wherein a microprocessor capable of detecting that an illegal instruction has been fetched is used. And detecting an illegal instruction fetch from the same user task a predetermined number of times in succession, forcibly terminating the user task, and executing another user task.
JP03142671A 1991-05-20 1991-05-20 Exception handling method of embedded multitasking operating system Expired - Fee Related JP3124788B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP03142671A JP3124788B2 (en) 1991-05-20 1991-05-20 Exception handling method of embedded multitasking operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP03142671A JP3124788B2 (en) 1991-05-20 1991-05-20 Exception handling method of embedded multitasking operating system

Publications (2)

Publication Number Publication Date
JPH04343148A JPH04343148A (en) 1992-11-30
JP3124788B2 true JP3124788B2 (en) 2001-01-15

Family

ID=15320798

Family Applications (1)

Application Number Title Priority Date Filing Date
JP03142671A Expired - Fee Related JP3124788B2 (en) 1991-05-20 1991-05-20 Exception handling method of embedded multitasking operating system

Country Status (1)

Country Link
JP (1) JP3124788B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2014035741A (en) * 2012-08-10 2014-02-24 Denso Corp Electronic control device

Also Published As

Publication number Publication date
JPH04343148A (en) 1992-11-30

Similar Documents

Publication Publication Date Title
JPH1021094A (en) Real-time control system
EP1967950A2 (en) Multiprocessor system for continuing program execution upon detection of abnormality
EP1125199B1 (en) Method of debugging a program thread
US6697959B2 (en) Fault handling in a data processing system utilizing a fault vector pointer table
JP3124788B2 (en) Exception handling method of embedded multitasking operating system
JPH0731617B2 (en) Program runaway detection method
JPH04266141A (en) Stack overflow detection system
JP2737724B2 (en) NMI communication device between processors and system bus controller
US20020112202A1 (en) Fault vector pointer table
JP4543505B2 (en) Microcomputer control method and abnormality monitoring device
JPH01125633A (en) System for debugging multi-processing system
JP3171615B2 (en) Data transfer retry control method
JP2562838B2 (en) Processor and store buffer control method
JP3102568B2 (en) Software development equipment
JP2002251299A (en) Program tracing device
JPH04229331A (en) Exception processing method of built-in multitask operating system
JP2665173B2 (en) Processor trap circuit
JP2654105B2 (en) Microprocessor
JPH0319574B2 (en)
JPH04337847A (en) Program check method
JPH04199336A (en) Microcomputer
JPH01175052A (en) Microaddress register mechanism
JPH07210421A (en) Debugging method in thread environment
JPH0333939A (en) Microprocessor
JP2004318469A (en) Program tracing system

Legal Events

Date Code Title Description
LAPS Cancellation because of no payment of annual fees