JP2000076081A - Task manager and program recording medium - Google Patents

Task manager and program recording medium

Info

Publication number
JP2000076081A
JP2000076081A JP10241933A JP24193398A JP2000076081A JP 2000076081 A JP2000076081 A JP 2000076081A JP 10241933 A JP10241933 A JP 10241933A JP 24193398 A JP24193398 A JP 24193398A JP 2000076081 A JP2000076081 A JP 2000076081A
Authority
JP
Japan
Prior art keywords
task
data
stack
execution
area
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP10241933A
Other languages
Japanese (ja)
Inventor
Kenichi Suehiro
憲一 末廣
Junji Soga
順二 曽我
Mitsunari Nakahara
充也 中原
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.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial 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 Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP10241933A priority Critical patent/JP2000076081A/en
Publication of JP2000076081A publication Critical patent/JP2000076081A/en
Pending legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To provide a task manager and a program recording medium for preventing the malfunction of program or runaway of microprocessor by detecting a specified task is to use stack areas more than previously allocated ones. SOLUTION: Before the activation of a task, a stack area initializing part 231 initializes the stack areas to be used for respective tasks and when the execution of the task is interrupted, data at the final part of the stack area used for this task are read out by a stack boundary monitoring part 2 and compared with the initialized data in the stack area so that the occurrence of overflow of tasks can be detected.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明はマイクロプロセッサ
上でマルチタスク処理を行う場合に、複数のプログラム
の実行を順番に切り換える動作を行うタスクマネージャ
ーに関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a task manager that performs an operation of sequentially switching the execution of a plurality of programs when performing multitask processing on a microprocessor.

【0002】[0002]

【従来の技術】家電製品に使われる機器組込用のマイク
ロプロセッサでは、家電商品の高機能化が進むにつれ
て、複数の処理を時分割で順番に実行する、いわゆるマ
ルチタスク処理が必要になってきた。
2. Description of the Related Art In a microprocessor incorporated in a device used in a home electric appliance, as the functions of the home electric appliance become more sophisticated, a so-called multi-task process for sequentially executing a plurality of processes in a time-sharing manner becomes necessary. Was.

【0003】このように、1つのマイクロプロセッサ上
で複数のプログラム処理を切り換えて実行するには、一
般的にマイコンメーカーやOSメーカーが開発し市販し
ているリアルタイムOSと呼ばれるプログラムを使うこ
とで実現できる。しかしながら、このようなリアルタイ
ムOSは高機能でありプログラムサイズも大きくなって
しまうため、マイクロプロセッサの処理性能やROM、
RAMサイズの制限から、使用できないことが多い。こ
のため、従来は家電メーカーの機器組込プログラム開発
者が、複数のプログラムの実行切換のみを行う単純な構
造を持つタスクマネージャープログラムを通常のプログ
ラムと一緒に開発し、マルチタスク処理を実現してい
た。
As described above, switching and executing a plurality of program processes on one microprocessor is realized by using a program called a real-time OS which is generally developed and marketed by a microcomputer manufacturer or an OS manufacturer. it can. However, such a real-time OS has a high function and a large program size.
In many cases, it cannot be used due to the limitation of the RAM size. For this reason, conventionally, a device embedded program developer of a home appliance maker has developed a task manager program having a simple structure for performing only the execution switching of a plurality of programs together with a normal program, thereby realizing multitask processing. Was.

【0004】図6に従来のタスクマネージャーの構造の
一例を示す。図6で1はプログラムの実行単位である複
数のタスクの中から実行する1つのタスクを選択する実
行タスク選択部、2は実行タスク選択部1が選択したタ
スクを実行するタスク実行部、3は実行中のタスクを中
断するタスク中断部、4〜5はプログラムの実行単位で
あるタスクA〜C、7〜8はタスクA〜Cが実行中にデ
ータを一時的に格納するスタック領域である。
FIG. 6 shows an example of the structure of a conventional task manager. In FIG. 6, reference numeral 1 denotes an execution task selection unit that selects one task to be executed from among a plurality of tasks that are execution units of a program; 2, a task execution unit that executes the task selected by the execution task selection unit 1; A task suspending unit that suspends the task being executed, 4 to 5 are tasks A to C, which are execution units of the program, and 7 to 8 are stack areas for temporarily storing data while the tasks A to C are being executed.

【0005】図6のように構成された従来のタスクマネ
ージャーでは、まず、実行タスク選択部1がタスクA〜
Cの中からあらかじめ決められた順序にしたがって、実
行するタスクを決定し、たとえば実行を行うタスクがタ
スクBの場合には、タスクBを実行するようにタスク実
行部2に指令する。タスク実行部2は実行タスク選択部
1からタスクBを実行するように指令されるとタスクB
を実行させる。タスク実行部2によってタスクBが実行
されてから一定時間が経過すると、タスク実行中断部3
がタスクBの実行を中断し、他のタスクの実行を行うた
めに、実行タスク選択部1に次に実行するタスクを決定
するように指令する。
[0005] In the conventional task manager configured as shown in FIG.
The task to be executed is determined from C in a predetermined order. For example, when the task to be executed is the task B, the task execution unit 2 is instructed to execute the task B. When the task execution unit 2 is instructed by the execution task selection unit 1 to execute the task B, the task B
Is executed. When a predetermined time has passed since the task B was executed by the task execution unit 2, the task execution interruption unit 3
Instructs the execution task selection unit 1 to determine the next task to execute in order to interrupt the execution of the task B and execute another task.

【0006】このようにして、実行タスク選択部1が実
行するタスクを決定し、そのタスクをタスク実行部2が
実行し、一定時間このタスクの実行が行われると、他の
タスクの実行を行うためにタスク実行中断部3が実行中
のタスクの実行を中断し、実行タスク選択部1に次の実
行タスクの決定を行わせるという一連の動作が続けられ
ることによって、複数のタスクが時分割で順次実行され
ていく。
In this way, the task to be executed by the execution task selecting unit 1 is determined, and the task is executed by the task execution unit 2, and when this task is executed for a predetermined time, another task is executed. For this reason, the task execution interrupting unit 3 interrupts the execution of the task being executed, and a series of operations of causing the execution task selecting unit 1 to determine the next execution task is continued. It is executed sequentially.

【0007】[0007]

【発明が解決しようとする課題】図6に示される従来の
構成のタスクマネージャーでは、タスクの実行切換のみ
を行うだけであり、各タスクが使用するスタック領域は
管理しないため、各タスクの開発者があらかじめ各タス
クに割り当てられたスタック領域だけを使用するように
タスクのプログラムを設計する必要がある。
The task manager of the conventional configuration shown in FIG. 6 only switches the execution of tasks and does not manage the stack area used by each task. It is necessary to design a task program so that it uses only the stack area previously allocated to each task.

【0008】通常、各タスクに割り当てられたスタック
領域は、各タスクプログラム内でのデータの一時退避や
演算に利用されたり、各タスクプログラムがサブルーチ
ンコールを実行した場合の戻り番地やレジスタデータ等
を退避するために使われる。
Normally, a stack area allocated to each task is used for temporary saving and calculation of data in each task program, and a return address and register data when each task program executes a subroutine call. Used to evacuate.

【0009】しかしながら、プログラム設計開発中での
デバック時には正確に各タスクの実行に必要なスタック
領域の大きさを見積もることは困難であるため、あらか
じめ適当な大きさのスタック領域を各タスクに割り当て
ることになるが、機器組込用のマイクロプロセッサでは
メモリ領域が限られており、過分なスタック領域は割り
当てることができないので、特定のタスクがあらかじめ
割り当てられたスタック領域をオーバーして他のタスク
のスタック領域に対して書き込みを行ってしまう場合が
ある。
However, since it is difficult to accurately estimate the size of the stack area required for executing each task during debugging during program design and development, it is necessary to allocate a stack area of an appropriate size to each task in advance. However, the microprocessor area for embedded devices has a limited memory area, and an excessive stack area cannot be allocated.Therefore, a specific task exceeds the stack area allocated in advance and stacks other tasks. In some cases, writing is performed on the area.

【0010】このように従来のタスクマネージャーで、
特定のタスクが割り当てられたスタック領域をオーバー
し、他のタスクのスタック領域を使用してしまった場合
には、他のタスクが誤動作を起こしたり、最悪の場合に
はすべてのタスクが誤動作を起こし、マイクロプロセッ
サが暴走するという問題を有していた。
[0010] Thus, in the conventional task manager,
If a specific task exceeds the allocated stack area and uses the stack area of another task, other tasks will malfunction, or in the worst case, all tasks will malfunction. Had the problem that the microprocessor would run away.

【0011】本発明はこのような従来のタスクマネージ
ャーでは、特定のタスクが割り当てられたスタック領域
をオーバーし、他のタスクのスタック領域を使用してし
まった場合には、他のタスクが誤動作を起こしたり、最
悪の場合にはすべてのタスクが誤動作を起こし、マイク
ロプロセッサが暴走するという課題を考慮し、特定のタ
スクがあらかじめ割り当てられた以上のスタック領域を
使用した場合には、これを検出し、プログラムの誤動作
やマイクロプロセッサの暴走を未然に防ぐタスクマネー
ジャー及びプログラム記録媒体を提供することを目的と
するものである。
According to the present invention, in such a conventional task manager, when a specific task exceeds the allocated stack area and the stack area of another task is used, the other task malfunctions. Considering the task of causing a task or, in the worst case, all tasks to malfunction and causing the microprocessor to run away, if a particular task uses more than the pre-allocated stack space, this will be detected. It is another object of the present invention to provide a task manager and a program recording medium for preventing a malfunction of a program and a runaway of a microprocessor.

【0012】[0012]

【課題を解決するための手段】上述した課題を解決する
ために、第1の本発明(請求項1に対応)は、プログラ
ム処理の実行単位であるタスクが複数存在し、それらの
タスクを処理するタスクマネージャーにおいて、前記タ
スクの実行を順次切り替えるタスク切換手段と、前記タ
スクが予め割り当てられたスタック領域以外の領域にデ
ータの書き込みを行ったことを検出するスタック領域監
視手段と、を備えたことを特徴とするタスクマネージャ
ーである。
According to a first aspect of the present invention (corresponding to claim 1), there are a plurality of tasks which are execution units of a program processing, and these tasks are processed. A task switching means for sequentially switching the execution of the task, and a stack area monitoring means for detecting that the task has written data to an area other than a pre-allocated stack area. It is a task manager characterized by the following.

【0013】また第2の本発明(請求項2に対応)は、
前記スタック領域監視手段は、前記タスクを起動する前
に前記スタック領域の初期化を行うスタック領域初期化
手段と、それぞれの前記タスクに割り当てられたそれぞ
れの前記スタック領域の境界線から所定の範囲のデータ
が前記スタック領域初期化手段によって初期化された時
点のデータとは異なっていることを検出した際前記タス
クが予め割り当てられた前記スタック領域以外の領域に
データの書き込みを行ったものと判断するスタック境界
監視手段とで構成されたことを特徴とする第1の発明記
載のタスクマネージャーである。
[0013] The second invention (corresponding to claim 2) provides:
The stack area monitoring means includes: a stack area initializing means for initializing the stack area before activating the task; and a predetermined range from a boundary of each of the stack areas allocated to each of the tasks. When it is detected that the data is different from the data at the time when the data is initialized by the stack area initializing means, it is determined that the task has written data to an area other than the previously allocated stack area. The task manager according to the first invention, comprising a stack boundary monitoring means.

