JPH0991154A - Stack allocating method and control equipment - Google Patents

Stack allocating method and control equipment

Info

Publication number
JPH0991154A
JPH0991154A JP24613895A JP24613895A JPH0991154A JP H0991154 A JPH0991154 A JP H0991154A JP 24613895 A JP24613895 A JP 24613895A JP 24613895 A JP24613895 A JP 24613895A JP H0991154 A JPH0991154 A JP H0991154A
Authority
JP
Japan
Prior art keywords
task
stack
priority
tasks
flag
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
JP24613895A
Other languages
Japanese (ja)
Inventor
Hiroshi Ogura
弘 小倉
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.)
Hitachi Construction Machinery Co Ltd
Original Assignee
Hitachi Construction Machinery 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 Hitachi Construction Machinery Co Ltd filed Critical Hitachi Construction Machinery Co Ltd
Priority to JP24613895A priority Critical patent/JPH0991154A/en
Publication of JPH0991154A publication Critical patent/JPH0991154A/en
Pending legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To always preferentially starts a high-order task without the exclusive control of a stack by providing one stack for every priority of the task and sharing one stack between the tasks having the equal priority. SOLUTION: A task managing table 10 is provided for each task and has a flag 104 for distinguishing whether the task is a newly activated task or an interrupted task in addition to priority 101 for tasks, start address showing the execution program head of the task and stack pointer 103 instructing the final part of the stack allocated to the task as contents. In this case, one stack is allocated for every priority of the task and one stack is shared between the tasks having the equal priority. An executing task selection program 12 investigates queues Q6 and Q7 provided for every priority so that the tasks can be extracted and executed successively from the task which has the highest priority and early activated.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【発明の属する技術分野】本発明は、マルチタスクオペ
レーティングシステムで用いるスタック割り当て方法と
その方法を用いた制御装置に係り、特にRAMの容量が
少ないシングルチップマイコン用のマルチタスクオペレ
ーティングシステムに好適なスタック割り当て方法とそ
の方法を用いた制御装置に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a stack allocation method used in a multitasking operating system and a control device using the method, and particularly to a stack suitable for a multitasking operating system for a single-chip microcomputer having a small RAM capacity. The present invention relates to an allocation method and a control device using the method.

【0002】[0002]

【従来の技術】図2は、シングルチップマイコンを用い
た制御システムの例を示すもので、油圧ショベルの制御
系の説明図である。油圧ショベル100内に設置された
シングルチップマイコン200は、油圧ショベルに取り
付けられているシリンダの圧力センサ、斜板ポンプの傾
転角センサや操作パネルのスイッチの情報を入力とし、
油圧制御系や機械制御系の制御のための目標値を演算
し、その結果をポンプやエンジンに出力する。これらの
処理はソフトウェアによって行われるが、このソフトウ
ェアを実行させるためにマルチタスクオペレーティング
システム(以下マルチタスクOSと記す)が使用され
る。
2. Description of the Related Art FIG. 2 shows an example of a control system using a single-chip microcomputer and is an explanatory view of a control system of a hydraulic excavator. The single-chip microcomputer 200 installed in the hydraulic excavator 100 receives as input the pressure sensor of the cylinder attached to the hydraulic excavator, the tilt angle sensor of the swash plate pump, and the switch of the operation panel,
A target value for controlling the hydraulic control system or the machine control system is calculated, and the result is output to the pump or engine. These processes are performed by software, and a multitasking operating system (hereinafter referred to as a multitasking OS) is used to execute this software.

【0003】このマルチタスクOSのタスクは図3のよ
うに構成される。即ち、最上位優先度P1のタスクT1
1はエラー処理タスクであり、各種センサの誤動作ある
いは故障時に適切な値をバックアップするための処理を
行う。例えばブームシリンダの圧力センサに異常があ
り、正しい値が入力できなくなった場合は、入力値を0
〜5Vセンサであれば、ブームシリンダを安定的に操作
するために必要な値、例えば中間値である2.5Vに固
定して、以後の演算を続行させる。このタスクは緊急性
を要するタスクであることから、最上位優先度としてい
る。
The tasks of this multitasking OS are configured as shown in FIG. That is, the task T1 with the highest priority P1
Reference numeral 1 denotes an error processing task, which performs processing for backing up an appropriate value when the various sensors malfunction or fail. For example, if there is an abnormality in the pressure sensor of the boom cylinder and the correct value cannot be input, set the input value to 0.
If it is a ~ 5V sensor, it is fixed to a value required for stable operation of the boom cylinder, for example, 2.5V which is an intermediate value, and the subsequent calculations are continued. Since this task is an urgent task, it has the highest priority.

【0004】中位優先度P2のタスクは、各種センサか
らデータを入力し、各アクチュエータに指令を出すタス
クである。例えば、タスクT21は圧力センサからの情
報と作動油温を入力するタスク、T22はポンプ傾転角
を入力し、エンジンの回転数を制御するガバナに指令を
出すタスク、タスクT23は圧力センサからの情報を入
力し、ポンプの吐出流量を制御するレギュレータに指令
を出すタスクである。
The task of medium priority P2 is a task of inputting data from various sensors and issuing a command to each actuator. For example, task T21 is a task of inputting information and hydraulic oil temperature from a pressure sensor, T22 is a task of inputting a pump tilt angle and issuing a command to a governor for controlling the engine speed, and task T23 is a task of pressure sensor. This is a task that inputs information and issues a command to the regulator that controls the discharge flow rate of the pump.

