JP5633501B2 - Control apparatus and control method - Google Patents

Control apparatus and control method Download PDF

Info

Publication number
JP5633501B2
JP5633501B2 JP2011242470A JP2011242470A JP5633501B2 JP 5633501 B2 JP5633501 B2 JP 5633501B2 JP 2011242470 A JP2011242470 A JP 2011242470A JP 2011242470 A JP2011242470 A JP 2011242470A JP 5633501 B2 JP5633501 B2 JP 5633501B2
Authority
JP
Japan
Prior art keywords
task
control
partition
execution
wai
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.)
Active
Application number
JP2011242470A
Other languages
Japanese (ja)
Other versions
JP2013097719A (en
Inventor
平 哲也
哲也 平
浩司 尾藤
浩司 尾藤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Toyota Motor Corp
Original Assignee
Toyota Motor Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Toyota Motor Corp filed Critical Toyota Motor Corp
Priority to JP2011242470A priority Critical patent/JP5633501B2/en
Publication of JP2013097719A publication Critical patent/JP2013097719A/en
Application granted granted Critical
Publication of JP5633501B2 publication Critical patent/JP5633501B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、機能安全の確保のためにサービスロボットおよび輸送機器等に搭載される制御装置に関し、特に、コンピュータシステムを用いた制御装置に関する。   The present invention relates to a control device mounted on a service robot, transportation equipment, and the like for ensuring functional safety, and more particularly to a control device using a computer system.

サービスロボットは、外界センサや自己診断装置によって安全状態を常時監視し、何らかの危険を検知した場合に適切な安全制御ロジックを実行することで、機能安全を確保する必要がある。   Service robots must ensure functional safety by constantly monitoring the safety state with external sensors and self-diagnosis devices and executing appropriate safety control logic when any danger is detected.

上述したサービスロボットのほか、運輸機器等の電気的な原理で動作するシステムを対象とした機能安全に関する国際標準としてIEC 61508が制定されている。IEC 61508では、機能安全の確保のために設けられるシステムのことを安全関連系と呼んでいる。IEC 61508は、マイクロプロセッサ及びPLC(Programmable Logic Controller)等のハードウェアとコンピュータプログラム(ソフトウェア)によって安全関連系を構築するための様々な技法を定めている。IEC 61508で定められている技法を用いることで、コンピュータシステムを用いて安全関連系を構築することが可能となる。   In addition to the service robots described above, IEC 61508 has been established as an international standard for functional safety for systems that operate on electrical principles such as transportation equipment. In IEC 61508, a system provided for ensuring functional safety is called a safety-related system. IEC 61508 defines various techniques for constructing a safety-related system using hardware such as a microprocessor and a PLC (Programmable Logic Controller) and a computer program (software). By using the technique defined in IEC 61508, it is possible to construct a safety-related system using a computer system.

一方で、近年、マイクロプロセッサ等のプログラマブル電子機器の処理能力が向上している。このため、マルチタスクOS(Operating System)を利用し、1つのコンピュータシステム上で様々なアプリケーションプログラムを並列実行することで、サービスロボット及び自動車等の機器に搭載されている複数用途のコンピュータシステムを統合することができる。   On the other hand, in recent years, the processing capability of programmable electronic devices such as microprocessors has improved. For this reason, a multi-task OS (Operating System) is used, and various application programs are executed in parallel on one computer system, thereby integrating multiple-use computer systems installed in service robots and automobiles. can do.

例えば特許文献1に、機能安全の確保に関するアプリケーションプログラム(以下、安全関連アプリケーションと呼ぶ)を、その他のアプリケーションプログラム(以下、非安全関連アプリケーションと呼ぶ)と共に1つのコンピュータシステム上で動作させる技術が開示されている。   For example, Patent Literature 1 discloses a technique for causing an application program (hereinafter referred to as a safety-related application) related to ensuring functional safety to operate on one computer system together with other application programs (hereinafter referred to as a non-safety-related application). Has been.

IEC 61508で定められている技法を、安全関連アプリケーションおよび非安全関連アプリケーションを含むソフトウェア全体に適用すると、非安全関連アプリケーションにまで適用する必要性が生じる。このため、ソフトウェア開発コストが増大するという問題がある。   When the technique defined in IEC 61508 is applied to the entire software including safety-related applications and non-safety-related applications, it is necessary to apply even to non-safety-related applications. For this reason, there is a problem that the software development cost increases.

そこで、特許文献1に開示される技術では、システムプログラムのタイム・パーティションニングによって、安全関連アプリケーション(安全監視プログラム及び安全制御プログラム)を非安全関連アプリケーション(通常制御プログラム)から独立させている。このため、通常制御プログラムを安全関連系から除外することができ、コンピュータシステムを用いて構成される安全関連系の低コスト化に寄与することができる。   Therefore, in the technique disclosed in Patent Document 1, safety-related applications (safety monitoring program and safety control program) are made independent from non-safety-related applications (normal control program) by time partitioning of the system program. For this reason, the normal control program can be excluded from the safety-related system, which can contribute to the cost reduction of the safety-related system configured using the computer system.

特開2010−271759号公報JP 2010-271759 A

しかしながら、特許文献1に例示されるような安全制御装置には、以下に説明する課題があった。以下、図22及び図23を参照して、その課題について説明する。   However, the safety control device exemplified in Patent Document 1 has the following problems. The problem will be described below with reference to FIGS.

機能安全規格のIEC61508において、サービスロボット等のECU(Electronic Control Unit)では、シーケンスモニタ機能によって、予定されている時間内に処理が正しく実行することができているかを監視することが必要とされている。   In the functional safety standard IEC61508, an ECU (Electronic Control Unit) such as a service robot is required to monitor whether processing can be executed correctly within the scheduled time by the sequence monitor function. Yes.

例えば、サービスロボット等の制御では、図22に例示するように一定周期で繰り返し実行する必要のある処理が存在している。そのような処理として、サービスロボットのアクチュエータを制御する処理や、サービスロボットのセンサから情報を取得して、取得した情報を確認することでサービスロボットの状態を監視する処理等がある。ここで、図22及び図23において、「Partition 1」及び「Partition 2」は、タイムパーティションを示し、「Task」は、Partition 1で実行されるタスクを示している。タスクは、一定周期で繰り返し実行する必要のある処理を実行する。図22では、一定周期でアクティブとなるPartition 1でタスクを実行することによって、一定周期でタスクが実行されるようにしている。このようにすることで、例えば、定期的に監視結果に応じた制御対象の制御を行うことができるため、より安定した制御対象の制御を行うことが可能となる。   For example, in the control of a service robot or the like, there is a process that needs to be repeatedly executed at a constant cycle as illustrated in FIG. As such processing, there are processing for controlling an actuator of a service robot, processing for acquiring information from a sensor of the service robot, and monitoring the state of the service robot by confirming the acquired information. Here, in FIG. 22 and FIG. 23, “Partition 1” and “Partition 2” indicate time partitions, and “Task” indicates a task executed in Partition 1. The task executes a process that needs to be repeatedly executed at a constant cycle. In FIG. 22, the task is executed at a constant cycle by executing the task in Partition 1 that is active at a constant cycle. By doing in this way, for example, since control of the controlled object according to the monitoring result can be performed periodically, it becomes possible to perform more stable control of the controlled object.

しかしながら、図22に例示する場合において、一定周期でタスクが実行されるようにするためには、一定周期毎にタスクの実行が終了している必要がある。例えば、図23に例示するように、Partition 1の時間内にタスクの実行が終了していない場合、次にPartition 1がアクティブとなったときに、タスクは前回のPartition 1の時間の終了時に中断されたところからその実行を継続することになる。すなわち、この場合は、次にPartition 1がアクティブとなったときからタスクを再実行することができず、一定周期でタスクを実行することができなくなってしまう。したがって、一定周期でタスクを実行できていることを保障するためには、タイムパーティションの時間内にタスクを実行終了することができているか否かを監視することを可能とする必要がある。   However, in the case illustrated in FIG. 22, in order to execute the task at a constant cycle, it is necessary to finish the task execution at every constant cycle. For example, as shown in FIG. 23, if the task has not finished executing within the time of Partition 1, the task will be interrupted at the end of the previous Partition 1 time when Partition 1 becomes active next time. The execution will continue from where it was done. That is, in this case, the task cannot be re-executed from the next time Partition 1 becomes active, and the task cannot be executed at a constant cycle. Therefore, in order to ensure that the task can be executed at a constant cycle, it is necessary to be able to monitor whether or not the task can be completed within the time partition.

本発明は、上述した知見に基づいてなされたものであって、タイムパーティションの時間内にタスクを実行終了することができているか否かを監視することが可能となる制御装置及び制御方法を提供することを目的とする。   The present invention has been made based on the above-described knowledge, and provides a control device and a control method capable of monitoring whether or not the task can be completed within the time partition time. The purpose is to do.

本発明の第1の態様にかかる制御装置は、制御対象の制御に関する処理を行う制御関連タスクが実行される制御関連タイムパーティションを含む複数のタイムパーティションのスケジューリング内容を示すスケジューリング情報に従って、前記制御関連タスクをスケジューリングして実行するスケジューリング手段と、前記制御関連タスクの実行終了又は実行未終了を示す実行終了情報が格納される記憶部と、を備え、前記システムプログラムは、前記制御関連タイムパーティションに関する前記タイムパーティションの切り替え時に前記実行終了情報を実行未終了に更新するとともに、前記制御関連タスクの実行終了時に前記実行終了情報を実行終了に更新し、前記システムプログラムは、前記制御関連タイムパーティションに関する前記タイムパーティションの切り替え時に前記実行終了情報を実行未終了に更新する前に前記実行終了情報が実行未終了を示している場合を検出するものである。   The control device according to the first aspect of the present invention provides the control-related according to scheduling information indicating scheduling contents of a plurality of time partitions including a control-related time partition in which a control-related task for performing processing related to control of a control target is executed. Scheduling means for scheduling and executing a task, and a storage unit for storing execution end information indicating execution end or non-execution end of the control related task, and the system program relates to the control related time partition The execution end information is updated to non-execution at the time partition switching, and the execution end information is updated to execution end at the end of execution of the control-related task, and the system program relates to the control-related time partition. And it detects the case where the execution end information indicates the execution unfinished before updating the execution end information at the time of switching the im partitions run unfinished.

本発明の第2の態様にかかる制御方法は、制御対象の制御に関する処理を行う制御関連タスクが実行される制御関連タイムパーティションを含む複数のタイムパーティションのスケジューリング内容を示すスケジューリング情報に従って、前記制御関連タスクをプロセッサによってスケジューリングして実行する制御方法であって、前記プロセッサが、前記制御関連タイムパーティションに関する前記タイムパーティションの切り替え時に、前記制御関連タスクの実行終了又は実行未終了を示す実行終了情報を実行未終了に更新するステップと、前記プロセッサが、前記制御関連タスクの実行終了時に前記実行終了情報を実行終了に更新するステップと、前記プロセッサが、前記制御関連タイムパーティションに関する前記タイムパーティションの切り替え時に前記実行終了情報を前記制御関連タスクの実行未終了に更新する前に、前記実行終了情報が実行未終了を示している場合を検出するステップとを備えたものである。   The control method according to the second aspect of the present invention provides the control-related according to scheduling information indicating scheduling contents of a plurality of time partitions including a control-related time partition in which a control-related task that performs a process related to control of a control target is executed. A control method for scheduling and executing a task by a processor, wherein the processor executes execution end information indicating execution end or non-execution end of the control related task when switching the time partition related to the control related time partition Updating to non-finished, the processor updating the execution end information to end of execution at the end of execution of the control-related task, and the processor to the time partition related to the control-related time partition. The execution end information at the time of switching the emissions before updating to perform non-completion of the control-related tasks, in which a step of detecting if the execution end information indicates the execution unfinished.

上述した本発明の各態様によれば、タイムパーティションの時間内にタスクを実行終了することができているか否かを監視することが可能となる制御装置及び制御方法を提供することができる。   According to each aspect of the present invention described above, it is possible to provide a control device and a control method capable of monitoring whether or not the task can be completed within the time partition.

発明の実施の形態1にかかる安全制御装置の構成例を示すブロック図である。It is a block diagram which shows the structural example of the safety control apparatus concerning Embodiment 1 of invention. 発明の実施の形態1におけるタイム・パーティショニングの概念を説明するための図である。It is a figure for demonstrating the concept of the time partitioning in Embodiment 1 of invention. 発明の実施の形態1におけるリソース・パーティショニングの概念を説明するための概念図である。It is a conceptual diagram for demonstrating the concept of the resource partitioning in Embodiment 1 of invention. 発明の実施の形態1におけるパーティションスケジューラとタスクとの関係を示す図である。It is a figure which shows the relationship between the partition scheduler and task in Embodiment 1 of invention. スケジューリングパターンの具体例を示す図である。It is a figure which shows the specific example of a scheduling pattern. スケジューリングパターンの具体例を示す図である。It is a figure which shows the specific example of a scheduling pattern. 発明の実施の形態1にかかるパーティションスケジューラの処理手順の具体例を示すフローチャートである。It is a flowchart which shows the specific example of the process sequence of the partition scheduler concerning Embodiment 1 of invention. 発明の実施の形態1にかかるAPI関数wai_pswの処理手順の具体例を示すフローチャートである。It is a flowchart which shows the specific example of the process sequence of API function wai_psw concerning Embodiment 1 of invention. 発明の実施の形態1において、TPの時間内にタスクが実行終了した場合におけるタスクの実行状況の具体例を示す図である。In Embodiment 1 of this invention, it is a figure which shows the specific example of the execution condition of a task when execution of a task is completed within the time of TP. 発明の実施の形態1において、TPの時間内にタスクが実行終了しなかった場合におけるタスクの実行状況の具体例を示す図である。In Embodiment 1 of invention, it is a figure which shows the specific example of the execution condition of a task in case the execution of a task is not completed within the time of TP. 発明の実施の形態2におけるパーティションスケジューラとタスクとの関係を示す図である。It is a figure which shows the relationship between the partition scheduler and task in Embodiment 2 of invention. 発明の実施の形態2にかかるパーティションスケジューラの処理手順の具体例を示すフローチャートである。It is a flowchart which shows the specific example of the process sequence of the partition scheduler concerning Embodiment 2 of invention. 発明の実施の形態2にかかるAPI関数wai_pswの処理手順の具体例を示すフローチャートである。It is a flowchart which shows the specific example of the process sequence of API function wai_psw concerning Embodiment 2 of invention. 発明の実施の形態2において、TPの時間内にタスクが実行終了した場合におけるタスクの実行状況の具体例を示す図である。In Embodiment 2 of invention, it is a figure which shows the specific example of the execution condition of a task in case the execution of a task is completed within the time of TP. 発明の実施の形態2において、TPの時間内にタスクが実行終了しなかった場合におけるタスクの実行状況の具体例を示す図である。In Embodiment 2 of invention, it is a figure which shows the specific example of the execution condition of a task when a task does not complete | finish within the time of TP. 発明の実施の形態3におけるパーティションスケジューラとタスクとの関係を示す図である。It is a figure which shows the relationship between the partition scheduler and task in Embodiment 3 of invention. 発明の実施の形態3にかかるパーティションスケジューラの処理手順の具体例を示すフローチャートである。It is a flowchart which shows the specific example of the process sequence of the partition scheduler concerning Embodiment 3 of invention. 発明の実施の形態3にかかるAPI関数wai_pswの処理手順の具体例を示すフローチャートである。It is a flowchart which shows the specific example of the process sequence of API function wai_psw concerning Embodiment 3 of invention. 発明の実施の形態3において、TPの時間内にタスクが実行終了した場合におけるタスクの実行状況の具体例を示す図である。In Embodiment 3 of invention, it is a figure which shows the specific example of the execution condition of a task when execution of a task is completed within the time of TP. 発明の実施の形態3において、TPの時間内にタスクが実行終了した場合におけるタスクの実行状況の具体例を示す図である。In Embodiment 3 of invention, it is a figure which shows the specific example of the execution condition of a task when execution of a task is completed within the time of TP. その他の実施の形態にかかるパーティションスケジューラとタスクとの関係を示す図である。It is a figure which shows the relationship between the partition scheduler concerning other embodiment, and a task. その他の実施の形態にかかるパーティションスケジューラとタスクとの関係を示す図である。It is a figure which shows the relationship between the partition scheduler concerning other embodiment, and a task. 課題を説明するための図である。It is a figure for demonstrating a subject. 課題を説明するための図である。It is a figure for demonstrating a subject.

以下では、本発明を適用した具体的な実施の形態について、図面を参照しながら詳細に説明する。各図面において、同一要素には同一の符号が付されており、説明の明確化のため、必要に応じて重複説明は省略される。   Hereinafter, specific embodiments to which the present invention is applied will be described in detail with reference to the drawings. In the drawings, the same elements are denoted by the same reference numerals, and redundant description is omitted as necessary for the sake of clarity.

<発明の実施の形態1>
本実施の形態にかかる安全制御装置1は、サービスロボットや運輸機器等に搭載されて機能安全確保のための安全制御を実行する。安全制御装置1は、安全関連アプリケーションと非安全関連アプリケーションを同一のコンピュータシステムで実行するよう構成される。図1は、本実施の形態にかかる安全制御装置1の構成例を示すブロック図である。
<Embodiment 1 of the Invention>
The safety control device 1 according to the present embodiment is mounted on a service robot, a transportation device, or the like, and executes safety control for ensuring functional safety. The safety control device 1 is configured to execute a safety-related application and a non-safety-related application on the same computer system. FIG. 1 is a block diagram illustrating a configuration example of the safety control device 1 according to the present embodiment.

プロセッサ10は、プログラム(命令ストリーム)の取得、命令のデコード、命令のデコード結果に応じた演算処理を行う。なお、図1では、1つのプロセッサ10のみを示しているが、安全制御装置1は、複数のプロセッサ10を有するマルチプロセッサ構成であってもよい。また、プロセッサ10は、マルチコアプロセッサでもよい。プロセッサ10は、システムプログラムとしてのオペレーティングシステム(OS)100を実行することによりマルチプログラミング環境を提供する。マルチプログラミング環境とは、複数のプログラムを定期的に切り替えて実行したり、あるイベントの発生に応じて実行するプログラムを切り替えたりすることによって、複数のプログラムがあたかも並列実行されているような環境を意味する。   The processor 10 performs calculation processing according to acquisition of a program (instruction stream), instruction decoding, and instruction decoding result. Although only one processor 10 is shown in FIG. 1, the safety control device 1 may have a multiprocessor configuration having a plurality of processors 10. The processor 10 may be a multi-core processor. The processor 10 provides a multiprogramming environment by executing an operating system (OS) 100 as a system program. A multi-programming environment is an environment in which multiple programs are executed in parallel by periodically switching and executing multiple programs, or by switching the programs to be executed in response to the occurrence of a certain event. means.

マルチプログラミングは、マルチプロセス、マルチスレッド、マルチタスク等と呼ばれる場合もある。プロセス、スレッド及びタスクは、マルチプログラミング環境で並列実行されるプログラム単位を意味する。本実施の形態のプロセッサ10が具備するマルチプログラミング環境は、マルチプロセス環境でもよいし、マルチスレッド環境でもよい。   Multiprogramming is sometimes called multiprocess, multithread, multitask, and the like. A process, a thread, and a task mean a program unit that is executed in parallel in a multiprogramming environment. The multi-programming environment included in the processor 10 of the present embodiment may be a multi-process environment or a multi-thread environment.

実行用メモリ11は、プロセッサ10によるプログラム実行のために使用されるメモリである。実行用メモリ11には、不揮発性メモリ13からロードされたプログラム(OS100及びアプリケーション101〜103等)、プロセッサ10の入出力データ等が記憶される。なお、プロセッサ10は、プログラムを不揮発性メモリ13から実行用メモリ11にロードすることなく、これらのプログラムを不揮発性メモリ13から直接実行してもよい。   The execution memory 11 is a memory used for program execution by the processor 10. The execution memory 11 stores programs (such as the OS 100 and applications 101 to 103) loaded from the nonvolatile memory 13, input / output data of the processor 10, and the like. The processor 10 may directly execute these programs from the nonvolatile memory 13 without loading the programs from the nonvolatile memory 13 to the execution memory 11.

具体的には、実行用メモリ11は、SRAM(Static Random Access Memory)、DRAM(Dynamic Random Access Memory)等のランダムアクセス可能な揮発性メモリとすればよい。図1の実行用メモリ11は、論理的な構成単位を示している。すなわち、実行用メモリ11は、例えば、複数のSRAMデバイスの組み合わせ、複数のDRAMデバイスの組み合わせ、又はSRAMデバイスとDRAMデバイスの組み合わせでもよい。   Specifically, the execution memory 11 may be a random accessible volatile memory such as SRAM (Static Random Access Memory) or DRAM (Dynamic Random Access Memory). The execution memory 11 in FIG. 1 represents a logical unit. That is, the execution memory 11 may be, for example, a combination of a plurality of SRAM devices, a combination of a plurality of DRAM devices, or a combination of an SRAM device and a DRAM device.

I/Oポート12は、外部デバイスとの間のデータ送受信に使用される。例えば、安全制御装置1がサービスロボットに搭載される場合であれば、外部デバイスは、各種センサ及びサービスロボットを動作させるアクチュエータ等である。この場合、各種センサは、例えば、サービスロボット周囲の障害物を計測可能な視覚センサ、サービスロボットの姿勢を検知するための姿勢センサ、及びサービスロボットのアクチュエータの状態を検知するための回転センタ等のサービスロボットの内外の状態を検出するセンサを含む。   The I / O port 12 is used for data transmission / reception with an external device. For example, when the safety control device 1 is mounted on a service robot, the external device is various sensors and actuators that operate the service robot. In this case, the various sensors include, for example, a visual sensor capable of measuring obstacles around the service robot, a posture sensor for detecting the posture of the service robot, and a rotation center for detecting the state of the actuator of the service robot. It includes a sensor that detects the internal and external status of the service robot.

不揮発性メモリ13は、電力の供給を受けることなく、実行用メモリ11に比べて安定的に記憶内容を維持することが可能なメモリデバイスである。例えば、不揮発性メモリ13は、ROM(Read Only Memory)、フラッシュメモリ、ハードディスクドライブ若しくは光ディスクドライブ、又はこれらの組み合わせである。不揮発性メモリ13は、OS100及びアプリケーション101〜103を格納する。なお、不揮発性メモリ13の少なくとも一部は安全制御装置1から取り外し可能に構成されてもよい。例えば、アプリケーション101〜103が格納されたメモリを取り外し可能としてもよい。また、不揮発性メモリ13の少なくとも一部は、安全制御装置1の外部に配置されてもよい。   The non-volatile memory 13 is a memory device capable of maintaining stored contents more stably than the execution memory 11 without receiving power supply. For example, the nonvolatile memory 13 is a ROM (Read Only Memory), a flash memory, a hard disk drive or an optical disk drive, or a combination thereof. The nonvolatile memory 13 stores the OS 100 and the applications 101 to 103. Note that at least a part of the nonvolatile memory 13 may be configured to be removable from the safety control device 1. For example, the memory storing the applications 101 to 103 may be removable. Further, at least a part of the nonvolatile memory 13 may be disposed outside the safety control device 1.

OS100は、プロセッサ10によって実行されることにより、プロセッサ10及び実行用メモリ11及び不揮発性メモリ13等のハードウェア資源を利用して、タスクスケジューリングを含むタスク管理、割り込み管理、時間管理、資源管理、タスク間同期およびタスク間通信機構の提供等を行う。   The OS 100 is executed by the processor 10 to use task resources including task scheduling, interrupt management, time management, resource management using hardware resources such as the processor 10, the execution memory 11, and the nonvolatile memory 13. Provides inter-task synchronization and inter-task communication mechanism.

さらに、機能安全の確保に関連する安全監視アプリケーション101及び安全制御アプリケーション103の通常制御アプリケーション102からの独立性を高めるため、OS100は、ハードウェア資源を、時間的および空間的に保護する機能を有する。ここで、ハードウェア資源とは、プロセッサ10、実行用メモリ11、I/Oポート12を含む。   Further, in order to increase the independence of the safety monitoring application 101 and the safety control application 103 related to ensuring functional safety from the normal control application 102, the OS 100 has a function of protecting hardware resources temporally and spatially. . Here, the hardware resources include the processor 10, the execution memory 11, and the I / O port 12.

このうち、時間的な保護は、プロセッサ10の実行時間という時間的な資源をパーティショニングすることにより行う。具体的に述べると、時間的な保護は、プロセッサ10の実行時間をパーティショニングし、各パーティション(タイムパーティションと呼ぶ)にタスク(プロセス又はスレッド)を割り当てることにより行う。OS100のスケジューリング機能(パーティションスケジューラ21)は、各タイムパーティション(以下、TPと略称する場合がある。)に割り当てられたタスクに対して、プロセッサ10の実行時間を含む資源の利用を保証する。   Of these, temporal protection is performed by partitioning a temporal resource called the execution time of the processor 10. Specifically, temporal protection is performed by partitioning the execution time of the processor 10 and assigning a task (process or thread) to each partition (referred to as a time partition). The scheduling function (partition scheduler 21) of the OS 100 guarantees the use of resources including the execution time of the processor 10 for tasks assigned to each time partition (hereinafter sometimes referred to as TP).

図2は、タイム・パーティショニングに関する概念図である。図2の例では、予め定められた1サイクル時間を3つのTP1、TP2及びTP3に分割する例を示している。例えば、1サイクル時間を100Tickとした場合、このうち前半の20TickがTP1、中間の30TickがTP2、後半の50TickがTP3と規定される。   FIG. 2 is a conceptual diagram related to time partitioning. In the example of FIG. 2, an example in which a predetermined cycle time is divided into three TP1, TP2, and TP3 is shown. For example, when one cycle time is 100 Tick, the first 20 Tick is defined as TP1, the middle 30 Tick is defined as TP2, and the second 50 Tick is defined as TP3.

また、図2の例では、第1アプリケーション(APL1)〜第4アプリケーション(APL4)が、TP1〜TP3のいずれかに割り当てられている。OS100のスケジューリング機能(パーティションスケジューラ21)は、時間の経過に応じて、TP1〜TP3のいずれをアクティブにするかを選択・決定する。そして、アクティブなTPに割り当てられているアプリケーションが、プロセッサ10で実行される。   In the example of FIG. 2, the first application (APL1) to the fourth application (APL4) are assigned to any one of TP1 to TP3. The scheduling function (partition scheduler 21) of the OS 100 selects / determines which of TP1 to TP3 is activated as time elapses. Then, the application assigned to the active TP is executed by the processor 10.

一方、空間的な保護は、実行用メモリ11及びI/Oポート12を含む固定的な資源をパーティショニングし、各パーティション(リソースパーティションと呼ぶ)にタスクを割り当てることにより行う。OS100のスケジューリング機能(パーティションスケジューラ21)は、予め割り当てられたリソースパーティション(以下、RPと略称する場合がある。)を超えてタスクが他のリソースにアクセスすることを禁止する。   On the other hand, spatial protection is performed by partitioning fixed resources including the execution memory 11 and the I / O port 12 and assigning tasks to each partition (referred to as a resource partition). The scheduling function (partition scheduler 21) of the OS 100 prohibits a task from accessing other resources beyond a pre-assigned resource partition (hereinafter sometimes referred to as RP).

図3は、リソース・パーティショニングに関する概念図である。図3の例では、2つのRP(RP1及びRP2)を示している。RP1には、実行用メモリ11及び不揮発性メモリ13の一部(A領域)と、I/Oポート12の一部(ポートA)が割り当てられている。また、RP2には、実行用メモリ11及び不揮発性メモリ13の他の一部(B領域)と、I/Oポート12の他の一部(ポートB)が割り当てられている。RP1からはRP2に割り当てられたリソースへのアクセスが禁止され、RP2からはRP1に割り当てられたリソースへのアクセスが禁止される。   FIG. 3 is a conceptual diagram related to resource partitioning. In the example of FIG. 3, two RPs (RP1 and RP2) are shown. A part of the execution memory 11 and the nonvolatile memory 13 (A area) and a part of the I / O port 12 (port A) are allocated to RP1. Further, another part (B area) of the execution memory 11 and the nonvolatile memory 13 and another part (port B) of the I / O port 12 are allocated to RP2. Access from RP1 to the resource assigned to RP2 is prohibited, and access from RP2 to the resource assigned to RP1 is prohibited.

なお、全てのリソースがいずれかのRPに排他的に割り当てられる必要はない。つまり、複数のRPによって共有されるリソースがあってもよい。例えば、サービスロボットの安全制御を行う場合、アクチュエータには、通常制御アプリケーション102及び安全制御アプリケーション103の双方からアクセスできる必要がある。よって、通常制御アプリケーション102が属するRPと安全制御アプリケーション103が属するRPによって、アクチュエータを制御するためのI/Oポートを共有するとよい。   Note that not all resources need to be exclusively assigned to any RP. That is, there may be a resource shared by a plurality of RPs. For example, when performing safety control of a service robot, the actuator needs to be accessible from both the normal control application 102 and the safety control application 103. Therefore, the I / O port for controlling the actuator may be shared by the RP to which the normal control application 102 belongs and the RP to which the safety control application 103 belongs.

図1に戻り説明を続ける。アプリケーション101〜103は、OS100及びプロセッサ10によって提供されるマルチプログラミング環境で実行される。このうち、安全監視アプリケーション101は、通常制御アプリケーション102の実行状況の監視と、安全制御アプリケーション103の実行状況の監視と、I/Oポート12への入出力データの監視と、をプロセッサ10に実行させるための命令コードを含む。さらに、安全監視アプリケーション101は、パーティションスケジューラ21への結果通知をプロセッサ10に実行させるための命令コードを含む。つまり、安全監視アプリケーション101は、安全関連アプリケーションである。   Returning to FIG. The applications 101 to 103 are executed in a multiprogramming environment provided by the OS 100 and the processor 10. Among these, the safety monitoring application 101 executes the processor 10 to monitor the execution status of the normal control application 102, monitor the execution status of the safety control application 103, and monitor input / output data to the I / O port 12. Instruction code to make it Further, the safety monitoring application 101 includes an instruction code for causing the processor 10 to execute a result notification to the partition scheduler 21. That is, the safety monitoring application 101 is a safety related application.

また、通常制御アプリケーション102は、サービスロボット等の制御対象に通常の機能・動作を行わせるための制御手順をプロセッサ10に実行させるための命令コードを含む。さらに、通常制御アプリケーション102は、パーティションスケジューラ21への結果通知をプロセッサ10に実行させるための命令コードを含む。つまり、通常制御アプリケーション102は、非安全関連アプリケーションである。   Further, the normal control application 102 includes an instruction code for causing the processor 10 to execute a control procedure for causing a control target such as a service robot to perform a normal function / operation. Further, the normal control application 102 includes an instruction code for causing the processor 10 to execute a result notification to the partition scheduler 21. That is, the normal control application 102 is a non-safety related application.

また、安全制御アプリケーション103は、何らかの異常が検出された場合に対応して、機能安全を確保するために定められた制御手順をプロセッサ10に実行させるための命令コードを含む。さらに、安全制御アプリケーション103は、パーティションスケジューラ21への結果通知をプロセッサ10に実行させるための命令コードを含む。つまり、安全制御アプリケーション103は、安全関連アプリケーションである。   Further, the safety control application 103 includes an instruction code for causing the processor 10 to execute a control procedure determined to ensure functional safety in response to a case where some abnormality is detected. Further, the safety control application 103 includes an instruction code for causing the processor 10 to execute a result notification to the partition scheduler 21. That is, the safety control application 103 is a safety-related application.

リセット回路14は、OS100からの信号に基づき、マイクロコントローラ15のリセットを行う。パーティションスケジューラ21からリセット回路14に定期的に送信信号を送信するようにし、リセット回路14は、パーティションスケジューラ21からの送信信号が途絶えた場合に、マイクロコントローラ15をリセットする。例えば、パーティションスケジューラ21は、後述するように、1Tickごとに動作するタイミングで送信信号を送信する。また、OS100で異常を検知した場合、又は、アプリケーション101〜103のいずれかから異常を示す結果通知を受けた場合に、パーティションスケジューラ21がリセット回路14にリセット信号を送信するようにして、それに応じて、リセット回路14がマイクロコントローラ15をリセットするようにしてもよい。このようにすることで、マイクロコントローラ15に不具合が発生した場合に、マイクロコントローラ15をリセットして復旧することができる。   The reset circuit 14 resets the microcontroller 15 based on a signal from the OS 100. A transmission signal is periodically transmitted from the partition scheduler 21 to the reset circuit 14, and the reset circuit 14 resets the microcontroller 15 when the transmission signal from the partition scheduler 21 is interrupted. For example, as will be described later, the partition scheduler 21 transmits a transmission signal at a timing that operates every 1 tick. Further, when an abnormality is detected by the OS 100 or when a result notification indicating an abnormality is received from any of the applications 101 to 103, the partition scheduler 21 transmits a reset signal to the reset circuit 14 and responds accordingly. Thus, the reset circuit 14 may reset the microcontroller 15. In this way, when a failure occurs in the microcontroller 15, the microcontroller 15 can be reset and recovered.

続いて以下では、パーティションスケジューラ21と、アプリケーション101〜103の起動により生成されるタスクと、の関係について、図4を用いて説明する。図4は、OS100によって提供されるマルチプログラミング環境で起動される、パーティションスケジューラ21とタスク24、26、28との関係を示す図である。   Subsequently, the relationship between the partition scheduler 21 and the tasks generated by the activation of the applications 101 to 103 will be described with reference to FIG. FIG. 4 is a diagram showing the relationship between the partition scheduler 21 and the tasks 24, 26, and 28 that are activated in the multiprogramming environment provided by the OS 100.

マイクロコントローラ15は、プロセッサ10、実行用メモリ11、I/Oポート12、不揮発性メモリ13等を含む。なお、図4では、マイクロコントローラ15の外部にリセット回路14を備える構成を例示しているが、マイクロコントローラ15の内部にリセット回路14を含む構成としてもよい。   The microcontroller 15 includes a processor 10, an execution memory 11, an I / O port 12, a nonvolatile memory 13, and the like. 4 illustrates a configuration in which the reset circuit 14 is provided outside the microcontroller 15, but a configuration in which the reset circuit 14 is included in the microcontroller 15 may be employed.

マイクロコントローラ15には、外部のクロック源からのクロック信号が供給され、プロセッサ10等は、このクロック信号に基づく所定のタイマー周期で動作する。本実施の形態では、所定のタイマー周期を、1Tickであるとして説明する。このため、プロセッサ10によりOS100が実行されることで、パーティションスケジューラ21が1Tickごとに動作すると共に、各TPにおいて、タスクスケジューラ23、25、27およびタスク(安全監視タスク24、通常制御タスク26、安全制御タスク28)が1Tickごとに動作する。   The microcontroller 15 is supplied with a clock signal from an external clock source, and the processor 10 and the like operate at a predetermined timer period based on this clock signal. In the present embodiment, the predetermined timer cycle is described as 1 Tick. For this reason, when the processor 10 executes the OS 100, the partition scheduler 21 operates every 1 Tick, and at each TP, the task schedulers 23, 25, 27 and tasks (safety monitoring task 24, normal control task 26, safety The control task 28) operates every 1 Tick.

パーティションスケジューラ21は、1Tickごとに動作し、TPの切り替え(パーティション・スケジューリング)を行う。パーティションスケジューラ21は、次の1Tickの間にTP1〜TP3のいずれをアクティブにするかを選択・決定する。さらに、パーティションスケジューラ21は、選択したTPに関するタスクスケジューラの動作を開始させる。   The partition scheduler 21 operates every 1 tick and performs TP switching (partition scheduling). The partition scheduler 21 selects and determines which of TP1 to TP3 is activated during the next 1 Tick. Furthermore, the partition scheduler 21 starts the operation of the task scheduler related to the selected TP.

パーティションスケジューラ21によるパーティション・スケジューリングについて具体的に述べると、パーティションスケジューラ21は、スケジューリングテーブル22を参照し、TPの設定を定めたスケジューリングパターンに従って、パーティション・スケジューリングを行う。   More specifically, partition scheduling by the partition scheduler 21 refers to the scheduling table 22 and performs partition scheduling according to a scheduling pattern that defines TP settings.

スケジューリングテーブル22は、TPの切り替え順序およびタイミングを規定したスケジューリングパターンを保持している。スケジューリングテーブル22は、例えば、実行用メモリ11に予め格納されている。なお、スケジューリングテーブル22は、少なくとも2つの異なるスケジューリングパターンを保持している。1つは、安全監視タスク24による異常検知が行われていない場合(つまり通常時)に適用されるスケジューリングパターンである。もう1つは、安全監視タスク24によって異常が検知された場合に適用されるスケジューリングパターンである。以下では、通常時に適用されるスケジューリングパターンを"通常制御スケジューリングパターン"と呼ぶ。また、異常検知時に適用されるスケジューリングパターンを"安全制御スケジューリングパターン"と呼ぶ。   The scheduling table 22 holds a scheduling pattern that defines the TP switching order and timing. For example, the scheduling table 22 is stored in advance in the execution memory 11. The scheduling table 22 holds at least two different scheduling patterns. One is a scheduling pattern that is applied when abnormality detection by the safety monitoring task 24 is not performed (that is, during normal time). The other is a scheduling pattern applied when an abnormality is detected by the safety monitoring task 24. Hereinafter, the scheduling pattern applied in the normal time is referred to as “normal control scheduling pattern”. A scheduling pattern applied at the time of detecting an abnormality is called a “safe control scheduling pattern”.

図5Aは、通常制御スケジューリングパターンの具体例を示している。図5Aでは、通常制御タスク26が属するTP2が1サイクル時間の前半(T1)に割り当てられている。また、安全監視タスク24が属するTP1が1サイクル時間の後半(T2)に割り当てられている。図5Aのスケジューリングパターンによれば、通常制御タスク26と安全監視タスク24が繰り返しスケジューリングされる。   FIG. 5A shows a specific example of the normal control scheduling pattern. In FIG. 5A, TP2 to which the normal control task 26 belongs is assigned to the first half (T1) of one cycle time. In addition, TP1 to which the safety monitoring task 24 belongs is assigned to the second half (T2) of one cycle time. According to the scheduling pattern of FIG. 5A, the normal control task 26 and the safety monitoring task 24 are repeatedly scheduled.

図5Bは、安全制御スケジューリングパターンの具体例を示している。図5Bでは、安全制御タスク28が属するTP3が1サイクル時間の前半(T3)に割り当てられている。また、安全監視タスク24が属するTP1が1サイクル時間の後半(T4)に割り当てられている。図5Bのスケジューリングパターンによれば、安全制御タスク28と安全監視タスク24が繰り返しスケジューリングされる。   FIG. 5B shows a specific example of the safety control scheduling pattern. In FIG. 5B, TP3 to which the safety control task 28 belongs is assigned to the first half (T3) of one cycle time. In addition, TP1 to which the safety monitoring task 24 belongs is assigned to the second half (T4) of one cycle time. According to the scheduling pattern of FIG. 5B, the safety control task 28 and the safety monitoring task 24 are repeatedly scheduled.

図4に戻り説明を続ける。タスクスケジューラ23、25、27は、それぞれが属するTP内でのタスクのスケジューリングを行う。各TP内でのタスクのスケジューリングには、一般的な優先度ベースのスケジューリングを適用すればよい。なお、図4では、各TPはそれぞれ1つのタスクのみを含むものとして図示しているが、1以上のタスクが含まれるようにしてもよい。例えば、通常制御用のTP2内には、通常制御タスクA及び通常制御タスクBの2つのタスクが含まれていてもよい。   Returning to FIG. The task schedulers 23, 25, and 27 perform task scheduling in the TP to which each belongs. For scheduling tasks in each TP, general priority-based scheduling may be applied. In FIG. 4, each TP is illustrated as including only one task, but one or more tasks may be included. For example, the normal control task A and the normal control task B may be included in the normal control TP2.

安全監視タスク24は、安全監視アプリケーション101の起動によって生成されるタスクである。図4の例では、安全監視タスク24は、TP1及びRP1に割り当てられている。安全監視タスク24は、非安全関連アプリケーションである通常制御タスク26の実行状況の監視と、安全関連アプリケーションである安全制御タスク28の実行状況の監視と、I/Oポート12の入出力データを監視する。さらに、安全監視タスク24は、タスクの実行状況を、パーティションスケジューラ21へ通知する。   The safety monitoring task 24 is a task generated when the safety monitoring application 101 is activated. In the example of FIG. 4, the safety monitoring task 24 is assigned to TP1 and RP1. The safety monitoring task 24 monitors the execution status of the normal control task 26 that is a non-safety related application, monitors the execution status of the safety control task 28 that is a safety related application, and monitors input / output data of the I / O port 12. To do. Furthermore, the safety monitoring task 24 notifies the partition scheduler 21 of the task execution status.

通常制御タスク26は、通常制御アプリケーション102の起動によって生成されるタスクである。図4の例では、通常制御タスク26は、TP2及びRP2に割り当てられている。通常制御タスク26は、サービスロボット等の制御対象に通常の機能・動作を行わせるための制御を行う。さらに、通常制御タスク26は、タスクの実行状況を、パーティションスケジューラ21へ通知する。   The normal control task 26 is a task generated when the normal control application 102 is activated. In the example of FIG. 4, the normal control task 26 is assigned to TP2 and RP2. The normal control task 26 performs control for causing a control target such as a service robot to perform a normal function / operation. Further, the normal control task 26 notifies the partition scheduler 21 of the task execution status.

安全制御タスク28は、安全制御アプリケーション103の起動によって生成されるタスクである。図4の例では、安全制御タスク28は、TP3及びRP3に割り当てられている。安全制御タスク28は、何らかの異常が検出された場合に対応して、機能安全を確保するために定められた制御を行う。さらに、安全制御タスク28は、タスクの実行状況を、パーティションスケジューラ21へ通知する。   The safety control task 28 is a task generated when the safety control application 103 is activated. In the example of FIG. 4, the safety control task 28 is assigned to TP3 and RP3. The safety control task 28 performs control determined to ensure functional safety in response to any abnormality being detected. Further, the safety control task 28 notifies the partition scheduler 21 of the task execution status.

なお、各タスクからパーティションスケジューラ21へと結果を通知する具体的な構成としては、様々な手法を採用することができる。例えば、タスクがOS100のシステムコール(サービスコール)を呼び出し、OS100を介して、パーティションスケジューラ21に結果を通知することができる。具体的には、例えば、タスク間通信を行うシステムコールを呼び出す。また、例えば、タスクの実行状況に関するフラグを実行用メモリ11に格納するものとして、タスクがその実行状況に応じてフラグの値を設定し、パーティションスケジューラ21がフラグの設定値に応じてタスクの実行状況を判断することもできる。   Various methods can be adopted as a specific configuration for notifying the result from each task to the partition scheduler 21. For example, a task can call a system call (service call) of the OS 100 and notify the partition scheduler 21 of the result via the OS 100. Specifically, for example, a system call for performing communication between tasks is called. Also, for example, assuming that a flag related to the task execution status is stored in the execution memory 11, the task sets a flag value according to the execution status, and the partition scheduler 21 executes the task according to the flag set value. The situation can also be judged.

ここで、OS100は、各タスク24、26、28に対して、次回にタスクが属するタイムパーティションがアクティブとなるまで、そのタスクを実行終了してスリープさせるAPI(Application Program Interface)関数を提供する。したがって、一定周期でアクティブとなるTPに属するタスクに、このAPI関数を呼び出してスリープさせるようにすることで、そのタスクが一定周期で実行されるようにすることができる。以下、このAPI関数を「wai_psw」と記載する。   Here, the OS 100 provides an API (Application Program Interface) function that causes each task 24, 26, and 28 to end execution and sleep until the time partition to which the task belongs next becomes active. Therefore, a task belonging to a TP that becomes active at a constant cycle can be made to execute at a constant cycle by calling this API function to sleep. Hereinafter, this API function is referred to as “wai_psw”.

wai_pswフラグ29は、タスク24、26、28のそれぞれに対応するように、複数用意される。wai_pswフラグ29は、例えば、実行用メモリ11に格納される。wai_pswフラグ29は、「OK」又は「NG」のいずれかを示す値をとる変数である。wai_pswフラグ29がOKである場合、そのwai_pswフラグ29に対応するタスクが実行終了していることを意味する。一方、wai_pswフラグ29がNGである場合、そのwai_pswフラグ29に対応するタスクが実行終了していないことを意味する。   A plurality of wai_psw flags 29 are prepared so as to correspond to the tasks 24, 26, and 28, respectively. The wai_psw flag 29 is stored in the execution memory 11, for example. The wai_psw flag 29 is a variable that takes a value indicating either “OK” or “NG”. If the wai_psw flag 29 is OK, it means that the task corresponding to the wai_psw flag 29 has been executed. On the other hand, if the wai_psw flag 29 is NG, it means that the task corresponding to the wai_psw flag 29 has not finished executing.

wai_pswフラグ29は、初期値がOKを示す値になっている。パーティションスケジューラ21は、TPがアクティブになったときに、そのTPに属するタスクに対応するwai_pswフラグ29をNGに更新する。そして、各タスク24、26、28のそれぞれは、TP内で実行すべき処理を実行終了したとき、wai_pswを呼び出すことによって、スリープするとともにwai_pswフラグ29をOKに更新する。つまり、wai_pswには、呼び出し元のタスクに対応するwai_pswフラグ29をOKに更新する処理が含まれている。これらの処理によれば、次にTPがアクティブとなったときにwai_pswフラグ29がOKであれば、前回のTPの時間内にタスクが実行終了していたこと分かり、次にTPがアクティブとなったときにwai_pswフラグ29がNGであれば、前回のTPの時間内にタスクが実行終了していなかったことが分かる。   The initial value of the wai_psw flag 29 is a value indicating OK. When the TP becomes active, the partition scheduler 21 updates the wai_psw flag 29 corresponding to the task belonging to the TP to NG. Each of the tasks 24, 26, and 28 sleeps and updates the wai_psw flag 29 to OK by calling wai_psw when the processing to be executed in the TP is finished. That is, wai_psw includes processing for updating the wai_psw flag 29 corresponding to the caller task to OK. According to these processes, if the wai_psw flag 29 is OK when the TP becomes active next, it means that the task has been executed within the time of the previous TP, and the TP becomes active next. If the wai_psw flag 29 is NG at this time, it is understood that the task has not been completed within the time of the previous TP.

ここで、wai_pswフラグ29は、例えば、OKを示す値を0とし、NGを示す値を1としてもよく、OKを示す値を1とし、NGを示す値を0としてもよい。また、wai_pswフラグ29は、OK又はNGを示す情報であれば、フラグのように2値化された情報に限られない。   Here, for example, the wai_psw flag 29 may have a value indicating OK as 0, a value indicating NG as 1, a value indicating OK as 1, and a value indicating NG as 0. The wai_psw flag 29 is not limited to binarized information as long as it is information indicating OK or NG.

起床フラグ30は、タスク24、26、28のそれぞれに対応するように、複数用意される。起床フラグ30は、例えば、実行用メモリ11に格納される。起床フラグ30は、「E_OK」又は「E_TMOUT」のいずれかを示す値をとる変数である。起床フラグ30がE_OKである場合、その起床フラグ30に対応するタスクが、そのタスクが属するTPの時間内に実行終了できていたことを意味する。起床フラグ30がE_TMOUTである場合、その起床フラグ30に対応するタスクが、そのタスクが属するTPの時間内に実行終了できていなかったことを意味する。   A plurality of wake-up flags 30 are prepared so as to correspond to the tasks 24, 26, and 28, respectively. The wakeup flag 30 is stored in the execution memory 11, for example. The wake-up flag 30 is a variable that takes a value indicating either “E_OK” or “E_TMOUT”. When the wakeup flag 30 is E_OK, it means that the task corresponding to the wakeup flag 30 has been completed within the time of the TP to which the task belongs. When the wakeup flag 30 is E_TMOUT, it means that the task corresponding to the wakeup flag 30 has not been completed within the time of the TP to which the task belongs.

起床フラグ30は、初期値がE_OKを示す値になっている。パーティションスケジューラ21は、TPがアクティブになったときに、そのTPに属するタスクに対応するwai_pswフラグ29がNGである場合、そのタスクに対応する起床フラグ30をE_TMOUTに更新する。これによって、起床フラグ30がE_TMOUTに更新されている場合、その起床フラグ30に対応するタスクがTPの時間内に実行終了できていなかったことが分かる。   The initial value of the wake-up flag 30 is a value indicating E_OK. If the wai_psw flag 29 corresponding to the task belonging to the TP is NG when the TP becomes active, the partition scheduler 21 updates the wake-up flag 30 corresponding to the task to E_TMOUT. As a result, when the wakeup flag 30 is updated to E_TMOUT, it can be seen that the task corresponding to the wakeup flag 30 has not been completed within the TP time.

wai_pswは、呼び出し元のタスクに対応する起床フラグ30がE_OKある場合、E_OKを示す値を戻り値として呼び出し元のタスクに返す。一方、wai_pswは、呼び出し元のタスクに対応する起床フラグ30がE_TMOUTである場合、E_TMOUTを示す値を戻り値として呼び出し元のタスクに返す。この戻り値は、wai_pswを呼び出してスリープしていたタスクが起床してwai_pswから復帰するときに、そのタスクに返される。これによって、呼び出し元のタスクは、wai_pswからの戻り値がE_OKである場合、TPの時間内に自身が実行終了できていたことを認識することができる。逆に、呼び出し元のタスクは、wai_pswからの戻り値がE_TMOUTである場合、TPの時間内に自身が実行終了できていなかったことを認識することができる。   When the wakeup flag 30 corresponding to the caller task is E_OK, wai_psw returns a value indicating E_OK to the caller task as a return value. On the other hand, when the wakeup flag 30 corresponding to the caller task is E_TMOUT, wai_psw returns a value indicating E_TMOUT to the caller task as a return value. This return value is returned to a task that has been sleeping by calling wai_psw and wakes up and returns from wai_psw. As a result, when the return value from wai_psw is E_OK, the calling task can recognize that it has finished executing within the time of TP. Conversely, when the return value from wai_psw is E_TMOUT, the caller task can recognize that it has not completed execution within the TP time.

そして、呼び出し元のタスクは、wai_pswからの戻り値に応じた処理を実行する。例えば、wai_pswからの戻り値がE_OKである場合、呼び出し元のタスクは、通常の処理を実行する。逆に、wai_pswからの戻り値がE_TMOUTである場合、呼び出し元のタスクは、異常処置を実行する。ここで、異常処置は、制御対象を安全な方向に動作させるための処置であればどのようなものであってもよい。例えば、図5Aに示す通常制御スケジューリングパターンに従って動作している場合、呼び出し元のタスクは、タスクの実行状況が異常である旨をパーティションスケジューラ21に通知する。そして、パーティションスケジューラ21は、その通知に応じて、スケジューリングパターンを、図5Bに示す安全制御スケジューリングパターンに切り替えるようにしてもよい。また、パーティションスケジューラ21は、その通知に応じて、次の動作タイミングで、TPを強制的にTP3に切り替えるようにしてもよい。そして、TP3へ切り替えた後は、例えば、安全制御タスク28によって制御対象を停止させる。また、パーティションスケジューラ21は、タスクの実行状況が異常である旨の通知を安全制御タスク28から通知された場合、パーティションスケジューラ21自身が、制御対象を停止させるように制御するようにしてもよい。   Then, the caller task executes processing according to the return value from wai_psw. For example, when the return value from wai_psw is E_OK, the calling task executes normal processing. On the other hand, when the return value from wai_psw is E_TMOUT, the calling task executes an abnormality treatment. Here, the abnormality treatment may be any treatment as long as it is a treatment for moving the controlled object in a safe direction. For example, when operating according to the normal control scheduling pattern shown in FIG. 5A, the calling task notifies the partition scheduler 21 that the task execution status is abnormal. Then, the partition scheduler 21 may switch the scheduling pattern to the safety control scheduling pattern shown in FIG. 5B according to the notification. Further, the partition scheduler 21 may forcibly switch TP to TP3 at the next operation timing according to the notification. Then, after switching to TP3, for example, the control target is stopped by the safety control task 28. Further, the partition scheduler 21 may control the partition scheduler 21 to stop the control target when notified from the safety control task 28 that the task execution status is abnormal.

ここで、起床フラグ30及び戻り値のそれぞれは、例えば、E_OKを示す値を0とし、E_TMOUTを示す値を1としてもよく、E_OKを示す値を1とし、E_TMOUTを示す値を0としてもよい。また、起床フラグ30及び戻り値のそれぞれは、E_OK又はE_TMOUTを示す情報であれば、フラグのように2値化された情報に限られない。さらに、起床フラグ30と戻り値とで、E_OKを示す値及びE_TMOUTを示す値のそれぞれが異なる値で定義されていてもよい。   Here, for each of the wake-up flag 30 and the return value, for example, the value indicating E_OK may be 0, the value indicating E_TMOUT may be 1, the value indicating E_OK may be 1, and the value indicating E_TMOUT may be 0. . Further, each of the wakeup flag 30 and the return value is not limited to the binarized information as long as it is information indicating E_OK or E_TMOUT. Further, the value indicating E_OK and the value indicating E_TMOUT may be defined as different values for the wakeup flag 30 and the return value.

上述したように、パーティションスケジューラ21が1Tickごとに動作し、TP1〜TP3のいずれをアクティブにするかを選択・決定する。さらに、パーティションスケジューラ21が、選択したTPに関するタスクスケジューラの動作を開始させる。そして、タスクスケジューラ23、25、27が動作を開始することでタスクのスケジューリングが行われ、プロセッサ10が、タスクスケジューラ23、25、27によりスケジューリングされた順序に従って、TP内でのタスクを実行していく。これによって、アクティブなTPに割り当てられているアプリケーションが、プロセッサ10で実行される。   As described above, the partition scheduler 21 operates every 1 Tick, and selects and determines which of TP1 to TP3 is activated. Further, the partition scheduler 21 starts the operation of the task scheduler related to the selected TP. Then, task scheduling is performed by the task schedulers 23, 25, and 27 starting operations, and the processor 10 executes the tasks in the TP according to the order scheduled by the task schedulers 23, 25, and 27. Go. As a result, the application assigned to the active TP is executed by the processor 10.

続いて以下では、パーティションスケジューラ21によるパーティション・スケジューリング処理及びフラグ制御処理について、図6を用いて説明する。図6は、発明の実施の形態1にかかるパーティションスケジューラ21の処理手順の具体例を示すフローチャートである。   Subsequently, partition scheduling processing and flag control processing by the partition scheduler 21 will be described below with reference to FIG. FIG. 6 is a flowchart showing a specific example of the processing procedure of the partition scheduler 21 according to the first embodiment of the invention.

なお、図6では、通常制御スケジューリングパターン(例えば図5A)または安全制御スケジューリングパターン(例えば図5B)に従って、スケジューリングを実行する場合を例に説明する。すなわち、TP2またはTP3に続く次のTPはTP1であり、かつ、TP2での異常がTP1で検知された場合に、TP1からの結果を受けて次に選択・決定されるTPはTP3である場合を例に説明する。   Note that FIG. 6 illustrates an example in which scheduling is performed according to a normal control scheduling pattern (for example, FIG. 5A) or a safety control scheduling pattern (for example, FIG. 5B). That is, when the next TP following TP2 or TP3 is TP1, and when an abnormality in TP2 is detected in TP1, the next TP selected and determined based on the result from TP1 is TP3 Will be described as an example.

OS100は、1Tick経過するごとに(S11)、パーティションスケジューラ21を起動する(S12)。パーティションスケジューラ21は、スケジューリングパターンを参照して、TPの切り替えタイミングか否かを判定する(S13)。   The OS 100 starts the partition scheduler 21 every time one tick elapses (S11) (S12). The partition scheduler 21 refers to the scheduling pattern and determines whether or not it is TP switching timing (S13).

TPの切り替えタイミングでないと判定した場合(S13でNo)、パーティションスケジューラ21は、同一のTPXについての動作を継続させて、S19に進む。このため、TPの切り替えタイミングとなるまでの間、S11〜S13、S19、S20の処理が繰り返される。ここで、変数XはTPの番号を示し、Xは1〜3のうちのいずれかの値となる。すなわち、通常制御スケジューリングパターンに従ってパーティション・スケジューリングを実施している場合は、安全制御用のTP3を除いた、TP2又はTP1のいずれかを動作させる。   When it is determined that it is not the TP switching timing (No in S13), the partition scheduler 21 continues the operation for the same TPX and proceeds to S19. For this reason, the processes of S11 to S13, S19, and S20 are repeated until the TP switching timing is reached. Here, the variable X indicates the number of TP, and X is any one of 1 to 3. That is, when partition scheduling is performed according to the normal control scheduling pattern, either TP2 or TP1 except for TP3 for safety control is operated.

一方、TPの切り替えタイミングであると判定した場合(S13でYes)、パーティションスケジューラ21は、TPの切り替えを実行する(S14)。このように、パーティションスケジューラ21は、次にアクティブにするTPを変更する(S13でYes)場合には、さらに、切り替え前のTPに属するタスクからの通知結果に応じて、タスクの実行状況が正常であったか否かを判断する。判断の結果、タスクの実行状況が異常であった場合、パーティションスケジューラ21は、次の1Tickの間にアクティブにするTPを、安全制御スケジューリングパターンに従って選択・決定する。そして、パーティションスケジューラ21は、切り替え先のTPに属するタスクに対応するwai_pswフラグ29がOKか否かを判定する(S15)。   On the other hand, when it is determined that it is TP switching timing (Yes in S13), the partition scheduler 21 executes TP switching (S14). Thus, when the partition scheduler 21 changes the TP to be activated next (Yes in S13), the task execution status is normal according to the notification result from the task belonging to the TP before switching. It is determined whether or not. If the task execution status is abnormal as a result of the determination, the partition scheduler 21 selects and determines a TP to be activated during the next 1 Tick according to the safety control scheduling pattern. Then, the partition scheduler 21 determines whether or not the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is OK (S15).

切り替え先のTPに属するタスクに対応するwai_pswフラグ29がOKである場合(S15でYes)、切り替え先のTPが前回にアクティブだったときに、そのTPの時間内で、そのwai_pswフラグ29に対応するタスクが実行終了していたことを意味する。そのため、パーティションスケジューラ21は、そのタスクに対応する起床フラグ30をE_OKに更新する(S16)。そして、パーティションスケジューラ21は、S18に進む。   When the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is OK (Yes in S15), when the switching destination TP was last active, the wai_psw flag 29 is supported within the time of the TP. This means that the task to be executed has ended. Therefore, the partition scheduler 21 updates the wakeup flag 30 corresponding to the task to E_OK (S16). Then, the partition scheduler 21 proceeds to S18.

一方、切り替え先のTPに属するタスクに対応するwai_pswフラグ29がOKでない場合(S15でNo)、切り替え先のTPが前回にアクティブだったときに、そのTPの時間内で、そのwai_pswフラグ29に対応するタスクが実行終了していなかったことを意味する。そのため、パーティションスケジューラ21は、そのタスクに対応する起床フラグ30をE_TMOUTに更新する(S17)。すなわち、切り替え先のTPに属するタスクに対応するwai_pswフラグ29がNGである場合に、S17を実行する。そして、パーティションスケジューラ21は、S18に進む。   On the other hand, if the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is not OK (No in S15), when the switching destination TP was previously active, the wai_psw flag 29 is set within the time of the TP. This means that the corresponding task has not finished executing. Therefore, the partition scheduler 21 updates the wakeup flag 30 corresponding to the task to E_TMOUT (S17). That is, when the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is NG, S17 is executed. Then, the partition scheduler 21 proceeds to S18.

S18では、パーティションスケジューラ21は、切り替え先のTPに属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。これによれば、切り替え先のTPでタスクが実行終了するためにwai_pswを呼び出してwai_pswフラグ29をOKに更新しなかった場合に、wai_pswフラグ29がNGのままとなる。すなわち、切り替え先のTPの時間内にタスクが実行終了しなかったことを、次回にその切り替え先のTPがアクティブとなったときのwai_pswフラグ29の値によって判定すること(S15)が可能となる。そして、パーティションスケジューラ21は、S19に進む。なお、S15〜S18の処理は、TP内に複数のタスクが属している場合、その複数のタスクに対応するwai_pswフラグ29及び起床フラグ30のそれぞれに対して行われることになる。   In S18, the partition scheduler 21 updates the wai_psw flag 29 corresponding to the task belonging to the switching destination TP to NG (S18). According to this, when the wai_psw is called and the wai_psw flag 29 is not updated to OK because the task finishes executing at the switching destination TP, the wai_psw flag 29 remains NG. That is, it is possible to determine from the value of the wai_psw flag 29 when the switching destination TP becomes active next time that the task has not finished executing within the time of the switching destination TP (S15). . Then, the partition scheduler 21 proceeds to S19. Note that when a plurality of tasks belong to the TP, the processes of S15 to S18 are performed for each of the wai_psw flag 29 and the wake-up flag 30 corresponding to the plurality of tasks.

S19では、パーティションスケジューラ21は、現在アクティブになっているTPXのタスクスケジューラを動作させる(S19)。S19で動作を開始したTPXのタスクスケジューラは、TPX内のタスクを優先度に応じて実行する(S20)。   In S19, the partition scheduler 21 operates the task scheduler of the currently active TPX (S19). The task scheduler of TPX that started the operation in S19 executes the task in TPX according to the priority (S20).

具体的には、TPXのタスクスケジューラは、スリープしていたTPX内のタスクを優先度に応じた順番で起床させる。起床したタスクは、wai_pswから復帰する。このとき、起床したタスクは、上述したようにwai_pswの戻り値に応じた処理を実行する。すなわち、wai_pswからの戻り値がE_OKである場合、起床したタスクがTPの時間内に実行終了できていたことになるため、通常の処理を実行する。逆に、wai_pswからの戻り値がE_TMOUTである場合、起床したタスクがTPの時間内に実行終了できていなかったことになるため、タスクの実行状況が異常である旨をパーティションスケジューラ21に通知する処理を実行する。そして、これらのTP内で実行すべき処理が終了した場合、タスクは、wai_pswを呼び出して再びスリープする。なお、wai_pswにおけるフラグ制御処理の処理手順については、図7を参照して後述する。   Specifically, the task scheduler of TPX wakes up the tasks in TPX that have been sleeping in the order corresponding to the priority. The task that wakes up returns from wai_psw. At this time, the task that wakes up executes processing according to the return value of wai_psw as described above. That is, when the return value from wai_psw is E_OK, the wake-up task has been completed within the time of TP, so normal processing is executed. Conversely, if the return value from wai_psw is E_TMOUT, it means that the task that woke up has not finished executing within the time of TP, so the partition scheduler 21 is notified that the task execution status is abnormal. Execute the process. When the processing to be executed in these TPs is completed, the task calls wai_psw and sleeps again. Note that the processing procedure of the flag control processing in wai_psw will be described later with reference to FIG.

そして、1Tickが経過すると(S11)、パーティションスケジューラ21が、再びTPのスケジューリングを開始する(S12)。すなわち、パーティションスケジューラ21は、スケジューリングパターンに従って、次の1Tickの間にいずれのTPをアクティブにするかを選択・決定する。   When 1 Tick elapses (S11), the partition scheduler 21 starts TP scheduling again (S12). That is, the partition scheduler 21 selects and determines which TP is to be activated during the next 1 Tick according to the scheduling pattern.

続いて以下では、タスクにおけるフラグ制御処理について、図7を用いて説明する。図7は、発明の実施の形態1にかかるAPI関数wai_pswの処理手順の具体例を示すフローチャートである。   Subsequently, the flag control process in the task will be described with reference to FIG. FIG. 7 is a flowchart showing a specific example of the processing procedure of the API function wai_psw according to the first embodiment of the invention.

タスクスケジューラによって実行されたタスクは、TP内で実行すべき処理を実行終了した後、次のTPまでスリープするときに、wai_pswを呼び出す(S21)。呼び出されたwai_pswは、呼び出し元のタスクに対応するwai_pswフラグ29をOKに更新する(S22)。そして、wai_pswは、呼び出し元のタスクに対応する起床フラグ30がE_TMOUTであるか否かを判定する(S23)。   The task executed by the task scheduler calls wai_psw when it sleeps to the next TP after completing the processing to be executed in the TP (S21). The called wai_psw updates the wai_psw flag 29 corresponding to the caller task to OK (S22). Then, wai_psw determines whether or not the wakeup flag 30 corresponding to the caller task is E_TMOUT (S23).

呼び出し元のタスクに対応する起床フラグ30がE_TMOUTでない場合(S23でNo)、wai_pswは、wai_pswの戻り値にE_OKを設定し(S24)、S26に進む。すなわち、呼び出し元のタスクに対応する起床フラグ30がE_OKである場合、S24が実行される。一方、起床フラグがE_TMOUTである場合、wai_pswは、wai_pswの戻り値にE_TMOUTを設定し(S25)、S26に進む。   If the wakeup flag 30 corresponding to the caller task is not E_TMOUT (No in S23), wai_psw sets E_OK as the return value of wai_psw (S24), and proceeds to S26. That is, when the wakeup flag 30 corresponding to the caller task is E_OK, S24 is executed. On the other hand, when the wakeup flag is E_TMOUT, wai_psw sets E_TMOUT as the return value of wai_psw (S25), and proceeds to S26.

wai_pswは、タスクスケジューラに、呼び出し元のタスクをスリープさせるスリープ処理を実行させる(S26)。すなわち、タスクスケジューラは、呼び出し元のタスクを実行終了して、スリープ状態に遷移させる。これによって、呼び出し元のタスクに対して割り当てたプロセッサ10の実行時間が解放される。なお、上述したように、wai_pswによってスリープしたタスクは、そのタスクが属するTPが次にアクティブとなるまでは、スリープ状態を継続する。そして、次にそのTPがアクティブになって、タスクスケジューラによってプロセッサ10の実行時間が割り当てられたときに、タスクは、スリープ時に設定された戻り値をwai_pswから受け取って、wai_pswから復帰する。つまり、タスクが起床して、タスクの実行が開始される。そして、タスクは、wai_pswからの戻り値がE_OKである場合、通常の処理を実行し、wai_pswからの戻り値がE_TMOUTである場合、異常処置を実行する。   The wai_psw causes the task scheduler to execute a sleep process that causes the calling task to sleep (S26). In other words, the task scheduler finishes executing the caller task, and transitions to the sleep state. As a result, the execution time of the processor 10 assigned to the caller task is released. Note that, as described above, a task that sleeps due to wai_psw continues to sleep until the TP to which the task belongs becomes active next. Then, when the TP becomes active next and the execution time of the processor 10 is allocated by the task scheduler, the task receives the return value set at the time of sleep from wai_psw and returns from wai_psw. That is, the task wakes up and the task execution is started. Then, when the return value from wai_psw is E_OK, the task executes normal processing, and when the return value from wai_psw is E_TMOUT, the task executes an abnormality treatment.

ここで、タスクが属するTPが次にアクティブとなるまで、そのタスクをスリープさせる方法は、例えば、次に説明する方法で実現するようにしてもよく、同様の方法であれば、この方法にも限定されない。具体的には、タスクのそれぞれに対応する起床抑止フラグを実行用メモリ11上に用意し、タスクがスリープしたときに、そのタスクに対応する起床抑止フラグを有効な値に更新する。例えば、wai_pswによって更新する。そして、起床抑止フラグが有効な値を示す場合は、同一TP内で、再度、その起床抑止フラグに対応するタスクの起床することを抑止するようにすればよい。なお、この場合、起床抑止フラグは、TPの時間が終了してから、そのTPが次にアクティブとなったときまでに、OS100又はパーティションスケジューラ21等によって、無効な値に更新するようにすればよい。   Here, the method of putting a task to sleep until the TP to which the task belongs becomes active next may be realized by, for example, the method described below. It is not limited. Specifically, a wakeup suppression flag corresponding to each task is prepared on the execution memory 11, and when the task sleeps, the wakeup suppression flag corresponding to the task is updated to a valid value. For example, it is updated by wai_psw. When the wakeup suppression flag indicates a valid value, it is only necessary to prevent the task corresponding to the wakeup suppression flag from waking up again in the same TP. In this case, if the wakeup suppression flag is updated to an invalid value by the OS 100 or the partition scheduler 21 or the like after the TP time has expired and before the next TP becomes active. Good.

図6及び図7で示した処理に関して、パーティション・スケジューリングの具体例を説明する。まず、図5Aに例示した通常制御スケジューリングパターンに従って、S19においてTP2がアクティブの状態からスケジューリングを開始した場合を説明する。この場合、S19ではTPX=TP2として開始し、続くS20、S11〜S13にかけてもTPX=TP2のままである。そして、S13でNoが続く限り、TPX=TP2の状態が維持される。S13でYesとなり、S14でTP2からTP1へと変更された場合、続くS15〜S20、S11〜S13にかけてTP1のままである。そして、S13でNoが続く限り、TPX=TP1の状態が維持される。TP1がアクティブのときに、S20で、TP2に関する実行状況(データ入出力等)が正常であると判定されており、かつ、TP1に関するタスクの実行状況が正常(戻り値がE_OK)であると判定されていた場合には、次のS14では、TPX=TP2となる(つまり、TP2から開始する通常制御スケジューリングパターンが継続される。)。一方で、S20で、TP2に関する実行状況(データ入出力等)が異常であると判定されていた場合、又は、TP1に関するタスクの実行状況が異常(戻り値がE_TMOUT)であると判定されていた場合には、次のS14で、TPX=TP3となる(つまり、TP3から開始する安全制御スケジューリングパターンに切り替わる。)。   A specific example of partition scheduling will be described with respect to the processing shown in FIGS. First, according to the normal control scheduling pattern illustrated in FIG. 5A, the case where scheduling is started from the active state of TP2 in S19 will be described. In this case, TPX = TP2 is started in S19, and TPX = TP2 remains even in subsequent S20 and S11 to S13. And as long as No continues in S13, the state of TPX = TP2 is maintained. If S13 is Yes and TP2 is changed to TP1 in S14, TP1 remains in S15 to S20 and S11 to S13. As long as No continues in S13, the state of TPX = TP1 is maintained. When TP1 is active, it is determined in S20 that the execution status (data input / output, etc.) related to TP2 is normal, and the task execution status related to TP1 is normal (return value is E_OK) If so, in the next S14, TPX = TP2 (that is, the normal control scheduling pattern starting from TP2 is continued). On the other hand, when the execution status (data input / output, etc.) related to TP2 is determined to be abnormal in S20, or the task execution status related to TP1 is determined to be abnormal (return value is E_TMOUT) In this case, TPX = TP3 in the next S14 (that is, the safety control scheduling pattern starts from TP3).

また、図5Bに例示した安全制御スケジューリングパターンに従って、S19においてTP3がアクティブの状態からスケジューリングを開始した場合を説明する。この場合、S19ではTPX=TP3として開始し、続くS20、S11〜S13にかけてもTPX=TP3のままである。そして、S13でNoが続く限り、TPX=TP3の状態が維持される。S13でYesとなり、S14でTP3からTP1へと変更された場合、続くS15〜S20、S11〜S13にかけてTP1のままである。そして、S13でNoが続く限り、TPX=TP1の状態が維持される。TP1がアクティブのときに、S20で、TP3に関する実行状況(データ入出力等)が正常であると判定されており、かつ、TP1に関するタスクの実行状況が正常(戻り値がE_OK)であると判定されていた場合には、次のS14では、TPX=TP2としてもよい(つまり、TP2から開始する通常制御スケジューリングパターンに切り替わる。)。ただし、制御対象の状態に応じては、スケジューリングパターンの切り替えは行わず、異常処理を継続して制御対象を停止させるようにしてもよい。一方で、S20で、TP3に関する実行状況(データ入出力等)に異常があると判定されていた場合、又は、TP1に関するタスクの実行状況が異常(戻り値がE_TMOUT)であると判定されていた場合には、次のS14で、TPX=TP3となる(つまり、TP3から開始する安全制御スケジューリングパターンが継続される。)。   Further, a case will be described in which scheduling is started from the active state of TP3 in S19 according to the safety control scheduling pattern illustrated in FIG. 5B. In this case, TPX = TP3 is started in S19, and TPX = TP3 remains even in subsequent S20 and S11 to S13. And as long as No continues in S13, the state of TPX = TP3 is maintained. If it is Yes in S13 and changed from TP3 to TP1 in S14, it remains TP1 over the subsequent S15 to S20 and S11 to S13. As long as No continues in S13, the state of TPX = TP1 is maintained. When TP1 is active, it is determined in S20 that the execution status (data input / output, etc.) related to TP3 is normal, and the task execution status related to TP1 is normal (return value is E_OK) If it has been done, TPX = TP2 may be set in the next S14 (that is, switching to the normal control scheduling pattern starting from TP2). However, depending on the state of the control target, the scheduling pattern may not be switched, and the abnormal process may be continued to stop the control target. On the other hand, if it is determined in S20 that the execution status (data input / output, etc.) related to TP3 is abnormal, or the task execution status related to TP1 is determined to be abnormal (return value is E_TMOUT) In this case, TPX = TP3 in the next S14 (that is, the safety control scheduling pattern starting from TP3 is continued).

続いて、図6及び図7を参照して説明したフラグ制御処理によるタスクの実行状況監視の具体例について、図8及び図9を参照して説明する。図8は、TPの時間内にタスクが実行終了した場合におけるタスクの実行状況の具体例を示す図であり、図9は、TPの時間内にタスクが実行終了しなかった場合におけるタスクの実行状況の具体例を示す図である。なお、図8及び図9において、「Partition 1」及び「Partition 2」は、タイムパーティションを示し、「Task」は、Partition 1に属するタスクを示している。例えば、図5Aに示す通常制御スケジューリングパターンに従って動作している場合、「Partition 1」及び「Partition 2」は、TP1及びTP2に相当する。   Next, a specific example of task execution status monitoring by the flag control process described with reference to FIGS. 6 and 7 will be described with reference to FIGS. FIG. 8 is a diagram showing a specific example of the task execution status when the task is completed within the time of TP, and FIG. 9 is the task execution when the task is not completed within the time of TP. It is a figure which shows the specific example of a condition. 8 and 9, “Partition 1” and “Partition 2” indicate time partitions, and “Task” indicates a task belonging to Partition 1. For example, when operating according to the normal control scheduling pattern shown in FIG. 5A, “Partition 1” and “Partition 2” correspond to TP1 and TP2.

まず、図8を参照して、TPの時間内にタスクが実行終了した場合について説明する。ここで、wai_pswフラグ29はOKであり、起床フラグ30はE_OKであるものとする。図8は、1Tickが経過して起動されたパーティションスケジューラ21が、Partition 1をアクティブにしたとき(S11〜S14)から図示されている。   First, with reference to FIG. 8, the case where the task has been executed within the time of TP will be described. Here, it is assumed that the wai_psw flag 29 is OK and the wake-up flag 30 is E_OK. FIG. 8 is illustrated from the time when the partition scheduler 21 activated after 1 tick has activated Partition 1 (S11 to S14).

この場合、Partition 1に属するタスクに対応するwai_pswフラグ29はOKとなっているため(S15でYes)、パーティションスケジューラ21は、Partition 1に属するタスクに対応する起床フラグ30をE_OKに更新する(S16)。また、パーティションスケジューラ21は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。タスクは、通常の処理を実行終了したとき、wai_pswを呼び出す(S21)。wai_pswは、呼び出し元のタスクに対応するwai_pswフラグをOKに更新する(S22)。また、上記S16で起床フラグ30はE_OKとなっているため(S23でNo)、wai_pswは、戻り値にE_OKを設定する(S24)。そして、wai_pswは、呼び出し元のタスクをスリープさせる(S26)。   In this case, since the wai_psw flag 29 corresponding to the task belonging to Partition 1 is OK (Yes in S15), the partition scheduler 21 updates the wake-up flag 30 corresponding to the task belonging to Partition 1 to E_OK (S16). ). Further, the partition scheduler 21 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20). When the task finishes executing normal processing, the task calls wai_psw (S21). The wai_psw updates the wai_psw flag corresponding to the caller task to OK (S22). Since the wake-up flag 30 is E_OK in S16 (No in S23), wai_psw sets E_OK as the return value (S24). Then, wai_psw causes the calling task to sleep (S26).