【0014】また第3の本発明(請求項3に対応)は、
前記スタック領域監視手段は、前記タスクを所定の時間
実行した後で実行を中断された際前記タスクに割り当て
られた前記スタック領域の境界線から所定の範囲のデー
タを格納するスタック境界データ格納手段と、前記スタ
ック境界データ格納手段によって格納された過去のデー
タと現時点でのスタック領域の境界線から所定の範囲の
互いに対応するデータとの比較を行い、異なっているこ
とを検出すると前記タスクが予め割り当てられたスタッ
ク領域以外の領域にデータの書き込みを行ったものと判
断するスタック境界監視手段とで構成されたことを特徴
とする第1の発明記載のタスクマネージャーである。
A third aspect of the present invention (corresponding to claim 3) is:
A stack boundary data storage unit configured to store data in a predetermined range from a boundary of the stack area allocated to the task when the execution of the task is interrupted after executing the task for a predetermined time; and Comparing the past data stored by the stack boundary data storage means with data corresponding to each other within a predetermined range from the boundary line of the stack area at the current time, and when detecting a difference, the task is allocated in advance. The task manager according to the first aspect of the present invention, comprising: a stack boundary monitoring unit that determines that data has been written to an area other than the specified stack area.

【0015】また第4の本発明(請求項4に対応)は、
前記タスク切換手段は、特定のタスクが予め割り当てら
れた前記スタック領域以外の領域にデータの書き込みを
行ったことを前記スタック領域監視手段が検出すると、
このタスクの実行を停止することを特徴とする第1の発
明記載のタスクマネージャーである。
A fourth aspect of the present invention (corresponding to claim 4) is:
The task switching unit, when the stack area monitoring unit detects that a specific task has written data to an area other than the stack area allocated in advance,
The task manager according to the first aspect of the present invention, wherein execution of the task is stopped.

【0016】また第5の本発明(請求項5に対応)は、
前記タスク切換手段は、予め割り当てられたスタック領
域以外の領域にデータの書き込みを行ったことを前記ス
タック領域監視手段が検出すると、予め割り当てられた
前記スタック領域以外の領域にデータの書き込みを行っ
たタスクと、このタスクによって予め割り当てられた前
記スタック領域を書き換えられた全てのタスクの実行を
停止することを特徴とする第1の発明記載のタスクマネ
ージャーである。
A fifth aspect of the present invention (corresponding to claim 5) is:
The task switching means writes data to an area other than the previously allocated stack area when the stack area monitoring means detects that the data has been written to an area other than the previously allocated stack area. The task manager according to the first aspect of the present invention, wherein execution of a task and all tasks whose stack areas previously allocated by the task have been rewritten are stopped.

【0017】また第6の本発明(請求項6に対応)は、
前記タスク切換手段は、予め割り当てられた前記スタッ
ク領域以外の領域にデータの書き込みを行ったことを前
記スタック領域監視手段が検出すると、全てのタスクの
実行を停止することを特徴とする第1の発明記載のタス
クマネージャーである。
A sixth aspect of the present invention (corresponding to claim 6) is:
The first task switching means stops execution of all tasks when the stack area monitoring means detects that data has been written to an area other than the previously allocated stack area. It is a task manager according to the invention.

【0018】また第7の本発明(請求項7に対応)は、
前記タスク切換手段は、予め割り当てられたスタック領
域以外の領域にデータの書き込みを行ったことを前記ス
タック領域監視手段が検出すると、全てのタスクの実行
を停止するとともに、予め指定されたタスクを実行する
ことを特徴とする第1の発明記載のタスクマネージャー
である。
A seventh aspect of the present invention (corresponding to claim 7) is:
When the stack area monitoring means detects that data has been written to an area other than the pre-allocated stack area, the task switching means stops execution of all tasks and executes a predetermined task. A task manager according to the first aspect of the present invention.

【0019】また第8の本発明(請求項8に対応)は、
第1〜8の発明のいずれかに記載の各手段の全部または
一部の機能を実現するためのプログラムを格納している
ことを特徴とするプログラム記録媒体である。
An eighth aspect of the present invention (corresponding to claim 8) is:
A program recording medium storing a program for realizing all or a part of the functions of each means described in any one of the first to eighth inventions.

【0020】[0020]

【発明の実施の形態】以下、本発明の実施の形態につい
て、図1から図5を用いて説明する。
DESCRIPTION OF THE PREFERRED EMBODIMENTS Embodiments of the present invention will be described below with reference to FIGS.

【0021】(実施の形態1)図1は、本発明のタスク
マネージャーの一実施の形態を示し、図1において21
0〜212はそれぞれプログラムの実行単位であるタス
クA〜C、220はタスク切換手段であるタスク切換
部、230はスタック領域監視部、620はスタック領
域である。
(Embodiment 1) FIG. 1 shows an embodiment of a task manager according to the present invention.
Reference numerals 0 to 212 denote tasks A to C, which are execution units of the program, 220, a task switching unit as task switching means, 230, a stack area monitoring unit, and 620, a stack area.

【0022】タスク切換部220は実行するタスクを決
定する実行タスク選択部221と、タスクの実行開始及
び実行再開を行うタスク実行部222と、実行している
タスクの中断を行うタスク実行中断部223で構成され
る。
The task switching unit 220 includes an execution task selection unit 221 for determining a task to be executed, a task execution unit 222 for starting and resuming execution of the task, and a task execution interruption unit 223 for interrupting the task being executed. It consists of.

【0023】スタック領域監視部230は各タスクの実
行開始前に各タスクが使用するスタック領域を初期化す
るスタック領域初期化部231と各タスクがあらかじめ
決められたスタック領域を越えて別の領域に書き込みを
行ったことを検出するスタック境界監視部232で構成
される。
The stack area monitoring section 230 initializes a stack area used by each task before the start of execution of each task, and the stack area initialization section 231 and each task move to a different area beyond a predetermined stack area. The stack boundary monitoring unit 232 detects that writing has been performed.

【0024】スタック領域620はタスクA〜Cがそれ
ぞれ実行中にデータを一時的に格納するために使用する
スタック領域621〜623で構成されている。また、
領域624〜626はそれぞれスタック領域621〜6
23の各領域内に含まれる領域であり、各領域内で一番
最後にデータの書き込みが行われる各領域の最終格納領
域である。
The stack area 620 is composed of stack areas 621 to 623 used for temporarily storing data during execution of the tasks A to C, respectively. Also,
Areas 624 to 626 are stack areas 621 to 626, respectively.
23 is an area included in each area, and is a last storage area of each area in which data is written last in each area.

【0025】なお、タスク切換部220が本発明のタス
ク切換手段の例であり、スタック領域監視部230が本
発明のスタック領域監視手段の例であり、スタック領域
初期化部231が本発明のスタック領域初期化手段の例
であり、スタック境界監視部232が本発明のスタック
境界監視手段の例である。
The task switching section 220 is an example of the task switching section of the present invention, the stack area monitoring section 230 is an example of the stack area monitoring section of the present invention, and the stack area initializing section 231 is the stack switching section of the present invention. This is an example of the area initialization unit, and the stack boundary monitoring unit 232 is an example of the stack boundary monitoring unit of the present invention.

【0026】以上のように構成されたタスクマネージャ
ーについて、図1及び図2を用いて、以下、その動作を
述べる。
The operation of the task manager configured as described above will be described below with reference to FIGS. 1 and 2.

【0027】図2は図1のタスクマネージャーの処理の
流れを示した図である。図2でタスクnとなっている部
分はタスクA、タスクB、タスクCのいずれかであるこ
とを示している。
FIG. 2 is a diagram showing a process flow of the task manager of FIG. In FIG. 2, the portion indicated as task n indicates that it is one of task A, task B, and task C.

【0028】なお、実行するタスクはタスクA〜Cの3
つのタスクであり、タスクA→タスクB→タスクC→タ
スクA→タスクB・・・の繰り返しで実行切換が行われ
る場合について説明する。また、各タスクがそれぞれ使
用するスタック領域621〜623は各領域ともデータ
格納場所を示すアドレスの大きい方から小さい方に順次
使用されていくものとする。
The tasks to be executed are tasks A to C.
A description will be given of a case in which the execution switching is performed by repeating task A → task B → task C → task A → task B. Also, the stack areas 621 to 623 used by the tasks are assumed to be used in order from the larger address indicating the data storage location to the smaller address in each area.

【0029】まず各タスクの実行に先立って、スタック
領域初期化部231が各タスクの使用するスタック領域
621〜623を初期化する。この初期化はスタック領
域621〜623のすべての領域に対して同じデータ
(たとえば0)を書き込むことにより行われる。
First, prior to execution of each task, the stack area initialization unit 231 initializes stack areas 621 to 623 used by each task. This initialization is performed by writing the same data (for example, 0) to all of the stack areas 621 to 623.

【0030】スタック領域初期化部231によるスタッ
ク領域621〜623の初期化処理が終了すると、実行
タスク選択部221はあらかじめ決められた順番にした
がって実行を開始するタスクを決定し、最初に起動する
タスクAのタスクIDをタスク実行部222に供給す
る。
When the initialization of the stack areas 621 to 623 by the stack area initialization unit 231 is completed, the execution task selection unit 221 determines a task to start execution in a predetermined order, and starts the task to be started first. The task ID of A is supplied to the task execution unit 222.

【0031】タスク実行部222は実行タスク選択部2
21から供給されるタスクIDにしたがって、タスクA
の処理を最初から実行する。
The task execution section 222 is an execution task selection section 2
21 according to the task ID supplied from
Is executed from the beginning.

【0032】タスクAの実行が開始されてから、タスク
Aに対してあらかじめ決められた実行割当時間が経過す
ると、タスク実行中断部223が実行中であるタスクA
の処理実行を中断し、中断した時点でのタスクAの状
態、即ちタスクAの処理がどこまで行われたかというこ
とと、タスクAの処理の途中経過の状態を退避し、中断
されたタスクがどのタスクであるかをスタック境界監視
部232に供給する。
When a predetermined execution allotted time elapses for the task A from the start of the execution of the task A, the task execution suspending unit 223
Of the task A at the time of the interruption, that is, how much the processing of the task A has been performed, and the state of the progress of the processing of the task A are saved. Whether the task is a task is supplied to the stack boundary monitoring unit 232.

【0033】スタック境界監視部232はタスク実行中
断部223から中断したタスクがタスクAであるという
情報を受け取ると、タスクAが使用するスタック領域6
21の領域内の最終領域624に書き込まれているデー
タを読み出し、このデータがスタック領域初期化部23
1によって初期化された時のデータと異なっているかど
うかを確認する。タスクAのスタック領域の最終領域6
24に格納されているデータがスタック領域初期化部2
31によって初期化された時のデータと異なっている場
合には、このタスクのタスクIDをスタックオーバーフ
ロータスクとして登録する。
When the stack boundary monitoring unit 232 receives the information that the interrupted task is the task A from the task execution interrupting unit 223, the stack area 6 used by the task A
The data written in the last area 624 in the area 21 is read out, and this data is stored in the stack area initialization unit 23.
Check if the data is different from the data when initialized by 1. Last area 6 of task A stack area
24 is the stack area initialization unit 2
If the data is different from the data initialized at step 31, the task ID of this task is registered as a stack overflow task.

【0034】スタック境界監視部232によるスタック
領域の監視動作が終了すると、実行タスク選択部221
はあらかじめ決められた順番にしたがって実行を開始す
るタスクを決定し、2番目に起動するタスクBのタスク
IDをタスク実行部222に供給する。
When the operation of monitoring the stack area by the stack boundary monitoring unit 232 is completed, the execution task selection unit 221
Determines a task to start execution in accordance with a predetermined order, and supplies the task execution unit 222 with the task ID of the task B to be started second.

【0035】以下、図2の処理ブロック10の部分に示
されるように、タスクAの実行開始、実行中断の場合と
同様にして、タスクB及びタスクCの実行開始、実行中
断が行われる。
Thereafter, as shown in the processing block 10 of FIG. 2, the execution of the task B and the execution of the task C are interrupted and the execution of the task C are interrupted in the same manner as the execution of the task A and the interruption of the execution.