【0005】下位優先度P3のタスクは、油圧制御系あ
るいは機械制御系の制御のための目標値を演算するだけ
のタスクである。例えばタスクT31はポンプの吐出流
量を制御するための演算を行うタスク、T32は走行モ
ータを制御するための演算を行うタスク、T33はエン
ジンの回転数を制御するための演算を行うためのタスク
である。これらのタスクは、上位優先度P1、P2のタ
スクが実行されていないときに処理を行えばよいので下
位優先度としている。中位優先度P2のタスク群は優先
度P3のタスク群で演算した結果の出力を行うタスク群
である。更に、各優先度にあっては、複数タスクから成
る場合(例えばP3は3つのタスク、P2も3つのタス
クから成る)、その優先度内でのタスクはT21→T2
2→T23の如く逐次的に実行される。
The task of lower priority P3 is only a task of calculating a target value for controlling the hydraulic control system or the mechanical control system. For example, task T31 is a task for performing a calculation for controlling the discharge flow rate of the pump, T32 is a task for performing a calculation for controlling the traveling motor, and T33 is a task for performing a calculation for controlling the engine speed. is there. These tasks have lower priorities because they can be processed when tasks with higher priorities P1 and P2 are not being executed. The task group with the medium priority P2 is a task group that outputs the result calculated by the task group with the priority P3. Furthermore, in the case where each priority has a plurality of tasks (for example, P3 has three tasks and P2 also has three tasks), the tasks within that priority are T21 → T2.
It is executed sequentially as 2 → T23.

【0006】このようなマルチタスクOSでは、内部変
数・タスクが一時停止されたとき、それを再開するため
に必要な戻り番地やレジスタの情報、サブルーチンコー
ルしたときの戻り番地などを格納するスタック領域をR
AMに用意する。本発明は、このようなスタック領域の
構成方法に関するものであるが、メモリに十分な余裕が
あるようなシステムでは、タスクごとにスタック領域を
固定的に割り当て、複数のタスクの並列処理を容易にし
ている。しかし、シングルチップマイコンのように小規
模のメモリしか使えないシステムでは多数のタスクの全
てにスタック領域を固定的に割り当てるのは無理であ
る。
In such a multi-task OS, when an internal variable or task is suspended, a return address or register information necessary for restarting it, a stack area for storing a return address when a subroutine is called, etc. R
Prepare for AM. The present invention relates to such a stack area configuration method, but in a system having a sufficient memory, a stack area is fixedly assigned to each task to facilitate parallel processing of a plurality of tasks. ing. However, in a system such as a single-chip microcomputer that can use only a small memory, it is impossible to fixedly allocate the stack area to all of a large number of tasks.

【0007】これを解決するため、最近のシングルチッ
プマイコン向けマルチタスクOSでは、RAM領域内の
データ領域やスタック領域を共有することが知られてい
る。この1つの領域を複数のタスクで共有するシステム
では、タスクの起動要求が行われると、シングルチップ
マイコンの場合、スタック領域が極めて小さいから、ス
タック領域が使用中であるかどうかの確認を行い、起動
要求が発行されたタスクを実行させるか、あるいは待ち
状態にするかの排他制御を行っている。
In order to solve this problem, it is known that a recent multi-task OS for a single chip microcomputer shares a data area and a stack area in a RAM area. In a system in which this one area is shared by multiple tasks, when a task activation request is made, in the case of a single-chip microcomputer, the stack area is extremely small, so it is confirmed whether the stack area is in use. Exclusive control is performed to determine whether to execute the task for which the activation request was issued or place it in the waiting state.

【0008】また、スタック領域の排他制御を行わず
に、複数のタスク間でスタックを共有する方法として
は、スタック領域を、一時停止・再開のための情報を記
憶する部分と、サブルーチン・割り込みの復帰情報を記
憶する部分に分け、サブルーチン・割り込み情報記憶ス
タックを複数のタスク間で共有する、特開平5−173
810号に開示されるような方式がある。
As a method of sharing a stack between a plurality of tasks without performing exclusive control of the stack area, the stack area may include a portion for storing information for temporary suspension / resumption and a subroutine / interruption. A subroutine / interrupt information storage stack is shared among a plurality of tasks by dividing it into sections for storing return information.
There is a method as disclosed in No. 810.

【0009】[0009]

【発明が解決しようとする課題】上記した従来技術で、
タスクごとにスタックを割り当てる方法では、装置の基
板の大型化にともなうスペースの増大及びコスト増大を
招く。また、建設機械などでは、回路の大型化にともな
い振動に弱くなる問題がある。そこでシングルチップマ
イコンが用いられるが、複数のタスクでスタック領域を
共有すると、マルチタスクOS内に共有スタック領域を
管理するための機能をもたせる必要があり、タスク切り
替え時の処理時間の増大につながる。またタスクに実行
優先度を設け、それによりタスクの切り替えを行う方式
のマルチタスクOSでは、異なる優先度のタスクでスタ
ック領域の共有を行った場合、優先度の高いタスクが、
資源待ちのために優先度の低いタスクに待たされてしま
うということがおきる。
With the above-mentioned conventional technique,
The method of allocating a stack for each task causes an increase in space and cost associated with an increase in the size of the substrate of the device. In addition, construction machines and the like have a problem that they become vulnerable to vibration as the circuit becomes larger. Therefore, a single-chip microcomputer is used. However, if the stack area is shared by a plurality of tasks, it is necessary to provide the multitask OS with a function for managing the shared stack area, which leads to an increase in processing time at the time of task switching. Further, in a multi-task OS in which a task is provided with an execution priority and task switching is performed by this, when a stack area is shared by tasks having different priorities, a task with a higher priority is
It may happen that a task with a low priority is kept waiting because of waiting for resources.