パーティションスケジューラ21が、次にPartition 1をアクティブにしたとき(S11〜S14)、Partition 1に属するタスクに対応するwai_pswフラグ29はOKであるため(S15でYes)、パーティションスケジューラ21は、Partition 1に属するタスクに対応する起床フラグ30をE_OKに更新する(S16)。すなわち、起床フラグ30は、E_OKのままとなる。また、パーティションスケジューラ21は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。このとき、タスクは、スリープ時に設定されたE_OKを戻り値としてwai_pswから受け取って、wai_pswから復帰する。タスクは、通常の処理を実行終了したとき、wai_pswを呼び出す(S21)。wai_pswは、呼び出し元のタスクに対応するwai_pswフラグ29をOKに更新する(S22)。また、上記S16で起床フラグ30はE_OKとなっているため、wai_pswは、戻り値にE_OKを設定する(S24)。そして、wai_pswは、呼び出し元のタスクをスリープさせる(S26)。   When the partition scheduler 21 next activates Partition 1 (S11 to S14), since the wai_psw flag 29 corresponding to the task belonging to Partition 1 is OK (Yes in S15), the partition scheduler 21 changes to Partition 1. The wakeup flag 30 corresponding to the task to which it belongs is updated to E_OK (S16). That is, the wake-up flag 30 remains E_OK. Further, the partition scheduler 21 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20). At this time, the task receives E_OK set during sleep from wai_psw as a return value and returns from wai_psw. When the task finishes executing normal processing, the task calls wai_psw (S21). The wai_psw updates the wai_psw flag 29 corresponding to the caller task to OK (S22). Further, since the wakeup flag 30 is E_OK in S16, wai_psw sets E_OK as the return value (S24). Then, wai_psw causes the calling task to sleep (S26).