【0036】タスクA〜Cの全てのタスクの起動が終了
し、最後に起動したタスクCがタスク実行中断部223
によって実行を中断され、スタック境界監視部232に
よるスタック領域の監視動作が終了すると、実行タスク
選択部221は図2の処理ブランチ20に示すように、
すべてのタスクを起動したかどうかを確認し、すべての
タスクの起動が完了しているので、以降は実行を中断さ
れた各タスクの中から、実行を再開するタスクを順次選
択し実行していく。
The activation of all of the tasks A to C is completed, and the last activated task C is executed by the task execution suspending unit 223.
When the execution is interrupted and the operation of monitoring the stack area by the stack boundary monitoring unit 232 ends, the execution task selection unit 221 sets the processing branch 20 in FIG.
Check whether all tasks have been started, and since all tasks have been started, select the task whose execution is to be resumed from each task whose execution has been interrupted, and then execute it. .

【0037】実行タスク選択部221は、まずあらかじ
め決められた順番にしたがって、最初に実行を再開する
タスクであるタスクAのタスクIDをタスク実行部22
2に供給する。
The execution task selection unit 221 first assigns the task ID of the task A, which is the task whose execution is to be resumed first, to the task execution unit 22 in a predetermined order.
Feed to 2.

【0038】タスク実行部222は実行タスク選択部2
21から供給されるタスクIDにしたがって、タスクA
の処理を実行中断された部分から実行する。即ち、タス
ク実行中断部223が格納した実行中断時点でのタスク
Aの状態を復帰し、タスクAの処理を実行中断された部
分から実行する。
The task execution section 222 is an execution task selection section 2
21 according to the task ID supplied from
Is executed from the part where the execution was interrupted. That is, the state of the task A at the time of the execution interruption stored by the task execution interruption unit 223 is restored, and the processing of the task A is executed from the part where the execution was interrupted.

【0039】タスクAが起動されてから実行を中断した
時と同じように、タスクAの実行が再開されてから、タ
スクAに対してあらかじめ決められた実行割当時間が経
過すると、タスク実行中断部223がタスクAの処理実
行を再び中断し、中断した時点でのタスクAの状態を退
避し、スタック境界監視部232がスタック領域の監視
動作を行う。
In the same manner as when the execution of the task A is suspended after the start of the task A, when a predetermined execution allotted time for the task A elapses after the execution of the task A is resumed, the task execution suspending unit 223 again suspends the processing execution of task A, saves the state of task A at the time of the suspension, and stack boundary monitoring unit 232 performs a monitoring operation of the stack area.

【0040】以降、図2の処理ブロック30の部分に示
すように、実行タスク選択部221が実行タスクを決定
し、タスク実行部222が実行を再開するタスクの状態
の復帰とこのタスクの実行再開を行い、タスク実行中断
部223が実行中のタスクの中断と、中断した時点での
タスクの状態の退避を行い、スタック境界監視部232
が実行を中断したタスクのスタック領域の監視動作を行
うという一連の動作が続けられる。これにより、タスク
A→タスクB→タスクC→タスクA→タスクB・・・の
繰り返しで順次タスクの実行切換が行われる。
Thereafter, as shown in the processing block 30 in FIG. 2, the execution task selection unit 221 determines the execution task, and the task execution unit 222 returns the state of the task to be resumed, and resumes the execution of this task. The task execution suspending unit 223 suspends the task being executed, and saves the state of the task at the time of the suspension.
Performs a monitoring operation of the stack area of the task whose execution has been interrupted. Thus, the execution of the tasks is sequentially switched by repeating the task A → the task B → the task C → the task A → the task B.

【0041】以上のようにして、タスクマネージャーに
よってタスクの実行が順次切換られながら、各タスクの
実行が行われている時に、特定のタスクたとえばタスク
Bがあらかじめ決められたタスクBのスタック領域62
2を越えて別の領域にデータを書き込んだ場合の動作に
ついて説明する。
As described above, when the execution of each task is performed while the execution of the tasks is sequentially switched by the task manager, a specific task, for example, the task B is stored in the stack area 62 of the predetermined task B.
The operation in the case where data is written in another area beyond 2 will be described.

【0042】タスクBはデータの一時的な格納領域とし
て、あらかじめ割り当てられたタスクBのスタック領域
622に対して、領域内のアドレスの大きい部分から小
さい部分(図1のスタック領域622で下から上の方
向)に向かってデータの書き込みを行っていくが、たく
さんのデータを書き込んでいくと最後にはタスクBのス
タック領域622の領域内の最終領域625にデータを
書き込み、さらにデータの書き込みを続けると、タスク
Aのスタック領域621の最初の領域にデータを書き込
むことになる。
The task B is used as a temporary storage area for data, with respect to the stack area 622 of the task B allocated in advance, from a portion having a large address to a portion having a small address (from bottom to top in the stack region 622 in FIG. 1). The data is written toward () direction. However, when a large amount of data is written, finally, the data is written to the last area 625 in the area of the stack area 622 of the task B, and further the data writing is continued. Then, data is written to the first area of the stack area 621 of the task A.

【0043】タスクBがタスクAのスタック領域621
の最初の領域にデータを書き込むと、タスクAが実行再
開し、この部分に一時的に格納したデータを読み出そう
とした場合に、タスクBによってデータが書き換えられ
ているために、正しいデータが得られず、間違った処理
を実行したり、最悪の場合にはタスクAが異常処理を行
ってしまう。
Task B is the stack area 621 of task A.
When the data is written to the first area of the task A, the task A resumes execution. When the data temporarily stored in this part is read, the data is rewritten by the task B. It cannot be obtained, and performs wrong processing. In the worst case, task A performs abnormal processing.

【0044】このような場合には、図2の処理ブランチ
11及び処理ブロック12、もしくは処理ブランチ31
及び処理ブロック32に示すように、スタック境界監視
部232がタスクBのスタック領域622の領域内の最
終領域625のデータを読み出し、このデータがスタッ
ク領域初期化部231が初期化したときのデータとは異
なっていることを検出し、タスクBのタスクIDをスタ
ックオーバーフロータスクとして登録する。
In such a case, the processing branch 11 and the processing block 12 in FIG.
As shown in the processing block 32, the stack boundary monitoring unit 232 reads the data of the last area 625 in the area of the stack area 622 of the task B, and this data is the data when the stack area initialization unit 231 initializes the data. Detects that they are different, and registers the task ID of task B as a stack overflow task.

【0045】そして、タスクBがスタックオーバーフロ
ータスクとして登録されると、実行タスク選択部221
は全てのタスクの実行を停止し、タスクが異常処理を行
うことを防止するとともにスタックオーバーフローが発
生したことを示す信号を出力する。
When the task B is registered as a stack overflow task, the execution task selection unit 221
Stops execution of all tasks, prevents the tasks from performing abnormal processing, and outputs a signal indicating that a stack overflow has occurred.

【0046】図3は、図1に示した本発明のタスクマネ
ージャーを一般的なマイクロプロセッサ上で動作するプ
ログラムで実現した場合の具体的な構成を示している。
なお、図1のタスクマネージャーの各構成要素は図1と
図3で同じ番号で示している。
FIG. 3 shows a specific configuration when the task manager of the present invention shown in FIG. 1 is realized by a program operating on a general microprocessor.
Note that each component of the task manager in FIG. 1 is indicated by the same number in FIGS. 1 and 3.

【0047】図3において100はプログラムカウン
タ、200は命令ROM、250は命令選択回路、30
0は命令解読回路、400はALU、500はレジス
タ、600はRAM、630はアドレスデコーダ、64
0はスタックポインタ、700はタイマー、800は割
込処理制御回路、900はデータバス、950はローカ
ルバス、1000はアドレスバスである。
In FIG. 3, 100 is a program counter, 200 is an instruction ROM, 250 is an instruction selection circuit, 30
0 is an instruction decoding circuit, 400 is an ALU, 500 is a register, 600 is a RAM, 630 is an address decoder, 64
0 is a stack pointer, 700 is a timer, 800 is an interrupt processing control circuit, 900 is a data bus, 950 is a local bus, and 1000 is an address bus.

【0048】プログラムカウンタ100は実行するプロ
グラムの実行アドレスデータの出力と実行アドレスデー
タの更新動作を行い、出力された実行アドレスデータは
命令選択回路250に供給される。
The program counter 100 outputs the execution address data of the program to be executed and updates the execution address data. The output execution address data is supplied to the instruction selection circuit 250.

【0049】命令ROM200は命令コードデータ群で
構成された複数のプログラムが格納されている。命令R
OM200には、タスクA〜C(図3では210〜21
2で示されている)と、一定時間ごとにタスクA〜Bの
実行切換を行うプログラムであるタスク切換部220、
タスクA〜Cが使用するスタック領域を監視するプログ
ラムであるスタック領域監視部230が格納されてい
る。
The instruction ROM 200 stores a plurality of programs each composed of an instruction code data group. Instruction R
The OM 200 includes tasks A to C (210 to 21 in FIG. 3).
2), and a task switching unit 220 which is a program for switching the execution of the tasks A and B at regular intervals.
A stack area monitoring unit 230, which is a program for monitoring a stack area used by tasks A to C, is stored.

【0050】プログラムカウンタ100から実行アドレ
スデータが命令選択回路250に供給されると、命令選
択回路250は命令ROM200に格納された命令コー
ドデータの中から、供給された実行アドレスデータに対
応した命令コードデータを選択し、選択した命令コード
データを命令解読回路300に供給する。
When the execution address data is supplied from the program counter 100 to the instruction selection circuit 250, the instruction selection circuit 250 selects an instruction code corresponding to the supplied execution address data from the instruction code data stored in the instruction ROM 200. Data is selected, and the selected instruction code data is supplied to the instruction decoding circuit 300.

【0051】命令解読回路300は命令選択回路250
から供給された命令コードデータを解読し、その命令に
対応した制御信号をマイクロプロセッサ各部に供給す
る。
The instruction decoding circuit 300 includes an instruction selection circuit 250
And decodes the instruction code data supplied from the microprocessor and supplies a control signal corresponding to the instruction to each section of the microprocessor.

【0052】レジスタ500はディジタルデータの算術
および論理演算を行う場合に一時的にディジタルデータ
を格納する汎用レジスタ510と演算結果やプロセッサ
の動作状態を示すフラグが集合したPSW520で構成
される。
The register 500 includes a general-purpose register 510 for temporarily storing digital data when performing arithmetic and logical operations on digital data, and a PSW 520 in which flags indicating the operation results and the operating state of the processor are collected.

【0053】RAM600はデータバス900またはロ
ーカルバス950を介してディジタルデータの読み書き
を行うランダムアクセスメモリであり、データ格納領域
610とスタック領域620で構成されており、アドレ
スデコーダ630あるいはスタックポインタ640が選
択した領域に対し、ディジタルデータの書き込みあるい
は読み出しが行われる。
The RAM 600 is a random access memory for reading and writing digital data via the data bus 900 or the local bus 950. The RAM 600 includes a data storage area 610 and a stack area 620, and is selected by the address decoder 630 or the stack pointer 640. Writing or reading of digital data is performed on the area thus set.

【0054】アドレスデコーダ630はアドレスバス1
000から供給されるアドレスデータに応じてRAM6
00のデータ領域610を選択する。
The address decoder 630 is connected to the address bus 1
RAM 6 according to the address data supplied from
00 data area 610 is selected.

【0055】スタックポインタ640はRAM600の
スタック領域620内の1つの格納領域を選択するポイ
ンタレジスタと、このポインタレジスタに格納されたス
タックポインタデータをインクリメントあるいはデクリ
メントさせる加減算器で構成され、命令解読回路300
から供給される制御信号によって、スタックポインタデ
ータがインクリメントあるいはデクリメントされる。
The stack pointer 640 is composed of a pointer register for selecting one storage area in the stack area 620 of the RAM 600, and an adder / subtractor for incrementing or decrementing the stack pointer data stored in this pointer register.
The stack pointer data is incremented or decremented by the control signal supplied from the controller.