【0010】この後者の問題は、次のように生じる。
今、例えば図3のタスクT22の実行中により高い優先
度のタスクT11が起動されると、OSはタスクT22
の実行を中断してスタック領域にタスクT22の戻り番
地やレジスタ情報を格納してタスクT11を実行しよう
とする。ここでもしタスクT11とT22がスタック領
域を共有していると高順位のタスクの実行が開始でき
ず、タスクT22の処理が再開され、タスクT11はタ
スクT22の終了を待つことになる。ところが中位優先
度のタスクで入力したデータに異常があった場合や下位
優先度タスクでの演算結果に異常があった場合、即時に
最上位優先度のタスクT11を実行し、異常があったセ
ンサのバックアップ、あるいは演算結果の補正を行う必
要があるが、このタスクT11の実行が後になってしま
うと、異常のあったデータを用いて演算した結果をその
ままアクチュエータに出力し、機械の誤動作につながる
恐れがある。例えば、オペレータの操作通りにフロント
が動作しないことになる。
This latter problem occurs as follows.
Now, for example, when the task T11 of higher priority is activated during execution of the task T22 of FIG.
The execution of task T11 is interrupted, the return address of the task T22 and the register information are stored in the stack area, and the task T11 is executed. Here, if the tasks T11 and T22 share the stack area, the execution of the high-order task cannot be started, the processing of the task T22 is restarted, and the task T11 waits for the end of the task T22. However, if there is an abnormality in the data input by the medium priority task or if there is an abnormality in the calculation result of the lower priority task, the highest priority task T11 is immediately executed and there is an abnormality. It is necessary to back up the sensor or correct the calculation result, but if the task T11 is executed later, the calculation result using the abnormal data is output to the actuator as it is, and the machine malfunctions. There is a risk of being connected. For example, the front does not operate according to the operator's operation.

【0011】このような問題が起きないよう、ソフトウ
ェア開発時にタスクのスタック領域を、明らかに並列処
理がされないと考えられるタスク毎に割り当てることも
考えられる。しかし、このようなスタック領域の割り当
てを行うためには、ソフトウェアの知識の他に、マイコ
ンのハードウェアの知識をも必要とするため、ソフトウ
ェア開発担当者の負担が増大する。これはマルチタスク
OSを導入することによるソフトウェア開発効率向上と
いうメリットを打ち消してしまうものである。また、特
開平5−173810号に記載のスタック領域を一時停
止・再開情報記憶部分とサブルーチン・割り込み情報記
憶部分に分ける方式は、スタックの全ての部分を共有化
できるわけではないので、ユーザのプログラムの構成に
よっては、まだRAM領域の無駄が残る。
In order to prevent such a problem, it is possible to allocate a task stack area to each task which is apparently not processed in parallel during software development. However, in order to allocate such a stack area, knowledge of the hardware of the microcomputer is required in addition to knowledge of the software, which increases the burden on the person in charge of software development. This negates the merit of improving the software development efficiency by introducing the multitasking OS. Further, the method of dividing the stack area into the pause / resume information storage portion and the subroutine / interrupt information storage portion described in Japanese Patent Laid-Open No. 5-173810 cannot share all the portions of the stack. Depending on the configuration, waste of the RAM area still remains.

【0012】本発明の目的は、小容量のスタック領域を
用い、優先度によってタスク切り替えを行うマルチタス
クOSにおいて、スタックの排他制御なしで常に高順位
のタスクを優先して起動できるようにしたスタック領域
の割り当て方法とその方法を用いた制御装置を提供する
にある。
An object of the present invention is to provide a multi-task OS which uses a small-capacity stack area and performs task switching according to priority so that a high-order task can always be activated with priority without stack exclusive control. An object is to provide an area allocation method and a control device using the method.

【0013】[0013]

【課題を解決するための手段】本発明は、マルチタスク
オペレーティングシステムに於るスタック割り当て方法
であって、タスクの優先度ごとに1つのスタックを設
け、優先度が同じタスクは1つのスタックを共用するよ
うにしたことを特徴とするスタック割り当て方法を開示
する。
The present invention is a stack allocation method in a multitasking operating system, in which one stack is provided for each priority of tasks, and tasks having the same priority share one stack. Disclosed is a stack allocating method.

【0014】更に本発明は、同じ優先度を有する第1の
タスク群と、該タスク群とは異なる優先度を有する第2
のタスク群に対し、前記第1のタスク群の任意のタスク
と前記第2のタスク群の任意のタスクとが競合しない場
合には、前記第1のタスク群対応のスタックと前記第2
のタスク群対応のスタックとを共用して1つにしたこと
を特徴とするスタック割り当て方法を開示する。
Further, according to the present invention, a first task group having the same priority and a second task group having a different priority from the task group.
When the arbitrary task of the first task group and the arbitrary task of the second task group do not compete for the task group of No. 1, the stack corresponding to the first task group and the second task group
Disclosed is a stack allocating method, which is characterized in that a stack corresponding to the task group of 1 is shared to be one.

【0015】更に本発明は、優先度ごとにキューを設
け、更にタスクごとにフラグを設けるとともに、割り込
みにより中断されたタスクに対しては当該タスクの優先
度対応のスタックへ再開に必要な情報を格納し、そのフ
ラグを中断を示す値として当該タスクをその優先度対応
のキューの先頭へ接続し、起動がかけられたタスクに対
してはそのフラグを新規起動を示す値として当該タスク
をその優先度対応のキューの最後尾へ接続し、前記キュ
ーを調べることにより1つのタスクが実行タスクとして
選択されたときに、当該実行タスクのフラグが中断を示
しているときには、前記対応スタックに格納した再開に
必要な情報を用いて処理を再開し、前記選択された実行
タスクのフラグが新規起動を示しているときには、当該
実行タスクの優先度対応のスタックに当該実行タスクの
スタートアドレスをセットして該セットしたスタートア
ドレスから処理を開始し、こうしてダイナミックにスタ
ックを割り当ててマルチタスク処理を行うことを特徴と
するスタック割り当て方法を開示する。
Further, according to the present invention, a queue is provided for each priority, a flag is provided for each task, and for a task interrupted by an interrupt, information necessary for restarting the stack corresponding to the priority of the task is provided. Store the task, connect the task to the head of the queue corresponding to its priority with the flag as a value indicating suspension, and for the task that has been activated, set the flag as a value indicating new activation and give priority to the task. When one task is selected as an executing task by checking the queue by connecting to the end of the corresponding queue, and when the flag of the executing task indicates interruption, the restart stored in the corresponding stack is resumed. When the flag of the selected execution task indicates new activation, the priority of the execution task is restarted by using the information necessary for Starts the processing from the start address the set by setting the start address of the execution task to the stack of response, to perform multitasking by assigning stack thus dynamically discloses stack allocation method comprising.