次に、Partition 1がアクティブとなったときも、wai_pswフラグ29にE_OKが設定されており、wai_pswの戻り値にE_OKが設定されているため、同様の処理が繰り返される。このように、タスクがPartition 1の時間内に実行終了できているときはwai_pswの戻り値がE_OKとなることに基づいて、タスクは、通常の処理を実行してもよいということを認識することが可能となる。   Next, when Partition 1 becomes active, E_OK is set in the wai_psw flag 29 and E_OK is set in the return value of wai_psw, so the same processing is repeated. In this way, when the task is finished executing within the time of Partition 1, it recognizes that the task may execute normal processing based on the return value of wai_psw being E_OK. Is possible.

次に、図9を参照して、TPの時間内にタスクが実行終了しなかった場合について説明する。ここで、wai_pswフラグ29はOKであり、起床フラグ30はE_OKであるものとする。図9は、1Tickが経過して起動されたパーティションスケジューラ21が、Partition 1をアクティブにしたとき(S11〜S14)から図示されている。   Next, with reference to FIG. 9, a case where the task has not finished executing within the time of TP will be described. Here, it is assumed that the wai_psw flag 29 is OK and the wake-up flag 30 is E_OK. FIG. 9 is shown from the time when the partition scheduler 21 activated after 1 Tick has activated Partition 1 (S11 to S14).

