JP2007249357A - Information processor, distributed processing system, and task management method - Google Patents

Information processor, distributed processing system, and task management method Download PDF

Info

Publication number
JP2007249357A
JP2007249357A JP2006069130A JP2006069130A JP2007249357A JP 2007249357 A JP2007249357 A JP 2007249357A JP 2006069130 A JP2006069130 A JP 2006069130A JP 2006069130 A JP2006069130 A JP 2006069130A JP 2007249357 A JP2007249357 A JP 2007249357A
Authority
JP
Japan
Prior art keywords
task
data
reception
cpu
priority
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2006069130A
Other languages
Japanese (ja)
Inventor
Tetsuya Taira
哲也 平
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 JP2006069130A priority Critical patent/JP2007249357A/en
Publication of JP2007249357A publication Critical patent/JP2007249357A/en
Pending legal-status Critical Current

Links

Landscapes

  • Small-Scale Networks (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a distributed processing system for improving the predictability of a time required for the transmission/reception processing of communication data. <P>SOLUTION: An MCU 10 is provided with a CPU 101 and a communication I/F 104, and a real time OS 20 for carrying out the scheduling of a task to be performed by the CPU 101 is mounted. When an interruption request to the CPU 101 is generated by the data reception of the communication I/F 104, the CPU 101 starts an interruption handler. The interruption handler determines the wake-up order of a plurality of tasks in a standby status for data reception based on priority information applied to reception data arriving at the communication I/F 104, and makes performable a task RTA in a standby status for the reception of reception data applied with high priority based on the priority information. Furthermore, a real time OS20 determines the task assigned to the CPU 101 based on the priority of the plurality of tasks in an executable status. <P>COPYRIGHT: (C)2007,JPO&INPIT

Description

本発明は、情報処理装置間での送受信処理を一定時間内に完了させるリアルタイム通信の実現に有効な情報処理装置に関する。   The present invention relates to an information processing apparatus effective for realizing real-time communication in which transmission / reception processing between information processing apparatuses is completed within a predetermined time.

リアルタイム通信とは、一定時間内に送受信処理が完了する通信を意味する。リアルタイム通信は、複数の情報処理装置、即ちコンピュータが相互に接続されて構成され、ハードリアルタイムが要求される制御システム等の分散処理システムにおいて、コンピュータ間のデータ送受信を行うために特に必要とされる。このようなハードリアルタイムが要求される分散処理システムには、例えば、センサ情報を用いて姿勢制御を行うロボットの制御システムや、ブレーキ制御等の自動車の制御システムがある。   Real-time communication means communication in which transmission / reception processing is completed within a certain time. Real-time communication is particularly necessary for transmitting and receiving data between computers in a distributed processing system such as a control system in which a plurality of information processing apparatuses, that is, computers are connected to each other and require hard real-time. . Such distributed processing systems that require hard real-time include, for example, a robot control system that performs posture control using sensor information, and an automobile control system such as brake control.

上述したリアルタイム通信を実現可能な通信インタフェースとして、CAN(Controller Area Network)、ARCNET(登録商標)、FlexRay(登録商標)等が知られている。しかしながら、これらの通信インタフェースの制御システムへの適用には、特別なノウハウが要求される、また、システム開発環境のコストが高い。さらに、これらの通信インタフェースのデータ転送速度の上限は10Mbit/s程度であり、高速通信に対応していない。   As a communication interface capable of realizing the above-mentioned real-time communication, CAN (Controller Area Network), ARCNET (registered trademark), FlexRay (registered trademark), and the like are known. However, application of these communication interfaces to the control system requires special know-how, and the cost of the system development environment is high. Furthermore, the upper limit of the data transfer rate of these communication interfaces is about 10 Mbit / s, and does not support high-speed communication.

一方で、高速通信に対応した通信インタフェースに、イーサネット(登録商標)、USB(Universal Serial Bus)2.0、IEEE1394等のインタフェースがある。なお、本明細書では、IEEE802.3委員会によって標準化された10BASE−T、100BASE−TX、1000BASE−T等を総称してイーサネット(登録商標)と呼ぶ。これらのインタフェースは、PC向けの通信インタフェースとして広く普及していることから開発環境が充実しているという利点がある。しかしながら、リアルタイム通信機能を持っていないため、ハードリアルタイムを要求する制御システムに適用することが困難であった。   On the other hand, there are interfaces such as Ethernet (registered trademark), USB (Universal Serial Bus) 2.0, and IEEE 1394 as communication interfaces corresponding to high-speed communication. In this specification, 10BASE-T, 100BASE-TX, 1000BASE-T and the like standardized by the IEEE 802.3 committee are collectively referred to as Ethernet (registered trademark). Since these interfaces are widely used as communication interfaces for PCs, there is an advantage that the development environment is substantial. However, since it does not have a real-time communication function, it has been difficult to apply it to a control system that requires hard real-time.

イーサネット(登録商標)等の高速通信インタフェースにおいてリアルタイム通信を実現するため、又はリアルタイム通信に近づけるためには、通信データの送受信処理に要する時間の予測可能性を高める必要がある。   In order to realize real-time communication or approach real-time communication in a high-speed communication interface such as Ethernet (registered trademark), it is necessary to increase the predictability of time required for transmission / reception processing of communication data.

ここで、通信データの送受信処理に要する時間は、データ送信側でのデータ送信処理に要する時間、送信側の通信インタフェースと受信側の通信インタフェースの間の通信ネットワークの転送時間、受信側でのデータ受信処理に要する時間を総合して定まるものである。通信データの送受信処理に要する時間の予測可能性を向上させるためには、これらの各要素の処理時間の変動を抑制する必要がある。   Here, the time required for the transmission / reception process of communication data includes the time required for the data transmission process on the data transmission side, the transfer time of the communication network between the communication interface on the transmission side and the communication interface on the reception side, and the data on the reception side. The time required for the reception process is determined comprehensively. In order to improve the predictability of the time required for transmission / reception processing of communication data, it is necessary to suppress variations in the processing time of each of these elements.

さらに、ロボット等の制御システムを構成するコンピュータ間で転送される通信データは、ハードリアルタイムが要求されるものに限らない。つまり、一定周期でのデータ送受信は必ずしも必要でないが、データ量が大きいために高い転送速度を要求する通信データも存在している。   Furthermore, communication data transferred between computers constituting a control system such as a robot is not limited to data that requires hard real time. That is, data transmission / reception at a constant cycle is not necessarily required, but there is communication data that requires a high transfer rate because of a large amount of data.

このようなリアルタイム性に対する要求レベルの異なる様々な通信データが1つの通信インタフェースに到着し、通信データの到着待ちを行うタスクが複数存在している状況において、リアルタイム性の要求レベルが高いタスクの受信処理が、通信インタフェースに先に到着している他の通信データの受信処理によって待たされるようでは、リアルタイム性を要求するタスクのデータ受信処理に要する時間の予測可能性を高めることは困難である。   In such a situation where various communication data with different real-time requirement levels arrive at one communication interface and there are a plurality of tasks waiting for the arrival of communication data, reception of a task with a high real-time requirement level is received. It is difficult to increase the predictability of the time required for the data reception processing of a task that requires real-time performance so that the processing is waited by reception processing of other communication data that has arrived at the communication interface first.

なお、特許文献1には、リアルタイム通信と非リアルタイム通信の両方を行うことが可能な環境において、リアルタイム通信によるデータ通信に遅れが生じないようにする通信装置が開示されている。具体的には、リアルタイム通信用のデータを格納するバッファと非リアルタイム通信用のデータを格納するバッファとを備えることとし、データの送信時又は受信時には、リアルタイム通信用のデータを格納するバッファから優先してデータを取り出してデータ送信又はデータ受信を行うものである。
特開2005−198023号公報
Patent Document 1 discloses a communication device that prevents a delay in data communication by real-time communication in an environment where both real-time communication and non-real-time communication can be performed. Specifically, a buffer for storing data for real-time communication and a buffer for storing data for non-real-time communication are provided, and priority is given to the buffer for storing data for real-time communication when data is transmitted or received. Thus, data is taken out and data transmission or data reception is performed.
JP 2005-198023 A

本発明は、上述した事情を考慮してなされたものであり、複数のコンピュータが接続された分散処理システムにおいて、通信データの送受信処理に要する時間の予測可能性を向上させることを目的とする。   The present invention has been made in consideration of the above-described circumstances, and an object of the present invention is to improve the predictability of time required for transmission / reception processing of communication data in a distributed processing system in which a plurality of computers are connected.

本発明にかかる情報処理装置は、タスクを実行するCPU、データを送受信可能な通信デバイス、イベント処理手段、及びスケジューリング手段とを備える。ここで、前記イベント処理手段は、前記通信デバイスに到着した受信データに付与されている優先度情報に基づいて、データ受信のために待ち状態にある複数のタスクの起床順序を決定し、前記優先度情報によって高い優先度が与えられた受信データの受信待ちを行っているタスクを優先的に実行可能とする。さらに、前記スケジューリング手段は、実行可能な状態にある複数のタスクの優先順位に基づいて、前記CPUに割り当てるタスクを決定する。   An information processing apparatus according to the present invention includes a CPU that executes a task, a communication device that can transmit and receive data, an event processing unit, and a scheduling unit. Here, the event processing means determines the wake-up order of a plurality of tasks waiting for data reception based on the priority information given to the received data arriving at the communication device, and the priority It is possible to preferentially execute a task waiting for reception of received data to which a high priority is given by the degree information. Further, the scheduling means determines a task to be assigned to the CPU based on a priority order of a plurality of tasks in an executable state.

このような構成により、イベント処理手段によって優先順位の高いタスクをいち早く実行可能状態に遷移させ、スケジュール手段によって当該タスクをいち早く実行状態にディスパッチすることができる。このため、1つの通信デバイスに対して複数のタスクがデータの受信待ちを行っており、当該通信デバイスに複数の受信データが到着している場合であっても、リアルタイム通信を要求するような優先順位の高いタスクを優先的に実行できる。これにより、受信データの到着から優先順位の高い受信タスクが実行されるまでの処理時間が規定でき、通信データの送受信処理に要する時間の予測可能性を向上させることが可能となる。   With such a configuration, a task having a high priority can be quickly transitioned to an executable state by the event processing unit, and the task can be dispatched to an execution state quickly by the scheduling unit. For this reason, priority is given to requesting real-time communication even when a plurality of tasks are waiting to receive data for one communication device and a plurality of received data have arrived at the communication device. High priority tasks can be executed preferentially. As a result, the processing time from the arrival of received data to the execution of a receiving task with a high priority can be defined, and the predictability of the time required for the transmission / reception processing of communication data can be improved.

なお、前記優先度情報が示す前記受信データの優先度は、当該受信データを処理するタスクの優先順位を反映して決定されていることが望ましい。   It is desirable that the priority of the received data indicated by the priority information is determined by reflecting the priority order of tasks that process the received data.

また、前記イベント処理手段は、前記通信デバイスから前記CPUに対する割り込み要求に応じて起動される割り込みハンドラ・プログラムを実行することにより実現することが望ましい。このように割り込みハンドラによって実現すれば、イベント処理手段が行う機能の実装に際して、タスク・スケジューリングを行うリアルタイムOSの改良を特に必要としないという利点がある。   The event processing means is preferably realized by executing an interrupt handler program that is activated in response to an interrupt request from the communication device to the CPU. When implemented by an interrupt handler in this way, there is an advantage that no special improvement of the real-time OS for performing task scheduling is required when implementing the function performed by the event processing means.

さらに、上述した本発明にかかる情報処理装置は、前記CPUで実行されるタスクの状態を管理するタスク管理手段を備えることが望ましい。ここで、前記タスク管理手段は、前記CPUに割り当てられて実行されている第1の状態、実行可能であるが、前記CPUにおいて他のタスクが実行中であるために前記CPUに割り当てられていない第2の状態、前記通信デバイスに到着するデータの受信待ちのために停止された第3の状態、及び、前記通信デバイスに到着するデータの受信待ちを除く他の条件成立待ちのために停止された第4の状態の少なくとも4つの状態でタスクを管理し、前記第3の状態にあるタスクが受信待ちを行っているデータが、所定の時間内に前記通信デバイスに到着しない場合には、当該タスクを前記第2の状態に遷移させることを特徴とする。   Furthermore, the information processing apparatus according to the present invention described above preferably includes a task management unit that manages a state of a task executed by the CPU. Here, the task management means is executable in the first state assigned and executed by the CPU, but is not assigned to the CPU because another task is being executed in the CPU. The second state, the third state stopped due to the reception of data arriving at the communication device, and the other state other than the waiting for the reception of data arriving at the communication device; If the task is managed in at least four states of the fourth state, and the data waiting for reception of the task in the third state does not arrive at the communication device within a predetermined time, The task is transited to the second state.

このように、所定の時間内に受信データが得られない場合に、受信待ちを行っているタスクを、CPUに割り当てられる状態に遷移させることにより、リアルタイム性を要求するタスクの定期的な処理を継続できる。   As described above, when the received data is not obtained within a predetermined time, the task waiting for reception is changed to the state assigned to the CPU, thereby periodically processing the task that requires real-time performance. Can continue.

また、上述した本発明にかかる情報処理装置は、一定周期で割り込み要求を生成するタイマと、前記通信デバイスからのデータ送信処理を実行する送信タスクを、前記タイマが生成する割り込み要求に応じて実行可能な状態とする手段を備えることが望ましい。これにより、リアルタイム通信の実現に必要なデータ送信の開始時刻を制御でき、通信データの送受信処理に要する時間の予測可能性をさらに向上させることが可能となる。   The information processing apparatus according to the present invention described above executes a timer for generating an interrupt request at a constant period and a transmission task for executing a data transmission process from the communication device in response to the interrupt request generated by the timer. It is desirable to provide a means for making it possible. Thereby, it is possible to control the start time of data transmission necessary for realizing real-time communication, and it is possible to further improve the predictability of the time required for communication data transmission / reception processing.

さらに、本発明にかかる情報処理装置におけるデータ送信処理では、前記通信デバイスから送信されるデータは、前記送信タスクによって、前記送信タスクがアクセス可能なユーザメモリ領域から前記通信デバイスにDMA転送することが望ましい。このような構成により、CPUによるデータコピーを伴わずに送信データの転送を開始できるため、メモリコピーに伴う遅延を回避し、送信処理を高速に行うことができる。また、さらに、前記送信タスクは、前記送信タスクの生成に応じて割り当てられたユーザメモリ領域を、当該送信タスクの終了まで前記DMA転送に継続的に使用することが望ましい。これにより、送信データが発生するたびにメモリ領域の確保と解放を繰り返すことによる予測不可能な遅延を排除できるため、送信処理に要する処理時間の予測可能性を向上させることができる。   Furthermore, in the data transmission process in the information processing apparatus according to the present invention, the data transmitted from the communication device may be DMA-transferred from the user memory area accessible to the transmission task to the communication device by the transmission task. desirable. With such a configuration, since transmission of transmission data can be started without data copying by the CPU, a delay associated with memory copying can be avoided and transmission processing can be performed at high speed. Further, it is desirable that the transmission task continuously uses the user memory area allocated according to the generation of the transmission task for the DMA transfer until the end of the transmission task. As a result, an unpredictable delay caused by repeatedly securing and releasing the memory area each time transmission data is generated can be eliminated, so that the predictability of the processing time required for the transmission process can be improved.

本発明にかかる分散処理システムは、上述した本発明にかかる情報処理装置を複数備えており、複数の前記情報処理装置が備える前記通信デバイスはイーサネット(登録商標)デバイスであって、前記複数の情報処理装置はレイヤ2スイッチを介して通信可能に接続されているものである。このような構成であれば、レイヤ2スイッチと情報処理装置を繋ぐリンクは全二重で専有された状態である。このため、MACフレーム衝突によるデータ送信待ちが発生する余地はなく、情報処理装置を繋ぐネットワークでのデータ転送時間の予測が可能となる。   The distributed processing system according to the present invention includes a plurality of information processing apparatuses according to the present invention described above, and the communication devices included in the plurality of information processing apparatuses are Ethernet (registered trademark) devices, and the plurality of information The processing devices are communicably connected via a layer 2 switch. With such a configuration, the link connecting the layer 2 switch and the information processing apparatus is in a full-duplex exclusive state. For this reason, there is no room for waiting for data transmission due to a MAC frame collision, and the data transfer time in the network connecting the information processing apparatuses can be predicted.

本発明にかかるタスク管理方法は、実行可能状態にある複数のタスクのCPUへの割り当て順序をタスクの優先度に基づいてスケジューリングするリアルタイムOSを搭載した情報処理装置におけるタスク管理方法である。具体的には、まず、前記CPUが、前記情報処理装置が備える通信デバイスにデータが到着したことを示す割り込み要求に応じて割り込みハンドラを起動する。次に、前記割り込みハンドラが、前記通信デバイスに到着している複数の受信データに付与されている優先度情報を走査することにより、前記優先度情報によって最も高い優先度が与えられた受信データを選択し、選択した受信データの受信待ちを行っているタスクを優先的に実行可能状態に遷移させる。最後に、前記リアルタイムOSが、前記割り込みハンドラによって実行可能状態とされたタスクのスケジューリング及び前記CPUへの割り当てを行うものである。   The task management method according to the present invention is a task management method in an information processing apparatus equipped with a real-time OS that schedules an assignment order of a plurality of tasks in an executable state to a CPU based on task priority. Specifically, first, the CPU activates an interrupt handler in response to an interrupt request indicating that data has arrived at a communication device included in the information processing apparatus. Next, the interrupt handler scans the priority information given to the plurality of reception data arriving at the communication device, so that the reception data given the highest priority by the priority information is obtained. Select and preferentially transition the task waiting for reception of the selected received data to an executable state. Finally, the real-time OS performs scheduling of tasks that are made executable by the interrupt handler and assigns them to the CPU.

このような方法により、通信デバイスに受信データが到着してから優先順位の高い受信タスクが実行されるまでの処理時間が規定でき、通信データの送受信処理に要する時間の予測可能性を向上させることが可能となる。   By such a method, it is possible to specify the processing time from when the received data arrives at the communication device until the reception task with a higher priority is executed, and to improve the predictability of the time required for the transmission / reception processing of the communication data Is possible.

本発明により、通信データの送受信処理に要する時間の予測可能性を向上させることが可能な情報処理装置、分散処理システム、及びタスク管理方法を提供できる。   According to the present invention, it is possible to provide an information processing apparatus, a distributed processing system, and a task management method capable of improving the predictability of time required for communication data transmission / reception processing.

以下では、本発明を適用した具体的な実施の形態について、図面を参照しながら詳細に説明する。各図面において、同一要素には同一の符号が付されており、説明の明確化のため、必要に応じて重複説明は省略する。   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 will be omitted as necessary for the sake of clarity.

発明の実施の形態1.
本実施の形態にかかる制御システム1の構成例を図1に示す。制御システム1は、複数のマイクロ・コントローラ・ユニット(MCU)10が相互に接続された分散制御システムである。図1では、2つのマイクロ・コントローラ・ユニット(MCU)10a及び10bが、イーサネット(登録商標)、具体的には100BASE−TXによって相互に接続された構成例を示している。MCU10aは、カメラ11によって入力された画像データに対する画像処理を行うコンピュータである。MCU11bは、イーサネット(登録商標)を介してMCU10aの画像処理結果を入力し、MCU10aの画像処理結果(例えば、目標物の位置情報など)を利用して、ロボットの可動部を駆動するためのモータ12を制御するコンピュータである。なお、図1の構成は一例であり、イーサネット(登録商標)を介して制御に必要なデータを交換するMCU10a及び10bは、様々な対象を制御する目的に使用可能である。以下では、MCU10a及び10bのハードウェア構成、ソフトウェア構成、及びリアルタイム通信の実現に有効な処理等について説明する。なお、以下では、MCU10a及び10bをまとめてMCU10と記載している。
Embodiment 1 of the Invention
A configuration example of the control system 1 according to the present embodiment is shown in FIG. The control system 1 is a distributed control system in which a plurality of micro controller units (MCUs) 10 are connected to each other. FIG. 1 shows a configuration example in which two micro controller units (MCUs) 10a and 10b are connected to each other by Ethernet (registered trademark), specifically, 100BASE-TX. The MCU 10 a is a computer that performs image processing on image data input by the camera 11. The MCU 11b inputs the image processing result of the MCU 10a via the Ethernet (registered trademark), and uses the image processing result (for example, position information of the target) of the MCU 10a to drive a movable part of the robot. 12 is a computer for controlling 12. The configuration of FIG. 1 is an example, and MCUs 10a and 10b that exchange data necessary for control via Ethernet (registered trademark) can be used for the purpose of controlling various objects. Below, the hardware configuration of the MCUs 10a and 10b, the software configuration, processing effective for realizing real-time communication, and the like will be described. In the following, MCUs 10a and 10b are collectively referred to as MCU10.

MCU10のハードウェア構成を図2に示す。CPU101は、ROM(Read Only Memory)102又は図示しないフラッシュメモリ等の不揮発性メモリに格納されたシステム・プログラム及び対象物を制御するためのアプリケーション・プログラムを実行する演算処理部である。   The hardware configuration of the MCU 10 is shown in FIG. The CPU 101 is an arithmetic processing unit that executes a system program stored in a ROM (Read Only Memory) 102 or a nonvolatile memory such as a flash memory (not shown) and an application program for controlling an object.

RAM(Random Access Memory)103は、CPU101のワーク領域として使用され、後述する通信インタフェース104、デジタルI/O105、アナログI/O106を介して送受信されるデータの一時保存領域としても使用される。   A RAM (Random Access Memory) 103 is used as a work area of the CPU 101, and is also used as a temporary storage area for data transmitted and received via a communication interface 104, a digital I / O 105, and an analog I / O 106, which will be described later.

通信インタフェース104は、他のMCU10との間で制御データを送受信するためのインタフェースであり、図1の構成例では100BASE−TXインタフェースである。デジタルI/O105は、カメラ、圧力センサ、温度センサ等の様々なセンサから入力されるデータ、及びセンサに出力される制御信号等のデジタル信号の入出力を行うインタフェースである。一方、アナログI/Oは、A/D変換処理及びD/A変換処理を行うことによりアナログ信号の入出力を行うインタフェースである。なお、外部のセンサとのインタフェースをMCU10間でのデータ交換を行うデータ通信インタフェース104に統合してもよい。   The communication interface 104 is an interface for transmitting / receiving control data to / from another MCU 10, and is a 100BASE-TX interface in the configuration example of FIG. The digital I / O 105 is an interface that inputs and outputs data input from various sensors such as a camera, a pressure sensor, and a temperature sensor, and digital signals such as control signals output to the sensor. On the other hand, the analog I / O is an interface for inputting / outputting analog signals by performing A / D conversion processing and D / A conversion processing. Note that an interface with an external sensor may be integrated into the data communication interface 104 that exchanges data between the MCUs 10.

次に、CPU101において実行されるシステム・プログラム及びアプリケーション・プログラムについて、図3を用いて説明する。本実施の形態のMCU10が実行するシステム・プログラムはマルチタスク環境を備えるリアルタイムOSであり、アプリケーション・プログラムは時間制約の違い等に基づいてタスクに分割されている。図3は、MCU10が実行するリアルタイムOS20と、リアルタイムOS20が提供するマルチタスク環境上で並列処理される複数のタスクの構成を示している。   Next, system programs and application programs executed by the CPU 101 will be described with reference to FIG. The system program executed by the MCU 10 of the present embodiment is a real-time OS having a multitask environment, and the application program is divided into tasks based on differences in time constraints. FIG. 3 shows a configuration of a real-time OS 20 executed by the MCU 10 and a plurality of tasks processed in parallel on a multitask environment provided by the real-time OS 20.

ここで、リアルタイムOSとは、マルチタスク環境を提供し、プリエンプティブな優先度ベースのタスク・スケジューリングを行うシステム・プログラムである。プリエンプティブとは、実行途中のタスクの処理を停止して、他のタスクにCPUを割り当て可能であることを意味する。優先度ベースとは、タスクに与えられた優先度の高低によってCPUで実行するタスクが決定されることを意味する。また、タスクとは、リアルタイムOSが提供するマルチタスク環境において並列実行されるプログラム単位である。なお、リアルタイムOSは、リアルタイム・カーネルとも呼ばれる場合もある。なお、リアルタイムOSとしては、社団法人トロン協会によって規定されたμITRON4.0仕様が、リアルタイムOSの標準仕様として広く普及している。   Here, the real-time OS is a system program that provides a multitasking environment and performs preemptive priority-based task scheduling. Preemptive means that processing of a task in the middle of execution can be stopped and a CPU can be assigned to another task. Priority-based means that the task to be executed by the CPU is determined by the priority level given to the task. A task is a program unit that is executed in parallel in a multitasking environment provided by the real-time OS. The real-time OS may also be called a real-time kernel. As a real-time OS, the μITRON 4.0 specification defined by the TRON Association is widely used as a standard specification for a real-time OS.

リアルタイムOS20は、CPU101、RAM103等のハードウェア資源を利用して、タスク管理、タスク間同期、割り込み管理、メモリ管理、時間管理、デバイス管理等を実行する。これらの機能は、従来のリアルタイムOSが標準的に備える機能であるため、各機能の概略のみを以下に示す。   The real-time OS 20 executes task management, synchronization between tasks, interrupt management, memory management, time management, device management, and the like using hardware resources such as the CPU 101 and the RAM 103. Since these functions are functions that a conventional real-time OS is provided as standard, only an outline of each function is shown below.

タスク管理は、タスク状態の管理、起動可能な状態にあるタスクを実行順序を示すレディキューの管理、タスクに与えられた優先度の管理、コンテキストの保存等を行うことにより、タスクの生成、削除、起動、及び終了を行う手段を提供するものである。タスク管理によって実現される管理機構を以下ではスケジューラと呼ぶこととする。   Task management creates and deletes tasks by managing task states, managing ready queues that indicate the execution order of tasks that can be started, managing priorities assigned to tasks, and saving contexts. , Providing means for starting and ending. Hereinafter, a management mechanism realized by task management will be referred to as a scheduler.

タスク間同期は、セマフォやリンクリストに基づくメールボックス等を利用して、タスク間通信及びタスク間での処理の待ち合わせを行う手段を提供するものである。   Inter-task synchronization provides means for inter-task communication and waiting for processing between tasks using a semaphore, a mailbox based on a linked list, or the like.

割り込み管理は、CPUへの割込みに応じて起動される割り込みハンドラを管理するものである。具体的には、割り込みハンドラを定義し、割り込みと割り込みハンドラとを対応させる役割を担うものである。   Interrupt management manages interrupt handlers that are activated in response to interrupts to the CPU. Specifically, it defines an interrupt handler and plays a role of associating interrupts with interrupt handlers.

時間管理は、システム時刻を管理し、時間に依存した処理を実現する。具体的には、システム時刻に基づいて、一定周期で起動されるハンドラ(周期ハンドラと呼ぶ)、指定した時刻に起動されるハンドラ(アラームハンドラと呼ぶ)等のいわゆるタイムイベントハンドラの生成、削除を行う。   Time management manages system time and realizes time-dependent processing. Specifically, based on the system time, generation and deletion of so-called time event handlers such as handlers that are activated at regular intervals (called cyclic handlers), handlers that are activated at specified times (called alarm handlers), etc. Do.

メモリ管理は、タスク間通信等に用いられる共有メモリ領域の管理を担うものである。   Memory management is responsible for managing a shared memory area used for inter-task communication and the like.

最後に、デバイス管理は、通信インタフェース104の入出力制御等の各ハードウェア・デバイスを動作させるためのデバイス・ドライバ機能、及びデバイス・ドライバ管理機能を提供する。なお、デバイス・ドライバ機能は、タスク管理、タスク間同期、割り込み管理、メモリ管理、及び時間管理等のカーネル部分から独立したソフトウェアとして実現される場合もある。   Finally, the device management provides a device driver function for operating each hardware device such as input / output control of the communication interface 104, and a device driver management function. The device driver function may be realized as software independent from the kernel part such as task management, inter-task synchronization, interrupt management, memory management, and time management.

受信タスクRTA、受信タスクRTB、送信タスクSTC、及びタスクTDは、上述したリアルタイムOS20のマルチタスク環境で実行されるタスク群の一例を示すものである。なお、後の説明のため、受信タスクRTA及び受信タスクRTBは、通信インタフェース104によって受信されるデータを処理するタスクとする。さらに、受信タスクRTAはリアルタイム通信を要求する時間制約が厳しいタスクであり、受信タスクRTAには受信タスクRTBより高い優先度が与えられているものとする。   The reception task RTA, the reception task RTB, the transmission task STC, and the task TD indicate an example of a task group that is executed in the multitask environment of the real-time OS 20 described above. For the following explanation, it is assumed that the reception task RTA and the reception task RTB are tasks for processing data received by the communication interface 104. Furthermore, it is assumed that the reception task RTA is a task with strict time constraints that require real-time communication, and the reception task RTA is given higher priority than the reception task RTB.

また、送信タスクSTCは、通信インタフェース105を介して他のMCU10にデータを送信する処理を実行するタスクとする。タスクTDは、通信インタフェース104を介したデータ送受信を行わないタスクであり、受信タスクRTA、受信タスクRTB、及び送信タスクSTCに比べて低い優先度がタスクTDに与えられているものとする。   The transmission task STC is a task that executes a process of transmitting data to another MCU 10 via the communication interface 105. The task TD is a task that does not perform data transmission / reception via the communication interface 104. It is assumed that the task TD has a lower priority than the reception task RTA, the reception task RTB, and the transmission task STC.

割り込みハンドラINHは、CPU101に接続された通信インタフェース104等のデバイスが要求するハードウェア割り込みに応じて起動されるプログラムである。   The interrupt handler INH is a program that is activated in response to a hardware interrupt requested by a device such as the communication interface 104 connected to the CPU 101.

続いて以下では、通信インタフェース104でのリアルタイム通信の実現に有効であるMCU10の特徴的な処理、及び制御システム1の構成について説明する。   Subsequently, the characteristic processing of the MCU 10 that is effective for realizing real-time communication in the communication interface 104 and the configuration of the control system 1 will be described.

<データ受信処理>
MCU10が備える通信インタフェース104に受信データが到着したときに行わるタスク・ディスパッチの流れを図4乃至6を用いて説明する。図4は、通信インタフェース104がデータを受信してから、データ受信待ちのために停止されていた受信タスクRTAが起動されるまでを示すタイミング図である。
<Data reception processing>
The flow of task dispatch performed when received data arrives at the communication interface 104 provided in the MCU 10 will be described with reference to FIGS. FIG. 4 is a timing chart showing the period from when the communication interface 104 receives data until the reception task RTA that has been stopped because of waiting for data reception is started.

図4において、通信インタフェース104にデータが到着すると、通信インタフェース104からCPU101に対して割り込み要求が行われる(S11)。この割り込み要求に応じてCPU101によって割り込みハンドラINHが起動され、割り込みハンドラNHによる割り込み処理が実行される(S12)。   In FIG. 4, when data arrives at the communication interface 104, an interrupt request is made from the communication interface 104 to the CPU 101 (S11). In response to this interrupt request, the CPU 101 activates the interrupt handler INH, and interrupt processing by the interrupt handler NH is executed (S12).

ここで、通信インタフェース104のデータ受信に基づいて起動された割り込みハンドラINHが行う割り込み処理(S12)の詳細を図5のフローチャートを用いて説明する。割り込みハンドラINHが起動されると、通信インタフェース104の受信データが格納されたメモリ領域にアクセスし、受信データに与えられた優先度を走査する(ステップS21)。ここで、受信データに与えられた優先度とは、データ送信側のMCU10によって通信データに付加されるものであり、時間制約が厳しいタスクに引き渡されるデータほど高い優先度が与えられている。   Here, details of the interrupt processing (S12) performed by the interrupt handler INH activated based on the data reception of the communication interface 104 will be described with reference to the flowchart of FIG. When the interrupt handler INH is activated, the memory area where the received data of the communication interface 104 is stored is accessed, and the priority given to the received data is scanned (step S21). Here, the priority given to the received data is added to the communication data by the MCU 10 on the data transmission side, and higher priority is given to data that is handed over to a task with severe time constraints.

通信インタフェース104で転送される通信データに優先度を与えるためには、まず、リアルタイム通信を要求する送信タスク及び受信タスクが他のタスクより優先的に実行されるように、スケジューラにおいて他のタスクに比べて高い優先度を与えることとする。ここでの他のタスクには、リアルタイム通信を要求しない受信タスク及び送信タスクが含まれる。その上で、送信タスクの実行時に、スケジューラがリアルタイム通信を要求するタスクに対して与える優先度を反映した優先度を転送データに付加することとすればよい。   In order to give priority to communication data transferred by the communication interface 104, first, other tasks are executed in the scheduler so that a transmission task and a reception task that request real-time communication are executed with priority over other tasks. A higher priority will be given. The other tasks here include a reception task and a transmission task that do not require real-time communication. In addition, when the transmission task is executed, a priority reflecting the priority given by the scheduler to the task requesting real-time communication may be added to the transfer data.

通信インタフェース104が100BASE−TXインタフェースである場合に転送されるMACフレームの構成を図6に示す。このようなMACフレームによるデータ転送を行う場合は、IEEE802.1pで規定されるVLANタグを挿入し、VLANタグ中の3ビットのユーザ優先度フィールドを、タスクに対して与える優先度を反映した優先度を示すフィールドとして利用してもよい。また、フレーム・ヘッダではなく、ペイロード中の所定の位置に挿入することとしてもよい。   FIG. 6 shows the structure of a MAC frame transferred when the communication interface 104 is a 100BASE-TX interface. When performing data transfer using such a MAC frame, a VLAN tag defined by IEEE802.1p is inserted, and a priority reflecting the priority given to the task by the 3-bit user priority field in the VLAN tag It may be used as a field indicating the degree. Moreover, it is good also as inserting not in a frame header but in the predetermined position in a payload.

図5に戻り、ステップS22では、最も優先度が高い受信データを判定し、当該受信データに対応する受信タスクを判定する。例えば、図3に示した受信タスクRTAが受信待ちを行っているデータ、及び受信タスクRTBが受信待ちを行っているデータがともに通信インタフェース104に到着している場合には、優先順位の高い受信タスクRTAが受信待ちを行っているデータが判定され、これに対応する受信タスクRTAが判定される。   Returning to FIG. 5, in step S22, the reception data with the highest priority is determined, and the reception task corresponding to the reception data is determined. For example, when both the data waiting for reception by the reception task RTA shown in FIG. 3 and the data waiting for reception by the reception task RTB have arrived at the communication interface 104, reception with high priority is performed. The data that the task RTA is waiting to receive is determined, and the reception task RTA corresponding to this is determined.

ステップS23では、ステップS22で判定された受信タスクRTAを起床する。具体的には、受信データの格納場所を示すアドレスを受信タスクRTAに引き渡すとともに、受信タスクRTAの状態を、データ受信を待っている状態からスケジューリング対象となる実行可能状態(Ready状態)に変更する。なお、データ受信を待っている状態とは、コンテキストを保存してタスクの実行が中断された待ち状態(Waiting状態)又は後述するCommunication状態(以下、Com状態と呼ぶ)である。   In step S23, the reception task RTA determined in step S22 is woken up. Specifically, the address indicating the storage location of the received data is handed over to the reception task RTA, and the state of the reception task RTA is changed from a state waiting for data reception to an executable state (Ready state) to be scheduled. . Note that the state of waiting for data reception is a waiting state (waiting state) in which the context is saved and execution of the task is interrupted, or a communication state (to be referred to as a “com state” hereinafter).

続いて図4に戻り、割り込みハンドラINHによる割り込み処理(S12)に引き続く処理を説明する。割り込みハンドラINHの終了後のS13では、リアルタイムOS20によるタスクのスケジューリングが行われる。なお、当該スケジューリングの要請は、割り込みハンドラINHが明示的に要請する場合と、割り込みハンドラINHの終了に応じてリアルタイムOS20が暗黙に行う場合がある。このスケジューリングによって、データ受信待ちが解除されてReady状態となった受信タスクRTAがスケジューリングされる。このとき、リアルタイム通信を要求する受信タスクRTAに最も高い優先度を与えておくことにより、受信タスクRTAのディスパッチ処理が行われ(S14)、受信タスクRTAがCPU101において実行される(S15)。   Subsequently, returning to FIG. 4, processing subsequent to the interrupt processing (S12) by the interrupt handler INH will be described. In S13 after the end of the interrupt handler INH, task scheduling by the real-time OS 20 is performed. The scheduling request may be explicitly requested by the interrupt handler INH or may be implicitly performed by the real-time OS 20 according to the end of the interrupt handler INH. By this scheduling, the reception task RTA that has been released from the data reception wait state and is in the Ready state is scheduled. At this time, by giving the highest priority to the reception task RTA that requests real-time communication, the reception task RTA is dispatched (S14), and the reception task RTA is executed in the CPU 101 (S15).

上述したように本実施の形態にかかるMCU10では、対応するタスクの優先順位を反映した優先度情報をMCU10間の通信データに付与することとし、通信データに付与された優先度を参照することによってスケジューリング対象とすべき受信タスクを選択するものである。これにより、優先度の低い受信タスクRTBに対する受信データが優先度の高い受信タスクRTAに対する受信データより先に通信インタフェース104に到着していた場合であっても、受信タスクRTAを優先して実行できる。   As described above, in the MCU 10 according to the present embodiment, priority information reflecting the priority order of the corresponding task is given to the communication data between the MCUs 10, and the priority given to the communication data is referred to. A reception task to be scheduled is selected. As a result, even when the reception data for the reception task RTB having a low priority arrives at the communication interface 104 before the reception data for the reception task RTA having a high priority, the reception task RTA can be executed with priority. .

通信インタフェース104に複数のデータが到着しているために、リアルタイム通信を要求する受信タスクRTAの実行開始が遅れたのでは、受信データの到着から受信タスクRTAがディスパッチされるまでの処理時間に予測不可能な変動が発生することになる。これに対して本実施の形態のMCU10は、通信インタフェース104に複数のデータが到着している状況下でも、受信タスクRTAを優先して実行可能である。このため、受信データの到着から受信タスクRTAがディスパッチされるまでの処理時間の予測可能性を向上させることができる。   If the start of execution of the reception task RTA that requests real-time communication is delayed because a plurality of data has arrived at the communication interface 104, the processing time from the arrival of the reception data until the reception task RTA is dispatched is predicted. Unacceptable fluctuations will occur. In contrast, the MCU 10 according to the present embodiment can execute the reception task RTA with priority even under a situation where a plurality of data arrives at the communication interface 104. For this reason, it is possible to improve the predictability of the processing time from the arrival of the received data until the reception task RTA is dispatched.

また、受信データに付与された優先度情報に基づいて、データ受信待ちからReady状態に遷移させるタスクを決定する処理は、割り込みハンドラINHによって実現されている。このため、本機能の実装に際して、リアルタイムOS20、具体的にはタスク・スケジューリングを行うタスク管理機能(スケジューラ)の改良を特に必要としないという利点がある。   Further, based on the priority information given to the received data, the process for determining the task to be shifted from the data reception waiting state to the Ready state is realized by the interrupt handler INH. Therefore, when implementing this function, there is an advantage that the real-time OS 20, specifically, a task management function (scheduler) for performing task scheduling is not particularly required to be improved.

なお、図4のS11において通信インタフェース104からの割り込み要求に言及したが、CPU101には通信インタフェース104以外にも多数のデバイスが接続されていることが通常である。このため、割り込み要因の異なる様々な割り込み要求が、CPU101に対して行われることになる。このような多数の割り込み要求を調停するため、各割り込み要求には、予め割り込み要因に応じて優先度が割り当てられる。これにより、割り込み要因が異なる複数の割り込み要求が同時に発生している場合は、CPU101又はCPU101に割り込み要因を伝達するデバイスである割り込みコントローラ(不図示)によって、優先順位の高い割り込み要因に基づく割り込み要求が優先的に処理されることになる。   In addition, although the interrupt request from the communication interface 104 was mentioned in S11 of FIG. 4, it is normal that many devices other than the communication interface 104 are connected to the CPU 101. For this reason, various interrupt requests with different interrupt factors are made to the CPU 101. In order to arbitrate such a large number of interrupt requests, a priority is assigned to each interrupt request in advance according to the interrupt factor. As a result, when a plurality of interrupt requests having different interrupt factors are generated at the same time, an interrupt request based on an interrupt factor having a higher priority is performed by the CPU 101 or an interrupt controller (not shown) which is a device that transmits the interrupt factor to the CPU 101. Will be processed preferentially.

このため、通信インタフェース104においてリアルタイム通信を行うためには、通信インタフェース104のデータ受信を要因とする割り込み要求に対して、他のデバイスが行う割り込み要求よりも高い優先度を与えることが望ましい。このように構成することによって、通信インタフェース104のデータ受信を要因とする割り込み要求が優先的に処理されることになり、他の割り込み要求の処理を待つことによる予測不可能な処理遅延の発生を回避できる。これにより、データ受信処理の処理時間の予測可能性を向上させることができる。   For this reason, in order to perform real-time communication in the communication interface 104, it is desirable to give higher priority to interrupt requests caused by data reception of the communication interface 104 than interrupt requests made by other devices. With this configuration, an interrupt request due to data reception of the communication interface 104 is preferentially processed, and an unpredictable processing delay due to waiting for another interrupt request is generated. Can be avoided. Thereby, the predictability of the processing time of the data reception process can be improved.

<タスク管理>
次に、リアルタイムOS20におけるタスク管理について説明する。リアルタイムOS20におけるタスク状態の遷移図を図7に示す。図7に示すタスク状態のうち、Running状態301、Ready状態302、Waiting状態303、及びDormant状態305は、従来のタスク管理において定義されているタスク状態と同様である。具体的には、Running状態301は、CPU101が割り当てられてタスクを実行している状態である。Ready状態302は、タスクの実行に必要な条件は整っているが、当該タスクよりも優先度が高いタスク、又は当該タスクと同一優先度で先に実行可能となったタスクがRunning状態301にあるために実行できない状態である。
<Task management>
Next, task management in the real-time OS 20 will be described. FIG. 7 shows a task state transition diagram in the real-time OS 20. Among the task states shown in FIG. 7, the Running state 301, the Ready state 302, the Waiting state 303, and the Dormant state 305 are the same as the task states defined in the conventional task management. Specifically, the Running state 301 is a state in which the CPU 101 is assigned and a task is being executed. In the Ready state 302, conditions necessary for execution of a task are in place, but a task having a higher priority than the task or a task that can be executed first with the same priority as the task is in the Running state 301. Therefore, it cannot be executed.

Running状態301にあるタスクが終了した場合、又はRunning状態301にあるタスクより優先度が高いタスクがReady状態302になった場合は、新たなタスクが実行状態にディスパッチされる(S31)。なお、優先度が高いタスクにプリエンプトされたタスクは、Running状態301からReady状態302に遷移する(S32)。   When a task in the running state 301 is completed, or a task having a higher priority than the task in the running state 301 enters the ready state 302, a new task is dispatched to the execution state (S31). Note that a task preempted by a task with a higher priority makes a transition from the Running state 301 to the Ready state 302 (S32).

Waitng状態303は、タスクを実行するための条件が整わず、何らかの条件成立を待っている状態である。Running状態301にあるタスクは、何らかの条件成立を待つ場合に、Waitng状態303に遷移し(S33)、条件が成立すればReady状態302に遷移する(S34)。   The Waiting state 303 is a state in which a condition for executing a task is not satisfied and a certain condition is awaited. The task in the Running state 301 transitions to the Waiting state 303 when waiting for the establishment of some condition (S33), and transitions to the Ready state 302 if the condition is met (S34).

Dormant状態305は、まだ一度も起動されていないタスク又は実行が終了したタスクが遷移する状態である。Dormant状態305から起動されたタスクは、Ready状態に遷移する(S37)。実行が終了したタスクは、Running状態301又はReady状態302から、Dormant状態305に遷移する(S38又はS39)。   The Dormant state 305 is a state in which a task that has never been started or a task that has been executed has transitioned. The task activated from the Dormant state 305 makes a transition to the Ready state (S37). The task whose execution has been completed transits from the Running state 301 or the Ready state 302 to the Dormant state 305 (S38 or S39).

これら4つの状態に加えて、本実施の形態では、通信データの到着待ちのために待機しているタスク状態をCom状態304と定義し、リアルタイム通信を要求するタスクが受信待ちとなる際に、当該タスクをCom状態304に遷移させる(S35)。Com状態304からReady状態302に遷移する遷移する1つの条件は、データ受信待ちの解除である。具体的には、上述した割り込みハンドラINHによってReady状態302への変更が行われる。これとは別に、Com状態304からReady状態302に遷移する遷移するもう1つの条件はタイムアウトである。即ち、Com状態304に入る際にタイムアウト時間を指定し、タイムアウト時間が経過しても受信データが到着しない場合には、Com状態304からReady状態302に遷移することとする。   In addition to these four states, in this embodiment, the task state that is waiting for the arrival of communication data is defined as the Com state 304, and when a task that requests real-time communication waits for reception, The task is transitioned to the Com state 304 (S35). One condition for the transition from the Com state 304 to the Ready state 302 is to cancel waiting for data reception. Specifically, the change to the Ready state 302 is performed by the interrupt handler INH described above. Apart from this, another condition for transition from the Com state 304 to the Ready state 302 is a timeout. That is, when entering the Com state 304, a timeout time is specified, and if the received data does not arrive even after the timeout time has elapsed, the state transitions from the Com state 304 to the Ready state 302.

リアルタイム通信を要求するタスクは、通常、ハードリアルタイムを要求する処理に関するタスクである。このため、データ受信待ちを継続し続けることは、ハードリアルタイムを要求する処理に破綻をきたすことになり好ましくない。一方で、ハードリアルタイムを要求する処理であっても、新たな受信データが得られない場合に過去の受信データを用いた代替処理を実行することにより、危機的な状況の発生を回避可能な場合がある。本実施の形態のMCU10では、上述したCom状態304を定義し、タイムアウト時間が経過しても受信データが到着しない場合に、Com状態304からReady状態302に遷移する。これにより、タスクの定期的な処理を継続でき、上述したような代替処理の実行が可能となる。   The task that requests real-time communication is usually a task related to processing that requests hard real-time. For this reason, it is not preferable to continue waiting for data reception because it will cause a failure in processing that requires hard real-time. On the other hand, even if it is a process that requires hard real-time, when new received data cannot be obtained, it is possible to avoid the occurrence of a critical situation by executing an alternative process using past received data There is. In the MCU 10 according to the present embodiment, the above-described Com state 304 is defined, and the transition is made from the Com state 304 to the Ready state 302 when the received data does not arrive even after the timeout time elapses. Thereby, the periodic processing of the task can be continued, and the alternative processing as described above can be executed.

<データ送信処理>
リアルタイム通信を要求する送信タスクSTCによって、通信インタフェース104からデータを送信する処理について説明する。まず、リアルタイム通信の実現のためには、データ送信の開始時刻を制御する必要がる。これを実現するためには、当該タスクによってデータを送信するタイミングを、上述したリアルタイムOS20が備える時間管理機能を利用して決定すればよい。具体的には、システム時刻に基づいて一定周期で起動される周期ハンドラによって、通信インタフェース104に対するデータ送信を行うこととすればよい。
<Data transmission process>
A process of transmitting data from the communication interface 104 by the transmission task STC that requests real-time communication will be described. First, in order to realize real-time communication, it is necessary to control the start time of data transmission. In order to realize this, the timing for transmitting data by the task may be determined using the time management function provided in the real-time OS 20 described above. Specifically, data transmission to the communication interface 104 may be performed by a periodic handler that is activated at a constant period based on the system time.

さらに短い周期でのリアルタイム通信を実現するためには、送信処理を高速に行うことが望ましい。そこで、本実施の形態にかかるMCU10では、通信インタフェース104のDMA(Direct Memory Access)機能を利用して、送信タスクから通信インタフェース104に対して送信データをDMA転送することとする。通常の通信では、送信タスクが生成した送信データがユーザメモリ領域からシステムメモリ領域にコピーされた後に通信インタフェースに転送されるのに対して、本実施の形態ではCPU101によるデータコピーを伴わずに送信データの転送を開始できる。このため、メモリコピーに伴う遅延を回避し、送信処理を高速に行うことができる。   In order to realize real-time communication with a shorter cycle, it is desirable to perform transmission processing at high speed. Thus, in the MCU 10 according to the present embodiment, the transmission data is DMA-transferred from the transmission task to the communication interface 104 using the DMA (Direct Memory Access) function of the communication interface 104. In normal communication, the transmission data generated by the transmission task is copied from the user memory area to the system memory area and then transferred to the communication interface. In the present embodiment, transmission is performed without data copying by the CPU 101. Data transfer can be started. For this reason, a delay associated with memory copy can be avoided and transmission processing can be performed at high speed.

なお、上述したDMA転送を行うためには、送信データを生成するメモリ領域としてDMA転送可能な領域を確保する必要がある。しかし、一般にメモリ領域を確保する処理は処理時間の予測が困難である。このため、本実施の形態のMCU10では、送信データが発生するたびにメモリ領域の確保と解放を繰り返すのではなく、リアルタイム通信を要求するタスクの起動時に確保したメモリ領域を、当該タスクの終了時まで繰り返し利用することとする。これにより、メモリ領域の確保と解放はそれぞれタスクの起動時と終了時に行うだけでよく、メモリ領域の確保処理による予測不可能な遅延を排除でき、送信処理に要する処理時間の予測可能性を向上させることができる。   In order to perform the above-described DMA transfer, it is necessary to secure an area where DMA transfer is possible as a memory area for generating transmission data. However, in general, it is difficult to predict the processing time in the process of securing the memory area. For this reason, the MCU 10 according to the present embodiment does not repeat the securing and releasing of the memory area every time transmission data is generated, but uses the memory area secured at the start of the task that requires real-time communication at the end of the task. Will be used repeatedly. As a result, memory area allocation and release need only be performed at the start and end of a task, respectively, and unpredictable delays due to memory area allocation processing can be eliminated, improving the predictability of processing time required for transmission processing. Can be made.

<再送機能の不使用>
イーサネット(登録商標)の上位層(ネットワーク層及びトランスポート層)として、TCP/IPが広く使用されている。しかしながら、TCP/IPは、送信データの不到達時に再送処理を行うものであり、また、経路選択などの高度な転送制御を可能とするプロトコルであるため、処理が複雑で通信データの処理時間の予測が困難であるという問題がある。そこで、本実施の形態のMCU10では、TCP/IPを使用しないこととした。具体的には、ネットワーク層及びトランスポート層では、通信インタフェース104とタスクとを対応付けるデータの受け渡しのみを行うこととし、MCU10間でのデータ転送は、イーサネット(登録商標)のデータリンク層が行う隣接装置間でのデータ転送制御のみを使用することとする。
<Not using retransmission function>
TCP / IP is widely used as an upper layer (network layer and transport layer) of Ethernet (registered trademark). However, TCP / IP performs retransmission processing when transmission data does not arrive, and is a protocol that enables advanced transfer control such as route selection, so that the processing is complicated and the processing time of communication data is reduced. There is a problem that it is difficult to predict. Therefore, the MCU 10 of the present embodiment does not use TCP / IP. Specifically, in the network layer and the transport layer, only data that associates the communication interface 104 with the task is transferred, and data transfer between the MCUs 10 is performed by the Ethernet (registered trademark) data link layer. Only data transfer control between devices is used.

このとき、MCU10間の物理的な接続は、図1に示したpoint−to−point接続のほか、MACアドレスに基づいてスイッチングを行うレイヤ2スイッチ30を介して2以上のMCU10を接続する形態が使用できる。レイヤ2スイッチ30を用いたスター接続による制御システムの構成例を図8に示す。スター接続の場合でも、1つのレイヤ2スイッチ30とMCU10との間の物理リンク(100BASE−TXであればツイスト・ペア・ケーブル)は全二重で専有された状態である。このため、MACフレーム衝突によるデータ送信待ちが発生する余地はなく、データ転送時間の予測が可能となる。なお、レイヤ2スイッチ30を使用する場合は、レイヤ2スイッチ30内部でのデータストア処理及びフォワーディング処理に伴う内部遅延が発生するが、この内部遅延時間の変動量の予測は可能である。   At this time, the physical connection between the MCUs 10 is not limited to the point-to-point connection shown in FIG. 1, but two or more MCUs 10 are connected via the layer 2 switch 30 that performs switching based on the MAC address. Can be used. A configuration example of a control system by star connection using the layer 2 switch 30 is shown in FIG. Even in the case of star connection, the physical link between one layer 2 switch 30 and the MCU 10 (twisted pair cable in the case of 100BASE-TX) is occupied in full duplex. For this reason, there is no room for waiting for data transmission due to a MAC frame collision, and the data transfer time can be predicted. When the layer 2 switch 30 is used, an internal delay associated with data store processing and forwarding processing within the layer 2 switch 30 occurs, but the amount of fluctuation in the internal delay time can be predicted.

このように、送信データの再送を行わず、MCU10間を接続するネットワーク構成として通信データの衝突が発生しない構成を採用することにより、データ送信処理に要する時間の予測可能性を向上させることができる。   As described above, by adopting a configuration in which communication data collision does not occur as a network configuration for connecting the MCUs 10 without retransmitting transmission data, it is possible to improve predictability of time required for data transmission processing. .

その他の実施の形態.
上述した発明の実施の形態1にかかるMCU10は、データ受信処理、タスク管理、データ送信処理、及び再送機能の不使用といった特徴的な構成を有しており、これらの特徴的な構成の相乗的な効果によって、MCU10間でのリアルタイム通信を実現するために必要となるend−to−endでの送受信処理に要する時間の予測可能性を向上させている。しかしながら、MCU10が有する特徴的な構成の全てを具備しなくても、end−to−endでの送受信処理に要する時間の予測可能性を向上させることは可能である。
Other embodiments.
The MCU 10 according to the first embodiment of the present invention described above has characteristic configurations such as data reception processing, task management, data transmission processing, and non-use of the retransmission function. As a result, the predictability of the time required for the end-to-end transmission / reception processing required to realize real-time communication between the MCUs 10 is improved. However, it is possible to improve the predictability of the time required for the end-to-end transmission / reception processing without having all of the characteristic configurations of the MCU 10.

例えば、通信データに付与された優先度を参照することにより、優先的に起動する受信タスクの選択を行うデータ受信処理のみを利用する場合でも、データ受信処理の処理時間の予測可能性を向上することが可能であるため、end−to−endでの送受信処理に要する時間の予測可能性の向上に寄与することができる。即ち、本発明にかかるMCUは、発明の実施の形態1にかかるMCU10が備える特徴的な構成の全てを備える必要はなく、これらの特徴的な構成の一部を具備するものであってもよい。   For example, by referring to the priority given to communication data, even when only the data reception process for selecting the reception task to be activated preferentially is used, the predictability of the processing time of the data reception process is improved. Therefore, it is possible to contribute to improvement in predictability of time required for end-to-end transmission / reception processing. That is, the MCU according to the present invention does not have to include all of the characteristic configurations included in the MCU 10 according to the first embodiment of the invention, and may include a part of these characteristic configurations. .

さらに、本発明は上述した実施の形態のみに限定されるものではなく、既に述べた本発明の要旨を逸脱しない範囲において種々の変更が可能であることは勿論である。   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.

発明の実施の形態1にかかる制御システムの構成図である。It is a block diagram of the control system concerning Embodiment 1 of invention. 発明の実施の形態1にかかるMCUのハードウェア構成を示す図である。It is a figure which shows the hardware constitutions of MCU concerning Embodiment 1 of invention. 発明の実施の形態1にかかるMCUのソフトウェア構成を示す図である。It is a figure which shows the software structure of MCU concerning Embodiment 1 of invention. 発明の実施の形態1にかかるMCUにおけるデータ受信処理を説明するためのタイミング図である。It is a timing diagram for demonstrating the data reception process in MCU concerning Embodiment 1 of invention. 発明の実施の形態1にかかるMCUにおけるデータ受信処理を説明するためのフローチャートである。It is a flowchart for demonstrating the data reception process in MCU concerning Embodiment 1 of invention. MACフレームのフレーム形式を示す図である。It is a figure which shows the frame format of a MAC frame. 発明の実施の形態1にかかるMCUのタスク管理を説明するための状態遷移図である。It is a state transition diagram for demonstrating the task management of MCU concerning Embodiment 1 of invention. 発明の実施の形態1にかかる制御システムの物理的な接続構成の一例を示す図である。It is a figure which shows an example of the physical connection structure of the control system concerning Embodiment 1 of invention.

符号の説明Explanation of symbols

1 制御システム
10、10a、10b マイクロ・コントローラ・ユニット(MCU)
101 CPU
102 ROM
103 RAM
104 通信インタフェース
105 デジタルI/O(DIO)
106 アナログI/O(AIO)
20 リアルタイムOS(RTOS)
30 レイヤ2スイッチ
RTA、RTB 受信タスク
STD 送信タスク
INH 割り込みハンドラ
1 Control system 10, 10a, 10b Micro controller unit (MCU)
101 CPU
102 ROM
103 RAM
104 Communication interface 105 Digital I / O (DIO)
106 Analog I / O (AIO)
20 Real-time OS (RTOS)
30 Layer 2 switch RTA, RTB reception task STD transmission task INH interrupt handler

Claims (8)

タスクを実行するCPUと、
データを送受信可能な通信デバイスと、
前記通信デバイスに到着した受信データに付与されている優先度情報に基づいて、データ受信のために待ち状態にある複数のタスクの起床順序を決定し、前記優先度情報によって高い優先度が与えられた受信データの受信待ちを行っているタスクを優先的に実行可能とするイベント処理手段と、
実行可能な状態にある複数のタスクの優先順位に基づいて、前記CPUに割り当てるタスクを決定するスケジューリング手段とを備える情報処理装置。
A CPU that executes tasks;
A communication device capable of transmitting and receiving data;
Based on the priority information given to the received data arriving at the communication device, the wake-up order of a plurality of tasks waiting for data reception is determined, and a high priority is given by the priority information. Event processing means for preferentially executing a task waiting to receive received data;
An information processing apparatus comprising scheduling means for determining a task to be assigned to the CPU based on a priority order of a plurality of tasks in an executable state.
前記優先度情報が示す前記受信データの優先度は、当該受信データを処理するタスクの優先順位を反映して決定されている請求項1に記載の情報処理装置。   The information processing apparatus according to claim 1, wherein the priority of the received data indicated by the priority information is determined by reflecting a priority of a task that processes the received data. 前記イベント処理手段は、前記通信デバイスから前記CPUに対する割り込み要求に応じて起動される割り込みハンドラ・プログラムを実行することにより実現される請求項1に記載の情報処理装置。   The information processing apparatus according to claim 1, wherein the event processing unit is realized by executing an interrupt handler program started in response to an interrupt request from the communication device to the CPU. 前記CPUで実行されるタスクの状態を管理するタスク管理手段を備え、
前記タスク管理手段は、前記CPUに割り当てられて実行されている第1の状態、実行可能であるが、前記CPUにおいて他のタスクが実行中であるために前記CPUに割り当てられていない第2の状態、前記通信デバイスに到着するデータの受信待ちのために停止された第3の状態、及び、前記通信デバイスに到着するデータの受信待ちを除く他の条件成立待ちのために停止された第4の状態の少なくとも4つの状態でタスクを管理し、
前記第3の状態にあるタスクが受信待ちを行っているデータが、所定の時間内に前記通信デバイスに到着しない場合には、当該タスクを前記第2の状態に遷移させることを特徴とする請求項1に記載の情報処理装置。
Task management means for managing the status of tasks executed by the CPU;
The task management means is executable in a first state assigned to the CPU and executed, but is not assigned to the CPU because another task is being executed in the CPU. State, a third state stopped due to waiting for reception of data arriving at the communication device, and a fourth state stopped due to waiting for establishment of other conditions other than waiting for reception of data arriving at the communication device Manage tasks in at least four states
The task waiting for reception by the task in the third state transitions to the second state if the data does not arrive at the communication device within a predetermined time. Item 4. The information processing apparatus according to Item 1.
一定周期で割り込み要求を生成するタイマと、
前記通信デバイスからのデータ送信処理を実行する送信タスクを、前記タイマが生成する割り込み要求に応じて実行可能な状態に遷移させる手段とをさらに備える請求項1又は4に記載の情報処理装置。
A timer that generates interrupt requests at regular intervals;
5. The information processing apparatus according to claim 1, further comprising means for causing a transmission task for executing data transmission processing from the communication device to transition to an executable state in response to an interrupt request generated by the timer.
前記通信デバイスから送信されるデータは、前記送信タスクによって、前記送信タスクがアクセス可能なユーザメモリ領域から前記通信デバイスにDMA転送され、
前記送信タスクは、前記送信タスクの生成に応じて割り当てられたユーザメモリ領域を、当該送信タスクの終了まで前記DMA転送に継続的に使用する請求項5に記載の情報処理装置。
Data transmitted from the communication device is DMA-transferred from the user memory area accessible to the transmission task to the communication device by the transmission task,
The information processing apparatus according to claim 5, wherein the transmission task continuously uses the user memory area allocated according to the generation of the transmission task for the DMA transfer until the end of the transmission task.
請求項1乃至6のいずれかに記載された情報処理装置を複数備え、
複数の前記情報処理装置が備える前記通信デバイスはイーサネット(登録商標)デバイスであって、
前記複数の情報処理装置はレイヤ2スイッチを介して通信可能に接続されている分散処理システム。
A plurality of the information processing devices according to any one of claims 1 to 6,
The communication devices included in the plurality of information processing apparatuses are Ethernet (registered trademark) devices,
The distributed processing system in which the plurality of information processing apparatuses are communicably connected via a layer 2 switch.
実行可能状態にある複数のタスクのCPUへの割り当て順序をタスクの優先度に基づいてスケジューリングするリアルタイムOSを搭載した情報処理装置におけるタスク管理方法であって、
前記CPUが、前記情報処理装置が備える通信デバイスにデータが到着したことを示す割り込み要求に応じて割り込みハンドラを起動し、
前記割り込みハンドラが、前記通信デバイスに到着している複数の受信データに付与されている優先度情報を走査することにより、前記優先度情報によって最も高い優先度が与えられた受信データを選択し、選択した受信データの受信待ちを行っているタスクを優先的に実行可能状態に遷移させ、
前記リアルタイムOSが、前記割り込みハンドラによって実行可能状態とされたタスクのスケジューリング及び前記CPUへの割り当てを行うタスク管理方法。
A task management method in an information processing apparatus equipped with a real-time OS that schedules an assignment order of a plurality of tasks in an executable state to a CPU based on task priority,
The CPU activates an interrupt handler in response to an interrupt request indicating that data has arrived at a communication device included in the information processing apparatus,
The interrupt handler scans the priority information given to a plurality of received data arriving at the communication device, and selects the received data given the highest priority by the priority information, The task waiting to receive the selected received data is preferentially transitioned to the executable state,
A task management method in which the real-time OS performs scheduling of tasks that are made executable by the interrupt handler and assigns them to the CPU.
JP2006069130A 2006-03-14 2006-03-14 Information processor, distributed processing system, and task management method Pending JP2007249357A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2006069130A JP2007249357A (en) 2006-03-14 2006-03-14 Information processor, distributed processing system, and task management method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2006069130A JP2007249357A (en) 2006-03-14 2006-03-14 Information processor, distributed processing system, and task management method

Publications (1)

Publication Number Publication Date
JP2007249357A true JP2007249357A (en) 2007-09-27

Family

ID=38593620

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2006069130A Pending JP2007249357A (en) 2006-03-14 2006-03-14 Information processor, distributed processing system, and task management method

Country Status (1)

Country Link
JP (1) JP2007249357A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009282987A (en) * 2008-05-21 2009-12-03 Korea Advanced Inst Of Sci Technol Method of interrupt scheduling
JP2011155443A (en) * 2010-01-27 2011-08-11 Nippon Telegr & Teleph Corp <Ntt> Mpcp processor of pon system
US10412017B2 (en) 2017-09-13 2019-09-10 Kabushiki Kaisha Toshiba Transfer device, transfer method, and computer program product
JP2020526968A (en) * 2017-07-12 2020-08-31 インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation Methods, computer systems, and computer programs performed by processors for remote node discovery and communication channel verification and communication channel connectivity.
JP2020149526A (en) * 2019-03-15 2020-09-17 株式会社東芝 Processing apparatus, processing method and program

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009282987A (en) * 2008-05-21 2009-12-03 Korea Advanced Inst Of Sci Technol Method of interrupt scheduling
JP2011155443A (en) * 2010-01-27 2011-08-11 Nippon Telegr & Teleph Corp <Ntt> Mpcp processor of pon system
JP2020526968A (en) * 2017-07-12 2020-08-31 インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation Methods, computer systems, and computer programs performed by processors for remote node discovery and communication channel verification and communication channel connectivity.
JP7098711B2 (en) 2017-07-12 2022-07-11 インターナショナル・ビジネス・マシーンズ・コーポレーション Methods, computer systems, and computer programs performed by processors for remote node discovery, as well as communication channel confirmation and communication channel connectivity.
US10412017B2 (en) 2017-09-13 2019-09-10 Kabushiki Kaisha Toshiba Transfer device, transfer method, and computer program product
JP2020149526A (en) * 2019-03-15 2020-09-17 株式会社東芝 Processing apparatus, processing method and program
JP2022121525A (en) * 2019-03-15 2022-08-19 株式会社東芝 Processing apparatus, processing method and program
JP7354361B2 (en) 2019-03-15 2023-10-02 株式会社東芝 Processing equipment, processing method and program

Similar Documents

Publication Publication Date Title
Tindell et al. Analysis of hard real-time communications
Tovar et al. Real-time fieldbus communications using Profibus networks
JP2009265963A (en) Information processing system and task execution control method
JP3922070B2 (en) Distributed control method and apparatus
US10785014B2 (en) Computation device, control device and control method
US20160056905A1 (en) Interface Device and Method for Exchanging User Data
US20090086737A1 (en) System-on-chip communication manager
JP2000284980A (en) Multi-task system and message transmission scheduling method in the system
JP2011505037A (en) Read data buffering system and method
US20100095036A1 (en) Priority Based Bus Arbiters Avoiding Deadlock And Starvation On Buses That Support Retrying Of Transactions
WO2012001835A1 (en) Multiprocessor system
JPH09128351A (en) Parallel process scheduling method in parallel computer and processor for parallel computer
JP5058167B2 (en) Delayed arbitration of memory access requests
TWI484346B (en) Network adaptor optimization and interrupt reduction
JP2020048045A (en) Switching device, switching method, and program
EP3304331A1 (en) Single-chip multi-processor communication
JP2007249357A (en) Information processor, distributed processing system, and task management method
JP4184614B2 (en) Bus system and method for adjusting execution order thereof
Bello et al. Priority-driven swapping-based scheduling of aperiodic real-time messages over EtherCAT networks
JP4183712B2 (en) Data processing method, system and apparatus for moving processor task in multiprocessor system
JP5109748B2 (en) Virtual computer system, packet transmission control method, and network interface card used therefor
Pöhnl et al. A middleware journey from microcontrollers to microprocessors
CN109426562B (en) priority weighted round robin scheduler
EP1450256A2 (en) Inter-task communications method, program, recording medium, and electronic device
JP3713977B2 (en) Real-time distributed system