【0016】更に本発明は、制御対象の状態量を取り込
むためのタスク、該タスクにより取り込まれた状態量を
用いて制御対象のモニタ及び制御信号生成処理を行うた
めのタスク、及び異常処理のためのタスクの少なくとも
1つを含むタスクを、請求項1〜3の内の1つに記載の
スタック割り当て方法により割り当てられたスタックを
用いて処理を実行し、制御対象の制御を行うように構成
したことを特徴とする制御装置を開示する。
Furthermore, the present invention provides a task for fetching a state quantity of a control target, a task for performing monitoring and control signal generation processing of a control target using the state quantity fetched by the task, and an abnormality processing. A task including at least one of the tasks described above is configured to execute processing using a stack allocated by the stack allocation method according to any one of claims 1 to 3, and to control a control target. Disclosed is a control device.

【0017】更に本発明は、前記制御対象が建設用の機
械であり、前記タスクの実行手段がシングルチップマイ
コンであり、前記スタックは前記シングルチップマイコ
ンのメモリに設定して成ることを特徴とする制御装置を
開示する。
Further, the present invention is characterized in that the controlled object is a construction machine, the task executing means is a single-chip microcomputer, and the stack is set in a memory of the single-chip microcomputer. A control device is disclosed.

【0018】[0018]

【発明の実施の形態】以下、本発明をその実施の形態に
沿って説明する。図1は、本発明になるスタック割り当
て方法を用いたマルチタスクOSの構成例を示すもの
で、タスク切り替えに関する部分のみを示している。タ
スク管理テーブル10はタスクごとに設けられ、当該タ
スクの優先度101、当該タスクの実行プログラム先頭
を示すスタートアドレス102、当該タスクに割り当て
られたスタックの最後部を指すスタックポインタ103
の他に、当該タスクが新規に起動がかけられたタスク
か、中断されていたタスクかを区別するためのフラグ1
04をその内容として有している。
BEST MODE FOR CARRYING OUT THE INVENTION The present invention will be described below with reference to its embodiments. FIG. 1 shows an example of the configuration of a multi-task OS using the stack allocation method according to the present invention, and shows only the part related to task switching. The task management table 10 is provided for each task, and the priority 101 of the task, the start address 102 indicating the head of the execution program of the task, and the stack pointer 103 indicating the end of the stack allocated to the task.
In addition to this, a flag 1 for distinguishing whether the task is a newly started task or a suspended task
It has 04 as its contents.

【0019】ここで、本実施の形態では、タスクの優先
度ごとに1つのスタックを割り当てておき、同一の優先
度のタスクは1つのスタックを共用するものとする。図
1ではRAM20に優先度「6」及び「7」用のスタッ
クST6及びST7が例示されている。スタックポイン
タ設定テーブル11は、これら優先度ごとのスタックの
先頭アドレスを格納しておくもので、タスク管理テーブ
ル10作成時に優先度を参照してこの先頭アドレスがス
タックポインタとしてタスク管理テーブル10に書き込
まれる。また、優先度101及びスタートアドレス10
2は、ユーザがタスク毎に指定することにより与えら
れ、タスク管理テーブル10へ書き込まれる。
Here, in this embodiment, one stack is allocated for each priority of tasks, and tasks having the same priority share one stack. In FIG. 1, the stacks ST6 and ST7 for the priorities “6” and “7” are illustrated in the RAM 20. The stack pointer setting table 11 stores the top address of the stack for each priority, and the priority is referred to when the task management table 10 is created, and this top address is written in the task management table 10 as a stack pointer. . Also, priority 101 and start address 10
2 is given by the user designating each task and is written in the task management table 10.

【0020】待ち行列(キュー)Q6、Q7は、各優先
度ごとの実行可能なタスクをその起動された順に並べて
管理するためのリストコントロールブロックで、図1で
は優先度「6」及び「7」のキューのみ示したが、実際
にはすべての優先度に対して設けられている。そして各
待ち行列は、起動されたタスクに対応するタスク管理テ
ーブル10の先頭アドレスにより当該タスクを管理す
る。実行タスク選択プログラム12は、上記の各優先度
毎に設けられた待ち行列を調べ、優先度が最も高く、且
つ早く起動がかけられタスクから順に取り出してそのタ
スクが実行されるようにする。
Queues (queues) Q6, Q7 are list control blocks for arranging and managing the executable tasks of each priority in the order in which they are started. In FIG. 1, the priorities "6" and "7" are set. Although only the queue is shown, it is actually provided for all priorities. Then, each queue manages the task by the head address of the task management table 10 corresponding to the activated task. The execution task selection program 12 examines the queue provided for each of the above priorities, and has the highest priority and is activated earlier so that the tasks are taken out in order and executed.

【0021】図4は、上記のようなマルチタスクOSに
よるタスク切り替え処理を示すフローチャートである。
今、タスクBの実行中にそれとは別のタスクAの起動要
求が発生すると(ステップ401)、実行中タスクBを
中断し、それを再開するための戻り番地やそのときのレ
ジスタ情報等を、タスクBの優先度対応に設けられたス
タックBへ格納する(ステップ402)。更にタスクB
用のタスク管理テーブルのスタックポインタ103の値
を、ステップ402でスタックBへ格納した情報の最後
のアドレスとし(ステップ403)、タスクBをその優
先度対応の待ち行列の先頭へ接続する(ステップ40
4)。更にフラグ104を“1”とする(ステップ40
5)。但しフラグ値“1”は、当該タスクが中断中であ
ることを示すものとする。
FIG. 4 is a flow chart showing the task switching processing by the multitask OS as described above.
If another task A activation request is issued during execution of task B (step 401), the execution task B is interrupted, and a return address for restarting it and register information at that time are given. The task B is stored in the stack B provided in correspondence with the priority (step 402). Further task B
The value of the stack pointer 103 of the task management table for the task is set as the last address of the information stored in the stack B in step 402 (step 403), and the task B is connected to the head of the queue corresponding to the priority (step 40).
4). Further, the flag 104 is set to "1" (step 40).
5). However, the flag value "1" indicates that the task is suspended.