この場合、Partition 1に属するタスクに対応するwai_pswフラグ29はOKであるため(S15でYes)、パーティションスケジューラ21は、Partition 1に属するタスクに対応する起床フラグ30をE_OKに更新する(S16)。また、パーティションスケジューラ21は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。   In this case, since the wai_psw flag 29 corresponding to the task belonging to Partition 1 is OK (Yes in S15), the partition scheduler 21 updates the wake-up flag 30 corresponding to the task belonging to Partition 1 to E_OK (S16). Further, the partition scheduler 21 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20).

図9では、このときに、Partition 1の時間内にタスクが実行終了しなかった場合について図示している。この場合、Partition 1の時間が満了したときにタスクスケジューラによってタスクの実行が中断され、パーティションスケジューラ21によってTPがPartition 2に切り替えられる(S11〜S14)。この場合は、タスクによってwai_pswが呼び出されていないため、wai_pswフラグ29はNGのままとなる。   FIG. 9 illustrates a case where the task does not finish executing within the time of Partition 1 at this time. In this case, when the time of Partition 1 expires, task execution is interrupted by the task scheduler, and TP is switched to Partition 2 by the partition scheduler 21 (S11 to S14). In this case, since wai_psw has not been called by the task, the wai_psw flag 29 remains NG.