【0056】ALU400は汎用レジスタ510を一時
的なデータ格納場所として使用したり、PSW520の
データをもとにして条件判断を行うことで、RAM60
0に格納されたディジタルデータの算術および論理演算
を実行する演算器である。
The ALU 400 uses the general-purpose register 510 as a temporary data storage location, or makes a condition judgment based on the data of the PSW 520, thereby allowing the RAM 60
An arithmetic unit that performs arithmetic and logical operations on digital data stored in 0.

【0057】タイマー700はデータバス900を介し
て時間データが設定され、設定された時間データに対応
する時間が経過すると割込処理制御回路800にタイマ
ーオーバーフロー信号を供給する。割込処理制御回路8
00はタイマー700からタイマーオーバーフロー信号
が供給されるとプログラムカウンタ100、ALU40
0、レジスタ500、RAM600、スタックポインタ
640に割込処理開始信号を供給し、通常処理を強制的
に中断して割込処理を起動する。
Time data is set in the timer 700 via the data bus 900, and when a time corresponding to the set time data elapses, a timer overflow signal is supplied to the interrupt processing control circuit 800. Interrupt processing control circuit 8
When the timer 700 receives a timer overflow signal from the timer 700, the program counter 100 and the ALU 40
0, an interrupt processing start signal is supplied to the register 500, the RAM 600, and the stack pointer 640, and the normal processing is forcibly interrupted to start the interrupt processing.

【0058】以上のような構成要素を持つ一般的なマイ
クロプロセッサで図1に示した本発明のタスクマネージ
ャーを実現した場合の動作について以下に説明する。
The operation when the task manager of the present invention shown in FIG. 1 is realized by a general microprocessor having the above components will be described below.

【0059】図3のマイクロプロセッサがリセットされ
て動作し始めると、まずスタック領域監視部230のプ
ログラム処理が実行され、図1のスタック領域初期化部
231に対応するプログラムの処理が行われる。
When the microprocessor of FIG. 3 is reset and starts operating, first, the program processing of the stack area monitoring unit 230 is executed, and the processing of the program corresponding to the stack area initialization unit 231 of FIG. 1 is performed.

【0060】即ち、プログラムカウンタ100は、命令
ROM200内にマイクロプロセッサの命令コードデー
タ群として格納されているスタック領域初期化部231
に対応したプログラムの先頭アドレスデータを初期デー
タとし、このアドレスデータを出力及びインクリメント
して更新していくことを繰り返して、スタック領域初期
化部231に対応したプログラムの先頭アドレスデータ
から終了アドレスデータまでのアドレスデータを順番に
命令選択回路250に供給する。
That is, the program counter 100 includes a stack area initialization unit 231 stored in the instruction ROM 200 as a group of instruction code data of the microprocessor.
The start address data of the program corresponding to the stack area initialization unit 231 is repeatedly output and incremented and updated by setting the start address data of the program corresponding to the initial data to the end address data. Are sequentially supplied to the instruction selection circuit 250.

【0061】命令選択回路250はプログラムカウンタ
100から順次供給されるアドレスデータに対応したプ
ログラムの命令コードを命令ROM200から読み出し
て命令解読回路300に順次供給し、命令解読回路30
0は供給された命令コードを順番に解読して命令コード
に応じた制御信号、即ちスタック領域初期化部231の
動作に対応した指令信号をマイクロプロセッサ各部に順
次供給する。
The instruction selecting circuit 250 reads from the instruction ROM 200 the instruction code of the program corresponding to the address data sequentially supplied from the program counter 100 and sequentially supplies the instruction code to the instruction decoding circuit 300.
Numeral 0 sequentially decodes the supplied instruction code and sequentially supplies a control signal corresponding to the instruction code, that is, a command signal corresponding to the operation of the stack area initialization unit 231 to each unit of the microprocessor.

【0062】なお、スタック領域初期化部231に対応
するプログラムでは、ALU400からローカルバス9
50を介して、スタック領域初期化データがスタック領
域620に供給され、スタック領域620の全ての領域
に対して順次初期化データの書き込みが行われるように
命令コードが記述されている。
In the program corresponding to the stack area initialization unit 231, the local bus 9 is transmitted from the ALU 400.
The stack area initialization data is supplied to the stack area 620 via 50, and the instruction code is described so that the initialization data is sequentially written to all the areas of the stack area 620.

【0063】このようにして、スタック領域初期化部2
31に対応したプログラムの処理が実行され、スタック
領域620の初期化が終了すると、次にタスク切換部2
20に対応したプログラム処理が実行される。
Thus, the stack area initialization unit 2
When the processing of the program corresponding to S31 is executed and the initialization of the stack area 620 is completed, the task switching unit 2
The program processing corresponding to 20 is executed.

【0064】タスク切換部220に対応したプログラム
処理の実行もスタック領域初期化部231に対応したプ
ログラムの処理の場合と全く同様にして実行される。即
ち、プログラムカウンタ100がタスク切換部220に
対応したプログラムの先頭アドレスから終了アドレスま
でのプログラムアドレスを命令選択回路250に順次出
力し、命令選択回路250が供給されるプログラムアド
レスに対応した命令コードデータを命令ROM200か
ら読み出し、命令解読回路300が命令を解読し、マイ
クロプロセッサ各部に制御信号を順次供給することによ
って行われる。
The execution of the program processing corresponding to the task switching section 220 is executed in exactly the same way as the processing of the program corresponding to the stack area initialization section 231. That is, the program counter 100 sequentially outputs the program addresses from the start address to the end address of the program corresponding to the task switching unit 220 to the instruction selection circuit 250, and the instruction selection circuit 250 supplies instruction code data corresponding to the supplied program address. From the instruction ROM 200, the instruction decoding circuit 300 decodes the instruction, and sequentially supplies a control signal to each section of the microprocessor.

【0065】タスク切換部220に対応したプログラム
処理では、まず実行タスク選択部221に対応する処理
が行われ、最初に起動するタスクAのタスクIDをデー
タ格納領域610の起動タスクID格納領域に格納す
る。
In the program processing corresponding to the task switching unit 220, first, the processing corresponding to the execution task selection unit 221 is performed, and the task ID of the task A to be activated first is stored in the activation task ID storage area of the data storage area 610. I do.

【0066】次にタスク実行部222に対応するプログ
ラム処理が行われる。タスク実行部222に対応するプ
ログラム処理では、データ格納領域610の起動タスク
ID格納領域に格納された起動タスクのIDを読みとる
ことで、起動するタスクがタスクAであると判断する。
これにより、最初に起動するタスクがタスクAであるこ
とがわかるので、タスク実行部222に対応するプログ
ラム処理では引き続き、データバス900を介してタス
クAの実行時間に対応する時間データをタイマー700
に設定し、タスクAのスタック領域を指し示すポインタ
データをスタックポインタ640に設定し、プログラム
カウンタ100にタスクAのプログラムの先頭アドレス
を設定して実行を終了する。
Next, a program process corresponding to the task execution unit 222 is performed. In the program processing corresponding to the task execution unit 222, the task to be activated is determined to be the task A by reading the ID of the activated task stored in the activated task ID storage area of the data storage area 610.
As a result, it is known that the task to be activated first is the task A. Therefore, in the program processing corresponding to the task execution unit 222, the time data corresponding to the execution time of the task A is continuously transmitted via the data bus 900 to the timer 700.
, The pointer data indicating the stack area of the task A is set in the stack pointer 640, the start address of the program of the task A is set in the program counter 100, and the execution ends.

【0067】このように、タスク実行部222に対応す
るプログラム処理によって、最初に起動するタスクであ
るタスクAのプログラムの先頭アドレスがプログラムカ
ウンタ100に設定されることで、タスクAのプログラ
ム処理が起動される。
As described above, the program processing corresponding to the task execution unit 222 sets the start address of the task A program which is the task to be started first in the program counter 100, so that the program processing of the task A is started. Is done.

【0068】以降、タスク切換部220に対応するプロ
グラムが実行された場合と同様にして、タスクAのプロ
グラム処理が順に実行されていく。
Thereafter, the program processing of the task A is sequentially executed in the same manner as when the program corresponding to the task switching section 220 is executed.

【0069】また、タスク実行部222に対応するプロ
グラム処理によって、スタックポインタ640にタスク
Aに割り当てられたスタック領域を指し示すスタックポ
インタデータが設定されるので、タスクAのプログラム
実行中にスタック領域に読み書きされるデータは図1の
タスクAのスタック領域621に対して行われることに
なる。
Further, since the stack pointer data indicating the stack area allocated to the task A is set in the stack pointer 640 by the program processing corresponding to the task execution section 222, reading and writing to the stack area during the execution of the task A program is performed. The data to be performed is performed on the stack area 621 of the task A in FIG.

【0070】タイマー700はタスク実行部222に対
応するプログラム処理よって設定されたタスクAの実行
時間が経過すると、タイマーオーバーフロー信号を割込
処理制御回路800に供給する。割込処理制御回路80
0はタイマーオーバーフロー信号が供給されると割込発
生信号をプログラムカウンタ100、ALU400、レ
ジスタ500、RAM600、スタックポインタ640
に供給し、マイクロプロセッサで実行中のタスクAの処
理を中断させ、割込処理を起動する。
The timer 700 supplies a timer overflow signal to the interrupt processing control circuit 800 when the execution time of the task A set by the program processing corresponding to the task execution section 222 has elapsed. Interrupt processing control circuit 80
0 indicates that when the timer overflow signal is supplied, the interrupt generation signal is transmitted to the program counter 100, the ALU 400, the register 500, the RAM 600, and the stack pointer 640.
To interrupt the processing of the task A being executed by the microprocessor and start the interrupt processing.

【0071】プログラムカウンタ100は割込発生信号
が供給されるとそのときのプログラムカウンタ100に
格納されているプログラムアドレスデータ、即ち実行中
のプログラムであるタスクAの実行プログラムアドレス
をデータバス900に出力し、このデータバスに出力さ
れたプログラムアドレスはALU400を介してスタッ
ク領域620に供給される。スタックポインタ640は
割込発生信号が供給されるとスタックポインタデータを
デクリメントし、RAM600はALU400からロー
カルバス950を介して供給されたプログラムアドレス
データをスタックポインタデータに対応するスタック領
域に格納する。
When the interrupt generation signal is supplied, the program counter 100 outputs to the data bus 900 the program address data stored in the program counter 100 at that time, that is, the execution program address of the task A which is the program being executed. The program address output to the data bus is supplied to the stack area 620 via the ALU 400. The stack pointer 640 decrements the stack pointer data when the interrupt generation signal is supplied, and the RAM 600 stores the program address data supplied from the ALU 400 via the local bus 950 in a stack area corresponding to the stack pointer data.

【0072】また、レジスタ500は割込発生信号が供
給されるとそのときのPSW520に格納されているデ
ータをデータバス900に出力し、このデータバスに出
力されたPSW520のデータはALU400を介して
スタック領域620に供給される。スタックポインタ6
40は先に送られてきたプログラムアドレスデータの格
納が終了すると、スタックポインタデータをさらにデク
リメントし、RAM600はALU400からローカル
バス950を介して供給されるPSW520のデータを
スタックポインタデータに対応するスタック領域に格納
する。
When the interrupt generation signal is supplied, register 500 outputs the data stored in PSW 520 at that time to data bus 900, and the data of PSW 520 output to this data bus is transmitted through ALU 400. The data is supplied to the stack area 620. Stack pointer 6
When the storage of the previously transmitted program address data is completed, the stack pointer data is further decremented, and the RAM 600 stores the data of the PSW 520 supplied from the ALU 400 via the local bus 950 in the stack area corresponding to the stack pointer data. To be stored.