【0022】以上の処理で実行中タスクBの中断とそれ
に伴う処理が終わるので、次に今起動要求のあったタス
クAを当該タスクの優先度対応の待ち行列へ接続する。
例えばタスクAの優先度が「6」であれば、待ち行列Q
6内の最後の位置にタスクAの管理テーブルの先頭アド
レスを入力する(ステップ406)。そしてタスク対応
の管理テーブルのフラグを“0”とする(ステップ40
7)。この“0”は、当該タスクが新しく起動要求され
たものであることを示すものとする。
Since the suspension of the task B being executed and the processing associated therewith are completed by the above processing, the task A for which the activation request has been made next is connected to the queue corresponding to the priority of the task.
For example, if the priority of task A is “6”, the queue Q
The start address of the management table of task A is input to the last position within 6 (step 406). Then, the flag in the management table corresponding to the task is set to "0" (step 40).
7). This "0" indicates that the task has been newly requested to be activated.

【0023】次に実行タスク選択プログラム12により
各待ち行列を調べ、各待ち行列に接続されているタスク
の内で、最も優先度が高く、且つその優先度対応の待ち
行列の先頭にあるタスクCを取り出し(ステップ40
8)、そのタスクCのフラグをみて新しく起動されたも
のかを調べる(ステップ409)。もしフラグ=
“1”、即ち中断されていたタスクであれば、タスク管
理テーブル10のスタックポインタ103に再開のため
のスタックポインタがかき込まれているので、このアド
レスに対する割り込み復帰命令を発行して当該中断され
ていたタスクCの実行を再開する(ステップ410)。
またもしタスクCのフラグ=“1”、即ち新規に起動さ
れたタスクのときは、そのタスクの管理テーブルのスタ
ートアドレス102を当該タスク優先度対応のスタック
にセットし(ステップ411)、そのスタックポインタ
に対する割り込み復帰命令を発行して当該タスクCの実
行を開始する(ステップ412)。
Next, the execution task selection program 12 examines each queue, and among the tasks connected to each queue, the task C with the highest priority and at the head of the queue corresponding to that priority. (Step 40
8) The task C flag is checked to see if it has been newly activated (step 409). If flag =
If the task is "1", that is, the suspended task, the stack pointer 103 for resuming is written in the stack pointer 103 of the task management table 10. Therefore, an interrupt return instruction for this address is issued and the suspended task is suspended. The execution of task C that has been restarted is restarted (step 410).
If the flag of the task C is "1", that is, if the task is newly started, the start address 102 of the task management table is set in the stack corresponding to the task priority (step 411), and the stack pointer is set. Issue an interrupt return instruction to start execution of the task C (step 412).

【0024】図5は、上に説明したシステムにおいて、
タスクを切り替える際のマルチタスクOSのスタックの
割り当て例を示したものである。優先度「7」のタスク
1と優先度「6」のタスク3が並列に動作している状態
では、タスク1は優先度「7」タスク用のスタックST
7、タスク3は優先度「6」タスク用のスタックST6
を使用する。タスク3の実行が終わり、同じ優先度
「6」のタスク4が起動された場合、タスク4は優先度
「6」タスク用のスタックST6を使用する。同じよう
にタスク1とタスク4の実行が終了し、タスク2とタス
ク5が起動された場合、タスク2は優先度「7」タスク
用スタックST7を、タスク5は優先度「6」タスク用
のスタックST6を使用する。もしタスク1実行中にタ
スク2が起動された場合は、タスク2にスタックを割り
当てるのはタスク1の終了後になるから、タスク1とタ
スク2で同じスタックをアクセスするようなことはな
い。
FIG. 5 is a block diagram of the system described above.
6 illustrates an example of stack allocation of a multi-task OS when switching tasks. In a state where the task 1 with the priority “7” and the task 3 with the priority “6” are operating in parallel, the task 1 is the stack ST for the task with the priority “7”.
7, task 3 is stack ST6 for task with priority "6"
To use. When the execution of the task 3 is finished and the task 4 having the same priority “6” is activated, the task 4 uses the stack ST6 for the task of the priority “6”. Similarly, when the executions of task 1 and task 4 are completed and task 2 and task 5 are activated, task 2 uses task stack ST7 for priority "7" and task 5 uses task stack ST7 for priority "6". The stack ST6 is used. If task 2 is activated during execution of task 1, the stack is allocated to task 2 only after task 1 ends, so task 1 and task 2 do not access the same stack.

【0025】以上のようにして、本発明では優先度ごと
にスタックを用意しているので、優先度の高いタスクの
実行がそれより優先度の低いタスクの実行完了待ちにな
ることはなく、緊急に処理を必要とする処理を優先的に
実行できる。また、同一優先度のタスクが複数個起動さ
れたときには、後から起動された新規のタスクに対して
はスタックを用いることなく、そのタスクが待ち行列か
ら読み出されて実行段階となったときにスタックを実行
開始作業用に用いることで、複雑な排他制御をしなくて
も不用意にスタック内容が書き換えられるのを防ぐこと
ができる。しかも優先度ごとに1つのスタックを用意す
ればよいから、スタック領域が全体として少なくてす
み、シングルチップマイコンのようにメモリの小さい場
合でもマルチタスク処理が容易に行える。
As described above, according to the present invention, since the stack is prepared for each priority, the execution of the task with the higher priority does not wait for the completion of the execution of the task with the lower priority, and the urgent task is required. The process that requires the process can be preferentially executed. Also, when multiple tasks with the same priority are started, the stack is not used for new tasks that are started later, and when that task is read from the queue and enters the execution stage. By using the stack for work to start execution, it is possible to prevent the contents of the stack from being accidentally rewritten without complicated exclusive control. Moreover, since one stack may be prepared for each priority, the stack area can be reduced as a whole, and multitask processing can be easily performed even when the memory is small like a single-chip microcomputer.