パーティションスケジューラ21が、次にPartition 1をアクティブにしたとき(S11〜S14)、Partition 1に属するタスクに対応するwai_pswフラグ29はNGであるため(S15でNo)、パーティションスケジューラ21は、Partition 1に属するタスクに対応する起床フラグ30をE_TMOUTに更新する(S17)。また、パーティションスケジューラ21は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。このとき、タスクは、中断されたところから実行が再開される。タスクは、通常の処理を実行終了したとき、wai_pswを呼び出す(S21)。wai_pswは、呼び出し元のタスクに対応するwai_pswフラグ29をOKに更新する(S22)。また、上記S17で起床フラグ30はE_TMOUTとなっているため、wai_pswは、戻り値にE_TMOUTを設定する(S25)。そして、wai_pswは、呼び出し元のタスクをスリープさせる(S26)。   When the partition scheduler 21 next activates Partition 1 (S11 to S14), since the wai_psw flag 29 corresponding to the task belonging to Partition 1 is NG (No in S15), the partition scheduler 21 changes to Partition 1. The wakeup flag 30 corresponding to the task to which it belongs is updated to E_TMOUT (S17). Further, the partition scheduler 21 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20). At this time, the task is resumed from where it was interrupted. When the task finishes executing normal processing, the task calls wai_psw (S21). The wai_psw updates the wai_psw flag 29 corresponding to the caller task to OK (S22). Further, since the wakeup flag 30 is E_TMOUT in S17, wai_psw sets E_TMOUT as a return value (S25). Then, wai_psw causes the calling task to sleep (S26).

パーティションスケジューラ21が、次にPartition 1をアクティブにしたとき(S11〜S14)、上記と同様にS15でYesの場合の処理が実行された後、Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。このとき、タスクは、スリープ時に設定されたE_TMOUTを戻り値としてwai_pswから受け取って、wai_pswから復帰する。このように、wai_pswの戻り値がE_TMOUTであることに基づいて、タスクは、自身がPartition 1の時間内に実行終了できていなかったため、異常処置を実行する必要があるということを認識することが可能となる。   When the partition scheduler 21 next activates Partition 1 (S11 to S14), after the processing in the case of Yes in S15 is executed as described above, the task scheduler of Partition 1 starts its operation ( S19), the task in Partition 1 is executed (S20). At this time, the task receives E_TMOUT set during sleep from wai_psw as a return value, and returns from wai_psw. In this way, based on the return value of wai_psw being E_TMOUT, the task can recognize that it has not completed execution within the time of Partition 1 and that it needs to perform an abnormal action. It becomes possible.

以上に説明したように、本実施の形態1では、TPの切り替え時に切り替え先のTPに属するタスクに対応するwai_pswフラグ29をNGに更新するとともに、そのタスクの実行終了時にwai_pswフラグ29をOKに更新するようにしている。そして、TPの切り替え時に切り替え先のTPに属するタスクに対応するwai_pswフラグ29をNGに更新する前に、wai_pswフラグ29がNGとなっていることを検出するようにしている。   As described above, in the first embodiment, the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is updated to NG when the TP is switched, and the wai_psw flag 29 is set to OK when the execution of the task is completed. I try to update it. Then, before the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is updated to NG when the TP is switched, it is detected that the wai_psw flag 29 is NG.

これによれば、TPの時間内にタスクが実行終了しなかったことを、wai_pswフラグ29がNGであることによって検出することができる。すなわち、TPの時間内にタスクを実行終了することができているか否かを監視することが可能となる。また、所定のタイミングで情報(wai_pswフラグ29)を更新するのみという簡易な処理での監視が可能となる。   According to this, it can be detected that the task has not finished executing within the time of TP by the wai_psw flag 29 being NG. That is, it is possible to monitor whether or not the task can be completed within the time of TP. In addition, it is possible to monitor with a simple process of only updating information (wai_psw flag 29) at a predetermined timing.

ここで、一定周期でタスクの実行が終了しているか否かを監視する方法として、個々のタスクにおいて一定周期で実行が終了しているか否かを監視する仕組みを作り込む方法も考えることもできる。しかしながら、そのようにした場合、タスクを生成するアプリケーションプログラムのそれぞれに対して独立して監視する仕組みを実装した場合には、アプリケーションプログラムが複雑になってしまうという問題があった。   Here, as a method for monitoring whether or not the execution of a task is completed at a constant cycle, a method for monitoring whether or not the execution of each task is completed at a predetermined cycle can be considered. . However, in such a case, there is a problem that the application program becomes complicated when a mechanism for independently monitoring each application program that generates a task is implemented.

それに対して、さらに、本実施の形態1では、タスクがその処理を実行終了してスリープするときに呼び出すAPI関数において、wai_pswフラグ29をOKに更新するようにしている。また、TPをスケジューリングするパーティションスケジューラ21において、TPの切り替え時にwai_pswフラグ29をNGに更新するとともに、TPの切り替え時にwai_pswフラグ29を更新する前にwai_pswフラグ29がNGとなっているかを検出するようにしている。   In contrast to this, in the first embodiment, the wai_psw flag 29 is updated to OK in the API function that is called when the task finishes executing the process and sleeps. Further, the partition scheduler 21 that schedules the TP updates the wai_psw flag 29 to NG at the time of TP switching, and detects whether the wai_psw flag 29 is NG before updating the wai_psw flag 29 at the time of TP switching. I have to.

これによれば、タイム・パーティショニングを採用したマルチタスクシステムにおける既存の処理タイミングを利用して、監視する仕組みを実装することができる。すなわち、より簡易に、TPの時間内にタスクを実行終了することができているか否かを監視することが可能となる。   According to this, it is possible to implement a monitoring mechanism using the existing processing timing in the multitask system adopting time partitioning. That is, it becomes possible to monitor whether or not the task can be completed within the time of TP.

なお、上述の例では、スケジューリングパターンとして、3つのTP(安全監視用のTP1、通常制御用のTP2、安全制御用のTP3)のみを組み合わせた場合を例に説明したが、TP2のような通常制御用パーティションや、TP3のような安全制御用パーティションについては、それぞれ複数個存在するものとしてもよい。例えば、2つの通常制御用のTP2及びTP4と、安全監視用のTP1と、2つの安全制御用のTP3及びTP5と、が存在し、これら5つのTP(TP1〜TP5)を組み合わせてスケジューリングパターンを構成してもよい。この場合、S14では、パーティションスケジューラ21が、TPXに関する実行状況(データ入出力等)の異常状態の種類を判定し、その異常種類に応じて、安全制御用のTP3またはTP5のいずれかを選択すればよい。また、S14では、通常制御用のTP2またはTP4のいずれかを選択すればよい。   In the above-described example, a case where only three TPs (safety monitoring TP1, normal control TP2 and safety control TP3) are combined as a scheduling pattern has been described as an example. There may be a plurality of control partitions and safety control partitions such as TP3. For example, there are two TP2 and TP4 for normal control, TP1 for safety monitoring, and two TP3 and TP5 for safety control, and these five TPs (TP1 to TP5) are combined to form a scheduling pattern. It may be configured. In this case, in S14, the partition scheduler 21 determines the type of the abnormal state of the execution status (data input / output, etc.) related to TPX, and selects either TP3 or TP5 for safety control according to the abnormal type. That's fine. In S14, either TP2 or TP4 for normal control may be selected.

上述したように、本実施の形態では、OS100は、安全監視用のTP1からの通知、または、各TPからの通知に応じて、次にアクティブとするパーティションを選択・決定するパーティションスケジューラ21を備えている。パーティションスケジューラ21は、各TPにおいて実行されるタスクとは独立して、所定のタイマー周期で動作する。   As described above, in this embodiment, the OS 100 includes the partition scheduler 21 that selects and determines the partition to be activated next in response to a notification from the TP1 for safety monitoring or a notification from each TP. ing. The partition scheduler 21 operates at a predetermined timer period independently of the tasks executed in each TP.

独立に動作するパーティションスケジューラ21が、全てのTPから結果通知を受ける構成とすることで、パーティションスケジューラ21は、全てのTPに関する状況を一元的に把握することができる。このため、例えば、安全監視用のTP1からの結果通知に応じて、パーティションスケジューラ21が次のパーティションを決定・選択しようとする場合には、パーティションスケジューラ21は、各TPの状況を考慮した上で、正常状態にあるTPのみから次のパーティションを決定・選択することもできる。これによれば、より正確なパーティション・スケジューリングを実現することができるという効果を奏する。   With the configuration in which the partition scheduler 21 that operates independently receives the result notification from all TPs, the partition scheduler 21 can centrally grasp the situation regarding all TPs. Therefore, for example, when the partition scheduler 21 decides and selects the next partition in response to the result notification from the safety monitoring TP1, the partition scheduler 21 considers the situation of each TP. The next partition can be determined and selected only from the TP in the normal state. According to this, there is an effect that more accurate partition scheduling can be realized.

<発明の実施の形態2>
続いて、本発明の実施の形態2にかかる安全制御装置について説明する。本実施の形態2にかかる安全制御装置の構成は、OS100に代えてOS200を有すること以外は、図1を参照して説明した実施の形態1にかかる安全制御装置の構成と同様であるため、その説明を省略する。以下では、パーティションスケジューラ31と、アプリケーション101〜103の起動により生成されるタスクと、の関係について、図を用いて説明する。図10は、OS200によって提供されるマルチプログラミング環境で起動される、パーティションスケジューラ31とタスク24、26、28との関係を示す図である。
<Embodiment 2 of the Invention>
Then, the safety control apparatus concerning Embodiment 2 of this invention is demonstrated. Since the configuration of the safety control device according to the second embodiment is the same as the configuration of the safety control device according to the first embodiment described with reference to FIG. 1 except that the OS 200 is provided instead of the OS 100, The description is omitted. Below, the relationship between the partition scheduler 31 and the tasks generated by starting up the applications 101 to 103 will be described with reference to the drawings. FIG. 10 is a diagram showing the relationship between the partition scheduler 31 and the tasks 24, 26, and 28 that are activated in the multiprogramming environment provided by the OS 200.

図10に示すように、本実施の形態2は、実施の形態1と比較して、OS100に代えてOS200を有し、パーティションスケジューラ21に代えてパーティションスケジューラ31を有し、起床フラグ30に代えて起床カウンタ32を有する点が異なる。以下、実施の形態1と同様の内容については、適宜省略して説明する。   As shown in FIG. 10, the second embodiment has an OS 200 instead of the OS 100, a partition scheduler 31 instead of the partition scheduler 21, and a wake-up flag 30 as compared with the first embodiment. The point of having a wake-up counter 32 is different. Hereinafter, the same contents as those in the first embodiment will be omitted as appropriate.

パーティションスケジューラ31は、実施の形態1にかかるパーティションスケジューラ21と比較して、起床フラグ30の更新に代えて、起床カウンタ32を更新する点が異なる。   The partition scheduler 31 differs from the partition scheduler 21 according to the first embodiment in that instead of updating the wakeup flag 30, the wakeup counter 32 is updated.

起床カウンタ32は、タスク24、26、28のそれぞれに対応するように、複数用意される。起床カウンタ32は、例えば、実行用メモリ11に格納される。起床カウンタ32は、カウンタ値をとる変数である。起床カウンタ32の値が0である場合、その起床カウンタ32に対応するタスクが、そのタスクが属するTPの1TP分の時間内に実行終了できていたことを意味する。起床カウンタ32が1以上の値である場合、そのタスクが属するTPの1TP分の時間内に実行終了できていなかったことを意味する。また、この場合、その起床カウンタ32の値は、その起床カウンタ32に対応するタスクが実行開始されてから実行終了するまでに、そのタスクが属するTPをいくつ跨いだのかを意味する。   A plurality of wake-up counters 32 are prepared so as to correspond to the tasks 24, 26, and 28, respectively. The wake-up counter 32 is stored in the execution memory 11, for example. The wake-up counter 32 is a variable that takes a counter value. When the value of the wake-up counter 32 is 0, it means that the task corresponding to the wake-up counter 32 has been completed within the time of 1 TP of the TP to which the task belongs. When the wakeup counter 32 has a value of 1 or more, it means that the execution has not been completed within the time of 1TP of the TP to which the task belongs. In this case, the value of the wake-up counter 32 means how many TPs to which the task belongs are straddled from the start of execution of the task corresponding to the wake-up counter 32 to the end of execution.

起床カウンタ32は、初期値が0になっている。パーティションスケジューラ31は、TPがアクティブになったときに、そのTPに属するタスクに対応するwai_pswフラグ29がNGである場合、そのタスクに対応する起床カウンタ32をカウントアップする。すなわち、タスクが実行終了せずに、いくつものTPを跨って実行が継続され続けてしまった場合、そのタスクに対応する起床カウンタ32の値がカウントアップされ続けていくことになる。これによって、起床カウンタ32が1以上の値に更新されている場合、その起床カウンタ32に対応するタスクがTPの1TP分の時間内に実行終了できていなかったこと、及び、その起床カウンタ32に対応するタスクが実行終了するまでにそのタスクが属するTPをいくつ跨いだのかが分かる。   The wake-up counter 32 has an initial value of 0. When the wai_psw flag 29 corresponding to the task belonging to the TP is NG when the TP becomes active, the partition scheduler 31 counts up the wake-up counter 32 corresponding to the task. That is, if the task continues to be executed across several TPs without completing the execution, the value of the wake-up counter 32 corresponding to the task continues to be counted up. As a result, when the wake-up counter 32 is updated to a value of 1 or more, the task corresponding to the wake-up counter 32 has not been executed within the time of 1TP of TP, and the wake-up counter 32 It can be seen how many TPs the task belongs to before the corresponding task finishes executing.

OS200は、実施の形態1にかかるOS100と比較して、提供するwai_pswの処理内容が一部異なる。OS200の提供するwai_pswは、実施の形態1にかかるOS100と比較して、起床フラグ30に応じた値に代えて起床カウンタ32の値を戻り値として呼び出し元のタスクに返す点、及び、起床カウンタ32の値を初期化する点が異なる。この戻り値は、wai_pswを呼び出してスリープしていたタスクが起床してwai_pswから復帰するときに、そのタスクに返される。これによって、呼び出し元のタスクは、wai_pswからの戻り値が0である場合、1TPの時間内に自身が実行終了できていたことを認識することができる。逆に、呼び出し元のタスクは、wai_pswからの戻り値が1以上である場合、1TPの時間内に自身が実行終了できていなかったこと、及び、自身が実行終了するまでにTPをいくつ跨いだのかを認識することができる。   The OS 200 is partially different from the OS 100 according to the first embodiment in the processing content of the provided wai_psw. Compared with the OS 100 according to the first embodiment, the wai_psw provided by the OS 200 returns the value of the wake-up counter 32 to the calling task as a return value instead of the value corresponding to the wake-up flag 30, and the wake-up counter The difference is that the value of 32 is initialized. This return value is returned to a task that has been sleeping by calling wai_psw and wakes up and returns from wai_psw. As a result, when the return value from wai_psw is 0, the calling task can recognize that it has completed execution within the time of 1TP. On the other hand, if the return value from wai_psw is 1 or more, the caller task has not completed execution within the time of 1TP, and straddles several TPs until it completes execution. Can be recognized.

そして、呼び出し元のタスクは、wai_pswからの戻り値に応じた処理を実行する。まず、呼び出し元のタスクが、1TPの時間内に実行を終了する必要があるタスクである場合について説明する。この場合、wai_pswからの戻り値が0であるときに、呼び出し元のタスクは、通常の処理を実行する。逆に、wai_pswからの戻り値が1以上であるときに、呼び出し元のタスクは、異常処置を実行する。   Then, the caller task executes processing according to the return value from wai_psw. First, a case will be described in which the caller task is a task that needs to be completed within the time of 1TP. In this case, when the return value from wai_psw is 0, the calling task executes normal processing. On the other hand, when the return value from wai_psw is 1 or more, the calling task executes an abnormality treatment.

次に、呼び出し元のタスクが、合計で2TPの時間内に実行を終了すればよいタスクである場合について説明する。この場合、wai_pswからの戻り値が0又は1であるときに、呼び出し元のタスクは、通常の処理を実行する。逆に、wai_pswからの戻り値が2以上であるときに、呼び出し元のタスクは、異常処置を実行する。このように、本実施の形態2では、処理を必ずしも1TP内で実行終了する必要がないタスクに対しても、それに応じた適切な監視を行うことが可能となる。すなわち、それぞれのタスクに適した、戻り値に対する閾値を設定し、戻り値が閾値以上である場合に、異常処置を実行するようにすればよい。   Next, a case will be described in which the caller task is a task that only needs to be completed within a time of 2TP. In this case, when the return value from wai_psw is 0 or 1, the calling task executes normal processing. On the other hand, when the return value from wai_psw is 2 or more, the calling task executes an abnormality treatment. As described above, in the second embodiment, it is possible to perform appropriate monitoring according to a task that does not necessarily have to be completed within 1TP. That is, a threshold value for the return value suitable for each task is set, and when the return value is equal to or greater than the threshold value, the abnormality treatment may be executed.

ここで、タスクの処理にかかる時間が可変である場合も、動的に閾値を変更することで適切な監視を行うようにすることも可能である。例えば、タスクのそれぞれに対応する閾値を実行用メモリ11上に用意し、タスクもしくはパーティションスケジューラ31がその閾値を任意のタイミングで更新するようにする。   Here, even when the time required for task processing is variable, it is also possible to perform appropriate monitoring by dynamically changing the threshold value. For example, a threshold corresponding to each task is prepared on the execution memory 11, and the task or the partition scheduler 31 updates the threshold at an arbitrary timing.

続いて以下では、パーティションスケジューラ31によるパーティション・スケジューリング処理及びフラグ制御処理について、図11を用いて説明する。図11は、発明の実施の形態1にかかるパーティションスケジューラ31の処理手順の具体例を示すフローチャートである。なお、図6を参照して説明した、実施の形態1にかかる処理手順と同様の処理手順については、同一の符号を付し、説明を省略する。本実施の形態2にかかる処理手順では、実施の形態1にかかる処理手順と比較して、S15でYesとなったときにS16を実行せずにS18を実行し、S17に代えてS27を実行するようにしている点が異なる。   Subsequently, the partition scheduling process and the flag control process performed by the partition scheduler 31 will be described below with reference to FIG. FIG. 11 is a flowchart showing a specific example of the processing procedure of the partition scheduler 31 according to the first embodiment of the invention. In addition, about the process procedure similar to the process procedure concerning Embodiment 1 demonstrated with reference to FIG. 6, the same code | symbol is attached | subjected and description is abbreviate | omitted. In the processing procedure according to the second embodiment, compared to the processing procedure according to the first embodiment, when the answer is YES in S15, S18 is executed without executing S16, and S27 is executed instead of S17. The difference is that you are trying to do.

本実施の形態2では、切り替え先のTPに属するタスクに対応するwai_pswフラグ29がOKである場合(S15でYes)、パーティションスケジューラ31は、S18に進む。一方、切り替え先のTPに属するタスクに対応するwai_pswフラグ29がNGである場合(S15でNo)、パーティションスケジューラ31は、そのタスクに対応する起床カウンタ32をカウントアップする(S27)。そして、パーティションスケジューラ31は、S18に進む。   In the second embodiment, when the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is OK (Yes in S15), the partition scheduler 31 proceeds to S18. On the other hand, when the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is NG (No in S15), the partition scheduler 31 counts up the wake-up counter 32 corresponding to the task (S27). Then, the partition scheduler 31 proceeds to S18.

続いて以下では、タスクにおけるフラグ制御処理について、図12を用いて説明する。図12は、発明の実施の形態2にかかるAPI関数wai_pswの処理手順の具体例を示すフローチャートである。なお、図7を参照して説明した、実施の形態1にかかる処理手順と同様の処理手順については、同一の符号を付し、説明を省略する。   Subsequently, the flag control process in the task will be described with reference to FIG. FIG. 12 is a flowchart showing a specific example of the processing procedure of the API function wai_psw according to the second embodiment of the invention. In addition, about the process procedure similar to the process procedure concerning Embodiment 1 demonstrated with reference to FIG. 7, the same code | symbol is attached | subjected and description is abbreviate | omitted.

本実施の形態2では、S22の処理を実行した後、wai_pswは、wai_pswの戻り値に、呼び出し元のタスクに対応する起床カウンタ32の値を設定する(S28)。そして、wai_pswは、起床カウンタ32の値を0で初期化し(S29)、S26に進む。   In the second embodiment, after executing the process of S22, wai_psw sets the value of the wakeup counter 32 corresponding to the caller task as the return value of wai_psw (S28). Then, wai_psw initializes the value of the wake-up counter 32 with 0 (S29), and proceeds to S26.