【0073】プログラムカウンタ100は実行中であっ
たタスクAのプログラムアドレスデータをデータバス1
00に出力すると、次の実行プログラムアドレスのデー
タを割込処理プログラムとして実行される図1のタスク
実行中断部223に対応するプログラムが格納されてい
るアドレスデータに変更し、このアドレスデータを命令
選択回路250に供給することによって、以降、実行中
断部223に対応するプログラムが実行される。
The program counter 100 transfers the program address data of the task A being executed to the data bus 1.
00, the data at the next execution program address is changed to the address data storing the program corresponding to the task execution suspending unit 223 in FIG. 1 to be executed as the interrupt processing program, and this address data is selected by the instruction selection. By supplying the program to the circuit 250, the program corresponding to the execution suspending unit 223 is thereafter executed.

【0074】タスク実行中断部223に対応したプログ
ラムは、まず、データ格納領域610の起動タスクID
格納領域に格納された起動タスクのIDを読みとること
で、実行を中断したタスクがタスクAであると判断す
る。
The program corresponding to the task execution suspending unit 223 first starts the activation task ID in the data storage area 610.
By reading the ID of the activation task stored in the storage area, it is determined that the task whose execution has been suspended is the task A.

【0075】次に、タスクAのスタック領域621に格
納されている、タスクAの実行中断時のプログラムアド
レスデータ及びPSW520のデータをデータ格納領域
610内のタスクマネージャーの管理する領域に格納す
る。また、タスクAが実行中断された時点のスタックポ
インタのデータを計算し、同様にデータ格納領域610
内のタスクマネージャーの管理する領域に格納する。こ
のようにして、タスク実行中断部223に対応したプロ
グラムはタスクAが中断された時のプログラムカウンタ
100、PSW520、スタックポインタ640の各デ
ータをデータ格納領域610内のタスクマネージャーの
管理する領域に格納し、次にタスクAの実行を再開する
ときに、中断したところから再び実行を再開できるよう
にする。
Next, the program address data and the PSW 520 data at the time of the interruption of the execution of the task A, which are stored in the stack area 621 of the task A, are stored in the area managed by the task manager in the data storage area 610. Further, the data of the stack pointer at the time when the execution of the task A is interrupted is calculated, and similarly, the data storage area 610 is calculated.
It is stored in the area managed by the task manager in. In this way, the program corresponding to the task execution suspending unit 223 stores the data of the program counter 100, the PSW 520, and the stack pointer 640 when the task A is suspended in the area managed by the task manager in the data storage area 610. Then, when the execution of the task A is resumed next, the execution can be resumed from where it was interrupted.

【0076】タスク実行中断部223に対応したプログ
ラムはタスクAの実行再開に必要なデータの退避が終了
すると、スタック境界監視部232に対応したプログラ
ムの処理を起動するために、スタックポインタ640が
指し示すスタック領域にスタック境界監視部232に対
応したプログラムを実行する場合のPSW520の初期
データを格納し、さらに、スタックポインタ640のデ
ータをインクリメントしてから、このインクリメントし
たスタックポインタ640のデータが指し示すスタック
領域にスタック境界監視部232のプログラム先頭アド
レスデータを格納する。
When the program corresponding to the task execution suspending unit 223 finishes saving the data necessary for resuming the execution of the task A, the stack pointer 640 points to start the processing of the program corresponding to the stack boundary monitoring unit 232. The initial data of the PSW 520 for executing the program corresponding to the stack boundary monitoring unit 232 is stored in the stack area, the data of the stack pointer 640 is incremented, and the stack area indicated by the data of the incremented stack pointer 640 is stored. Of the stack boundary monitoring unit 232 is stored.

【0077】タスク実行中断部223に対応したプログ
ラムはスタック境界監視部232に対応したプログラム
を実行する場合のPSW520の初期データとスタック
境界監視部232に対応したプログラムの先頭アドレス
データをスタック領域620に格納すると、スタックポ
インタ640のデータをデクリメントし、処理を終了す
るために割込処理終了命令を実行する。
The program corresponding to the task execution suspending unit 223 stores the initial data of the PSW 520 when the program corresponding to the stack boundary monitoring unit 232 is executed and the start address data of the program corresponding to the stack boundary monitoring unit 232 in the stack area 620. When stored, the data of the stack pointer 640 is decremented, and an interrupt processing end command is executed to end the processing.

【0078】タスク実行中断部223に対応したプログ
ラムが割込処理終了命令を実行すると、命令解読回路3
00からプログラムカウンタ100、ALU400、レ
ジスタ500、RAM600、スタックポインタ640
に割込処理終了の制御信号が供給され、次のような一連
の動作が行われて割込処理が終了する。
When the program corresponding to the task execution suspending unit 223 executes the interrupt processing end instruction, the instruction decoding circuit 3
00 to program counter 100, ALU 400, register 500, RAM 600, stack pointer 640
Is supplied with a control signal for terminating the interrupt processing, and the following series of operations are performed to terminate the interrupt processing.

【0079】割込処理終了の制御信号が供給されると、
RAM600はスタックポインタ640が指し示すスタ
ック領域に格納されたデータ、即ちスタック境界監視部
232に対応したプログラムを実行する場合のPSW5
20の初期データをデータバス900に出力し、PSW
520はALU400及びローカルバス950を介して
供給されるこのPSW初期データを取り込んで格納す
る。
When the control signal for terminating the interrupt processing is supplied,
The RAM 600 stores the data stored in the stack area pointed to by the stack pointer 640, that is, the PSW5 for executing the program corresponding to the stack boundary monitoring unit 232.
20 is output to the data bus 900, and the PSW
520 fetches and stores the PSW initial data supplied via the ALU 400 and the local bus 950.

【0080】PSW520がPSW初期データを格納終
了すると、スタックポインタ640はスタックポインタ
データをインクリメントし、スタック境界監視部232
に対応したプログラムの先頭アドレスデータが格納され
ているスタック領域を指し示し、RAM600はスタッ
クポインタ640が指し示すスタック領域に格納されて
いるスタック境界監視部232に対応したプログラムの
先頭アドレスデータをデータバス900に供給する。
When the PSW 520 finishes storing the PSW initial data, the stack pointer 640 increments the stack pointer data, and the stack boundary monitor 232
The RAM 600 points to the stack area where the start address data of the program corresponding to the stack boundary monitoring unit 232 stored in the stack area indicated by the stack pointer 640 is stored on the data bus 900. Supply.

【0081】プログラムカウンタ100はデータバスを
介して供給されるスタック境界監視部232に対応した
プログラムの先頭アドレスデータを取り込み、命令選択
回路250に出力する。
The program counter 100 takes in the start address data of the program corresponding to the stack boundary monitor 232 supplied via the data bus, and outputs it to the instruction selection circuit 250.

【0082】このようにして、割込処理として起動し実
行されたタスク実行中断部223に対応したプログラム
が終了し、スタック境界監視部232に対応したプログ
ラムの実行が開始される。
In this way, the program corresponding to the task execution suspending unit 223 started and executed as the interrupt processing ends, and the execution of the program corresponding to the stack boundary monitoring unit 232 starts.

【0083】スタック境界監視部232に対応したプロ
グラムは、タスク実行中断部223に対応したプログラ
ムと同様に、データ格納領域610の起動タスクID格
納領域に格納された起動タスクのIDを読みとること
で、実行を中断したタスクがタスクAであると判断す
る。次に実行を中断されたタスクである、タスクAが使
用していたスタック領域621の最終領域624に書き
込まれているデータをデータバス900を介して汎用レ
ジスタ510に読み出し、ALU400によってこのデ
ータとスタック領域620の初期化データとの比較を行
い、この2つのデータが異なっているかどうかを確認す
る。そして、タスクAのスタック領域内での最終領域6
24に格納されているデータがスタック領域620の初
期化データと異なっている場合には、データ格納領域6
10のスタックオーバーフロータスクID格納領域にこ
のタスク即ちタスクAのタスクIDを格納する。
The program corresponding to the stack boundary monitoring unit 232 reads the ID of the activation task stored in the activation task ID storage area of the data storage area 610 in the same manner as the program corresponding to the task execution suspension unit 223. It is determined that the task whose execution has been suspended is the task A. Next, the data written in the last area 624 of the stack area 621 used by the task A, which is the task whose execution has been interrupted, is read out to the general-purpose register 510 via the data bus 900, and this data and the stack are read by the ALU 400. A comparison is made with the initialization data in the area 620 to check whether the two data are different. Then, the final area 6 in the stack area of task A
24 is different from the initialization data of the stack area 620, the data storage area 6
The task ID of this task, ie, task A, is stored in the stack overflow task ID storage area of No. 10.

【0084】スタック境界監視部232に対応したプロ
グラムは、実行を中断したタスクがスタックオーバーフ
ローを起こしたかどうかの判断を終了すると、実行タス
ク選択部221に対応したプログラムを実行する。
The program corresponding to the stack boundary monitoring unit 232 executes the program corresponding to the execution task selection unit 221 when it has finished determining whether or not the task whose execution has been interrupted has caused a stack overflow.

【0085】以降同じようにして、実行タスク選択部2
21、タスク実行部222に対応したプログラムが実行
されて、タスクB、Cのプログラム処理が起動され、そ
して、タスクB、Cのプログラムの実行中にタスク実行
中断部223に対応するプログラムがタスクB、Cの実
行を中断し、その後スタック境界監視部232に対応し
たプログラムが実行されるという動作が繰り返される。
Thereafter, similarly, the execution task selecting unit 2
21, the program corresponding to the task execution unit 222 is executed, the program processing of the tasks B and C is started, and the program corresponding to the task execution suspension unit 223 is changed to the task B during execution of the programs of the tasks B and C. , C is interrupted, and then the operation of executing the program corresponding to the stack boundary monitoring unit 232 is repeated.

【0086】この繰り返し動作の中で、いずれかのタス
クがスタックオバーフローを起こした場合には、実行タ
スク選択部221に対応したプログラムがタスクを実行
する前にデータ格納領域610のスタックオーバーフロ
ータスクID格納領域を読み出すことよって、スタック
オーバーフローが発生したことを検知し、全てのタスク
の実行を停止する。
If any task causes a stack overflow during this repetitive operation, the program corresponding to the execution task selecting section 221 stores the stack overflow task ID in the data storage area 610 before executing the task. By reading the area, it is detected that a stack overflow has occurred, and execution of all tasks is stopped.

【0087】また、スタックオーバーフローが発生した
ことを検知すると、全てのタスクの実行を停止し、スタ
ックオーバーフローが発生したときに実行する処理(た
とえばマイクロプロセッサで制御するシステムの初期化
処理等)を起動するように実行タスク選択部221に対
応したプログラムを記述しておくことによって、マイク
ロプロセッサで制御される機器が異常な動作を起こすこ
とを防ぐことも可能である。
When it is detected that a stack overflow has occurred, execution of all tasks is stopped, and processing to be executed when a stack overflow occurs (eg, initialization of a system controlled by a microprocessor, etc.) is started. By writing a program corresponding to the execution task selection unit 221 such that the device controlled by the microprocessor does not perform an abnormal operation.

【0088】以上のようにして、スタック領域初期化部
231がタスクの起動前に各タスクの使用するスタック
領域を初期化し、タスクの実行が中断されたときにスタ
ック境界監視部232がこのタスクの使用するスタック
領域の最終部分のデータを読み出し、スタック領域の初
期化データと比較することでスタックのオーバーフロー
が発生したことを検出する。
As described above, the stack area initialization unit 231 initializes the stack area used by each task before the task is activated, and when the execution of the task is interrupted, the stack boundary monitoring unit 232 executes The data of the last part of the stack area to be used is read, and the overflow of the stack is detected by comparing the data with the initialization data of the stack area.

【0089】その結果、特定のタスクによってスタック
オーバーフローが発生してから、このタスク以外のタス
クの実行が行われる前にスタックのオーバーフローを検
出することができるので、スタックオーバーフローによ
るタスクの異常処理やプログラムの暴走を防ぐことが可
能となる。
As a result, a stack overflow can be detected before a task other than this task is executed after a stack overflow occurs due to a specific task. Runaway can be prevented.