【0026】なお、図1の構成に於ては、タスクの優先
度ごとに1つのスタックを割り当てるものとしたが、逐
次起動される一連のタスク群があり、それらが複数の優
先度のタスクを含んではいるが、異なる優先度のタスク
間では競合することがない場合には、これらのタスク群
を一まとめにして1つのスタックを割り当てれば、スタ
ックをより節約できる。このような割り当てを行うに
は、上記一連のタスク群に対応する複数の優先度のスタ
ックの先頭アドレスを同一値としてスタックポインタ設
定テーブル11に書き込んでおけばよい。
In the configuration of FIG. 1, one stack is assigned for each priority of the task, but there is a series of task groups that are sequentially activated, and those tasks have a plurality of priorities. However, if there is no conflict between tasks with different priorities, stacking these tasks together and allocating one stack saves more stack. In order to perform such allocation, the top addresses of stacks having a plurality of priorities corresponding to the series of task groups may be written in the stack pointer setting table 11 as the same value.

【0027】次に、本発明のスタック割り当て方法を用
いた建設機械の制御装置の例を説明する。建設機械の制
御装置としてはシングルチップマイコンが用いられる
が、図6はその構成例を示すブロック図で、図2で説明
した制御系を構成するための制御装置である。同図に於
て、建設機械に取り付けられた各種センサ、例えばポン
プ吐出圧を計測するセンサ、ポンプの傾転角を計測する
センサ、作動油温を計測するセンサなどからの情報は、
アナログ入力インターフェース65を介してRAM63
上のデータ保管領域に保存される。また、エンジン回転
数の計測は、エンジン回転数に応じた数のパルスがディ
ジタル入力インターフェース67に入力され、内蔵のタ
イマ64を用いてエンジン回転数が計測され、データは
RAM63上に保存される。CPU61は、ROM62
に格納されたプログラムを用いてこれらの情報を処理
し、油圧制御系あるいは機械制御系の制御目標値を演算
し、アナログ出力インターフェース66を通してポンプ
やエンジンに指令を出力する。これらデータの入出力や
外部への指令は複数のタスクがマルチタスクで動作する
ことによって行われるが、高度で複雑な制御をするほど
タスク数が増大する。
Next, an example of a construction machine control apparatus using the stack allocation method of the present invention will be described. A single-chip microcomputer is used as the control device for the construction machine, and FIG. 6 is a block diagram showing a configuration example thereof, which is a control device for forming the control system described in FIG. In the figure, information from various sensors attached to the construction machine, for example, a sensor that measures the pump discharge pressure, a sensor that measures the tilt angle of the pump, a sensor that measures the hydraulic oil temperature, etc.
RAM 63 via analog input interface 65
It is saved in the data storage area above. Further, in measuring the engine speed, a number of pulses corresponding to the engine speed are input to the digital input interface 67, the engine speed is measured using the built-in timer 64, and the data is stored in the RAM 63. CPU61 is ROM62
This information is processed by using the program stored in, the control target value of the hydraulic control system or the machine control system is calculated, and the command is output to the pump and the engine through the analog output interface 66. Input and output of these data and commands to the outside are performed by a plurality of tasks operating in multitask, but the number of tasks increases as the degree of sophisticated control is increased.

【0028】そこで建設機械の制御の重要度に応じてタ
スクに優先度を付与し、この優先度ごとに1つのスタッ
クをRAM63上に設けることで、比較的少ないスタッ
ク領域を用いたマルチタスク処理を実現する。例えば図
2の制御系では3つの優先度P1、P2、P3が示され
ているが、本発明ではこの優先度ごとに1つのスタック
を割り当てる。これにより、図2の場合には、タスクご
とに1つのスタックを割り当てる従来方法と比べると3
つのスタックでよいのでスタック領域は3/7でよい。
しかも、例えば下位優先度P2やP3のタスク実行中に
最上位優先度P1のタスクT11が起動要求されると、
下位タスクの終了を待たずにタスクT11の実行を開始
でき、建設機械の安全性、制御性を向上させることがで
きる。更に、処理装置が小型ですむことから、コスト低
下、省スペース化、及び耐振性の向上にともなう信頼性
向上がはかれる。
Therefore, priority is given to tasks according to the importance of control of the construction machine, and one stack is provided on the RAM 63 for each priority, thereby performing multitask processing using a relatively small stack area. To be realized. For example, the control system of FIG. 2 shows three priorities P1, P2, and P3, but in the present invention, one stack is allocated for each of these priorities. As a result, in the case of FIG. 2, compared with the conventional method of allocating one stack for each task,
Since only one stack is required, the stack area may be 3/7.
Moreover, for example, when the task T11 of the highest priority P1 is requested to be activated during the execution of the task of the lower priority P2 or P3,
Execution of the task T11 can be started without waiting for the end of the lower task, and the safety and controllability of the construction machine can be improved. Further, since the processing apparatus can be small in size, cost reduction, space saving, and improvement in reliability due to improvement in vibration resistance can be achieved.

【0029】なお、ここでは建設機械への適用例を説明
したが、本発明は、多数のタスクをシングルチップマイ
コンで処理する制御系、例えば自動車の制御装置等にも
好適なことは明らかである。
Although an example of application to a construction machine has been described here, it is obvious that the present invention is also suitable for a control system that processes a large number of tasks with a single-chip microcomputer, such as a control device for an automobile. .

【0030】[0030]