続いて、図11及び図12を参照して説明したフラグ制御処理によるタスクの実行状況監視の具体例について、図13及び図14を参照して説明する。図13は、1TPの時間内にタスクが実行終了した場合におけるタスクの実行状況の具体例を示す図であり、図14は、1TPの時間内にタスクが実行終了しなかった場合におけるタスクの実行状況の具体例を示す図である。なお、図13及び図14において、「Partition 1」及び「Partition 2」は、タイムパーティションを示し、「Task」は、Partition 1に属するタスクを示している。   Next, a specific example of task execution status monitoring by the flag control process described with reference to FIGS. 11 and 12 will be described with reference to FIGS. 13 and 14. FIG. 13 is a diagram showing a specific example of the task execution status when the task is completed within the time of 1TP, and FIG. 14 is the task execution when the task is not completed within the time of 1TP. It is a figure which shows the specific example of a condition. 13 and 14, “Partition 1” and “Partition 2” indicate time partitions, and “Task” indicates a task belonging to Partition 1.

まず、図13を参照して、1TPの時間内にタスクが実行終了した場合について説明する。ここで、wai_pswフラグ29はOKであり、起床カウンタ32は"0"であるものとする。図13は、1Tickが経過して起動されたパーティションスケジューラ31が、Partition 1をアクティブにしたとき(S11〜S14)から図示されている。   First, with reference to FIG. 13, a case will be described in which execution of a task is completed within a time of 1TP. Here, it is assumed that the wai_psw flag 29 is OK and the wake-up counter 32 is “0”. FIG. 13 is shown from the time when the partition scheduler 31 started after 1 Tick has activated Partition 1 (S11 to S14).

この場合、Partition 1に属するタスクに対応するwai_pswフラグはOKとなっているため(S15でYes)、パーティションスケジューラ31は、Partition 1に属するタスクに対応する起床カウンタ32はカウントアップしない。また、パーティションスケジューラ31は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。タスクは、通常の処理が実行終了したとき、wai_pswを呼び出す(S21)。wai_pswは、呼び出し元のタスクに対応するwai_pswフラグ29をOKに更新する(S22)。また、wai_pswは、wai_pswの戻り値に、呼び出し元のタスクに対応する起床カウンタ32の値"0"を設定する(S28)。さらに、wai_pswは、呼び出し元のタスクに対応する起床カウンタ32の値を"0"に初期化する(S29)。そして、wai_pswは、呼び出し元のタスクをスリープさせる(S26)。   In this case, since the wai_psw flag corresponding to the task belonging to Partition 1 is OK (Yes in S15), the partition scheduler 31 does not count up the wake-up counter 32 corresponding to the task belonging to Partition 1. In addition, the partition scheduler 31 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20). The task calls wai_psw when normal processing is finished (S21). The wai_psw updates the wai_psw flag 29 corresponding to the caller task to OK (S22). Also, wai_psw sets the value “0” of the wake-up counter 32 corresponding to the caller task to the return value of wai_psw (S28). Furthermore, wai_psw initializes the value of the wake-up counter 32 corresponding to the caller task to “0” (S29). Then, wai_psw causes the calling task to sleep (S26).

パーティションスケジューラ31が、次にPartition 1をアクティブにしたとき(S11〜S14)、Partition 1に属するタスクに対応するwai_pswフラグ29はOKであるため(S15でYes)、パーティションスケジューラ31は、Partition 1に属するタスクに対応する起床カウンタ32はカウントアップしない。すなわち、起床カウンタ32の値は、"0"のままとなる。また、パーティションスケジューラ31は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。このとき、タスクは、スリープ時に設定された値"0"を戻り値としてwai_pswから受け取って、wai_pswから復帰する。タスクは、通常の処理が実行終了したとき、wai_pswを呼び出す(S21)。wai_pswは、呼び出し元のタスクに対応するwai_pswフラグ29をOKに更新する(S22)。また、wai_pswは、wai_pswの戻り値に、呼び出し元のタスクに対応する起床カウンタ32の値"0"を設定する(S28)。さらに、wai_pswは、呼び出し元のタスクに対応する起床カウンタ32の値を"0"に初期化する(S29)。そして、wai_pswは、呼び出し元のタスクをスリープさせる(S26)。   When the partition scheduler 31 next activates Partition 1 (S11 to S14), since the wai_psw flag 29 corresponding to the task belonging to Partition 1 is OK (Yes in S15), the partition scheduler 31 changes to Partition 1. The wakeup counter 32 corresponding to the task to which it belongs does not count up. That is, the value of the wake-up counter 32 remains “0”. In addition, the partition scheduler 31 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20). At this time, the task receives the value “0” set at the time of sleep from wai_psw as a return value, and returns from wai_psw. The task calls wai_psw when normal processing is finished (S21). The wai_psw updates the wai_psw flag 29 corresponding to the caller task to OK (S22). Also, wai_psw sets the value “0” of the wake-up counter 32 corresponding to the caller task to the return value of wai_psw (S28). Furthermore, wai_psw initializes the value of the wake-up counter 32 corresponding to the caller task to “0” (S29). Then, wai_psw causes the calling task to sleep (S26).

次に、Partition 1がアクティブとなったときも、wai_pswフラグ29にE_OKが設定されており、wai_pswの戻り値に"0"が設定されているため、同様の処理が繰り返される。このように、タスクが1つ分のPartition 1の時間内に実行終了できているときはwai_pswの戻り値が"0"となることに基づいて、タスクは、通常の処理を実行してもよいということを認識することが可能となる。   Next, when Partition 1 becomes active, E_OK is set in the wai_psw flag 29 and “0” is set in the return value of wai_psw, so the same processing is repeated. As described above, when the task can be completed within the time of one partition 1, the task may execute normal processing based on the return value of wai_psw being “0”. It becomes possible to recognize that.

次に、図14を参照して、1TPの時間内にタスクが実行終了しなかった場合について説明する。ここで、wai_pswフラグ29はOKであり、起床カウンタ32は"0"であるものとする。図14は、1Tickが経過して起動されたパーティションスケジューラ31が、Partition 1をアクティブにしたとき(S11〜S14)から図示されている。   Next, with reference to FIG. 14, a case where the task has not finished executing within the time of 1TP will be described. Here, it is assumed that the wai_psw flag 29 is OK and the wake-up counter 32 is “0”. FIG. 14 is shown from the time when the partition scheduler 31 started after 1 Tick has activated Partition 1 (S11 to S14).

この場合、Partition 1に属するタスクに対応するwai_pswフラグ29はOKであるため(S15でYes)、パーティションスケジューラ31は、Partition 1に属するタスクに対応する起床カウンタ32はカウントアップしない。また、パーティションスケジューラ31は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。   In this case, since the wai_psw flag 29 corresponding to the task belonging to Partition 1 is OK (Yes in S15), the partition scheduler 31 does not increment the wake-up counter 32 corresponding to the task belonging to Partition 1. In addition, the partition scheduler 31 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20).

図14では、このときに、Partition 1の時間内にタスクが実行終了しなかった場合について図示している。この場合、Partition 1の時間が満了したときにタスクスケジューラによってタスクの実行が中断され、パーティションスケジューラ31によってTPがPartition 2に切り替えられる(S11〜S14)。この場合は、タスクによってwai_pswが呼び出されていないため、wai_pswフラグ29はNGのままとなる。   FIG. 14 illustrates a case where the task does not finish executing within the time of Partition 1 at this time. In this case, when the time of Partition 1 expires, task execution is interrupted by the task scheduler, and TP is switched to Partition 2 by the partition scheduler 31 (S11 to S14). In this case, since wai_psw has not been called by the task, the wai_psw flag 29 remains NG.

パーティションスケジューラ31が、次にPartition 1をアクティブにしたとき(S11〜S14)、Partition 1に属するタスクに対応するwai_pswフラグ29はNGであるため(S15でNo)、パーティションスケジューラ31は、Partition 1に属するタスクに対応する起床カウンタ32をカウントアップする(S27)。すなわち、起床カウンタ32の値が"1"となる。また、パーティションスケジューラ31は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。このとき、タスクは、中断されたところから実行が再開される。タスクは、通常の処理を実行終了したとき、wai_pswを呼び出す(S21)。wai_pswは、呼び出し元のタスクに対応するwai_pswフラグ29をOKに更新する(S22)。また、wai_pswは、wai_pswの戻り値に、呼び出し元のタスクに対応する起床カウンタ32の値"1"を設定する(S28)。さらに、wai_pswは、呼び出し元のタスクに対応する起床カウンタ32の値を"0"に初期化する(S29)。そして、wai_pswは、呼び出し元のタスクをスリープさせる(S26)。   When the partition scheduler 31 next activates Partition 1 (S11 to S14), since the wai_psw flag 29 corresponding to the task belonging to Partition 1 is NG (No in S15), the partition scheduler 31 changes to Partition 1. The wake-up counter 32 corresponding to the task to which it belongs is counted up (S27). That is, the value of the wake-up counter 32 is “1”. In addition, the partition scheduler 31 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20). At this time, the task is resumed from where it was interrupted. When the task finishes executing normal processing, the task calls wai_psw (S21). The wai_psw updates the wai_psw flag 29 corresponding to the caller task to OK (S22). Also, wai_psw sets the value “1” of the wake-up counter 32 corresponding to the caller task to the return value of wai_psw (S28). Furthermore, wai_psw initializes the value of the wake-up counter 32 corresponding to the caller task to “0” (S29). Then, wai_psw causes the calling task to sleep (S26).

パーティションスケジューラ31が、次にPartition 1をアクティブにしたとき(S11〜S14)、上記と同様にS15でYesの場合の処理が実行された後、Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。このとき、タスクは、スリープ時に設定された"1"を戻り値としてwai_pswから受け取って、wai_pswから復帰する。このように、wai_pswの戻り値が"1"であることによって、タスクは、自身が1つ分のPartition 1の時間内に実行終了できていなかったため、異常処置を実行する必要があることを認識することが可能となる。なお、上述したように、タスクが、そのタスクが属するTPを1回だけ跨ぐことが許容されているような場合、タスクは、異常と判断せずに通常の処理の実行するようにしてもよい。この場合、タスクは、wai_pswの戻り値が2以上である場合に、異常と判断して異常処理を実行する。   When the partition scheduler 31 next activates Partition 1 (S11 to S14), after the processing in the case of Yes in S15 is executed as described above, the task scheduler of Partition 1 starts its operation ( S19), the task in Partition 1 is executed (S20). At this time, the task receives “1” set at the time of sleep from wai_psw as a return value, and returns from wai_psw. In this way, when the return value of wai_psw is "1", the task has recognized that it has not been able to complete execution within the time of one partition 1 and that it is necessary to perform an error treatment. It becomes possible to do. Note that, as described above, when a task is allowed to cross the TP to which the task belongs only once, the task may execute normal processing without being determined to be abnormal. . In this case, when the return value of wai_psw is 2 or more, the task determines that there is an abnormality and executes the abnormality process.

以上に説明したように、本実施の形態2では、TPの切り替え時に切り替え先のTPに属するタスクに対応するwai_pswフラグ29をNGに更新するとともに、そのタスクの実行終了時にwai_pswフラグ29をOKに更新するようにしている。そして、TPの切り替え時に切り替え先のTPに属するタスクに対応するwai_pswフラグ29をNGに更新する前にwai_pswフラグ29がNGとなっていることを検出したときに、カウンタ値を更新するようにしている。   As described above, in the second embodiment, the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is updated to NG when the TP is switched, and the wai_psw flag 29 is set to OK when the execution of the task is completed. I try to update it. When the wai_psw flag 29 is detected to be NG before the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is updated to NG when the TP is switched, the counter value is updated. Yes.

これによれば、タスクが実行開始から実行終了するまでに、そのタスクが属するTPをいくつ跨いだかをカウンタ値によって認識することが可能となる。すなわち、所定数のTPの時間内にタスクを実行終了することができているか否かをカウンタ値によって監視することが可能となる。また、所定のタイミングでフラグ及びカウンタ値を更新するのみという簡易な処理での監視が可能となる。   According to this, it is possible to recognize from the counter value how many TPs the task belongs to from the start to the end of execution. That is, it is possible to monitor whether or not the task can be completed within a predetermined number of TPs using the counter value. In addition, it is possible to monitor by a simple process of only updating the flag and the counter value at a predetermined timing.

<発明の実施の形態3>
続いて、本発明の実施の形態3にかかる安全制御装置について説明する。本実施の形態3にかかる安全制御装置の構成は、OS100に代えてOS300を有すること以外は、図1を参照して説明した実施の形態1にかかる安全制御装置の構成と同様であるため、その説明を省略する。以下では、パーティションスケジューラ33と、アプリケーション101〜103の起動により生成されるタスクと、の関係について、図を用いて説明する。図15は、OS300によって提供されるマルチプログラミング環境で起動される、パーティションスケジューラ31とタスク24、26、28との関係を示す図である。
<Third Embodiment of the Invention>
Then, the safety control apparatus concerning Embodiment 3 of this invention is demonstrated. Since the configuration of the safety control device according to the third embodiment is the same as the configuration of the safety control device according to the first embodiment described with reference to FIG. 1 except that the OS 300 is provided instead of the OS 100, The description is omitted. Hereinafter, the relationship between the partition scheduler 33 and the tasks generated by the activation of the applications 101 to 103 will be described with reference to the drawings. FIG. 15 is a diagram showing the relationship between the partition scheduler 31 and the tasks 24, 26, and 28 that are activated in the multiprogramming environment provided by the OS 300.

図15に示すように、本実施の形態3は、実施の形態2と比較して、OS200に代えてOS300を有し、パーティションスケジューラ31に代えてパーティションスケジューラ33を有する点が異なる。以下、実施の形態2と同様の内容については、適宜省略して説明する。   As shown in FIG. 15, the third embodiment is different from the second embodiment in that an OS 300 is provided instead of the OS 200 and a partition scheduler 33 is provided instead of the partition scheduler 31. Hereinafter, the same contents as those in the second embodiment will be omitted as appropriate.

パーティションスケジューラ33は、実施の形態2にかかるパーティションスケジューラ31と比較して、起床カウンタ32をカウントアップするのではなく、カウントダウンして更新する点が異なる。つまり、本実施の形態3では、実施の形態2とは、起床カウンタ32の扱い方が異なる。   The partition scheduler 33 is different from the partition scheduler 31 according to the second embodiment in that it does not count up the wake-up counter 32 but updates it by counting down. That is, the third embodiment is different from the second embodiment in how to handle the wake-up counter 32.

具体的には、本実施の形態3では、起床カウンタ32の初期値は、その起床カウンタ32に対応するタスクが、そのタスクが属するTPを跨ぐことが許容される数になっている。パーティションスケジューラ33は、TPがアクティブになったときに、そのTPに属するタスクに対応するwai_pswフラグ29がNGである場合、そのタスクに対応する起床カウンタ32をカウントダウンする。すなわち、タスクが実行終了せずに、いくつものTPを跨って実行が継続され続けてしまった場合、そのタスクに対応する起床カウンタ32の値がカウントダウンされ続けていくことになる。これによって、起床カウンタ32が0未満の値に更新されている場合、その起床カウンタ32に対応するタスクが許容されるTP数分の時間内に実行終了できていなかったことが分かる。   Specifically, in the third embodiment, the initial value of the wakeup counter 32 is a number that allows the task corresponding to the wakeup counter 32 to cross the TP to which the task belongs. When the wai_psw flag 29 corresponding to the task belonging to the TP is NG when the TP becomes active, the partition scheduler 33 counts down the wake-up counter 32 corresponding to the task. That is, if the task continues to be executed across several TPs without completing the execution, the value of the wake-up counter 32 corresponding to the task continues to be counted down. As a result, when the wake-up counter 32 is updated to a value less than 0, it can be seen that the task corresponding to the wake-up counter 32 could not be completed within the time allowed for the number of TPs.

OS300は、実施の形態2にかかるOS200と比較して、提供するwai_pswの処理内容が一部異なる。OS300の提供するwai_pswは、実施の形態2にかかるOS200と比較して、起床カウンタ32の値を、タスクが跨ぐことが許容されるTP数で初期化する点が異なる。これによって、呼び出し元のタスクは、wai_pswからの戻り値が0以上である場合、許容されるTP数分の時間内に自身が実行終了できていたことを認識することができる。逆に、呼び出し元のタスクは、wai_pswからの戻り値が0未満である場合、許容されるTP数分の時間内に自身が実行終了できていなかったこと、及び、自身がTPをいくつ余分に跨いだのかを認識することができる。例えば、戻り値が−1である場合、TPを1つ余分に跨いだことになる。   The OS 300 is partially different from the OS 200 according to the second embodiment in the processing content of the provided wai_psw. The wai_psw provided by the OS 300 differs from the OS 200 according to the second embodiment in that the value of the wake-up counter 32 is initialized with the number of TPs that a task is allowed to cross. As a result, when the return value from wai_psw is 0 or more, the calling task can recognize that it has finished executing within the time corresponding to the number of allowed TPs. On the other hand, if the return value from wai_psw is less than 0, the caller task did not finish executing within the time of the allowable number of TPs, and the number of extra TPs by itself You can recognize whether you straddled. For example, when the return value is -1, one extra TP is straddled.

そして、呼び出し元のタスクは、wai_pswからの戻り値に応じた処理を実行する。まず、呼び出し元のタスクが、1TPの時間内に実行を終了する必要があるタスクである場合について説明する。この場合、TPを跨ぐことが許容されないため、起床カウンタ32の初期値は0となる。そして、wai_pswからの戻り値が0である場合、呼び出し元のタスクは、通常の処理を実行する。逆に、wai_pswからの戻り値が0未満である場合、呼び出し元のタスクは、異常処置を実行する。   Then, the caller task executes processing according to the return value from wai_psw. First, a case will be described in which the caller task is a task that needs to be completed within the time of 1TP. In this case, since it is not allowed to cross the TP, the initial value of the wake-up counter 32 is zero. If the return value from wai_psw is 0, the calling task executes normal processing. On the other hand, when the return value from wai_psw is less than 0, the caller task executes an abnormality treatment.

次に、呼び出し元のタスクが、合計で2TPの時間内に実行を終了すればよいタスクである場合について説明する。この場合、1回だけTPを跨ぐことが許容されるため、起床カウンタ32の初期値は1となる。そして、wai_pswからの戻り値が0又は1である場合、呼び出し元のタスクは、通常の処理を実行する。逆に、wai_pswからの戻り値が0未満である場合、呼び出し元のタスクは、異常処置を実行する。このように、本実施の形態3では、実施の形態2と同様に、処理を必ずしも1TP内で実行終了する必要がないタスクに対しても、それに応じた適切な監視を行うことが可能となる。すなわち、それぞれのタスクに適した、起床カウンタ32の初期値を設定し、それからカウントダウンされた起床カウンタ32の値が0未満である場合に、異常処置を実行するようにすればよい。   Next, a case will be described in which the caller task is a task that only needs to be completed within a time of 2TP. In this case, since it is allowed to cross the TP only once, the initial value of the wake-up counter 32 is 1. If the return value from wai_psw is 0 or 1, the caller task executes normal processing. On the other hand, when the return value from wai_psw is less than 0, the caller task executes an abnormality treatment. As described above, in the third embodiment, similarly to the second embodiment, it is possible to perform appropriate monitoring corresponding to a task that does not necessarily have to be terminated within 1TP. . That is, an initial value of the wake-up counter 32 suitable for each task is set, and when the value of the wake-up counter 32 counted down is less than 0, the abnormality treatment may be executed.

ここで、実施の形態2と同様にして、タスクの処理にかかる時間が可変である場合も、動的に初期値を変更することで適切な監視を行うようにすることを可能としてもよい。例えば、タスクのそれぞれに対応する起床カウンタ32の初期値を実行用メモリ11上に用意し、タスクもしくはパーティションスケジューラ33がその初期値を任意のタイミングで更新するようにしてもよい。そして、wai_pswは、起床カウンタ32の初期値として、実行用メモリ11に用意された初期値を設定するようにする。   Here, as in the second embodiment, even when the time required for task processing is variable, it is possible to perform appropriate monitoring by dynamically changing the initial value. For example, an initial value of the wake-up counter 32 corresponding to each task may be prepared in the execution memory 11, and the task or partition scheduler 33 may update the initial value at an arbitrary timing. The wai_psw sets an initial value prepared in the execution memory 11 as an initial value of the wakeup counter 32.

続いて以下では、パーティションスケジューラ33によるパーティション・スケジューリング処理及びフラグ制御処理について、図16を用いて説明する。図16は、発明の実施の形態1にかかるパーティションスケジューラ33の処理手順の具体例を示すフローチャートである。   Subsequently, partition scheduling processing and flag control processing by the partition scheduler 33 will be described below with reference to FIG. FIG. 16 is a flowchart showing a specific example of a processing procedure of the partition scheduler 33 according to the first embodiment of the invention.