【0090】(実施の形態2)図4は、本発明のタスク
マネージャーの一実施の形態を示し、図4において21
0〜212はそれぞれプログラムの実行単位であるタス
クA〜C、220はタスク切換手段であるタスク切換
部、230はスタック領域監視部、620はスタック領
域である。
(Embodiment 2) FIG. 4 shows an embodiment of a task manager according to the present invention.
Reference numerals 0 to 212 denote tasks A to C, which are execution units of the program, 220, a task switching unit as task switching means, 230, a stack area monitoring unit, and 620, a stack area.

【0091】図4で示される本発明のタスクマネージャ
ーは図1のタスクマネージャーに対し、スタック領域監
視部230の構成要素が異なっており、図4のスタック
領域監視部230では、タスクが中断されたときに各タ
スクに割り当てられたスタック領域の先頭領域及び最終
領域のデータを保持する境界データ保持部233と、タ
スクが中断されたときの各タスクのスタック領域の先頭
領域及び最終領域のデータと境界データ保持部233が
保持しているデータとの比較を行うスタック境界監視部
234で構成されている。
The task manager of the present invention shown in FIG. 4 differs from the task manager of FIG. 1 in the components of the stack area monitoring unit 230, and the task is interrupted in the stack area monitoring unit 230 of FIG. A boundary data holding unit 233 for holding the data of the start area and the last area of the stack area allocated to each task, and the boundary between the data of the start area and the last area of the stack area of each task when the task is interrupted. It is composed of a stack boundary monitoring unit 234 that compares the data with the data held by the data holding unit 233.

【0092】また、スタック領域620はタスクA〜C
がそれぞれ実行中にデータを一時的に格納するために使
用するスタック領域621〜623で構成されており、
領域627はタスクAに割り当てられたスタック領域6
21の先頭領域、領域624はタスクAに割り当てられ
たスタック領域621の中の最終領域である。同様に領
域628、領域625はそれぞれタスクBに割り当てら
れたスタック領域622の先頭領域及び最終領域であ
り、領域629、領域626はそれぞれタスクCに割り
当てられたスタック領域623の先頭領域及び最終領域
である。
The stack area 620 contains tasks A to C
Are each composed of stack areas 621 to 623 used for temporarily storing data during execution.
Area 627 is the stack area 6 assigned to task A
The first area 21 and the area 624 are the last area in the stack area 621 allocated to the task A. Similarly, an area 628 and an area 625 are a head area and an end area of the stack area 622 allocated to the task B, respectively, and an area 629 and an area 626 are a head area and an end area of the stack area 623 allocated to the task C, respectively. is there.

【0093】なお、タスク切換部220が本発明のタス
ク切換手段の例であり、スタック領域監視部230が本
発明のスタック領域監視手段の例であり、境界データ保
持部233が本発明の境界データ格納手段の例であり、
スタック境界監視部234が本発明のスタック境界監視
手段の例である。
The task switching section 220 is an example of the task switching section of the present invention, the stack area monitoring section 230 is an example of the stack area monitoring section of the present invention, and the boundary data holding section 233 is the boundary data of the present invention. It is an example of storage means,
The stack boundary monitoring unit 234 is an example of the stack boundary monitoring unit of the present invention.

【0094】以上のように構成されたタスクマネージャ
ーについて、図4及び図5を用いて、以下、その動作を
述べる。
The operation of the task manager configured as described above will be described below with reference to FIGS. 4 and 5.

【0095】図5は図4のタスクマネージャーの処理の
流れを示した図である。図5でタスクnとなっている部
分はタスクA、タスクB、タスクCのいずれかであるこ
とを示している。なお、実行するタスクはタスクA〜C
の3つのタスクであり、タスクA→タスクB→タスクC
→タスクA→タスクB・・・の繰り返しで実行切換が行
われる場合について説明する。また、各タスクがそれぞ
れ使用するスタック領域621〜623は各領域ともデ
ータ格納場所を示すアドレスの大きい方から小さい方に
順次使用されていくものとする。
FIG. 5 is a diagram showing a processing flow of the task manager of FIG. In FIG. 5, the part having the task n indicates that the task is one of the task A, the task B, and the task C. The tasks to be executed are tasks A to C
Task A → task B → task C
A case where execution switching is performed by repetition of → task A → task B... Will be described. Also, the stack areas 621 to 623 used by the tasks are assumed to be used in order from the larger address indicating the data storage location to the smaller address in each area.

【0096】実行タスク選択部221はあらかじめ決め
られた順番にしたがって実行を開始するタスクを決定
し、最初に起動するタスクAのタスクIDをタスク実行
部222に供給する。
The execution task selection unit 221 determines a task to start execution in a predetermined order, and supplies the task execution unit 222 with the task ID of the task A to be started first.

【0097】タスク実行部222は実行タスク選択部2
21から供給されるタスクIDにしたがって、タスクA
の処理を最初から実行する。
The task execution section 222 is an execution task selection section 2
21 according to the task ID supplied from
Is executed from the beginning.

【0098】タスクAの実行が開始されてから、タスク
Aに対してあらかじめ決められた実行割当時間が経過す
ると、タスク実行中断部223が実行中であるタスクA
の処理実行を中断し、中断した時点でのタスクAの状
態、即ちタスクAの処理がどこまで行われたかというこ
とと、タスクAの処理の途中経過の状態を退避し、中断
されたタスクがどのタスクであるかを境界データ保持部
233に供給する。
When a predetermined execution allotted time elapses for the task A after the execution of the task A is started, the task A
Of the task A at the time of the interruption, that is, how much the processing of the task A has been performed, and the state of the progress of the processing of the task A are saved. Whether the task is a task is supplied to the boundary data holding unit 233.

【0099】境界データ保持部233はタスク実行中断
部223から中断したタスクがタスクAであるという情
報を受け取るとタスクAのスタック領域621の中の先
頭領域627及び最終領域624に格納されているデー
タをタスクAの境界データとして保存する。
Upon receiving information from the task execution suspending unit 223 that the suspended task is the task A, the boundary data holding unit 233 stores the data stored in the head area 627 and the last area 624 in the stack area 621 of the task A. Is stored as the boundary data of task A.

【0100】境界データ保持部233によるタスクAの
スタック領域境界データの保存動作が終了すると、実行
タスク選択部221はあらかじめ決められた順番にした
がって実行を開始するタスクを決定し、2番目に起動す
るタスクBのタスクIDをタスク実行部222に供給す
る。
When the operation of storing the stack area boundary data of the task A by the boundary data holding unit 233 is completed, the execution task selection unit 221 determines a task to be executed according to a predetermined order, and starts the task second. The task ID of the task B is supplied to the task execution unit 222.

【0101】以下、図5の処理ブロック40の部分に示
されるように、タスクAの実行開始、実行中断の場合と
同様にして、タスクB及びタスクCの実行開始、実行中
断が行われる。
Thereafter, as indicated by the processing block 40 in FIG. 5, the execution of the task B and the execution of the task C are interrupted and the execution of the task C is interrupted in the same manner as the execution of the task A and the interruption of the execution.

【0102】タスクA〜Cの全てのタスクの起動が終了
し、最後に起動したタスクCがタスク実行中断部223
によって実行を中断され、境界データ保持部233によ
るタスクCのスタック領域境界データの保存動作が終了
すると、実行タスク選択部221は図5の処理ブランチ
50に示すように、すべてのタスクを起動したかどうか
を確認し、すべてのタスクの起動が完了しているので、
以降は実行を中断された各タスクの中から、実行を再開
するタスクを順次選択し実行していく。
The activation of all of the tasks A to C is completed, and the task C that has been activated last becomes the task execution suspending unit 223.
When the execution is interrupted and the operation of storing the stack area boundary data of the task C by the boundary data holding unit 233 ends, the execution task selection unit 221 determines whether all the tasks have been started as shown in the processing branch 50 of FIG. Check that all tasks have been started,
Thereafter, the task whose execution is to be resumed is sequentially selected and executed from among the tasks whose execution has been interrupted.

【0103】実行タスク選択部221は、あらかじめ決
められた順番にしたがって、最初に実行を再開するタス
クであるタスクAのタスクIDをタスク実行部222に
供給する。
The execution task selection section 221 supplies the task execution section 222 with the task ID of the task A, which is the task whose execution is to be resumed first, in a predetermined order.

【0104】タスク実行部222は実行タスク選択部2
21から供給されるタスクIDにしたがって、タスクA
の処理を実行中断された部分から実行する。即ち、タス
ク実行中断部223が格納した実行中断時点でのタスク
Aの状態を復帰し、タスクAの処理を実行中断された部
分から実行する。
The task execution section 222 is an execution task selection section 2
21 according to the task ID supplied from
Is executed from the part where the execution was interrupted. That is, the state of the task A at the time of the execution interruption stored by the task execution interruption unit 223 is restored, and the processing of the task A is executed from the part where the execution was interrupted.

【0105】タスクAの実行が再開されてから、タスク
Aに対してあらかじめ決められた実行割当時間が経過す
ると、タスク実行中断部223が実行中であるタスクA
の処理実行を中断し、中断した時点でのタスクAの状
態、即ちタスクAの処理がどこまで行われたかというこ
とと、タスクAの処理の途中経過の状態を退避し、中断
されたタスクがどのタスクであるかをスタック境界デー
タ保持部233と境界監視部234に供給する。
After the execution of the task A is resumed, when the predetermined execution allotted time has elapsed for the task A, the task A
Of the task A at the time of the interruption, that is, how much the processing of the task A has been performed, and the state of the progress of the processing of the task A are saved. Whether the task is a task is supplied to the stack boundary data holding unit 233 and the boundary monitoring unit 234.

【0106】境界データ保持部233はタスク実行中断
部223から中断したタスクがタスクAであるという情
報を受け取ると、タスクAのスタック領域621の中の
先頭領域627に格納されているデータのみを読み出
し、すでにタスクAの境界データとして保存してあるタ
スクAの過去の先頭領域のデータと置き換える。
Upon receiving information from the task execution suspending unit 223 that the suspended task is the task A, the boundary data holding unit 233 reads out only the data stored in the head area 627 in the stack area 621 of the task A. Is replaced with the data of the past head area of the task A which is already stored as the boundary data of the task A.

【0107】スタック境界監視部234はタスク実行中
断部223から中断したタスクがタスクAであるという
情報を受け取ると、タスクAのスタック領域621の最
終領域624に格納されているデータを読み出し、この
データが境界データ保持部233によってタスクAのス
タック境界データとして保存されている過去の最終領域
のデータと異なっているかどうかを確認する。
When the stack boundary monitoring unit 234 receives the information that the interrupted task is the task A from the task execution interrupting unit 223, the stack boundary monitoring unit 234 reads the data stored in the last area 624 of the stack area 621 of the task A, and Is different from the data of the past final area stored as the stack boundary data of the task A by the boundary data holding unit 233.

【0108】以降、図5の処理ブロック60の部分に示
すように、実行タスク選択部221が実行タスクを決定
し、タスク実行部222が実行を再開するタスクの状態
の復帰とこのタスクの実行再開を行い、タスク実行中断
部223が実行中のタスクの中断と、中断した時点での
タスクの状態の退避を行い、境界データ保持部233が
中断したタスクのスタック領域の先頭領域を読み出して
境界データの更新を行い、スタック境界監視部234が
実行を中断したタスクのスタック領域の監視動作を行う
という一連の動作が続けられる。これにより、タスクA
→タスクB→タスクC→タスクA→タスクB・・・の繰
り返しで順次タスクの実行切換が行われる。
Thereafter, as shown by the processing block 60 in FIG. 5, the execution task selection unit 221 determines the execution task, and the task execution unit 222 returns the state of the task to be resumed, and resumes the execution of this task. The task execution suspending unit 223 suspends the task being executed and saves the state of the task at the time of suspension, and the boundary data holding unit 233 reads the head area of the stack area of the interrupted task to read the boundary data. Is updated, and the stack boundary monitoring unit 234 continues the operation of monitoring the stack area of the task whose execution has been interrupted. Thereby, task A
The execution of the tasks is sequentially switched by repetition of → task B → task C → task A → task B.