【発明の効果】本発明によれば、同一優先度のタスクに
共通のスタック領域を割り当てることにより、マルチタ
スクOSのRAM領域使用量を少なくすることができ
る。また、複雑な資源の排他制御によるタスクの優先度
の逆転がなくなるとともに、タスク切り替え時間の短縮
化がはかれる。また、機器組み込み用の、RAM容量が
小さいシングルチップマイコンへマルチタスクOSが搭
載できるようになることで、プログラムが作りやすくな
ると共に、管理がしやすくなる。また、建設機械等の制
御装置のコスト低下、省スペース化、耐振性向上をはか
ることができる。
According to the present invention, by allocating a common stack area to tasks having the same priority, it is possible to reduce the RAM area usage of the multitask OS. In addition, task priority switching due to complicated resource exclusion control is eliminated, and task switching time is shortened. In addition, since the multi-task OS can be installed in a single-chip microcomputer with a small RAM capacity, which is embedded in a device, programs can be easily created and management can be facilitated. Further, it is possible to reduce the cost of a control device such as a construction machine, save space, and improve vibration resistance.

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

【図1】本発明になるスタック割り当て方法の説明図で
ある。
FIG. 1 is an explanatory diagram of a stack allocation method according to the present invention.

【図2】シングルチップマイコンを用いた油圧ショベル
制御装置の説明図である。
FIG. 2 is an explanatory diagram of a hydraulic excavator control device using a single-chip microcomputer.

【図3】マルチタスクOS上で動く油圧ショベル制御ソ
フトウェアの構成例である。
FIG. 3 is a configuration example of hydraulic excavator control software that runs on a multitasking OS.

【図4】本発明のスタック割り当て方法を用いたときの
タスク切り替え処理のフローチャートである。
FIG. 4 is a flowchart of task switching processing when the stack allocation method of the present invention is used.

【図5】本発明のスタック割り当て方法の例を示す図で
ある。
FIG. 5 is a diagram showing an example of a stack allocation method of the present invention.

【図6】制御装置の構成例を示すブロック図である。FIG. 6 is a block diagram showing a configuration example of a control device.

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

10 タスク管理テーブル 11 スタックポインタ設定テーブル 12 実行タスク選択プログラム 13 RAM 61 CPU 62 ROM 63 RAM 64 タイマ 65 アナログ入力インターフェース 66 アナログ出力インターフェース 67 ディジタル入力インターフェース 104 フラグ ST6、ST7 スタック Q6、Q7 待ち行列 10 task management table 11 stack pointer setting table 12 execution task selection program 13 RAM 61 CPU 62 ROM 63 RAM 64 timer 65 analog input interface 66 analog output interface 67 digital input interface 104 flag ST6, ST7 stack Q6, Q7 queue

Claims (5)

【特許請求の範囲】[Claims] 【請求項1】 マルチタスクオペレーティングシステム
に於るスタック割り当て方法であって、 タスクの優先度ごとに1つのスタックを設け、優先度が
同じタスクは1つのスタックを共用するようにしたこと
を特徴とするスタック割り当て方法。
1. A stack allocation method in a multitasking operating system, wherein one stack is provided for each priority of tasks, and tasks having the same priority share one stack. Stack allocation method.
【請求項2】 同じ優先度を有する第1のタスク群と、
該タスク群とは異なる優先度を有する第2のタスク群に
対し、前記第1のタスク群の任意のタスクと前記第2の
タスク群の任意のタスクとが競合しない場合には、前記
第1のタスク群対応のスタックと前記第2のタスク群対
応のスタックとを共用して1つにしたことを特徴とする
請求項1記載のスタック割り当て方法。
2. A first task group having the same priority,
If there is no conflict between an arbitrary task of the first task group and an arbitrary task of the second task group with respect to a second task group having a priority different from that of the task group, 2. The stack allocation method according to claim 1, wherein the stack corresponding to the task group and the stack corresponding to the second task group are shared to be one.
【請求項3】 優先度ごとにキューを設け、更にタスク
ごとにフラグを設けるとともに、 割り込みにより中断されたタスクに対しては当該タスク
の優先度対応のスタックへ再開に必要な情報を格納し、
そのフラグを中断を示す値として当該タスクをその優先
度対応のキューの先頭へ接続し、 起動がかけられたタスクに対してはそのフラグを新規起
動を示す値として当該タスクをその優先度対応のキュー
の最後尾へ接続し、 前記キューを調べることにより1つのタスクが実行タス
クとして選択されたときに、 当該実行タスクのフラグが中断を示しているときには、
前記対応スタックに格納した再開に必要な情報を用いて
処理を再開し、 前記選択された実行タスクのフラグが新規起動を示して
いるときには、当該実行タスクの優先度対応のスタック
に当該実行タスクのスタートアドレスをセットして該セ
ットしたスタートアドレスから処理を開始し、 こうしてダイナミックにスタックを割り当ててマルチタ
スク処理を行うことを特徴とする請求項1又は2記載の
スタック割り当て方法。
3. A queue is provided for each priority, a flag is provided for each task, and for a task interrupted by an interrupt, information necessary for restart is stored in a stack corresponding to the priority of the task,
The task is connected to the head of the queue corresponding to its priority with that flag as a value indicating suspension, and for the task that has been activated, the flag is set as a value indicating new activation and that task is associated with that priority. When one task is selected as an execution task by connecting to the end of the queue and examining the queue, and the flag of the execution task indicates suspension,
When the process is restarted using the information necessary for resumption stored in the corresponding stack, and the flag of the selected execution task indicates a new start, the stack of the execution task with the priority corresponding to the execution task 3. The stack allocating method according to claim 1, wherein a start address is set, processing is started from the set start address, and stacks are dynamically allocated in this way to perform multitask processing.
【請求項4】 制御対象の状態量を取り込むためのタス
ク、該タスクにより取り込まれた状態量を用いて制御対
象のモニタ及び制御信号生成処理を行うためのタスク、
及び異常処理のためのタスクの少なくとも1つを含むタ
スクを、請求項1〜3の内の1つに記載のスタック割り
当て方法により割り当てられたスタックを用いて処理を
実行し、制御対象の制御を行うように構成したことを特
徴とする制御装置。
4. A task for fetching a state quantity of a control target, a task for monitoring a control target and generating a control signal using the state quantity fetched by the task,
And a task including at least one of the tasks for abnormal processing is executed by using a stack allocated by the stack allocation method according to claim 1, and a control target is controlled. A control device characterized by being configured to perform.
【請求項5】 前記制御対象が建設用の機械であり、前
記タスクの実行手段がシングルチップマイコンであり、
前記スタックは前記シングルチップマイコンのメモリに
設定して成ることを特徴とする請求項4に記載の制御装
置。
5. The control target is a construction machine, and the task executing means is a single-chip microcomputer.
The control device according to claim 4, wherein the stack is set in a memory of the single-chip microcomputer.
JP24613895A 1995-09-25 1995-09-25 Stack allocating method and control equipment Pending JPH0991154A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP24613895A JPH0991154A (en) 1995-09-25 1995-09-25 Stack allocating method and control equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP24613895A JPH0991154A (en) 1995-09-25 1995-09-25 Stack allocating method and control equipment