本実施の形態3にかかる処理手順では、実施の形態2にかかる処理手順と比較して、S27に代えてS30を実行するようにしている点のみ異なる。すなわち、本実施の形態3では、切り替え先のTPに属するタスクに対応するwai_pswフラグ29がNGである場合(S15でNo)、パーティションスケジューラ33は、そのタスクに対応する起床カウンタ32をカウントダウンして(S30)、S18に進む。   The processing procedure according to the third embodiment is different from the processing procedure according to the second embodiment only in that S30 is executed instead of S27. That is, in the third embodiment, when the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is NG (No in S15), the partition scheduler 33 counts down the wake-up counter 32 corresponding to the task. (S30), go to S18.

続いて以下では、タスクにおけるフラグ制御処理について、図17を用いて説明する。図17は、発明の実施の形態2にかかるAPI関数wai_pswの処理手順の具体例を示すフローチャートである。   Subsequently, the flag control process in the task will be described with reference to FIG. FIG. 17 is a flowchart showing a specific example of the processing procedure of the API function wai_psw according to the second embodiment of the invention.

本実施の形態3にかかる処理手順では、実施の形態2にかかる処理手順と比較して、S29に代えてS31を実行するようにしている点のみ異なる。すなわち、本実施の形態3では、S28の処理を実行した後、wai_pswは、起床カウンタ32の値を、上述したような初期値で初期化して(S31)、S26に進む。   The processing procedure according to the third embodiment is different from the processing procedure according to the second embodiment only in that S31 is executed instead of S29. That is, in the third embodiment, after executing the process of S28, wai_psw initializes the value of the wake-up counter 32 with the initial value as described above (S31), and proceeds to S26.

続いて、フラグ制御処理によるタスクの実行状況監視の具体例について説明する。ここで、TPを跨ぐことが許容されないタスクである場合、起床カウンタ32の初期値は0となる。そのため、図13に示すケースでは、起床カウンタ32の初期値、起床カウンタ32の更新(S30)が無い点、wai_pswの戻り値、及びwai_pswの戻り値に応じたタスクの処理も、実施の形態2と同様となる。また、図14に示すケースでは、wai_pswの戻り値が−1となること以外は、実施の形態2と同様となる。そのため、本実施の形態3では、その特徴をより明確に説明するために、1回だけTPを跨ぐことが許容されるタスクが、図18及び図19に示す実行状況となった場合について説明する。   Next, a specific example of task execution status monitoring by flag control processing will be described. Here, when the task is not allowed to cross the TP, the initial value of the wake-up counter 32 is zero. Therefore, in the case shown in FIG. 13, the initial value of the wake-up counter 32, the point where the wake-up counter 32 is not updated (S30), the return value of wai_psw, and the task processing according to the return value of wai_psw are also described in the second embodiment. It will be the same. Further, in the case shown in FIG. 14, it is the same as in the second embodiment except that the return value of wai_psw is -1. Therefore, in this Embodiment 3, in order to explain the feature more clearly, a case where a task that is allowed to cross TP only once becomes the execution status shown in FIGS. 18 and 19 will be described. .

まず、図18を参照して、1TPの時間内にタスクが実行終了しなかった場合について説明する。ここで、wai_pswフラグ29はOKであり、起床カウンタ32は初期値の"1"であるものとする。図18は、1Tickが経過して起動されたパーティションスケジューラ33が、Partition 1をアクティブにしたとき(S11〜S14)から図示されている。   First, with reference to FIG. 18, a case will be described in which the task has not finished executing within the time of 1TP. Here, it is assumed that the wai_psw flag 29 is OK and the wake-up counter 32 is the initial value “1”. FIG. 18 is shown from the time when the partition scheduler 33 started after 1 Tick has activated Partition 1 (S11 to S14).

この場合、Partition 1に属するタスクに対応するwai_pswフラグ29はOKであるため(S15でYes)、パーティションスケジューラ33は、Partition 1に属するタスクに対応する起床カウンタ32はカウントダウンしない。また、パーティションスケジューラ33は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。   In this case, since the wai_psw flag 29 corresponding to the task belonging to Partition 1 is OK (Yes in S15), the partition scheduler 33 does not count down the wake-up counter 32 corresponding to the task belonging to Partition 1. Further, the partition scheduler 33 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20).

図18では、このときに、Partition 1の時間内にタスクが実行終了しなかった場合について図示している。この場合、Partition 1の時間が満了したときにタスクスケジューラによってタスクの実行が中断され、パーティションスケジューラ33によってTPがPartition 2に切り替えられる(S11〜S14)。この場合は、タスクによってwai_pswが呼び出されていないため、wai_pswフラグ29はNGのままとなる。   FIG. 18 illustrates a case where the task does not finish executing within the time of Partition 1 at this time. In this case, when the time of Partition 1 expires, task execution is interrupted by the task scheduler, and TP is switched to Partition 2 by the partition scheduler 33 (S11 to S14). In this case, since wai_psw has not been called by the task, the wai_psw flag 29 remains NG.

パーティションスケジューラ33が、次にPartition 1をアクティブにしたとき(S11〜S14)、Partition 1に属するタスクに対応するwai_pswフラグ29はNGであるため(S15でNo)、パーティションスケジューラ33は、Partition 1に属するタスクに対応する起床カウンタ32をカウントダウンする(S30)。すなわち、起床カウンタ32の値が"0"となる。また、パーティションスケジューラ33は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。このとき、タスクは、中断されたところから実行が再開される。タスクは、通常の処理を実行終了したとき、wai_pswを呼び出す(S21)。wai_pswは、呼び出し元のタスクに対応するwai_pswフラグ29をOKに更新する(S22)。また、wai_pswは、wai_pswの戻り値に、呼び出し元のタスクに対応する起床カウンタ32の値"0"を設定する(S28)。さらに、wai_pswは、呼び出し元のタスクに対応する起床カウンタ32の値を"1"に初期化する(S29)。そして、wai_pswは、呼び出し元のタスクをスリープさせる(S26)。   When the partition scheduler 33 next activates Partition 1 (S11 to S14), the wai_psw flag 29 corresponding to the task belonging to Partition 1 is NG (No in S15). The wake-up counter 32 corresponding to the task to which it belongs is counted down (S30). That is, the value of the wake-up counter 32 is “0”. Further, the partition scheduler 33 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20). At this time, the task is resumed from where it was interrupted. When the task finishes executing normal processing, the task calls wai_psw (S21). The wai_psw updates the wai_psw flag 29 corresponding to the caller task to OK (S22). Also, wai_psw sets the value “0” of the wake-up counter 32 corresponding to the caller task to the return value of wai_psw (S28). Furthermore, wai_psw initializes the value of the wake-up counter 32 corresponding to the caller task to “1” (S29). Then, wai_psw causes the calling task to sleep (S26).

パーティションスケジューラ33が、次にPartition 1をアクティブにしたとき(S11〜S14)、上記と同様にS15でYesの場合の処理が実行された後、Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。このとき、タスクは、スリープ時に設定された"0"を戻り値としてwai_pswから受け取って、wai_pswから復帰する。このように、wai_pswの戻り値が"0"であることによって、タスクは、自身が許容される2つ分のPartition 1の時間内に実行終了できていたため、通常の処理を実行してもよいということを認識することが可能となる。   When the partition scheduler 33 next activates Partition 1 (S11 to S14), after the processing in the case of Yes in S15 is executed as described above, the task scheduler of Partition 1 starts its operation ( S19), the task in Partition 1 is executed (S20). At this time, the task receives from the wai_psw as a return value “0” set at the time of sleep, and returns from wai_psw. As described above, since the return value of wai_psw is “0”, the task has been completed within the time period of two partitions 1 that the task itself is allowed to execute, and therefore normal processing may be executed. It becomes possible to recognize that.

まず、図19を参照して、合計で2TPの時間内にタスクが実行終了しなかった場合について説明する。ここで、wai_pswフラグ29はOKであり、起床カウンタ32は初期値の"1"であるものとする。図19は、1Tickが経過して起動されたパーティションスケジューラ33が、Partition 1をアクティブにしたとき(S11〜S14)から図示されている。   First, with reference to FIG. 19, a case will be described in which the task has not finished executing within a total time of 2TP. Here, it is assumed that the wai_psw flag 29 is OK and the wake-up counter 32 is the initial value “1”. FIG. 19 is shown from the time when the partition scheduler 33 started after 1 Tick has activated Partition 1 (S11 to S14).

この場合、Partition 1に属するタスクに対応するwai_pswフラグ29はOKであるため(S15でYes)、パーティションスケジューラ33は、Partition 1に属するタスクに対応する起床カウンタ32はカウントダウンしない。また、パーティションスケジューラ33は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。   In this case, since the wai_psw flag 29 corresponding to the task belonging to Partition 1 is OK (Yes in S15), the partition scheduler 33 does not count down the wake-up counter 32 corresponding to the task belonging to Partition 1. Further, the partition scheduler 33 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20).

図19では、このときに、Partition 1の時間内にタスクが実行終了しなかった場合について図示している。この場合、Partition 1の時間が満了したときにタスクスケジューラによってタスクの実行が中断され、パーティションスケジューラ33によってTPがPartition 2に切り替えられる(S11〜S14)。この場合は、タスクによってwai_pswが呼び出されていないため、wai_pswフラグ29はNGのままとなる。   FIG. 19 shows a case where the task has not finished executing within the time of Partition 1 at this time. In this case, when the time of Partition 1 expires, task execution is interrupted by the task scheduler, and TP is switched to Partition 2 by the partition scheduler 33 (S11 to S14). In this case, since wai_psw has not been called by the task, the wai_psw flag 29 remains NG.

パーティションスケジューラ33が、次にPartition 1をアクティブにしたとき(S11〜S14)、Partition 1に属するタスクに対応するwai_pswフラグ29はNGであるため(S15でNo)、パーティションスケジューラ33は、Partition 1に属するタスクに対応する起床カウンタ32をカウントダウンする(S30)。すなわち、起床カウンタ32の値が"0"となる。また、パーティションスケジューラ33は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。このとき、タスクは、中断されたところから実行が再開される。図19では、このときに、再度、Partition 1の時間内にタスクが実行終了しなかった場合について図示している。この場合、Partition 1の時間が満了したときにタスクスケジューラによってタスクの実行が中断され、パーティションスケジューラ33によってTPがPartition 2に切り替えられる(S11〜S14)。この場合は、タスクによってwai_pswが呼び出されていないため、wai_pswフラグ29はNGのままとなる。   When the partition scheduler 33 next activates Partition 1 (S11 to S14), the wai_psw flag 29 corresponding to the task belonging to Partition 1 is NG (No in S15). The wake-up counter 32 corresponding to the task to which it belongs is counted down (S30). That is, the value of the wake-up counter 32 is “0”. Further, the partition scheduler 33 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20). At this time, the task is resumed from where it was interrupted. FIG. 19 shows a case where the task has not finished executing again within the time of Partition 1 at this time. In this case, when the time of Partition 1 expires, task execution is interrupted by the task scheduler, and TP is switched to Partition 2 by the partition scheduler 33 (S11 to S14). In this case, since wai_psw has not been called by the task, the wai_psw flag 29 remains NG.

パーティションスケジューラ33が、次にPartition 1をアクティブにしたとき(S11〜S14)、Partition 1に属するタスクに対応するwai_pswフラグ29はNGであるため(S15でNo)、パーティションスケジューラ33は、Partition 1に属するタスクに対応する起床カウンタ32をカウントダウンする(S30)。すなわち、起床カウンタ32の値が"−1"となる。また、パーティションスケジューラ33は、Partition 1に属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)。Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。このとき、タスクは、中断されたところから実行が再開される。タスクは、通常の処理を実行終了したとき、wai_pswを呼び出す(S21)。wai_pswは、呼び出し元のタスクに対応するwai_pswフラグ29をOKに更新する(S22)。また、wai_pswは、wai_pswの戻り値に、呼び出し元のタスクに対応する起床カウンタ32の値"−1"を設定する(S28)。さらに、wai_pswは、呼び出し元のタスクに対応する起床カウンタ32の値を"1"に初期化する(S29)。そして、wai_pswは、呼び出し元のタスクをスリープさせる(S26)。   When the partition scheduler 33 next activates Partition 1 (S11 to S14), the wai_psw flag 29 corresponding to the task belonging to Partition 1 is NG (No in S15). The wake-up counter 32 corresponding to the task to which it belongs is counted down (S30). That is, the value of the wake-up counter 32 is “−1”. Further, the partition scheduler 33 updates the wai_psw flag 29 corresponding to the task belonging to Partition 1 to NG (S18). The task scheduler of Partition 1 starts its operation (S19) and executes the tasks in Partition 1 (S20). At this time, the task is resumed from where it was interrupted. When the task finishes executing normal processing, the task calls wai_psw (S21). The wai_psw updates the wai_psw flag 29 corresponding to the caller task to OK (S22). Further, wai_psw sets the value “−1” of the wake-up counter 32 corresponding to the caller task as the return value of wai_psw (S28). Furthermore, wai_psw initializes the value of the wake-up counter 32 corresponding to the caller task to “1” (S29). Then, wai_psw causes the calling task to sleep (S26).

パーティションスケジューラ33が、次にPartition 1をアクティブにしたとき(S11〜S14)、上記と同様にS15でYesの処理が実行された後、Partition 1のタスクスケジューラは、動作を開始して(S19)、Partition 1内のタスクを実行する(S20)。このとき、タスクは、スリープ時に設定された"−1"を戻り値としてwai_pswから受け取って、wai_pswから復帰する。このように、wai_pswの戻り値が"−1"であることによって、タスクは、自身が許容される2つ分のPartition 1の時間内に実行終了できていなかったため、異常処置を実行する必要があることを認識することが可能となる。   When the partition scheduler 33 next activates Partition 1 (S11 to S14), after the Yes processing is executed in S15 as described above, the task scheduler of Partition 1 starts its operation (S19). Then, the task in Partition 1 is executed (S20). At this time, the task receives “−1” set at the time of sleep as a return value from wai_psw and returns from wai_psw. As described above, since the return value of wai_psw is “−1”, the task has not been finished within the time period of two allowed Partition 1s, so it is necessary to perform an abnormality treatment. It becomes possible to recognize something.

以上に説明したように、本実施の形態3のように、TPの切り替え時に切り替え先のTPに属するタスクに対応するwai_pswフラグ29をNGに更新する前にwai_pswフラグ29がNGとなっていることを検出したときに、カウンタ値をカウントダウンすることによって更新することでも監視が可能である。   As described above, the wai_psw flag 29 is NG before the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is updated to NG at the time of TP switching as in the third embodiment. Monitoring is also possible by updating the counter value by counting down when it is detected.

発明の他の実施の形態.
本実施の形態では、TPのそれぞれに属するタスクが、それぞれ安全監視タスク24、通常制御タスク26及び安全制御タスク28である場合について例示したが、タスクの種類は、これに限られない。安全監視タスク24、通常制御タスク26及び安全制御タスク28に限られず、他の任意の制御対象の制御に関する処理を実行するタスクを有するようにしてもよい。
Another embodiment of the invention.
In the present embodiment, the case where the tasks belonging to each of the TPs are the safety monitoring task 24, the normal control task 26, and the safety control task 28, respectively, is exemplified, but the type of task is not limited to this. The task is not limited to the safety monitoring task 24, the normal control task 26, and the safety control task 28, and may have a task for executing processing related to control of any other control target.

例えば、図20に示すようなタスク34〜36を有するようにしてもよい。なお、この場合、安全制御装置は、アプリケーション101〜103に代えて、タスク34〜36に対応するアプリケーションを有する必要があるが、その点は自明であるため図示及び説明を省略する。   For example, you may make it have the tasks 34-36 as shown in FIG. In this case, the safety control device needs to have applications corresponding to the tasks 34 to 36 instead of the applications 101 to 103. However, since this point is obvious, illustration and description are omitted.

監視制御タスク34は、制御対象を制御する。具体的には、監視制御タスク34は、通常制御タスク35及び安全制御タスク36からの指令値に基づいて、制御対象のアクチュエータを制御する。通常制御タスク35は、制御対象に通常の機能・動作を行わせるための制御計算を行う。具体的には、通常制御タスク35は、通常制御におけるアクチュエータの制御計算をして、アクチュエータの指令値を算出する。通常制御タスク35は、算出した指令値を監視制御タスク34に出力する。安全制御タスク36は、機能安全を確保するために定められた制御計算を行う。具体的には、安全制御タスク36は、安全制御におけるアクチュエータの制御計算をして、アクチュエータの指令値を算出する。安全制御タスク36は、算出した指令値を監視制御タスク34のそれぞれに出力する。監視制御タスク34は、通常制御タスク41又は安全制御タスク36から出力された指令値に基づいてアクチュエータを制御する。   The supervisory control task 34 controls the controlled object. Specifically, the supervisory control task 34 controls the actuator to be controlled based on command values from the normal control task 35 and the safety control task 36. The normal control task 35 performs control calculation for causing the control target to perform a normal function / operation. Specifically, the normal control task 35 performs a control calculation of the actuator in the normal control and calculates an actuator command value. The normal control task 35 outputs the calculated command value to the monitoring control task 34. The safety control task 36 performs a control calculation determined to ensure functional safety. Specifically, the safety control task 36 calculates the actuator command value by performing a control calculation of the actuator in the safety control. The safety control task 36 outputs the calculated command value to each of the monitoring control tasks 34. The supervisory control task 34 controls the actuator based on the command value output from the normal control task 41 or the safety control task 36.

さらに、監視制御タスク34は、制御対象のセンサから、センサ値を取得する。監視制御タスク34は、取得したセンサ値を通常制御タスク35及び安全制御タスク36に出力する。通常制御タスク35及び安全制御タスク36のそれぞれは、監視制御タスク34から出力されたセンサ値に基づいて、アクチュエータの制御計算を行うようにしてもよい。   Furthermore, the monitoring control task 34 acquires a sensor value from the sensor to be controlled. The monitoring control task 34 outputs the acquired sensor value to the normal control task 35 and the safety control task 36. Each of the normal control task 35 and the safety control task 36 may perform actuator control calculation based on the sensor value output from the monitoring control task 34.

また、その他に、例えば、図21に示すようなタスク37〜39を有するようにしてもよい。なお、この場合、安全制御装置は、アプリケーション101〜103に代えて、タスク37〜39に対応するアプリケーションを有する必要があるが、その点は自明であるため図示及び説明を省略する。   In addition, for example, tasks 37 to 39 as shown in FIG. 21 may be included. In this case, the safety control device needs to have applications corresponding to the tasks 37 to 39 instead of the applications 101 to 103. However, since this point is obvious, illustration and description are omitted.

監視タスク37は、制御対象のセンサから、センサ値を取得する。このセンサには、上述したように制御対象の姿勢を検知するための姿勢センサを含む。ここで説明する例では、制御対象として、人が搭乗することができる走行装置に適用した場合について説明する。この場合、監視タスク37は、搭乗者による重心移動を姿勢センサにより検知することができる。監視タスク37は、取得したセンサ値をHMI(Human Machine Interface)タスク39に出力する。   The monitoring task 37 acquires a sensor value from the sensor to be controlled. This sensor includes a posture sensor for detecting the posture of the control target as described above. The example demonstrated here demonstrates the case where it applies to the traveling apparatus which a person can board as a control object. In this case, the monitoring task 37 can detect the movement of the center of gravity by the passenger using the posture sensor. The monitoring task 37 outputs the acquired sensor value to an HMI (Human Machine Interface) task 39.

HMIタスク39は、監視タスク37から出力されたセンサ値に基づいて、制御対象のアクチュエータの制御計算をして、アクチュエータの指令値を算出する。HMIタスク39は、算出した指令値を制御タスク38に出力する。制御タスク38は、HMIタスク39から出力された指令値に基づいて、アクチュエータを制御する。   Based on the sensor value output from the monitoring task 37, the HMI task 39 performs control calculation of the actuator to be controlled, and calculates an actuator command value. The HMI task 39 outputs the calculated command value to the control task 38. The control task 38 controls the actuator based on the command value output from the HMI task 39.