【0109】以上のようにして、タスクマネージャーに
よってタスクの実行が順次切り換えられながら、各タス
クの実行が行われている時に、特定のタスクたとえばタ
スクBが領域625及び領域627にデータを書き込ん
だ場合の動作について説明する。
As described above, when the execution of each task is performed while the execution of the tasks is sequentially switched by the task manager, a specific task, for example, task B writes data in the areas 625 and 627. Will be described.

【0110】タスクBはデータの一時的な格納領域とし
て、あらかじめ割り当てられたタスクBのスタック領域
622に対して、領域内のアドレスの大きい部分から小
さい部分(先頭領域628から最終領域625の方向)
に向かってデータの書き込みを行っていくが、たくさん
のデータを書き込んでいくと最後にはタスクBのスタッ
ク領域622の領域内の最終領域625にデータを書き
込み、さらにデータの書き込みを続けると、タスクAの
スタック領域621の先頭領域627にデータを書き込
むことになる。
The task B serves as a temporary data storage area with respect to the stack area 622 of the task B allocated in advance, from a part having a large address to a part having a small address in the area (from the head area 628 to the last area 625).
, Data is written to the last area 625 in the area of the stack area 622 of the task B when a lot of data is written, and when the data is further written, the task B is written. The data is written to the head area 627 of the stack area 621 of A.

【0111】タスクBがタスクAのスタック領域の先頭
領域627にデータを書き込むと、タスクAが実行再開
し、この部分に一時的に格納したデータを読み出そうと
した場合に、タスクBによってデータが書き換えられて
いるために、正しいデータが得られず、間違った処理を
実行したり、最悪の場合にはタスクAが異常処理を行っ
てしまう。
When the task B writes data to the head area 627 of the task A stack area, the task A resumes execution. If the task B attempts to read the data temporarily stored in this area, the task B Is rewritten, correct data cannot be obtained, and wrong processing is executed. In the worst case, task A performs abnormal processing.

【0112】また、タスクBがタスクAのスタック領域
の先頭領域627にはデータを書き込んではいないが、
タスクBのスタック領域の最終領域625にまでデータ
を書き込んだ場合には、タスクAの動作に影響は及ぼさ
ないが、この状態からタスクBがさらにスタック領域に
データを書き込むと、タスクAのスタック領域の先頭領
域627にデータを書き込むことになるので、危険な状
態である。
Although task B has not written data in the head area 627 of the stack area of task A,
When data is written to the last area 625 of the stack area of the task B, the operation of the task A is not affected. However, if the task B further writes data to the stack area from this state, the stack area of the task A This is dangerous because the data is written in the head area 627 of.

【0113】このような場合には、図5の処理ブランチ
61及び処理ブロック62に示すように、スタック境界
監視部234が領域627に格納されているデータを読
み出し、このデータが境界データ保持部233によって
タスクAのスタック境界データとして保存されているタ
スクAの実行中断時のスタック先頭領域データと比較
し、両者が異なっている場合にはタスクBの実行によっ
てタスクAのスタック領域621のデータが書き換えら
れているので、タスクAとタスクBのタスクIDを実行
停止タスクとして登録する。
In such a case, as shown by the processing branch 61 and the processing block 62 in FIG. 5, the stack boundary monitoring unit 234 reads out the data stored in the area 627, and this data is stored in the boundary data holding unit 233. Is compared with the stack top area data at the time of the interruption of the execution of the task A, which is stored as the stack boundary data of the task A. If the two are different, the data of the stack area 621 of the task A is rewritten by the execution of the task B. Therefore, the task IDs of task A and task B are registered as execution suspension tasks.

【0114】また、両者が異なっていない場合にはさら
に領域625に格納されているデータを読み出し、この
データが境界データ保持部233によってタスクBのス
タック境界データとして保存されているタスクBの実行
中断時のスタック最終領域データと比較し、この2つの
データが異なっている場合にはタスクBのタスクIDを
割り当てられたスタック領域全てを使ったタスクとして
登録する。
If the two are not different, the data stored in the area 625 is further read out, and this data is suspended by the boundary data holding unit 233 as the task B stack boundary data. When the two data are different from each other, the task ID of task B is registered as a task using all the allocated stack areas.

【0115】そして、タスクA及びタスクBが実行停止
タスクとして登録されると、実行タスク選択部221は
実行するタスクを選択するときに、これらの実行停止タ
スクとして登録されたタスク以外のタスクを実行するよ
うに動作するため、タスクAとタスクBは以降実行され
なくなる。
When the task A and the task B are registered as the execution suspension tasks, the execution task selection unit 221 executes the tasks other than the tasks registered as the execution suspension tasks when selecting the task to be executed. The task A and the task B are not executed thereafter.

【0116】以上のようにして、タスクが実行を中断さ
れたときに、スタック境界監視部234が中断されたタ
スクに割り当てられたスタックの最終領域のデータ及び
この最終データに隣接した他のタスクのスタックの先頭
領域のデータを読み出し、境界データ保持部233が1
回前にこのタスクが中断された時に保存したこのタスク
のスタックの最終領域のデータ及び隣接する他のタスク
のスタックの先頭領域のデータとそれぞれ比較すること
でスタックのオーバーフローが発生したことやスタック
のオーバーフローが発生する危険性があることを検出す
る。
As described above, when the execution of a task is interrupted, the stack boundary monitoring unit 234 outputs the data of the last area of the stack allocated to the interrupted task and the data of another task adjacent to this final data. The data in the top area of the stack is read, and the boundary data holding unit 233 reads 1
Compared with the data of the last area of the stack of this task and the data of the top area of the stack of the adjacent task saved when the task was interrupted the last time, the occurrence of stack overflow or the stack Detects the risk of overflow.

【0117】その結果、特定のタスクによってスタック
オーバーフローが発生してから、このタスク以外のタス
クの実行が行われる前にスタックのオーバーフローを検
出することができ、また、スタックオーバーフローが発
生する直前の状態も検出することができるので、スタッ
クオーバーフローによるタスクの異常処理やプログラム
の暴走を防ぐことが可能となる。
As a result, a stack overflow can be detected before a task other than this task is executed after a stack overflow has occurred by a specific task, and the state immediately before the stack overflow occurs can be detected. Therefore, it is possible to prevent abnormal processing of a task due to a stack overflow and runaway of a program.

【0118】なお、以上の説明では順次切り換えて実行
するタスクが3つの場合について説明したが、2以上の
いくつの場合でも同じようにして実現可能であり、得ら
れる効果も同等である。
In the above description, a case has been described in which three tasks are sequentially switched and executed. However, any number of two or more tasks can be realized in the same manner, and the obtained effects are equivalent.

【0119】また、以上の説明では各タスクがそれぞれ
使用するスタック領域は、各領域ともデータ格納場所を
示すアドレスの大きい方から小さい方に順次使用されと
したが、これとは逆に、各領域ともデータ格納場所を示
すアドレスの小さい方から大きい方に順次使用されると
した場合についても同様にして、スタックのオーバーフ
ローを検出する事が可能であり、同様の効果が得られ
る。
In the above description, the stack area used by each task is sequentially used from the largest address indicating the data storage location to the smaller address indicating the data storage location. In both cases, the stack overflow can be detected in the same manner when the addresses indicating the data storage locations are sequentially used from the smaller address to the larger address, and the same effect can be obtained.

【0120】また、本発明のスタック領域の境界線から
所定の範囲は、上述した実施の形態におけるように、ス
タック境界監視部が各タスクの使用するスタック領域の
最後の部分、即ちスタック領域の境界部分のデータを読
み出してスタックのオーバーフローの検出を行っている
が、これに限らず、オーバーフロー検出のために読み出
すデータ領域の大きさを大きくすることによって、より
確実にオーバーフローの検出を行うことが可能となるな
ど、要するにスタックオーバーフローを確実に検出でき
る範囲でありさえすればよい。
The predetermined range from the boundary of the stack area according to the present invention is, as in the above-mentioned embodiment, the last part of the stack area used by each task by the stack boundary monitor, that is, the boundary of the stack area. The overflow of the stack is detected by reading out part of the data, but this is not a limitation. By increasing the size of the data area to be read for overflow detection, overflow detection can be performed more reliably. In other words, it is only necessary to set the range so that the stack overflow can be reliably detected.

【0121】また、実施の形態2において、図5の40
のように初回のタスクを起動する際には、実施の形態1
のようにスタックオーバーフローの検出を行っていない
が、実際上問題になることはほとんどない。つまり、ス
タックオーバーフローが発生するのは、何回もタスクの
起動を繰り返し、スタック領域にデータが蓄積してきて
からのことが多いからである。しかし、あらかじめスタ
ック領域を初期化しておいて初回のタスクを起動した際
には、実施の形態1のようにスタックオーバーフローを
検出し、2回目のタスク起動以降は実施の形態2のよう
にしてスタックオーバーフローを検出することも可能で
ある。
In the second embodiment, reference numeral 40 in FIG.
When starting the first task as in the first embodiment,
Does not detect stack overflow like this, but it hardly causes a problem in practice. In other words, the reason why the stack overflow occurs is that the task is frequently started many times and data is accumulated in the stack area in many cases. However, when the first task is started after the stack area is initialized in advance, a stack overflow is detected as in the first embodiment, and the stack is started as in the second embodiment after the second task is started. It is also possible to detect overflow.

【0122】また、本発明は、その機能を実現する各手
段の全部または一部の機能を実現するためのプログラム
を格納していることを特徴とするプログラム記録媒体で
もある。
Further, the present invention is also a program recording medium characterized by storing a program for realizing all or a part of each means for realizing the function.

【0123】[0123]

【発明の効果】以上説明したところから明らかなよう
に、本発明は、特定のタスクによってスタックオーバー
フローが発生してから、このタスク以外のタスクの実行
が行われる前にスタックのオーバーフローを検出するこ
とができるので、スタックオーバーフローによるタスク
の異常処理やプログラムの暴走を防ぐタスクマネージャ
ー及びプログラム記録媒体を提供することができる。
As is apparent from the above description, the present invention detects a stack overflow after a specific task causes a stack overflow and before execution of a task other than this task is performed. Therefore, it is possible to provide a task manager and a program recording medium that prevent abnormal processing of a task or runaway of a program due to stack overflow.

【0124】また、本発明は、特定のタスクによってス
タックオーバーフローが発生してから、このタスク以外
のタスクの実行が行われる前にスタックのオーバーフロ
ーを検出することができ、さらに、スタックオーバーフ
ローが発生する直前の状態も検出することができるの
で、スタックオーバーフローになる直前にタスクの異常
処理やプログラムの暴走を防ぐタスクマネージャー及び
プログラム記録媒体を提供することができる。
Further, according to the present invention, a stack overflow can be detected before a task other than this task is executed after a specific task causes a stack overflow, and furthermore, a stack overflow occurs. Since the immediately preceding state can also be detected, it is possible to provide a task manager and a program recording medium which prevent abnormal processing of a task or runaway of a program immediately before a stack overflow occurs.

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

【図1】本発明の実施の形態1によるタスクマネージャ
ーの構成を示すブロック図。
FIG. 1 is a block diagram showing a configuration of a task manager according to a first embodiment of the present invention.

【図2】本発明の実施の形態1によるタスクマネージャ
ーの動作の流れを示す図。
FIG. 2 is a diagram showing an operation flow of a task manager according to the first embodiment of the present invention.

【図3】本発明の実施の形態1によるタスクマネージャ
ーを一般的なマイクロプロセッサで実現した場合の構成
を示すブロック図。
FIG. 3 is a block diagram showing a configuration when the task manager according to the first embodiment of the present invention is realized by a general microprocessor;

【図4】本発明の実施の形態2によるタスクマネージャ
ーの構成を示すブロック図。
FIG. 4 is a block diagram showing a configuration of a task manager according to a second embodiment of the present invention.