Publications (1)

Publication Number Publication Date
JPH0991154A true JPH0991154A (en) 1997-04-04

Family

ID=17144052

Family Applications (1)

Application Number Title Priority Date Filing Date
JP24613895A Pending JPH0991154A (en) 1995-09-25 1995-09-25 Stack allocating method and control equipment

Country Status (1)

Country Link
JP (1) JPH0991154A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8195885B2 (en) 2006-06-23 2012-06-05 Denso Corporation Electronic unit for saving state of task to be run in stack
US20130205403A1 (en) * 2012-02-08 2013-08-08 Arm Limited Maintaining secure data isolated from non-secure access when switching between domains
CN103412796A (en) * 2013-08-30 2013-11-27 北京经纬恒润科技有限公司 Stack allocation method and stack allocation unit for tasks in operating system
US9116711B2 (en) 2012-02-08 2015-08-25 Arm Limited Exception handling in a data processing apparatus having a secure domain and a less secure domain
US9202071B2 (en) 2012-02-08 2015-12-01 Arm Limited Exception handling in a data processing apparatus having a secure domain and a less secure domain
US9213828B2 (en) 2012-02-08 2015-12-15 Arm Limited Data processing apparatus and method for protecting secure data and program code from non-secure access when switching between secure and less secure domains
US10210349B2 (en) 2012-02-08 2019-02-19 Arm Limited Data processing apparatus and method using secure domain and less secure domain
CN113716495A (en) * 2021-09-02 2021-11-30 衡阳宝坤机械制造有限公司 Intelligent storage forklift control system
CN114116204A (en) * 2021-11-02 2022-03-01 郑州市中心医院 Sensor-based bruxism monitoring method and system

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8195885B2 (en) 2006-06-23 2012-06-05 Denso Corporation Electronic unit for saving state of task to be run in stack
US9477834B2 (en) * 2012-02-08 2016-10-25 Arm Limited Maintaining secure data isolated from non-secure access when switching between domains
US9116711B2 (en) 2012-02-08 2015-08-25 Arm Limited Exception handling in a data processing apparatus having a secure domain and a less secure domain
US9202071B2 (en) 2012-02-08 2015-12-01 Arm Limited Exception handling in a data processing apparatus having a secure domain and a less secure domain
US9213828B2 (en) 2012-02-08 2015-12-15 Arm Limited Data processing apparatus and method for protecting secure data and program code from non-secure access when switching between secure and less secure domains
US20130205403A1 (en) * 2012-02-08 2013-08-08 Arm Limited Maintaining secure data isolated from non-secure access when switching between domains
US10025923B2 (en) 2012-02-08 2018-07-17 Arm Limited Data processing apparatus and method for protecting secure data and program code from non-secure access when switching between secure and less secure domains
US10083040B2 (en) 2012-02-08 2018-09-25 Arm Limited Exception handling in a data processing apparatus having a secure domain and a less secure domain
US10169573B2 (en) 2012-02-08 2019-01-01 Arm Limited Maintaining secure data isolated from non-secure access when switching between domains
US10210349B2 (en) 2012-02-08 2019-02-19 Arm Limited Data processing apparatus and method using secure domain and less secure domain
CN103412796A (en) * 2013-08-30 2013-11-27 北京经纬恒润科技有限公司 Stack allocation method and stack allocation unit for tasks in operating system
CN113716495A (en) * 2021-09-02 2021-11-30 衡阳宝坤机械制造有限公司 Intelligent storage forklift control system
CN114116204A (en) * 2021-11-02 2022-03-01 郑州市中心医院 Sensor-based bruxism monitoring method and system

Similar Documents

Publication Publication Date Title
JP2692609B2 (en) Multitask program debugging method and apparatus
EP1720099A1 (en) Use of data engine within a data processing apparatus
JPH1015836A (en) Robot controller and method for controlling the same
JPH11202988A (en) System power consumption control method
JPH0991154A (en) Stack allocating method and control equipment
US7924858B2 (en) Use of a data engine within a data processing apparatus
US5867383A (en) Programmable logic controller
JPH0926889A (en) Virtual machine system
US8719836B2 (en) Method and device for operating a secondary operating system auxiliary to a primary operating system
JPH1139172A (en) Electronic controller
JP3022848B2 (en) Multitask task switching method and real-time operating system
JP2004534985A (en) Interrupt control device
JP3022398B2 (en) Virtual computer system
JPS6248871B2 (en)
JPH0744405A (en) Measuring control system for operating time of virtual computer in virtual computer system
JPS6223895B2 (en)
JPH04346136A (en) Virtual instruction processor structure control method
JPH07200283A (en) Exchange system for resident load module
JP2001323840A (en) Control unit for automobile
JPS635790B2 (en)
JP2021060923A (en) Vehicle control device
JPH0447425A (en) System software generating device
JP2021105368A (en) Engine control device
JP2000020479A (en) Centralized managing device for measuring system
JPH0387935A (en) Task preemption controlling system