これによれば、搭乗者の操作に応じて制御対象が制御されるというHMIを実現することができる。例えば、搭乗者が重心を前後に移動させることで制御対象が前後後退を行い、搭乗者が重心を左右に移動させることで制御対象が左右旋回を行うといった制御が可能となる。これについては、実施の形態1〜3及び図21によって説明した例についても同様のことが言える。具体的には、安全監視タスク24又は監視制御タスク34が取得したセンサ値に応じて、通常制御タスク26及び安全制御タスク28、もしくは、通常制御タスク35及び安全制御タスク36が同様の制御をすることで、HMIを実現することが可能である。また、本実施の形態によれば、より安定した制御対象の制御を行うことが可能となる。そのため、以上に説明したように、人が搭乗することができる走行装置を制御対象として適用することで、より安全性を向上した制御対象の制御を行うことが可能となる。   According to this, it is possible to realize an HMI in which a control target is controlled in accordance with a passenger's operation. For example, it is possible to perform control such that the control object moves back and forth when the passenger moves the center of gravity back and forth, and the control object turns left and right when the passenger moves the center of gravity left and right. The same can be said for the examples described with reference to the first to third embodiments and FIG. Specifically, the normal control task 26 and the safety control task 28 or the normal control task 35 and the safety control task 36 perform the same control according to the sensor value acquired by the safety monitoring task 24 or the monitoring control task 34. Thus, HMI can be realized. Moreover, according to this Embodiment, it becomes possible to perform control of the controlled object more stably. Therefore, as described above, it is possible to perform control of a controlled object with improved safety by applying a traveling device on which a person can board as a controlled object.

なお、走行装置として、例えば、立ち乗り方の同軸二輪車とすることもできる。その場合は、アクチュエータを制御することで、車輪が回転動作をすることになる。また、安全制御装置自体も制御対象に搭載される構成としてもよい。   In addition, as a traveling apparatus, it can also be set as the coaxial two-wheeled vehicle of standing up riding. In this case, the wheel rotates by controlling the actuator. Further, the safety control device itself may be mounted on the control target.

さらに、本発明は上述した実施の形態のみに限定されるものではなく、既に述べた本発明の要旨を逸脱しない範囲において種々の変更が可能であることは勿論である。   Furthermore, the present invention is not limited to the above-described embodiments, and various modifications can be made without departing from the gist of the present invention described above.

本実施の形態では、OSが、TP1〜TP3を有する場合について例示したが、TPの種類及び数は、これに限られない。スケジューリングパターンについても、本実施の形態に例示したものに限られない。   In the present embodiment, the case where the OS has TP1 to TP3 is illustrated, but the type and number of TPs are not limited to this. The scheduling pattern is not limited to that exemplified in the present embodiment.

また、本実施の形態では、タスクの数が3つである場合について例示したが、タスクの数は、これに限られない。例えば、本実施の形態では、TPがTP1〜TP3の3つである場合について例示したが、TPの数を3つ以外の数とし、それぞれのTPが1つ以上の任意の数のタスクを有するようにしてもよい。   Further, in the present embodiment, the case where the number of tasks is three is exemplified, but the number of tasks is not limited to this. For example, in the present embodiment, the case where there are three TPs TP1 to TP3 is illustrated, but the number of TPs is set to a number other than three, and each TP has one or more arbitrary numbers of tasks. You may do it.

本実施の形態では、TPの切り替え時に、切り替え先のTPに属するタスクに対応するwai_pswフラグ29をNGに更新するとともに、切り替え先のTPに属するタスクに対応するwai_pswフラグ29をNGに更新する(S18)前に、wai_pswフラグ29がNGとなっていることを検出して(S15でNo)、起床フラグ30をE_TMOUTに更新する(S17)ようにしているが、これに限られない。例えば、TPの切り替え時に、切り替え前のTPに属するタスクに対応するwai_pswフラグ29をNGに更新するとともに、切り替え前のTPに属するタスクに対応するwai_pswフラグ29をNGに更新する前に、wai_pswフラグ29がNGとなっていることを検出して、起床フラグ30をE_TMOUTに更新するようにしてもよい。   In this embodiment, when the TP is switched, the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is updated to NG, and the wai_psw flag 29 corresponding to the task belonging to the switching destination TP is updated to NG ( Before S18, it is detected that the wai_psw flag 29 is NG (No in S15) and the wake-up flag 30 is updated to E_TMOUT (S17), but this is not restrictive. For example, when switching the TP, the wai_psw flag 29 corresponding to the task belonging to the TP before switching is updated to NG, and the wai_psw flag 29 corresponding to the task belonging to the TP before switching is updated to NG. It is also possible to detect that 29 is NG and update the wakeup flag 30 to E_TMOUT.

本実施の形態では、パーティションスケジューラが、wai_pswフラグ29がNGとなっていることを検出したときに(S15でNo)、起床フラグ30の更新のみを行うようにしているが(S17)、これに限られない。例えば、パーティションスケジューラが、wai_pswフラグ29がNGとなっていることを検出したときに、異常処置に対応する処理を即時実施するようにしてもよい。しかしながら、本実施の形態のように、起床フラグ30によってタスクにおいて異常を認識して、タスクからパーティションスケジューラに異常を通知する構成とすることで、その他の異常等をタスクからパーティションスケジューラに通知をする仕組みに統合することができ、より少ない変更量でより簡易に実装することが可能となる。   In this embodiment, when the partition scheduler detects that the wai_psw flag 29 is NG (No in S15), it only updates the wakeup flag 30 (S17). Not limited. For example, when the partition scheduler detects that the wai_psw flag 29 is NG, the process corresponding to the abnormality treatment may be performed immediately. However, as in this embodiment, the task is configured to recognize an abnormality in the task by the wake-up flag 30 and notify the partition scheduler of the abnormality, so that the task notifies the partition scheduler of other abnormalities. It can be integrated into the mechanism and can be implemented more easily with a smaller amount of change.

本実施の形態1では、wai_pswは、起床フラグ30がE_TMOUTの場合に、戻り値にE_TMOUTを設定してタスクをスリープさせるようにしているが、これに限られない。例えば、起床フラグ30がE_TMOUTの場合に、タスクをスリープさせずに、E_TMOUTを戻り値として即時復帰するようにしてもよい。このようにすることで、タスクによる異常処置の応答性を高めることができる。しかしながら、本実施の形態1のように、正常系と異常系とで処理を統一することによって、より少ない変更量でより簡易に実装することが可能となる。なお、このことは、実施の形態2及び3においても、同様のことが言える。すなわち、実施の形態2において、wai_pswは、起床カウンタ32が閾値以上となっている場合に、タスクをスリープさせずに、即時復帰するようにしてもよい。また、実施の形態3において、wai_pswは、起床カウンタ32が0未満となっている場合に、タスクをスリープさせずに、即時復帰するようにしてもよい。   In the first embodiment, wai_psw sets the return value to E_TMOUT and causes the task to sleep when the wakeup flag 30 is E_TMOUT, but is not limited to this. For example, when the wake-up flag 30 is E_TMOUT, the task may be immediately returned using E_TMOUT as a return value without sleeping the task. By doing in this way, the responsiveness of the abnormal treatment by a task can be improved. However, as in the first embodiment, by unifying the processing between the normal system and the abnormal system, it is possible to more easily implement with a smaller change amount. The same can be said for the second and third embodiments. That is, in the second embodiment, wai_psw may return immediately without sleeping the task when the wake-up counter 32 is equal to or greater than the threshold value. In the third embodiment, wai_psw may be returned immediately without causing the task to sleep when the wake-up counter 32 is less than zero.

本実施の形態2では、起床カウンタ32の初期値を0としているが、これに限られない。例えば、起床カウンタ32の初期値を0以外の値とし、それに応じて閾値を設定するようにしてもよい。これは、本実施の形態3においても、同様のことが言える。すなわち、本実施の形態3において、0以外の値未満となったときに異常であると判定するようにし、それに応じて起床カウンタ32の初期値を設定するようにしてもよい。   In the second embodiment, the initial value of the wake-up counter 32 is set to 0, but is not limited to this. For example, the initial value of the wake-up counter 32 may be a value other than 0, and the threshold value may be set accordingly. The same can be said for the third embodiment. That is, in the third embodiment, it may be determined that there is an abnormality when the value is less than 0, and the initial value of the wake-up counter 32 may be set accordingly.

1 安全制御装置
10 プロセッサ
11 実行用メモリ
12 I/Oポート
13 不揮発性メモリ
14 リセット回路
15 マイクロコントローラ
21、31、33 パーティションスケジューラ
22 スケジューリングテーブル
23、25、27 タスクスケジューラ
24 安全監視タスク
26、35 通常制御タスク
28、36 安全制御タスク
29 wai_pswフラグ
30 起床フラグ
32 起床カウンタ
34 監視制御タスク
37 監視タスク
38 制御タスク
39 HMIタスク
100、200、300 オペレーティングシステム
101 安全監視アプリケーション
102 通常制御アプリケーション
103 安全制御アプリケーション
DESCRIPTION OF SYMBOLS 1 Safety control apparatus 10 Processor 11 Execution memory 12 I / O port 13 Non-volatile memory 14 Reset circuit 15 Microcontroller 21, 31, 33 Partition scheduler 22 Scheduling table 23, 25, 27 Task scheduler 24 Safety monitoring task 26, 35 Normal Control task 28, 36 Safety control task 29 wai_psw flag 30 Wake-up flag 32 Wake-up counter 34 Monitoring control task 37 Monitoring task 38 Control task 39 HMI task 100, 200, 300 Operating system 101 Safety monitoring application 102 Normal control application 103 Safety control application

Claims (12)

制御対象の制御に関する処理を行う制御関連タスクが実行される制御関連タイムパーティションを含む複数のタイムパーティションのスケジューリング内容を示すスケジューリング情報に従って、前記制御関連タスクをスケジューリングして実行するスケジューリング手段と、
前記制御関連タスクの実行終了又は実行未終了を示す実行終了情報が格納される記憶部と、を備え、
前記スケジューリング手段は、前記制御関連タイムパーティションに関する前記タイムパーティションの切り替え時に前記実行終了情報を実行未終了に更新するとともに、前記制御関連タスクの実行終了時に前記実行終了情報を実行終了に更新し、
前記スケジューリング手段は、前記制御関連タイムパーティションに関する前記タイムパーティションの切り替え時に前記実行終了情報を実行未終了に更新する前に前記実行終了情報が実行未終了を示している場合を検出する、
制御装置。
Scheduling means for scheduling and executing the control-related task according to scheduling information indicating scheduling contents of a plurality of time partitions including a control-related time partition in which a control-related task that performs processing related to control of a control target is executed;
A storage unit for storing execution end information indicating the end of execution of the control-related task or non-execution of execution, and
The scheduling means updates the execution end information to non-execution at the time of switching the time partition related to the control-related time partition, and updates the execution end information to execution at the end of execution of the control-related task,
The scheduling means detects a case where the execution end information indicates execution not completed before the execution end information is updated to non-execution at the time of switching the time partition related to the control-related time partition;
Control device.
前記スケジューリング手段は、
前記スケジューリング情報に従って、前記制御関連タスクをスケジューリングして実行するシステムプログラムと、
前記システムプログラムを実行するプロセッサと、を含む、
請求項1に記載の制御装置。
The scheduling means includes
A system program for scheduling and executing the control-related task according to the scheduling information;
A processor for executing the system program,
The control device according to claim 1.
前記システムプログラムは、前記制御関連タスクが呼び出したときに、当該制御関連タスクを実行終了してスリープさせるための関数を提供し、
前記関数は、前記実行終了情報を前記制御関連タスクの実行終了に更新する処理を含む、
請求項2に記載の制御装置。
When the control-related task is called, the system program provides a function for ending execution of the control-related task and sleeping.
The function includes a process of updating the execution end information to the execution end of the control related task.
The control device according to claim 2.
前記システムプログラムは、前記スケジューリング情報に従って、前記複数のタイムパーティションをスケジューリングするパーティションスケジューラを含み、
前記パーティションスケジューラは、前記制御関連タイムパーティションに関する前記タイムパーティションの切り替え時に前記実行終了情報を実行未終了に更新するとともに、前記制御関連タイムパーティションに関する前記タイムパーティションの切り替え時に前記実行終了情報を実行未終了に更新する前に前記実行終了情報が実行未終了を示している場合を検出する、
請求項3に記載の制御装置。
The system program includes a partition scheduler that schedules the plurality of time partitions according to the scheduling information,
The partition scheduler updates the execution end information to unexecuted when the time partition related to the control-related time partition is switched, and also executes the execution end information when the time partition related to the control-related time partition is switched. Detecting the case where the execution end information indicates non-execution before updating to
The control device according to claim 3.
前記関数は、前記実行終了情報が実行未終了を示している場合の検出状況に応じた戻り値を前記制御関連タスクに返す請求項4に記載の制御装置。   The control device according to claim 4, wherein the function returns a return value corresponding to a detection state when the execution end information indicates that the execution has not ended to the control-related task. 前記記憶部は、初期値として正常であることを示す正常値が設定される検出結果値がさらに格納され、
前記システムプログラムは、前記実行終了情報が実行未終了を示している場合を検出したときに、前記検出結果値を異常であることを示す異常値に更新し、
前記関数は、前記検出結果値に対応する値を前記戻り値に設定する請求項5に記載の制御装置。
The storage unit further stores a detection result value in which a normal value indicating normal is set as an initial value,
The system program updates the detection result value to an abnormal value indicating that the detection result value is abnormal when detecting a case where the execution end information indicates non-execution,
The control device according to claim 5, wherein the function sets a value corresponding to the detection result value as the return value.
前記記憶部は、カウンタ値がさらに格納され、
前記システムプログラムは、前記実行終了情報が実行未終了を示している場合を検出したときに、前記カウンタ値を更新し、
前記関数は、前記カウンタ値を前記戻り値に設定する請求項5に記載の制御装置。
The storage unit further stores a counter value,
The system program updates the counter value when it detects a case where the execution end information indicates non-execution,
The control device according to claim 5, wherein the function sets the counter value to the return value.
前記制御関連タスクは、前記関数の戻り値が異常値に対応する値である場合、通常の処理に代えて、異常に対応する処理を実行する請求項6に記載の制御装置。   The control device according to claim 6, wherein when the return value of the function is a value corresponding to an abnormal value, the control-related task executes a process corresponding to an abnormality instead of a normal process. 前記システムプログラムは、前記実行終了情報が実行未終了を示している場合を検出したときに、前記カウンタ値をカウントアップし、
前記制御関連タスクは、前記関数の戻り値が所定の閾値以上である場合、通常の処理に代えて、異常に対応する処理を実行する請求項7に記載の制御装置。
The system program counts up the counter value when it detects a case where the execution end information indicates non-execution,
The control device according to claim 7, wherein the control-related task executes a process corresponding to an abnormality instead of a normal process when a return value of the function is a predetermined threshold value or more.
前記スケジューリング情報は、異常に対応する処理を行う異常処置タスクが実行される異常処理タイムパーティションを含む複数のタイムパーティションのスケジューリング内容をさらに示し、
前記制御関連タスクにおける異常に対応する処理は、前記パーティションスケジューラに異常を通知する処理を含み、
前記パーティションスケジューラは、前記制御関連タスクからの通知に応じて、前記異常処理タイムパーティションを含む複数のタイムパーティションのスケジューリング内容に従った前記異常処置タスクのスケジューリングを開始する、
請求項8又は9に記載の制御装置。
The scheduling information further indicates scheduling contents of a plurality of time partitions including an abnormality processing time partition in which an abnormality treatment task for performing processing corresponding to the abnormality is executed,
The process corresponding to the abnormality in the control related task includes a process of notifying the partition scheduler of the abnormality,
The partition scheduler starts scheduling of the abnormal treatment task according to the scheduling content of a plurality of time partitions including the abnormal processing time partition in response to a notification from the control-related task.
The control device according to claim 8 or 9.
前記制御関連タイムパーティションに関する前記タイムパーティションの切り替え時は、他のタイムパーティションから前記制御関連タイムパーティションへの切り替え時、及び、前記制御関連タイムパーティションから他のタイムパーティションへの切り替え時のいずれかである請求項1乃至10のいずれか1項に記載の制御装置。   The switching of the time partition related to the control-related time partition is either when switching from another time partition to the control-related time partition or when switching from the control-related time partition to another time partition. The control device according to claim 1. 制御対象の制御に関する処理を行う制御関連タスクが実行される制御関連タイムパーティションを含む複数のタイムパーティションのスケジューリング内容を示すスケジューリング情報に従って、前記制御関連タスクをプロセッサによってスケジューリングして実行する制御方法であって、
前記プロセッサが、前記制御関連タイムパーティションに関する前記タイムパーティションの切り替え時に、前記制御関連タスクの実行終了又は実行未終了を示す実行終了情報を実行未終了に更新するステップと、
前記プロセッサが、前記制御関連タスクの実行終了時に前記実行終了情報を実行終了に更新するステップと、
前記プロセッサが、前記制御関連タイムパーティションに関する前記タイムパーティションの切り替え時に前記実行終了情報を前記制御関連タスクの実行未終了に更新する前に、前記実行終了情報が実行未終了を示している場合を検出するステップと、
を備えた制御方法。
A control method in which a control-related task is scheduled and executed by a processor according to scheduling information indicating scheduling contents of a plurality of time-partitions including a control-related time partition in which a control-related task that performs processing related to control of a control target is executed. And
The processor updates execution end information indicating execution end or non-execution of the control-related task to non-execution when switching the time partition related to the control-related time partition;
The processor updating the execution end information to the end of execution at the end of execution of the control-related task;
Detected when the execution end information indicates that execution has not ended before the processor updates the execution end information to non-execution of the control-related task when switching the time partition related to the control-related time partition. And steps to
Control method with.
JP2011242470A 2011-11-04 2011-11-04 Control apparatus and control method Active JP5633501B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011242470A JP5633501B2 (en) 2011-11-04 2011-11-04 Control apparatus and control method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011242470A JP5633501B2 (en) 2011-11-04 2011-11-04 Control apparatus and control method

Publications (2)

Publication Number Publication Date
JP2013097719A JP2013097719A (en) 2013-05-20
JP5633501B2 true JP5633501B2 (en) 2014-12-03

Family

ID=48619562

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011242470A Active JP5633501B2 (en) 2011-11-04 2011-11-04 Control apparatus and control method

Country Status (1)

Country Link
JP (1) JP5633501B2 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6690570B2 (en) * 2017-02-02 2020-04-28 株式会社デンソー Parallelization method, parallelization tool, in-vehicle control device
JP6927089B2 (en) * 2018-03-05 2021-08-25 オムロン株式会社 Control device, system program, control method
JP7263993B2 (en) * 2019-09-16 2023-04-25 株式会社デンソー Vehicle control system

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005301812A (en) * 2004-04-14 2005-10-27 Hitachi Ltd Digital controller, and engine controller using the same
JP2006090356A (en) * 2004-09-21 2006-04-06 Denso Corp Vehicle control device and processing load control program
JP2010181923A (en) * 2009-02-03 2010-08-19 Yaskawa Electric Corp Control system for robot and real-time os
JP5446447B2 (en) * 2009-05-19 2014-03-19 トヨタ自動車株式会社 SAFETY CONTROL DEVICE AND SAFETY CONTROL METHOD

Also Published As

Publication number Publication date
JP2013097719A (en) 2013-05-20

Similar Documents

Publication Publication Date Title
JP5136695B2 (en) SAFETY CONTROL DEVICE AND SAFETY CONTROL METHOD
JP5446447B2 (en) SAFETY CONTROL DEVICE AND SAFETY CONTROL METHOD
JP5321686B2 (en) SAFETY CONTROL DEVICE AND SAFETY CONTROL METHOD
EP2677377B1 (en) Safety control device and safety control method
US8756606B2 (en) Safety controller and safety control method in which time partitions are scheduled according to a scheduling pattern
JP5240402B2 (en) SAFETY CONTROL DEVICE AND SAFETY CONTROL METHOD
JP5621857B2 (en) SAFETY CONTROL DEVICE AND SAFETY CONTROL METHOD
JP5834935B2 (en) SAFETY CONTROL DEVICE AND SAFETY CONTROL METHOD
JP5633501B2 (en) Control apparatus and control method
JP5906584B2 (en) Control apparatus and control method
JP6004057B2 (en) Information processing apparatus and DMA controller operation check method
JP5811865B2 (en) Control device and program execution method
JP5803689B2 (en) Information processing apparatus and DMA controller operation check method
JP5853716B2 (en) Information processing apparatus and task control method
JP5699910B2 (en) Control apparatus and control method
JP5849731B2 (en) Information processing apparatus and data storage method

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20140117

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20140827

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

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20140916

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20140929

R151 Written notification of patent or utility model registration

Ref document number: 5633501

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151