【図5】本発明の実施の形態2によるタスクマネージャ
ーの動作の流れを示す図。
FIG. 5 is a diagram showing a flow of operation of a task manager according to the second embodiment of the present invention.

【図6】従来のタスクマネージャーの構成を示すブロッ
ク図。
FIG. 6 is a block diagram showing a configuration of a conventional task manager.

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

1 実行タスク選択部 2 タスク実行部 3 タスク実行中断部 4〜6 タスクA〜C 7〜9 スタック領域 100 プログラムカウンタ 200 命令ROM 210〜212 タスクA〜C 220 タスク切換部 221 実行タスク選択部 222 タスク実行部 223 タスク実行中断部 230 スタック領域監視部 231 スタック領域初期化部 232 スタック境界監視部 250 命令選択回路 300 命令解読回路 400 ALU 500 レジスタ 510 汎用レジスタ 520 PSW 600 RAM 610 データ格納領域 620 スタック領域 630 アドレスデコーダ 640 スタックポインタ 700 タイマー 800 割込処理制御回路 900 データバス 950 ローカルバス 1000 アドレスバス DESCRIPTION OF SYMBOLS 1 Execution task selection part 2 Task execution part 3 Task execution suspension part 4-6 Tasks A-C 7-9 Stack area 100 Program counter 200 Instruction ROM 210-212 Tasks A-C 220 Task switching part 221 Execution task selection part 222 Task Execution unit 223 Task execution suspension unit 230 Stack area monitoring unit 231 Stack area initialization unit 232 Stack boundary monitoring unit 250 Instruction selection circuit 300 Instruction decoding circuit 400 ALU 500 Register 510 General-purpose register 520 PSW 600 RAM 610 Data storage area 620 Stack area 630 Address decoder 640 stack pointer 700 timer 800 interrupt processing control circuit 900 data bus 950 local bus 1000 address bus

───────────────────────────────────────────────────── フロントページの続き (72)発明者 中原 充也 大阪府門真市大字門真1006番地 松下電器 産業株式会社内 Fターム(参考) 5B098 GA04 GA08 GC01 JJ01 JJ08 ──────────────────────────────────────────────────続 き Continued on the front page (72) Mitsuya Nakahara 1006 Kazuma Kadoma, Kadoma, Osaka Prefecture Matsushita Electric Industrial Co., Ltd. F-term (reference) 5B098 GA04 GA08 GC08 JJ01 JJ08

Claims (8)

【特許請求の範囲】[Claims] 【請求項1】 プログラム処理の実行単位であるタスク
が複数存在し、それらのタスクを処理するタスクマネー
ジャーにおいて、 前記タスクの実行を順次切り替えるタスク切換手段と、 前記タスクが予め割り当てられたスタック領域以外の領
域にデータの書き込みを行ったことを検出するスタック
領域監視手段と、を備えたことを特徴とするタスクマネ
ージャー。
1. A task manager for processing a plurality of tasks, which is a unit of execution of a program processing, wherein: a task switching unit for sequentially switching the execution of the tasks; and a stack area to which the tasks are allocated in advance. A stack area monitoring means for detecting that data has been written to the area.
【請求項2】 前記スタック領域監視手段は、前記タス
クを起動する前に前記スタック領域の初期化を行うスタ
ック領域初期化手段と、それぞれの前記タスクに割り当
てられたそれぞれの前記スタック領域の境界線から所定
の範囲のデータが前記スタック領域初期化手段によって
初期化された時点のデータとは異なっていることを検出
した際前記タスクが予め割り当てられた前記スタック領
域以外の領域にデータの書き込みを行ったものと判断す
るスタック境界監視手段とで構成されたことを特徴とす
る請求項1記載のタスクマネージャー。
2. The stack area monitoring means according to claim 1, wherein said stack area monitoring means initializes said stack area before activating said task, and a boundary line of each of said stack areas assigned to each of said tasks. When detecting that the data in a predetermined range is different from the data at the time when the data is initialized by the stack area initializing means, the task writes data to an area other than the previously allocated stack area. 2. The task manager according to claim 1, further comprising stack boundary monitoring means for judging that the task has occurred.
【請求項3】 前記スタック領域監視手段は、前記タス
クを所定の時間実行した後で実行を中断された際前記タ
スクに割り当てられた前記スタック領域の境界線から所
定の範囲のデータを格納するスタック境界データ格納手
段と、前記スタック境界データ格納手段によって格納さ
れた過去のデータと現時点でのスタック領域の境界線か
ら所定の範囲の互いに対応するデータとの比較を行い、
異なっていることを検出すると前記タスクが予め割り当
てられたスタック領域以外の領域にデータの書き込みを
行ったものと判断するスタック境界監視手段とで構成さ
れたことを特徴とする請求項1記載のタスクマネージャ
ー。
3. The stack area monitoring means stores data in a predetermined range from a boundary of the stack area allocated to the task when execution of the task is interrupted after execution of the task for a predetermined time. Boundary data storage means, comparing the past data stored by the stack boundary data storage means and corresponding data in a predetermined range from the boundary line of the current stack area,
2. The task according to claim 1, further comprising stack boundary monitoring means for judging that the task has written data to an area other than a pre-allocated stack area when the task is different. manager.
【請求項4】 前記タスク切換手段は、特定のタスクが
予め割り当てられた前記スタック領域以外の領域にデー
タの書き込みを行ったことを前記スタック領域監視手段
が検出すると、このタスクの実行を停止することを特徴
とする請求項1記載のタスクマネージャー。
4. The task switching means, when the stack area monitoring means detects that a specific task has written data to an area other than the pre-allocated stack area, suspends execution of the task. The task manager according to claim 1, wherein:
【請求項5】 前記タスク切換手段は、予め割り当てら
れたスタック領域以外の領域にデータの書き込みを行っ
たことを前記スタック領域監視手段が検出すると、予め
割り当てられた前記スタック領域以外の領域にデータの
書き込みを行ったタスクと、このタスクによって予め割
り当てられた前記スタック領域を書き換えられた全ての
タスクの実行を停止することを特徴とする請求項1記載
のタスクマネージャー。
5. When the stack area monitoring means detects that data has been written to an area other than the pre-allocated stack area, the task switching means stores the data in the area other than the pre-allocated stack area. 2. The task manager according to claim 1, wherein execution of the task in which the writing has been performed and all tasks in which the stack area allocated in advance by the task has been rewritten is stopped.
【請求項6】 前記タスク切換手段は、予め割り当てら
れた前記スタック領域以外の領域にデータの書き込みを
行ったことを前記スタック領域監視手段が検出すると、
全てのタスクの実行を停止することを特徴とする請求項
1記載のタスクマネージャー。
6. The task switching means, when the stack area monitoring means detects that data has been written to an area other than the previously allocated stack area,
The task manager according to claim 1, wherein execution of all tasks is stopped.
【請求項7】 前記タスク切換手段は、予め割り当てら
れたスタック領域以外の領域にデータの書き込みを行っ
たことを前記スタック領域監視手段が検出すると、全て
のタスクの実行を停止するとともに、予め指定されたタ
スクを実行することを特徴とする請求項1記載のタスク
マネージャー。
7. The task switching means, when the stack area monitoring means detects that data has been written to an area other than a pre-allocated stack area, suspends execution of all tasks and designates a task designated in advance. The task manager according to claim 1, wherein the task manager executes the performed task.
【請求項8】 請求項1〜7のいずれかに記載の各手段
の全部または一部の機能を実現するためのプログラムを
格納していることを特徴とするプログラム記録媒体。
8. A program recording medium storing a program for realizing all or a part of the functions of each means according to claim 1. Description:
JP10241933A 1998-08-27 1998-08-27 Task manager and program recording medium Pending JP2000076081A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP10241933A JP2000076081A (en) 1998-08-27 1998-08-27 Task manager and program recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP10241933A JP2000076081A (en) 1998-08-27 1998-08-27 Task manager and program recording medium

Publications (1)

Publication Number Publication Date
JP2000076081A true JP2000076081A (en) 2000-03-14

Family

ID=17081737

Family Applications (1)

Application Number Title Priority Date Filing Date
JP10241933A Pending JP2000076081A (en) 1998-08-27 1998-08-27 Task manager and program recording medium

Country Status (1)

Country Link
JP (1) JP2000076081A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002132528A (en) * 2000-10-26 2002-05-10 Nec Corp Microcomputer and initializing method of free memory area/stack release area
WO2005092766A1 (en) * 2004-03-26 2005-10-06 Mitsubishi Denki Kabushiki Kaisha Elevator control device
KR100804917B1 (en) * 2005-11-01 2008-02-20 미쓰비시덴키 가부시키가이샤 Elevator control device
JP2009301259A (en) * 2008-06-12 2009-12-24 Fujitsu Microelectronics Ltd Information processing system, method for detecting occurrence of stack overflow, and program
US7729806B2 (en) 2004-05-25 2010-06-01 Mitsubishi Denki Kabushiki Kaisha Elevator controller
JP2013003984A (en) * 2011-06-20 2013-01-07 Fuji Xerox Co Ltd Information processing apparatus, image forming apparatus, and program

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002132528A (en) * 2000-10-26 2002-05-10 Nec Corp Microcomputer and initializing method of free memory area/stack release area
WO2005092766A1 (en) * 2004-03-26 2005-10-06 Mitsubishi Denki Kabushiki Kaisha Elevator control device
JPWO2005092766A1 (en) * 2004-03-26 2007-08-30 三菱電機株式会社 Elevator control device
US7556127B2 (en) 2004-03-26 2009-07-07 Mitsubishi Denki Kabushiki Kaisha Elevator control device
JP5079326B2 (en) * 2004-03-26 2012-11-21 三菱電機株式会社 Elevator control device
US7729806B2 (en) 2004-05-25 2010-06-01 Mitsubishi Denki Kabushiki Kaisha Elevator controller
KR100804917B1 (en) * 2005-11-01 2008-02-20 미쓰비시덴키 가부시키가이샤 Elevator control device
JP2009301259A (en) * 2008-06-12 2009-12-24 Fujitsu Microelectronics Ltd Information processing system, method for detecting occurrence of stack overflow, and program
JP2013003984A (en) * 2011-06-20 2013-01-07 Fuji Xerox Co Ltd Information processing apparatus, image forming apparatus, and program

Similar Documents

Publication Publication Date Title
US9727343B2 (en) Apparatus and method for handling exception events
JP3970609B2 (en) Processor system
JP2000076081A (en) Task manager and program recording medium
JP6427575B2 (en) Handling of time-consuming instructions
JP2965075B2 (en) Program execution status monitoring method
JPH09198258A (en) Task stack overflow detecting circuit
JPH0668725B2 (en) Device for responding to interrupt condition in data processing system and method for responding to asynchronous interrupt condition
JPH064417A (en) Battery backup control system for memory
JP4647276B2 (en) Semiconductor circuit device
US20080126753A1 (en) Embedded system and operating method thereof
US5778207A (en) Assisting operating-system interrupts using application-based processing
JPH0836553A (en) Multiprocessor system and task scheduling method therein
WO1990007739A1 (en) Control method for robot
JP4387863B2 (en) Disturbance occurrence detection program and disturbance occurrence detection method
CA1223079A (en) Data processor having selective breakpoint capability with minimal overhead
JP2880658B2 (en) Runaway detection device for multitask program
JPH033041A (en) Time-out monitoring circuit
JPH07287660A (en) Interruption processing method for programmable controller
JPH04256027A (en) Microcomputer
JPH01147640A (en) Multi-programming debug device
JPH07210421A (en) Debugging method in thread environment
JP2003242129A (en) Processor adding and reducing method and computer system
JPS58142451A (en) Interruption control system
JPS5814256A (en) Microprogram diagnosis system
JPH02310634A (en) System for supervising runaway of program

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20050613

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20050705

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20051101