JP2016057798A - Program embedding device - Google Patents

Program embedding device Download PDF

Info

Publication number
JP2016057798A
JP2016057798A JP2014182980A JP2014182980A JP2016057798A JP 2016057798 A JP2016057798 A JP 2016057798A JP 2014182980 A JP2014182980 A JP 2014182980A JP 2014182980 A JP2014182980 A JP 2014182980A JP 2016057798 A JP2016057798 A JP 2016057798A
Authority
JP
Japan
Prior art keywords
embedding
code
program
periodic
unit
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.)
Granted
Application number
JP2014182980A
Other languages
Japanese (ja)
Other versions
JP6287709B2 (en
Inventor
圭祐 堀井
Keisuke Horii
圭祐 堀井
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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric 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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP2014182980A priority Critical patent/JP6287709B2/en
Publication of JP2016057798A publication Critical patent/JP2016057798A/en
Application granted granted Critical
Publication of JP6287709B2 publication Critical patent/JP6287709B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

PROBLEM TO BE SOLVED: To enable a cyclic process to be embedded in a program so that the cyclic process can be executed at intervals in time for a cycle time even in a situation where a timer interrupt cannot be used.SOLUTION: A program embedding device according to the present invention includes: a branch destination search unit 2020 for searching a program source converted into assembly code for a branch destination in which a cyclic process 221 that is repeatedly executed at constant intervals is to be embedded; and a first program embedding unit 2021 for embedding, in the branch destination, the cyclic process 221 and a determination process 220 for determining the execution of the cyclic process 221 by an elapsed time from the last time the cyclic process 221 was executed.SELECTED DRAWING: Figure 3

Description

本発明は、プログラムに周期処理を埋め込む装置に関するものである。   The present invention relates to an apparatus for embedding periodic processing in a program.

制御システムのような高い信頼性が要求されるシステムでは、システム内のOS(Operating System)および実行中のアプリケーションの異常を検知するための手段としてWDT(Watch Dog Timer)を用いて定期的に監視することが一般的である。
WDTとはハードウェア内部のタイマであり、所定の時間が経過(タイムアップ)すると、システムに異常が発生していると判断し、H/W(Hard Ware)を強制的にリセットするという特徴を持つ。システムはリセットすることによって異常を回避することができる。
これに対し、システム内のOSおよび実行中のアプリケーションは、このWDTがタイムアップする前にWDTのカウントを設定し直す処理(周期処理)を一定の時間(周期時間)おきに実行する必要がある。
In a system that requires high reliability such as a control system, WDT (Watch Dog Timer) is regularly monitored as a means for detecting abnormalities in the OS (Operating System) and running applications in the system. It is common to do.
WDT is a hardware internal timer. When a predetermined time elapses (time up), it is determined that an abnormality has occurred in the system, and H / W (Hard Wear) is forcibly reset. Have. The system can avoid anomalies by resetting.
On the other hand, the OS in the system and the application being executed need to execute a process for resetting the WDT count (periodic process) at regular intervals (periodic time) before this WDT times out. .

このような周期処理は、マイコンのタイマ割り込みを利用した割り込み処理ルーチンで実現するのが一般的である。しかし、ブートローダ起動時およびOS起動の初期段階では、利用できるH/Wが制約されるため、周期処理をタイマ割り込みに依存した割り込み処理ルーチンで記述することができない。このため、通常時に実行するプログラム(メインプログラム)のソースコードに直接周期処理を埋め込む必要がある。
例えば、特許文献1では、CPU資源の利用を制御するため、周期処理を関数呼出し単位、プログラム行、基本ブロックなどの間隔でプログラムのソースコードに埋め込む技術について開示されている。
Such periodic processing is generally realized by an interrupt processing routine using a timer interrupt of a microcomputer. However, at the time of boot loader activation and at the initial stage of OS activation, the available H / W is restricted, so that periodic processing cannot be described by an interrupt processing routine that relies on a timer interrupt. For this reason, it is necessary to embed periodic processing directly in the source code of the program (main program) that is normally executed.
For example, Patent Document 1 discloses a technique for embedding cyclic processing in a program source code at intervals such as a function call unit, a program line, and a basic block in order to control the use of CPU resources.

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

従来のプログラム埋め込み装置は、関数呼出し単位、プログラム行、基本ブロックなどプログラムの記述内容に従った間隔で埋め込みを実現していた。しかし、プログラムの実行時間については考慮されていないため、埋め込まれたプログラムが過度に実行する、もしくは周期時間内に実行できないといった課題がある。   The conventional program embedding device has realized embedding at intervals according to the description contents of the program such as a function call unit, a program line, and a basic block. However, since the execution time of the program is not considered, there is a problem that the embedded program is excessively executed or cannot be executed within the period time.

本発明は、上記のような課題を解決するためのものであり、プログラムの実行時間を計測しつつ周期時間内に周期処理を実行するよう、ソースコードへ周期処理実行命令の埋め込みを実現することを目的とする。   The present invention is to solve the above-described problems, and implements embedding a periodic processing execution instruction in a source code so as to execute periodic processing within the periodic time while measuring the execution time of the program. With the goal.

本発明のプログラム埋め込み装置は、アセンブリコードに変換したプログラムソースの中から、一定間隔で繰り返し実行する周期処理を埋め込むための分岐先を探索する分岐先探索部と、前記分岐先に対し、前記周期処理と前記周期処理の実行を前記周期処理が前回実行されてからの経過時間で判定する判定処理を埋め込む第1のプログラム埋め込み部とを備える。 The program embedding device of the present invention includes a branch destination search unit for searching for a branch destination for embedding a periodic process that is repeatedly executed at regular intervals, from the program source converted into assembly code, and the cycle with respect to the branch destination. A first program embedding unit that embeds a determination process for determining the process and the execution of the periodic process based on an elapsed time from the previous execution of the periodic process.

本発明によれば、タイマ割り込みが利用できない状況においても、周期処理を周期時間に間に合う間隔で実行できるよう、周期処理をプログラムに埋め込むことが可能となる。   According to the present invention, it is possible to embed periodic processing in a program so that the periodic processing can be executed at an interval in time for the periodic time even in a situation where a timer interrupt cannot be used.

この発明の実施の形態1におけるシステム構成の一例を示す図である。It is a figure which shows an example of the system configuration | structure in Embodiment 1 of this invention. この発明の実施の形態1におけるプログラム埋め込み装置20および実行用装置30のハードウェア構成の一例を示す図である。It is a figure which shows an example of the hardware constitutions of the program embedding apparatus 20 and the execution apparatus 30 in Embodiment 1 of this invention. この発明の実施の形態1におけるプログラム埋め込み装置20上で動作するソフトウェアの全体構成図である。It is a whole block diagram of the software which operate | moves on the program embedding apparatus 20 in Embodiment 1 of this invention. この発明の実施の形態1における埋め込み用周期処理コード22の一例を示す図である。It is a figure which shows an example of the periodic process code 22 for embedding in Embodiment 1 of this invention. この発明の実施の形態1における埋め込み用周期処理コード22の埋め込みを完了した後のアセンブリコードの一例を示す図である。It is a figure which shows an example of the assembly code after completing embedding of the periodic processing code 22 for embedding in Embodiment 1 of this invention. この発明の実施の形態1におけるプログラム埋め込み装置20の動作を示すフローチャートである。It is a flowchart which shows operation | movement of the program embedding apparatus 20 in Embodiment 1 of this invention. この発明の実施の形態1における経過時間計測処理コード220の動作を示すフローチャートである。It is a flowchart which shows operation | movement of the elapsed time measurement process code 220 in Embodiment 1 of this invention. この発明の実施の形態2におけるシステム構成の一例を示す図である。It is a figure which shows an example of the system configuration | structure in Embodiment 2 of this invention. この発明の実施の形態2におけるプログラム埋め込み装置20が第1の動作を行う場合のシステム構成を示す図である。It is a figure which shows the system configuration | structure in case the program embedding apparatus 20 in Embodiment 2 of this invention performs 1st operation | movement. この発明の実施の形態2における実行用装置30上で動作を行う場合のシステム構成を示す図である。It is a figure which shows the system configuration | structure when performing operation | movement on the apparatus 30 for execution in Embodiment 2 of this invention. この発明の実施の形態2におけるプログラム埋め込み装置20が第2の動作を行う場合のシステム構成を示す図である。It is a figure which shows the system configuration | structure in case the program embedding apparatus 20 in Embodiment 2 of this invention performs 2nd operation | movement. この発明の実施の形態2におけるプログラム埋め込み装置20上で動作するソフトウェアの全体構成図である。It is a whole block diagram of the software which operate | moves on the program embedding apparatus 20 in Embodiment 2 of this invention. この発明の実施の形態2におけるプログラム埋め込み装置20上で動作するソフトウェアのうち、第1の動作を行う場合に着目したソフトウェア構成図である。It is a software block diagram which paid its attention when performing 1st operation | movement among the software which operate | moves on the program embedding apparatus 20 in Embodiment 2 of this invention. この発明の実施の形態2におけるプログラム埋め込み装置20上で動作するソフトウェアのうち、第2の動作を行う場合に着目したソフトウェア構成図である。It is a software block diagram which paid its attention when performing 2nd operation | movement among the software which operate | moves on the program embedding apparatus 20 in Embodiment 2 of this invention. この発明の実施の形態2における埋め込み用周期処理コード27の一例を示す図である。It is a figure which shows an example of the periodic process code 27 for embedding in Embodiment 2 of this invention. この発明の実施の形態2におけるプログラム埋め込み装置20の第1の動作を説明するフロー図である。It is a flowchart explaining the 1st operation | movement of the program embedding apparatus 20 in Embodiment 2 of this invention. この発明の実施の形態2における埋め込み用時間計測処理コード24の動作を説明するフロー図である。It is a flowchart explaining operation | movement of the time measuring process code 24 for embedding in Embodiment 2 of this invention. この発明の実施の形態2における経過時間ログ26の一例を示す図である。It is a figure which shows an example of the elapsed time log 26 in Embodiment 2 of this invention. この発明の実施の形態2におけるプログラム埋め込み装置20の第2の動作を説明するフロー図である。It is a flowchart explaining the 2nd operation | movement of the program embedding apparatus 20 in Embodiment 2 of this invention. この発明の実施の形態2における埋め込み位置記録テーブルの一例を示す図である。It is a figure which shows an example of the embedding position recording table in Embodiment 2 of this invention. この発明の実施の形態2における複数回目用埋め込み用周期処理コードの一例を示す図である。It is a figure which shows an example of the periodic processing code for multiple times embedding in Embodiment 2 of this invention. この発明の実施の形態2における埋め込み位置決定部2060の動作を説明するフロー図である。It is a flowchart explaining operation | movement of the embedding position determination part 2060 in Embodiment 2 of this invention. この発明の実施の形態3におけるシステム構成の一例を示す図である。It is a figure which shows an example of the system configuration | structure in Embodiment 3 of this invention. この発明の実施の形態3におけるプログラム埋め込み装置20上で動作するソフトウェアの全体構成図である。It is a whole block diagram of the software which operate | moves on the program embedding apparatus 20 in Embodiment 3 of this invention. この発明の実施の形態3における命令実行クロック数一覧29の一例を示す図である。It is a figure which shows an example of the instruction execution clock number list 29 in Embodiment 3 of this invention. この発明の実施の形態3におけるプログラム埋め込み装置20の動作を示すフローチャートである。It is a flowchart which shows operation | movement of the program embedding apparatus 20 in Embodiment 3 of this invention.

実施の形態1.
図1は、本実施の形態におけるシステム構成図の一例である。本実施の形態におけるシステムでは、開発用装置10、プログラム埋め込み装置20、実行用装置30で構成される。
なお、開発用装置10からプログラム埋め込み装置20に対し、メインプログラムのソースコード21および埋め込み用周期処理コード22が渡され、プログラム埋め込み装置20から実行用装置30に対し、周期処理埋め込みバイナリ23が渡される。
Embodiment 1 FIG.
FIG. 1 is an example of a system configuration diagram in the present embodiment. The system according to the present embodiment includes a development device 10, a program embedding device 20, and an execution device 30.
Note that the source code 21 and the embedded periodic processing code 22 of the main program are passed from the development device 10 to the program embedding device 20, and the periodic processing embedded binary 23 is passed from the program embedding device 20 to the execution device 30. It is.

開発用装置10は、実行用装置30上で動作するプログラムを開発するための装置である。開発用装置10で開発されたメインプログラムのソースコード21と埋め込み用周期処理コード22が、プログラム埋め込み装置20に渡される。   The development device 10 is a device for developing a program that runs on the execution device 30. The main program source code 21 and the embedded periodic processing code 22 developed by the development apparatus 10 are transferred to the program embedding apparatus 20.

メインプログラムのソースコード21は、実行用装置30上で動作させたいプログラムのソースコードである。また、メインプログラムのソースコード21は、CやC++などのコンパイル可能なプログラミング言語で記述されたものであり、複数のファイルから構成されていてもよい。   The source code 21 of the main program is the source code of the program that is to be run on the execution device 30. The source code 21 of the main program is described in a compilable programming language such as C or C ++, and may be composed of a plurality of files.

埋め込み用周期処理コード22は、本来、実行用装置30上でタイマ割り込みを使用することができた場合に実行する周期処理プログラムのアセンブリコードである。埋め込み用周期処理コード22は、周期処理及び、前記周期処理を周期的に実行するためのプログラムのアセンブリコードで構成される。
埋め込み用周期処理コード22はアセンブリコードであるが、メインプログラムのソースコード21と同様、CやC++などのコンパイル可能なプログラミング言語で記述されたものであっても良い。しかし、その場合は以降で説明するアセンブリコード変換部201により、埋め込み前にアセンブリコードに変換する必要がある。
The periodic processing code 22 for embedding is an assembly code of a periodic processing program that is executed when a timer interrupt can be used on the execution device 30. The embedded periodic processing code 22 includes a periodic process and an assembly code of a program for periodically executing the periodic process.
The embedded periodic processing code 22 is an assembly code, but may be written in a compilable programming language such as C or C ++, like the source code 21 of the main program. However, in that case, it is necessary to convert to assembly code before embedding by an assembly code conversion unit 201 described later.

プログラム埋め込み装置20は、開発用装置10から受け取ったメインプログラムのソースコード21と埋め込み用周期処理コード22から周期処理埋め込みバイナリ23を生成し、実行用装置30に渡す。   The program embedding device 20 generates a periodic processing embedded binary 23 from the source code 21 of the main program received from the development device 10 and the periodic processing code 22 for embedding, and passes it to the execution device 30.

実行用装置30は、プログラム埋め込み装置20から渡された周期処理埋め込みバイナリ23を実行する。   The execution device 30 executes the periodic processing embedded binary 23 passed from the program embedding device 20.

なお、本実施の形態では、開発用装置10とプログラム埋め込み装置20を別の装置として説明をしたが、同一の装置上で、メインプログラムのソースコード21と埋め込み用周期処理コード22の開発および、周期処理埋め込みバイナリ23の生成を行っても良い。   In the present embodiment, the development device 10 and the program embedding device 20 have been described as separate devices. However, on the same device, the development of the source code 21 of the main program and the periodic processing code 22 for embedding, The periodic processing embedded binary 23 may be generated.

図2は、本実施の形態における、プログラム埋め込み装置20および実行用装置30のハードウェア構成図の一例である。なお、プログラム埋め込み装置20および実行用装置30のハードウェア構成は、いずれかもしくはどちらも図2に示す構成と異なる構成であっても構わない。   FIG. 2 is an example of a hardware configuration diagram of the program embedding device 20 and the execution device 30 in the present embodiment. Note that either or both of the hardware configurations of the program embedding device 20 and the execution device 30 may be different from the configuration shown in FIG.

図2において、プログラム埋め込み装置20および実行用装置30は、プログラムを実行するCPU1(Central Processor Unit)、プログラムやデータを記憶するROM2(Read Only Memory)、プログラムが使用・参照できるよう一時的にデータを記憶するRAM3(Random Access Memory)に加え、開発用装置10、プログラム埋め込み装置20、実行用装置30との間でファイルのやりとりを行うための通信モジュール4、時刻やプログラムの実行時間、デバイス7への出力タイミングなどを計測するタイマ5など複数のハードウェアを備えている。   In FIG. 2, a program embedding device 20 and an execution device 30 include a CPU 1 (Central Processor Unit) that executes a program, a ROM 2 (Read Only Memory) that stores programs and data, and temporary data that can be used and referenced by the program. In addition to the RAM 3 (Random Access Memory) for storing the data, the communication module 4 for exchanging files with the development device 10, the program embedding device 20, and the execution device 30, the time and the program execution time, the device 7 A plurality of hardware such as a timer 5 that measures the output timing to and the like is provided.

ROM2は、プログラムや固定データを格納する領域を提供する。フラッシュメモリなどが相当し、書き込まれたプログラム内容を書き換えることが可能である。
RAM3は、プログラムが使用するデータを保存及び参照するための作業領域を提供する。
The ROM 2 provides an area for storing programs and fixed data. It corresponds to a flash memory and the like, and the written program content can be rewritten.
The RAM 3 provides a work area for storing and referring to data used by the program.

通信モジュール4は、ネットワークを通じて、開発用装置10、プログラム埋め込み装置20、実行用装置30との間でファイルの受け渡しを行う。なお、本実施の形態では、通信モジュール4を用いたハードウェア構成の一例を示したが、通信モジュール4を用いず、例えば、開発用装置10、プログラム埋め込み装置20、実行用装置30との間でMT(磁気テープ)、FD(フレキシブルディスク)などのメディア媒体で受け渡しを行ってもよい。
タイマ5は、時刻のほか、周期処理を実行するタイミングなどを計測する。
The communication module 4 exchanges files with the development device 10, the program embedding device 20, and the execution device 30 through the network. In the present embodiment, an example of a hardware configuration using the communication module 4 is shown. However, the communication module 4 is not used, and for example, between the development device 10, the program embedding device 20, and the execution device 30. Then, delivery may be performed by media such as MT (magnetic tape) and FD (flexible disk).
The timer 5 measures not only the time but also the timing for executing the periodic processing.

図3は、実施の形態1におけるプログラム埋め込み装置20上で動作するソフトウェアの全体構成図である。これらのソフトウェアは、プログラム埋め込み装置20のROM2またはRAM3上に記憶され、CPU1により実行される。   FIG. 3 is an overall configuration diagram of software that operates on the program embedding device 20 according to the first embodiment. These software are stored on the ROM 2 or the RAM 3 of the program embedding device 20 and executed by the CPU 1.

図3において、プログラム埋め込み装置20は、プログラミング言語で記述されたソースコードをアセンブリコードに変換するアセンブリコード変換部201と、埋め込み用周期処理コード22をアセンブリレベルでメインプログラムへ埋め込む周期処理埋め込み部202と、周期処理の埋め込みが完了したアセンブリコードをCPU1で実行可能なオブジェクトコードに変換するオブジェクトコード変換部203と、オブジェクトコード(複数でもよい)との共有とライブラリとを結合するバイナリ変換部204を備えている。
なお、周期処理埋め込み部202は、アセンブリコードの中から分岐先ラベルを探索する分岐先ラベル探索部(分岐先探索部)2020と、埋め込み用周期処理コード22をアセンブリコードへ埋め込む処理を行うプログラム埋め込み部(第1のプログラム埋め込み部)2021を備えている。
In FIG. 3, a program embedding device 20 includes an assembly code conversion unit 201 that converts source code described in a programming language into assembly code, and a periodic processing embedding unit 202 that embeds a periodic processing code 22 for embedding in a main program at an assembly level. An object code conversion unit 203 that converts the assembly code that has been embedded in the cyclic processing into an object code that can be executed by the CPU 1, and a binary conversion unit 204 that combines sharing of the object code (s) and the library I have.
The periodic processing embedding unit 202 embeds a program for performing processing for embedding a branch destination label searching unit (branch destination searching unit) 2020 for searching for a branch destination label from the assembly code and an embedded periodic processing code 22 in the assembly code. Section (first program embedding section) 2021.

プログラム埋め込み装置20上で動作するソフトウェアの詳細について説明する。   Details of the software operating on the program embedding device 20 will be described.

アセンブリコード変換部201は、開発用装置10からメインプログラムのソースコード21を受け取り、アセンブリコードに変換を行う。アセンブリコード変換部201は、変換したアセンブリコードを周期処理埋め込み部202に渡す。   The assembly code conversion unit 201 receives the source code 21 of the main program from the development device 10 and converts it into assembly code. The assembly code conversion unit 201 passes the converted assembly code to the periodic processing embedding unit 202.

周期処理埋め込み部202は、アセンブリコード変換部201からメインプログラムのアセンブリコードを受け取り、分岐先ラベル探索部2020で、周期処理コードを埋め込む位置を決定する。分岐先ラベル探索部2020は、例えば、アセンブリコードで使用されている全てのラベルの探索を行う。
なお、本実施の形態では、ラベルを埋め込み箇所としているが、例えば、条件分岐命令があった箇所を分岐先ラベルの埋め込み箇所としても良い。条件分岐命令があった箇所を分岐先ラベルの埋め込み箇所とした場合、アセンブリコードの中から条件分岐命令の探索を行う。分岐先として探索するラベルは、一つだけとしても良いし、複数の組み合わせ、例えば「条件分岐命令と加算命令」のような組み合わせであってもよい。
The periodic processing embedding unit 202 receives the assembly code of the main program from the assembly code converting unit 201, and the branch destination label searching unit 2020 determines a position where the periodic processing code is embedded. The branch destination label search unit 2020 searches for all labels used in the assembly code, for example.
In the present embodiment, the label is embedded as a place to embed, but for example, a place where a conditional branch instruction is present may be set as a place to embed a branch destination label. When the location where the conditional branch instruction is present is set as the location where the branch destination label is embedded, the conditional branch instruction is searched from the assembly code. There may be only one label searched as a branch destination, or a plurality of combinations, for example, a combination such as “conditional branch instruction and addition instruction” may be used.

プログラム埋め込み部2021は、分岐先ラベル探索部2020が決定した埋め込む位置に、埋め込み用周期処理コード22を埋め込む。図4を用いて、埋め込まれるアセンブリコードについて詳しく説明する。   The program embedding unit 2021 embeds the embedding periodic processing code 22 at the embedding position determined by the branch destination label searching unit 2020. The embedded assembly code will be described in detail with reference to FIG.

図4は、埋め込み用周期処理コード22の一例を示す図である。埋め込み用周期処理コード22は、経過時間計測処理コード(判定処理)220と周期処理コード221を備える。   FIG. 4 is a diagram illustrating an example of the embedded periodic processing code 22. The embedded periodic process code 22 includes an elapsed time measurement process code (determination process) 220 and a periodic process code 221.

経過時間計測処理コード220は、現在の時刻を獲得し、同処理コードが前回呼び出された際の時刻との差分から経過時間を計測し、予め設定した時間を経過していた場合、周期処理を呼び出す処理が記述されたアセンブリコードである。
例えば、周期時間が10ミリ秒の周期処理であった場合、周期処理が前回実行した時刻から8ミリ秒経過していた場合、周期処理を実行し、現在の時刻を記録する。次に経過時間計測処理コード220が呼び出された際には、この記録された時刻が、前回の時刻となる。
The elapsed time measurement processing code 220 obtains the current time, measures the elapsed time from the difference from the time when the processing code was called last time, and if the preset time has elapsed, the periodic processing is performed. This is assembly code that describes the process to be called.
For example, if the periodic process is a periodic process of 10 milliseconds, if the periodic process has passed 8 milliseconds since the previous execution, the periodic process is executed and the current time is recorded. Next, when the elapsed time measurement processing code 220 is called, this recorded time becomes the previous time.

周期処理コード221は、周期処理を行うアセンブリコードである。本実施の形態では、周期処理コード221を開発用装置10で開発し、プログラム埋め込み装置20へ渡す構成で説明を行ったが、周期処理コード221を予めオブジェクトコードで提供しておき、バイナリ変換部204でバイナリ変換を行う際、同時に行ってもよい。
このような埋め込み用周期処理コード22の場合、前述したプログラム埋め込み部2021は、分岐先ラベル探索部2020が決定した埋め込む位置に、経過時間計測処理コード220と周期処理コード221を埋め込む。
The periodic processing code 221 is an assembly code that performs periodic processing. In the present embodiment, the periodic processing code 221 is developed by the development device 10 and is described as being passed to the program embedding device 20. However, the periodic processing code 221 is provided in advance as an object code, and the binary conversion unit When performing binary conversion in 204, it may be performed simultaneously.
In the case of such a periodic processing code 22 for embedding, the program embedding unit 2021 embeds the elapsed time measurement processing code 220 and the periodic processing code 221 at the embedding position determined by the branch destination label searching unit 2020.

なお、周期処理コード221は、全ての位置に経過時間計測処理コード220と同時に埋め込んでもよいし、一か所だけ関数として埋め込み、経過時間計測処理コード220から呼び出すようにしても良い。前者の全ての位置に埋め込む方法であれば、処理速度を向上でき、後者の一か所だけ関数として埋め込む方法だと、メモリを節約できる。
また、関数呼び出しとした場合、アセンブリコードとして周期処理コード221を用いるのではなく、オブジェクトコードとして用い(図示せず)、実行バイナリへ変換する際、一緒に変換しても良い。埋め込み用周期処理コード22の埋め込みを完了した後のアセンブリコードの一例を図5に示す。
The periodic processing code 221 may be embedded at all positions simultaneously with the elapsed time measurement processing code 220 or may be embedded as a function at one location and called from the elapsed time measurement processing code 220. If the method is embedded in all the former positions, the processing speed can be improved, and if the method is embedded only in one of the latter positions, memory can be saved.
In the case of a function call, the periodic processing code 221 is not used as an assembly code, but may be used as an object code (not shown) and converted together when converted into an execution binary. An example of the assembly code after the embedding of the embedding periodic process code 22 is shown in FIG.

オブジェクトコード変換部203は、周期処理埋め込み部202から、埋め込み用周期処理コード22の埋め込みを完了した後のアセンブリコードを受け取り、オブジェクトコードへの変換を行う。
オブジェクトコード変換部203は、変換したオブジェクトコードをバイナリ変換部204に渡す。
The object code converting unit 203 receives the assembly code after the embedding of the embedding periodic processing code 22 from the periodic processing embedding unit 202 and converts it into an object code.
The object code conversion unit 203 passes the converted object code to the binary conversion unit 204.

バイナリ変換部204は、オブジェクトコード変換部203からオブジェクトコードを受け取り、実行用装置30上で実行が可能なバイナリ、周期処理埋め込みバイナリ23への変換を行う。
バイナリ変換部204は、変換した周期処理埋め込みバイナリ23を実行用装置30へ渡す。
The binary conversion unit 204 receives the object code from the object code conversion unit 203 and converts the object code into a binary that can be executed on the execution apparatus 30 and a binary embedded in the cyclic processing 23.
The binary conversion unit 204 passes the converted periodic process embedded binary 23 to the execution apparatus 30.

周期処理埋め込みバイナリ23は、実行用装置30上のROM2またはRAM3に記憶され、実行用装置30上のCPU1が実行するソフトウェアである。実行用装置30上のCPU1は、周期処理埋め込みバイナリ23を実行する際、分岐先ラベルを通過する度に経過時間計測処理コードを実行し、予め設定された周期時間が経過したか否かを判定する。例えば8割以上経過していた場合、実行用装置30上のCPU1は、周期処理コードを実行する。   The cyclic processing embedded binary 23 is software that is stored in the ROM 2 or the RAM 3 on the execution device 30 and executed by the CPU 1 on the execution device 30. When executing the periodic processing embedded binary 23, the CPU 1 on the execution device 30 executes the elapsed time measurement processing code every time it passes through the branch destination label, and determines whether or not a preset periodic time has elapsed. To do. For example, when 80% or more has elapsed, the CPU 1 on the execution apparatus 30 executes the periodic process code.

次に図6を用いて、本実施の形態におけるプログラム埋め込み装置20の動作について説明する。なお、本実施の形態では、周期処理が一周経過する時間(周期時間)の間に分岐先ラベルを複数回通過すると仮定し、周期処理を埋め込む位置を分岐先ラベルの先頭に設定している。   Next, the operation of the program embedding device 20 in the present embodiment will be described with reference to FIG. In the present embodiment, it is assumed that the branch destination label passes a plurality of times during the time (period time) in which the cycle process passes once, and the position where the cycle process is embedded is set at the head of the branch destination label.

まず、アセンブリコード変換部201が、開発用装置10から受け取ったメインプログラムのソースコード21をアセンブリコードに変換する(S101)。メインプログラムのソースコード21をアセンブリコードに変換する方法は、例えば、gcc(GNU C Compiler)を用いた場合であれば、オプション“S”を設定することによって、行っても良い。   First, the assembly code conversion unit 201 converts the source code 21 of the main program received from the development device 10 into assembly code (S101). The method of converting the source code 21 of the main program into the assembly code may be performed by setting the option “S” if, for example, gcc (GNU C Compiler) is used.

アセンブリコード変換部201は、変換したアセンブリコードを周期処理埋め込み部202に渡す。
次に、分岐先ラベル探索部2020が、アセンブリコード変換部201から受け取ったアセンブリコードの先頭から1行ずつ読み込み(S102)、分岐先ラベルが記述されているかを判定する(S103)。
The assembly code conversion unit 201 passes the converted assembly code to the periodic processing embedding unit 202.
Next, the branch destination label search unit 2020 reads line by row from the beginning of the assembly code received from the assembly code conversion unit 201 (S102), and determines whether the branch destination label is described (S103).

分岐先ラベルが記述されていなかった場合(S103:NO)、分岐先ラベル探索部2020は、現在読み込んだ1行が、アセンブリコードの終端であるかを確認する(S105)。
一方、分岐先ラベルが記述されていた場合(S103:YES)、分岐先ラベル探索部2020は、プログラム埋め込み部2021を呼び出す。
If the branch destination label is not described (S103: NO), the branch destination label search unit 2020 checks whether the currently read one line is the end of the assembly code (S105).
On the other hand, when the branch destination label is described (S103: YES), the branch destination label search unit 2020 calls the program embedding unit 2021.

プログラム埋め込み部2021は、分岐先ラベル探索部2020が読み込んだ行の次の行へ、経過時間計測処理コード220を埋め込む(S104)。
次に分岐先ラベル探索部2020は、現在読み込んだ1行が、アセンブリコードの終端であるかを確認する(S105)。
The program embedding unit 2021 embeds the elapsed time measurement processing code 220 in the line next to the line read by the branch destination label search unit 2020 (S104).
Next, the branch destination label search unit 2020 confirms whether the currently read one line is the end of the assembly code (S105).

アセンブリコードの終端ではなかった場合(S105:NO)、分岐先ラベル探索部2020は、アセンブリコードの1行読み込み(S102)を再度実行し、次の1行を読み込む。
アセンブリコードの終端であった場合(S105:YES)、分岐先ラベル探索部2020は、プログラム埋め込み部2021を呼び出す。
When it is not the end of the assembly code (S105: NO), the branch destination label search unit 2020 reads one line of the assembly code (S102) again and reads the next line.
If it is the end of the assembly code (S105: YES), the branch label search unit 2020 calls the program embedding unit 2021.

プログラム埋め込み部2021は、周期処理コード221をアセンブリコードに埋め込む(S106)。周期処理コード221を埋め込む位置はアセンブリコード内のどこでもよい。また、本実施の形態では、分岐先ラベルを抽出する処理の後に周期処理コード221を埋め込んだが、分岐先ラベルを抽出する前に行っても良い。   The program embedding unit 2021 embeds the periodic process code 221 in the assembly code (S106). The position where the periodic processing code 221 is embedded may be anywhere in the assembly code. In this embodiment, the periodic process code 221 is embedded after the process of extracting the branch destination label, but may be performed before the branch destination label is extracted.

次にオブジェクトコード変換部203は、周期処理埋め込み部202が出力した埋め込み完了後アセンブリコードを、バイナリ形式であるオブジェクトコードに変換する(S107)。なお、本実施の形態では、周期処理コード221を埋め込み完了後アセンブリコードの一部となるよう埋め込んだが、埋め込み完了後アセンブリコードとは別のファイルとし、埋め込み完了後アセンブリコードとは別にオブジェクトコードに変換しても良い。   Next, the object code conversion unit 203 converts the assembly code after completion of embedding output from the periodic process embedding unit 202 into an object code in binary format (S107). In the present embodiment, the periodic processing code 221 is embedded so as to become a part of the assembly code after the embedding is completed. It may be converted.

最後にバイナリ変換部204が、オブジェクトコード(複数でもよい)と共有ライブラリを結合し、実行用装置上のCPU1で実行可能な形式である周期処理埋め込みバイナリ23を出力する。   Finally, the binary conversion unit 204 combines the object code (s) and the shared library, and outputs a periodic process embedded binary 23 that is a format executable by the CPU 1 on the execution apparatus.

次に図7を用いて、周期処理埋め込みバイナリ23に埋め込まれた経過時間計測処理コード220の動作について説明する。なお、周期処理埋め込みバイナリ23は、実行用装置30上のROM2またはRAM3上に記憶され、実行用装置30上のCPU1により実行される。周期処理埋め込みバイナリ23に埋め込まれた経過時間計測処理コード220が参照するタイマ5も、実行用装置30上のものである。   Next, the operation of the elapsed time measurement processing code 220 embedded in the periodic processing embedded binary 23 will be described with reference to FIG. The cyclic processing embedded binary 23 is stored in the ROM 2 or the RAM 3 on the execution device 30 and is executed by the CPU 1 on the execution device 30. The timer 5 referred to by the elapsed time measuring process code 220 embedded in the periodic process embedded binary 23 is also on the execution apparatus 30.

経過時間計測処理コード220は、タイマ5の値を読み込み、周期処理コード221が前回実行された時間との差分を計算する(S201)。
なお、本実施の形態では、タイマ5の初期値は0であり、周期処理埋め込みバイナリ23の実行開始と同時にカウントを開始していることを前提とする。つまり、経過時間計測処理コード220が読み込んだタイマ5の値は、前回周期処理コード221を実行してからの経過時間(差分)となる。
The elapsed time measurement processing code 220 reads the value of the timer 5 and calculates the difference from the time when the periodic processing code 221 was executed last time (S201).
In this embodiment, the initial value of the timer 5 is 0, and it is assumed that the count is started simultaneously with the start of the execution of the periodic process embedded binary 23. That is, the value of the timer 5 read by the elapsed time measurement processing code 220 is the elapsed time (difference) since the previous periodic processing code 221 was executed.

次に、経過時間計測処理コード220は、S201にて算出した差分が周期時間の8割以上であるかを判定する(S202)。なお、本実施の形態では、周期処理を周期時間内に確実に実行することを目的としているため、周期処理の実行条件を周期時間の8割経過時と定義としたが、周期時間を越えなければ特に8割以外であってもよい。   Next, the elapsed time measurement processing code 220 determines whether the difference calculated in S201 is 80% or more of the cycle time (S202). In this embodiment, since the purpose is to execute the periodic processing within the periodic time without fail, the execution condition of the periodic processing is defined as when 80% of the periodic time has elapsed, but the periodic time must be exceeded. In particular, it may be other than 80%.

判定した結果、8割以上であった場合(S202:YES)、経過時間計測処理コード220は、周期処理コード221を呼び出す(S203)。
経過時間計測処理コード220は、周期処理コード221を呼び出した後、現在のタイマ5のカウント値を前回実行時の値として記録(更新)する(S204)。
If the result of the determination is 80% or more (S202: YES), the elapsed time measurement process code 220 calls the periodic process code 221 (S203).
The elapsed time measurement processing code 220 records (updates) the current count value of the timer 5 as the value at the previous execution after calling the periodic processing code 221 (S204).

判定した結果8割未満であった場合(S202:NO)、経過時間計測処理コード220は、何もせずに終了する。   If the determination result is less than 80% (S202: NO), the elapsed time measurement processing code 220 is terminated without doing anything.

以上のように、メインプログラムのソースコード21を変換したアセンブリコードの中から分岐先ラベルを探索する分岐先ラベル探索部2020と、埋め込み用周期処理コード22をアセンブリコードへ埋め込む処理を行うプログラム埋め込み部2021を備えることにより、タイマ割り込みを利用せずとも周期処理を実行するバイナリ(周期処理埋め込みバイナリ23)を生成することが可能となる。   As described above, the branch destination label searching unit 2020 that searches for the branch destination label from the assembly code obtained by converting the source code 21 of the main program, and the program embedding unit that performs the process of embedding the embedded periodic processing code 22 in the assembly code. The provision of 2021 makes it possible to generate a binary (periodic processing embedded binary 23) that executes periodic processing without using a timer interrupt.

また、周期処理埋め込みバイナリ23を実行用装置30上で実行する際には、タイマ5のカウント値を確認しながら周期処理コード221を実行するか否かを判断するため、周期処理コード221の実行を必要最低限に留めることが可能となる。   Further, when the periodic process embedded binary 23 is executed on the execution apparatus 30, the execution of the periodic process code 221 is performed in order to determine whether to execute the periodic process code 221 while checking the count value of the timer 5. Can be kept to the minimum necessary.

さらに、タイマ5のカウント値を確認しながら周期処理コード221を実行するか否かを判断しているため、メインプログラムのソースコード21の内容が変化した場合でも、確実に周期処理を周期時間内に実行することが可能である。   Furthermore, since it is determined whether or not to execute the periodic processing code 221 while checking the count value of the timer 5, even if the contents of the source code 21 of the main program change, the periodic processing is reliably performed within the periodic time. Can be performed.

実施の形態2.
実施の形態1では、メインプログラムのソースコード21を変換したアセンブリコードの中から分岐先ラベルを探索する分岐先ラベル探索部2020と、埋め込み用周期処理コード22をアセンブリコードへ埋め込む処理を行うプログラム埋め込み部2021を備えることにより、実行用装置30上で、タイマ割り込みを利用せずとも周期処理を実行するバイナリを生成するプログラム埋め込み装置20について述べた。
実施の形態1で生成されたバイナリ(周期処理埋め込みバイナリ23)は、全ての分岐先ラベルの通過時に、周期処理を実行するか否かの判定を行っている。
本実施の形態では、実行用装置30で予めメインプログラムを実行しておき、各分岐先ラベルで計測した経過時間のログから周期処理が周期時間内に実行するために必要な分岐先ラベルの通過時のみ、周期処理の実行命令を埋め込むプログラム埋め込み装置20について述べる。
図8は、本実施の形態におけるシステムの構成図の一例である。本実施の形態におけるシステムでは、開発用装置10、プログラム埋め込み装置20、実行用装置30で構成される。
開発用装置10からプログラム埋め込み装置20に対し、メインプログラムのソースコード21、埋め込み用時間計測処理コード24および埋め込み用周期処理コード27が渡され、プログラム埋め込み装置20から実行用装置30に対し、測定用周期処理埋め込みバイナリ25と周期処理埋め込みバイナリ28が渡され、実行用装置30からプログラム埋め込み装置20に対し、経過時間ログ26が渡される。
なお、本実施の形態におけるプログラム埋め込み装置20は、第1の動作と第2の動作の2種類の動作を順に行う。このため、図9〜11を用いて、プログラム埋め込み装置20が第1の動作を行う場合のシステム構成(図9)、第1の動作によって生成された測定用周期処理埋め込みバイナリ25を受け取った実行用装置30が動作を行う場合のシステム構成(図10)、プログラム埋め込み装置20が第2の動作を行う場合のシステム構成(図11)について説明する。なお、図9〜11において、それぞれの各動作に関係のない構成要素については点線とした。
Embodiment 2. FIG.
In the first embodiment, a program for embedding a branch destination label search unit 2020 for searching for a branch destination label from the assembly code obtained by converting the source code 21 of the main program, and a process for embedding the embedded periodic processing code 22 in the assembly code. The program embedding device 20 that generates the binary for executing the periodic processing without using the timer interrupt on the execution device 30 by providing the unit 2021 has been described.
The binary (periodic processing embedded binary 23) generated in the first embodiment determines whether or not to execute periodic processing when all branch destination labels pass.
In the present embodiment, the main program is executed in advance by the execution device 30, and the passage of the branch destination label necessary for the periodic processing to be executed within the period time from the log of the elapsed time measured at each branch destination label. Only when will the program embedding device 20 embed an execution instruction for periodic processing be described.
FIG. 8 is an example of a system configuration diagram in the present embodiment. The system according to the present embodiment includes a development device 10, a program embedding device 20, and an execution device 30.
The development device 10 passes the source code 21 of the main program, the embedding time measurement processing code 24 and the embedding periodic processing code 27 to the program embedding device 20, and the program embedding device 20 measures the execution device 30. The periodic processing embedded binary 25 and the periodic processing embedded binary 28 are delivered, and the elapsed time log 26 is delivered from the execution device 30 to the program embedding device 20.
Note that the program embedding device 20 in the present embodiment sequentially performs two types of operations, a first operation and a second operation. 9-11, the system configuration when the program embedding apparatus 20 performs the first operation (FIG. 9), the execution of receiving the measurement periodic process embedded binary 25 generated by the first operation A system configuration (FIG. 10) when the operating device 30 performs the operation and a system configuration (FIG. 11) when the program embedding device 20 performs the second operation will be described. In addition, in FIGS. 9-11, the component which is not related to each operation | movement was made into the dotted line.

図9は、プログラム埋め込み装置20が第1の動作を行う場合のシステム構成図である。開発用装置10は、実行用装置30上で動作するプログラムを開発するための装置である。開発用装置10で開発されたメインプログラムのソースコード21と、埋め込み用時間計測処理コード24は、プログラム埋め込み装置20に渡される。   FIG. 9 is a system configuration diagram when the program embedding device 20 performs the first operation. The development device 10 is a device for developing a program that runs on the execution device 30. The source code 21 of the main program developed by the development apparatus 10 and the embedding time measurement processing code 24 are passed to the program embedding apparatus 20.

メインプログラムのソースコード21は、実行用装置30上で動作させたいプログラムのソースコードである。また、メインプログラムのソースコード21は、CやC++などのコンパイル可能なプログラミング言語で記述されたものであり、複数のファイルから構成されていてもよい。   The source code 21 of the main program is the source code of the program that is to be run on the execution device 30. The source code 21 of the main program is described in a compilable programming language such as C or C ++, and may be composed of a plurality of files.

埋め込み用時間計測処理コード24は、プログラムの実行(経過)時間を記録するアセンブリコードである。
埋め込み用時間計測処理コード24は、アセンブリコードであるが、メインプログラムのソースコード21と同様、CやC++などのコンパイル可能なプログラミング言語で記述されたものであっても良い。しかし、その場合はアセンブリコード変換部201により、埋め込み前にアセンブリコードに変換する必要がある。
第1の動作において、プログラム埋め込み装置20は、開発用装置10から受け取ったメインプログラムのソースコード21と埋め込み用時間計測処理コード24から測定用周期処理埋め込みバイナリ25を生成し、実行用装置30に渡す。
The embedded time measurement processing code 24 is an assembly code for recording the execution (elapsed) time of the program.
The embedding time measurement processing code 24 is an assembly code, but may be written in a compilable programming language such as C or C ++ like the source code 21 of the main program. However, in that case, the assembly code conversion unit 201 needs to convert the assembly code into an assembly code before embedding.
In the first operation, the program embedding device 20 generates the measurement periodic process embedded binary 25 from the source code 21 of the main program received from the development device 10 and the embedding time measurement processing code 24, and sends it to the execution device 30. hand over.

図10は、プログラム埋め込み装置20の第1の動作によって生成された測定用周期処理埋め込みバイナリ25を受け取った実行用装置30が動作を行う場合のシステム構成図である。実行用装置30は、プログラム埋め込み装置20から渡された測定用周期処理埋め込みバイナリ25を実行し、経過時間ログ26を出力する。実行用装置30が出力した経過時間ログ26は、プログラム埋め込み装置20に渡される。   FIG. 10 is a system configuration diagram in the case where the execution apparatus 30 that has received the measurement periodic process embedded binary 25 generated by the first operation of the program embedding apparatus 20 performs the operation. The execution device 30 executes the measurement periodic process embedded binary 25 passed from the program embedding device 20 and outputs an elapsed time log 26. The elapsed time log 26 output from the execution device 30 is passed to the program embedding device 20.

図11は、プログラム埋め込み装置20が第2の動作を行う場合のシステム構成図である。開発用装置10で開発されたメインプログラムのソースコード21と埋め込み用周期処理コード27および、実行用装置30が測定用周期処理埋め込みバイナリ25を実行した結果出力した経過時間ログ26がプログラム埋め込み装置20に渡される。   FIG. 11 is a system configuration diagram when the program embedding device 20 performs the second operation. The source code 21 and embedding periodic process code 27 of the main program developed by the development apparatus 10 and the elapsed time log 26 output as a result of the execution apparatus 30 executing the measurement periodic process embedded binary 25 are the program embedding apparatus 20. Passed to.

埋め込み用周期処理コード27は、本来、実行用装置30上でタイマ割り込みを使用することができた場合に実行する周期処理プログラムのアセンブリコードである。埋め込み用周期処理コード27は、周期処理及び、前期周期処理を実行するか否かを判定するためのプログラムのアセンブリコードで構成される。
埋め込み用周期処理コード27はアセンブリコードであるが、メインプログラムのソースコード21と同様、CやC++などのコンパイル可能なプログラミング言語で記述されたものであっても良い。しかし、その場合はアセンブリコード変換部201により、埋め込み前にアセンブリコードに変換する必要がある。
第2の動作において、プログラム埋め込み装置20は、開発用装置10から受け取ったメインプログラムのソースコード21と埋め込み用周期処理コード27および、実行用装置30から受け取った経過時間ログ26から、周期処理埋め込みバイナリ28を生成し、実行用装置30に渡す。
The periodic processing code 27 for embedding is an assembly code of a periodic processing program that is executed when a timer interrupt can be used on the execution device 30. The embedded periodic process code 27 is composed of an assembly code of a program for determining whether to execute the periodic process and the previous period process.
The embedded periodic processing code 27 is an assembly code, but may be written in a compilable programming language such as C or C ++, like the source code 21 of the main program. However, in that case, the assembly code conversion unit 201 needs to convert the assembly code into an assembly code before embedding.
In the second operation, the program embedding device 20 embeds periodic processing embedding from the source code 21 and embedding periodic processing code 27 received from the development device 10 and the elapsed time log 26 received from the execution device 30. A binary 28 is generated and passed to the execution device 30.

図12は、本実施の形態2におけるプログラム埋め込み装置20上で動作するソフトウェアの全体構成図である。これらのソフトウェアは、プログラム埋め込み装置20のROM2またはRAM3上に記憶され、CPU1により実行される。   FIG. 12 is an overall configuration diagram of software that operates on the program embedding device 20 according to the second embodiment. These software are stored on the ROM 2 or the RAM 3 of the program embedding device 20 and executed by the CPU 1.

図12において、プログラム埋め込み装置20は、プログラミング言語で記述されたソースコードをアセンブリコードに変換するアセンブリコード変換部201と、埋め込み用時間計測処理コード24をアセンブリレベルでメインプログラムへ埋め込む第1の周期処理埋め込み部205と、経過時間ログ26を参照しつつ、埋め込み用周期処理コード27をアセンブリレベルでメインプログラムへ埋め込む第2の周期処理埋め込み部206と、埋め込み用時間計測処理コード24もしくは埋め込み用周期処理コード27の埋め込みが完了したアセンブリコードを(実行用装置30上の)CPU1で実行可能なオブジェクトコードに変換するオブジェクトコード変換部203と、オブジェクトコード(複数でもよい)との共有とライブラリとを結合するバイナリ変換部204を備えている。   In FIG. 12, a program embedding device 20 includes an assembly code conversion unit 201 that converts source code described in a programming language into assembly code, and a first period in which embedding time measurement processing code 24 is embedded in the main program at the assembly level. With reference to the processing embedding unit 205 and the elapsed time log 26, a second periodic processing embedding unit 206 for embedding the embedding periodic processing code 27 into the main program at the assembly level, and an embedding time measuring processing code 24 or embedding cycle. An object code conversion unit 203 that converts assembly code in which the processing code 27 has been embedded into object code that can be executed by the CPU 1 (on the execution apparatus 30), sharing of object code (s), and a library And a binary conversion unit 204 for engagement.

なお、第1の周期処理埋め込み部205は、アセンブリコードの中から分岐先ラベルを探索する分岐先ラベル探索部2020と、埋め込み用時間計測処理コード24をアセンブリコードへ埋め込む処理を行うプログラム埋め込み部(第2のプログラム埋め込み部)2050を備えており、第2の周期処理埋め込み部206は、経過時間ログ26を参照し、アセンブリコードの中に埋め込み用周期処理コード27を埋め込む位置を決定する埋め込み位置決定部2060と、埋め込み用周期処理コード27をアセンブリコードへ埋め込む処理を行うプログラム埋め込み部2021を備えている。   The first periodic processing embedding unit 205 includes a branch destination label searching unit 2020 for searching for a branch destination label from the assembly code, and a program embedding unit (for embedding the embedding time measurement processing code 24 in the assembly code). (Second program embedding unit) 2050, and the second periodic processing embedding unit 206 refers to the elapsed time log 26 and determines an embedding position for determining a position for embedding the periodic processing code 27 for embedding in the assembly code. A determination unit 2060 and a program embedding unit 2021 for embedding the embedding periodic processing code 27 in the assembly code are provided.

前述したように、本実施の形態におけるプログラム埋め込み装置20は、第1の動作と第2の動作の2種類の動作を順に行う。それぞれの動作に着目した場合のプログラム埋め込み装置20上で動作するソフトウェアの全体構成図を図13と図14に示す。
本実施の形態では、2種類の周期処理埋め込み部から構成されており、実行動作に応じて処理を切り替える必要がある。処理の切替は、ソフトウェア実行時の引数などからプログラム埋め込み装置20が経過時間ログ26を受け取っているかどうかで判断させてもよい。また、経過時間ログ26が入力された場合には、第2の周期処理埋め込み部206を実行するように判断しても良い。
As described above, the program embedding device 20 in the present embodiment sequentially performs the two types of operations, the first operation and the second operation. FIG. 13 and FIG. 14 show an overall configuration diagram of software operating on the program embedding device 20 when attention is paid to each operation.
In this embodiment, it is composed of two types of periodic processing embedding units, and it is necessary to switch processing according to the execution operation. The process switching may be determined based on whether or not the program embedding device 20 has received the elapsed time log 26 from an argument at the time of software execution. In addition, when the elapsed time log 26 is input, it may be determined to execute the second periodic process embedding unit 206.

図13は、本実施の形態2におけるプログラム埋め込み装置20上で動作するソフトウェアの全体構成のうち、第1の動作を行う場合に着目したソフトウェア構成図である。
図13において、埋め込み用時間計測処理コード24は、実行用装置30上のタイマ5のカウント値、埋め込み用時間計測処理コード24が埋め込まれたファイル名、および分岐先ラベルを記録する命令が記述されたアセンブリコードである。
プログラム埋め込み部2050は、入力されたコードに関わらず、分岐先ラベル探索部2020が決定した埋め込む位置への埋め込みを実現する。
FIG. 13 is a software configuration diagram focusing on performing the first operation among the entire configuration of software operating on the program embedding device 20 in the second embodiment.
In FIG. 13, the embedding time measurement processing code 24 describes the count value of the timer 5 on the execution device 30, the file name in which the embedding time measurement processing code 24 is embedded, and an instruction to record the branch destination label. Assembly code.
The program embedding unit 2050 realizes embedding at the embedding position determined by the branch destination label searching unit 2020 regardless of the input code.

図14は、本実施の形態2におけるプログラム埋め込み装置20上で動作するソフトウェアの全体構成のうち、第2の動作を行う場合に着目したソフトウェア構成図である。
図14において、埋め込み位置決定部2060は、経過時間ログ26を参照して周期処理を実行する分岐先ラベルの位置を決定するものである。また、ループ処理などの場合は、同じ分岐先ラベルを複数回通過することが想定されるため、埋め込み位置決定部2060は、周期処理を実行する分岐先ラベルと通過回数を含めて埋め込み位置を決定する。
FIG. 14 is a software configuration diagram focusing on performing the second operation among the entire configuration of software operating on the program embedding device 20 in the second embodiment.
In FIG. 14, the embedding position determination unit 2060 determines the position of the branch destination label for executing the periodic process with reference to the elapsed time log 26. Further, in the case of loop processing or the like, it is assumed that the same branch destination label is passed a plurality of times, so the embedding position determination unit 2060 determines the embedding position including the branch destination label for performing the periodic processing and the number of times of passage. To do.

図15を用いて、埋め込み用周期処理コード27を説明する。
埋め込み用周期処理コード27は、分岐先ラベルが通過した回数を計測しながら周期処理の実行を判定する通過回数計測コード270、および周期処理コード221から構成される。
プログラム埋め込み部2021は、埋め込み位置決定部2060にて決定した位置にコードの埋め込みを行う。なお、通過回数が1回の場合には、周期処理コード221のみを埋め込み、複数回通過する場合には、通過回数計測コード270と併せて周期処理コード221を埋め込む。
The embedding periodic process code 27 will be described with reference to FIG.
The periodic processing code 27 for embedding includes a passage count measurement code 270 for determining execution of the periodic processing while measuring the number of times the branch destination label has passed, and a periodic processing code 221.
The program embedding unit 2021 embeds a code at the position determined by the embedding position determining unit 2060. If the number of passes is one, only the periodic processing code 221 is embedded, and if it passes a plurality of times, the periodic processing code 221 is embedded together with the passage count measurement code 270.

第1、第2の動作に共通してオブジェクトコード変換部203は、埋め込みが完了したアセンブリコードを受け取り、オブジェクトコードへの変換を行う。
オブジェクトコード変換部203は、変換したオブジェクトコードをバイナリ変換部204に渡す。
バイナリ変換部204は、オブジェクトコード変換部203からオブジェクトコードを受け取り、実行用装置30上で実行が可能なバイナリへの変換を行う。
第1の動作の際は、測定用周期処理埋め込みバイナリ25へと変換し、第2の動作の際は、周期処理埋め込みバイナリ28へと変換する。
In common with the first and second operations, the object code conversion unit 203 receives assembly code that has been embedded, and converts it into object code.
The object code conversion unit 203 passes the converted object code to the binary conversion unit 204.
The binary conversion unit 204 receives the object code from the object code conversion unit 203 and converts it into binary that can be executed on the execution apparatus 30.
In the first operation, it is converted into the periodic processing embedded binary 25 for measurement, and in the second operation, it is converted into the periodic processing embedded binary 28.

測定用周期処理埋め込みバイナリ25は、実行用装置30上のROM2またはRAM3に記憶され、実行用装置30上のCPU1が実行するソフトウェアである。
実行用装置30上のCPU1は、測定用周期処理埋め込みバイナリ25を実行する際、分岐先ラベルを通過する度にタイマ5の値を記録し、メインプログラムの経過時間を測定する。
The measurement periodic process embedded binary 25 is software stored in the ROM 2 or the RAM 3 on the execution device 30 and executed by the CPU 1 on the execution device 30.
When executing the periodic processing embedded binary 25 for measurement, the CPU 1 on the execution device 30 records the value of the timer 5 every time the branch destination label is passed, and measures the elapsed time of the main program.

周期処理埋め込みバイナリ28は、実行用装置30上のROM2またはRAM3に記憶され、実行用装置30上のCPU1が実行するソフトウェアである。
実行用装置30上のCPU1は、周期処理埋め込みバイナリ28を実行する際、埋め込み用周期処理コードが埋め込まれた分岐先ラベルを通過する度に、周期処理コード221を実行する。
The periodic processing embedded binary 28 is software that is stored in the ROM 2 or the RAM 3 on the execution device 30 and executed by the CPU 1 on the execution device 30.
When executing the periodic process embedded binary 28, the CPU 1 on the execution apparatus 30 executes the periodic process code 221 every time it passes through the branch destination label in which the embedded periodic process code is embedded.

次に、図16を用いて、本実施の形態におけるプログラム埋め込み装置20の第1の動作について説明する。
第1の動作とは、プログラム埋め込み装置20がメインプログラムのソースコード21と埋め込み用時間計測処理コード24から、実行用装置30で動作可能な測定用周期処理埋め込みバイナリ25を生成することを示す。
第1の動作においてプログラム埋め込み装置20は、分岐先ラベルの先頭行に埋め込み用時間計測処理コード24を挿入する(S301)。その他の動作内容については、実施の形態1で示した図6と同じである。
Next, the first operation of the program embedding device 20 in the present embodiment will be described with reference to FIG.
The first operation indicates that the program embedding device 20 generates a measurement periodic process embedded binary 25 operable by the execution device 30 from the source code 21 and the embedding time measurement processing code 24 of the main program.
In the first operation, the program embedding device 20 inserts the embedding time measurement processing code 24 into the first line of the branch destination label (S301). Other operation contents are the same as those in FIG. 6 described in the first embodiment.

次に、図17を用いて、測定用周期処理埋め込みバイナリ25に挿入された埋め込み用時間計測処理コード24の動作について説明する。なお、測定用周期処理埋め込みバイナリ25は、実行用装置30上のROM2またはRAM3上に記憶され、実行用装置30上のCPU1により実行される。測定用周期処理埋め込みバイナリ25に挿入された埋め込み用時間計測処理コード24が参照するタイマ5も実行用装置30上のものである。 Next, the operation of the embedding time measurement processing code 24 inserted into the measurement periodic process embedding binary 25 will be described with reference to FIG. The measurement periodic process embedded binary 25 is stored in the ROM 2 or the RAM 3 on the execution device 30 and is executed by the CPU 1 on the execution device 30. The timer 5 referred to by the embedded time measurement processing code 24 inserted into the measurement periodic process embedded binary 25 is also on the execution device 30.

埋め込み用時間計測処理コード24は、埋め込まれたプログラムのファイル名、および分岐先ラベル名を取得する(S206、S207)。
次に、埋め込み用時間計測処理コード24は、タイマ5の値を読み込む(S208)。最後に、取得した情報(ファイル名、分岐先ラベル、タイマ5の値)を経過ログに記録する(S209)。
The embedding time measurement processing code 24 acquires the file name of the embedded program and the branch destination label name (S206, S207).
Next, the embedding time measurement processing code 24 reads the value of the timer 5 (S208). Finally, the acquired information (file name, branch destination label, timer 5 value) is recorded in the progress log (S209).

図16、17では、埋め込み用時間計測処理コード24内にログを記録する命令を記述する場合の例を示したが、これらの命令は一か所だけ関数として埋め込み、埋め込み用時間計測処理コード24から呼び出すようにしても良い。 FIGS. 16 and 17 show an example in which an instruction for recording a log is described in the embedding time measuring process code 24. However, these instructions are embedded as a function at one place, and the embedding time measuring process code 24 is written. You may make it call from.

第1の動作によって生成された、測定用周期処理埋め込みバイナリ25を実行用装置30上で実行することによって経過時間ログ26が出力される。
図18は、実行用装置30上で測定用周期処理埋め込みバイナリ25を動作させた結果出力された、経過時間ログ26の一例である。
By executing the measurement periodic process embedded binary 25 generated by the first operation on the execution apparatus 30, the elapsed time log 26 is output.
FIG. 18 is an example of the elapsed time log 26 output as a result of operating the measurement periodic process embedded binary 25 on the execution apparatus 30.

次に、図19を用いて、本実施の形態におけるプログラム埋め込み装置20の第2の動作について説明する。
第2の動作とは、プログラム埋め込み装置20がメインプログラムのソースコード21と埋め込み用周期処理コード27を用いて、実行用装置30で動作可能な周期処理埋め込みバイナリ28を生成することを示す。
Next, the second operation of the program embedding device 20 in the present embodiment will be described with reference to FIG.
The second operation indicates that the program embedding device 20 uses the source code 21 and the embedding periodic processing code 27 of the main program to generate the periodic processing embedded binary 28 that can be operated by the execution device 30.

第2に動作において、まずアセンブリコード変換部201が開発用装置10から受け取ったメインプログラムのソースコード21をアセンブリコードに変換する(S101)。
アセンブリコード変換部201は、変換したアセンブリコードを第2の周期処理埋め込み部206に渡す。
次に、埋め込み位置決定部2060が、実行用装置30から受け取った経過時間ログ26に基づいて、埋め込み用周期処理コード27を挿入する位置を決定し、埋め込み位置テーブルに記録する(S302)。
Secondly, in the operation, first, the assembly code conversion unit 201 converts the source code 21 of the main program received from the development apparatus 10 into assembly code (S101).
The assembly code conversion unit 201 passes the converted assembly code to the second periodic processing embedding unit 206.
Next, the embedding position determination unit 2060 determines a position where the embedding period processing code 27 is inserted based on the elapsed time log 26 received from the execution apparatus 30, and records it in the embedding position table (S302).

埋め込み位置テーブルは、周期処理を行うファイル名、分岐先ラベル、通過回数を記録するためのものである。図20に埋め込み位置テーブルの一例を示す。S302の詳細な動作フローについては後述する。   The embedding position table is for recording the name of a file to be periodically processed, the branch destination label, and the number of passages. FIG. 20 shows an example of the embedded position table. The detailed operation flow of S302 will be described later.

埋め込み位置決定部2060は、埋め込み位置テーブルに記録された分岐先ラベルを1行ずつ読み込む(S303)。
次に、埋め込み位置決定部2060は、アセンブリコード変換部201から受け取ったメインプログラムのアセンブリコードの先頭から1行ずつ読み込み(S304)、S303で読み込んだ分岐先ラベルと一致するか判定する(S305)。
The embedding position determination unit 2060 reads the branch destination labels recorded in the embedding position table line by line (S303).
Next, the embedding position determination unit 2060 reads one line at a time from the beginning of the assembly code of the main program received from the assembly code conversion unit 201 (S304), and determines whether it matches the branch destination label read in S303 (S305). .

埋め込み位置テーブルの分岐先ラベルと一致しなかった場合(S305:NO)、埋め込み位置決定部2060は、アセンブリコードの1行読み込み(S304)を再度実行し、次の行を読み込む。
一方、埋め込み位置テーブルの分岐先ラベルと一致した場合(S305:YES)、埋め込み位置決定部2060は、埋め込み位置テーブルに記録されている分岐先ラベルの通過回数を判定する(S306)。
If it does not match the branching destination label in the embedding position table (S305: NO), the embedding position determining unit 2060 reads one line of assembly code (S304) again and reads the next line.
On the other hand, when it matches with the branch destination label of the embedded position table (S305: YES), the embedded position determining unit 2060 determines the number of passages of the branch destination label recorded in the embedded position table (S306).

埋め込み位置テーブルの通過回数が一回であった場合(S306:一回)、埋め込み位置決定部2060は、プログラム埋め込み部2021を呼び出す。
プログラム埋め込み部2021は、埋め込み位置決定部2060がアセンブリコードから読み込んだ分岐先ラベルの次の行へ周期処理コード221を挿入する(S308)。
なお、周期処理コード221は、全ての位置に埋め込んでもよいし、一か所だけ関数として埋め込み、分岐先ラベルには関数の呼び出し命令のみを挿入するようにしても良い。前者の全ての位置に埋め込む方法であれば、処理速度を向上でき、後者の一か所だけ関数として埋め込む方法だと、メモリを節約できる。
When the number of passes through the embedding position table is once (S306: once), the embedding position determination unit 2060 calls the program embedding unit 2021.
The program embedding unit 2021 inserts the periodic processing code 221 into the next line of the branch destination label read from the assembly code by the embedding position determination unit 2060 (S308).
The periodic processing code 221 may be embedded at all positions, or may be embedded as a function at only one place, and only a function call instruction may be inserted into the branch destination label. If the method is embedded in all the former positions, the processing speed can be improved, and if the method is embedded only in one of the latter positions, memory can be saved.

埋め込み位置テーブルの通過回数が複数回であった場合、埋め込み位置決定部2060は、アセンブリコードから読み込んだ分岐先ラベルの次の行へ通過回数計測コード270を挿入するよう、プログラム埋め込み部2021を呼び出し(S307)、さらに周期処理コード221を挿入するよう、プログラム埋め込み部2021を呼び出す(S308)。
なお、周期処理コード221は、全ての位置に通過回数計測コード270と同時に埋め込んでもよいし、一か所だけ関数として埋め込み、通過回数計測コード270から呼び出すようにしても良い。前者の全ての位置に埋め込む方法であれば、処理速度を向上でき、後者の一か所だけ関数として埋め込む方法だと、メモリを節約できる。
When the number of times of passage through the embedding position table is plural, the embedding position determination unit 2060 calls the program embedding unit 2021 to insert the passage number measurement code 270 into the next line of the branch destination label read from the assembly code. (S307) Then, the program embedding unit 2021 is called to insert the periodic processing code 221 (S308).
The periodic processing code 221 may be embedded at all positions at the same time as the passage count measurement code 270, or may be embedded as a function at one location and called from the passage count measurement code 270. If the method is embedded in all the former positions, the processing speed can be improved, and if the method is embedded only in one of the latter positions, memory can be saved.

次に、埋め込み位置決定部2060は、現在読み込んだ分岐先ラベルが埋め込み位置テーブルの終端であるかを確認する(S309)。
埋め込み位置テーブルの終端でなかった場合(S309:NO)、埋め込み位置決定部2060は、埋め込み位置テーブルの分岐先ラベルの読み込みを再度実行し(S303)、次の1行を読み込む。
Next, the embedding position determination unit 2060 checks whether the currently read branch destination label is the end of the embedding position table (S309).
If it is not the end of the embedding position table (S309: NO), the embedding position determination unit 2060 reads the branch destination label of the embedding position table again (S303), and reads the next line.

埋め込み位置テーブルの終端であった場合(S309:YES)、埋め込み位置決定部2060は、オブジェクトコード変換部203を呼び出す。
オブジェクトコード変換部203とバイナリ変換部204の動作内容(S106、S107)は実施の形態1と同様である。
If it is the end of the embedding position table (S309: YES), the embedding position determination unit 2060 calls the object code conversion unit 203.
The operation contents (S106, S107) of the object code conversion unit 203 and the binary conversion unit 204 are the same as those in the first embodiment.

次に、図21を用いて、周期処理埋め込みバイナリ28に挿入された通過回数計測コード270の動作について説明する。なお、周期処理埋め込みバイナリ28は、実行用装置30上のROM2またはRAM3上に記憶され、実行用装置30上のCPU1により実行される。 Next, the operation of the pass count code 270 inserted in the periodic process embedded binary 28 will be described with reference to FIG. The cyclic processing embedded binary 28 is stored in the ROM 2 or RAM 3 on the execution device 30 and is executed by the CPU 1 on the execution device 30.

通過回数計測コード270は、分岐先ラベルの通過回数をカウントしながら周期処理を実行するべきか判定する。
まず、通過回数計測コード270は、分岐先ラベルの通過回数に1を加算する(S210)。なお、通過回数計測コード270は、各分岐先ラベル毎の通過回数をカウントするためのテーブルなどを保持していることを前提とする。
The passage count measurement code 270 determines whether the periodic processing should be executed while counting the number of passages of the branch destination label.
First, the pass count measurement code 270 adds 1 to the pass count of the branch destination label (S210). It is assumed that the pass count measurement code 270 holds a table for counting the pass count for each branch destination label.

次に、通過回数計測コード270は、加算した通過回数が埋め込み位置テーブルに記録された周期処理を行う通過回数であるかを判定する(S203)。
周期処理を行う通過回数と一致した場合(S203:YES)、通過回数計測コード270は、周期処理コード221を呼び出し(S203)、終了する。
一方、周期処理を行う通過回数と一致しなかった場合(S203:NO)、通過回数計測コード270は何もせず終了する。
Next, the passage number measurement code 270 determines whether or not the added passage number is the number of passages for performing the periodic process recorded in the embedded position table (S203).
When the number of passes that matches the periodic processing (S203: YES), the passage count measurement code 270 calls the periodic processing code 221 (S203) and ends.
On the other hand, when it does not coincide with the number of times of passing the periodic process (S203: NO), the number of times of passing measurement code 270 is terminated without doing anything.

次に、図22を用いて、第2の周期処理埋め込み部206における埋め込み位置決定部2060が、経過ログ26を参照し埋め込み位置テーブルを作成する動作フロー(図19:S302の詳細)について説明する。   Next, an operation flow in which the embedding position determination unit 2060 in the second periodic processing embedding unit 206 creates an embedding position table with reference to the progress log 26 (FIG. 19: details of S302) will be described with reference to FIG. .

まず、埋め込み位置決定部2060は、実行用装置30から受け取った経過時間ログ26を先頭から1行ずつ読み込み(S310)、読み込んだ分岐先ラベルの通過回数に1を加算する(S311)。なお、埋め込み位置決定部2060は、各分岐先ラベル毎の通過回数をカウントするためのテーブルなどを保持していることを前提とする。   First, the embedding position determination unit 2060 reads the elapsed time log 26 received from the execution apparatus 30 line by line from the top (S310), and adds 1 to the number of passages of the read branch destination label (S311). Note that it is assumed that the embedding position determination unit 2060 holds a table or the like for counting the number of passes for each branch destination label.

次に、埋め込み位置決定部2060は、経過時間ログ26に記録されているタイマの値を読み込み、周期処理コード221が前回実行された時間との差分を計算する(S312)。なお、本実施の形態では、前回実行時の初期値は0に設定する。   Next, the embedding position determination unit 2060 reads the timer value recorded in the elapsed time log 26 and calculates the difference from the time when the periodic processing code 221 was executed last time (S312). In the present embodiment, the initial value at the previous execution is set to zero.

次に、埋め込み位置決定部2060は、S312にて算出した差分が周期時間未満であるかを判定する(S313)。
判定した結果、周期時間以上であった場合(S313:YES)、埋め込み位置決定部2060は経過時間ログに記録されている内容を一時バッファに記憶し(S314)、経過時間ログの終端であるか判定する(S317)。
Next, the embedding position determination unit 2060 determines whether the difference calculated in S312 is less than the cycle time (S313).
As a result of the determination, if it is not less than the cycle time (S313: YES), the embedding position determination unit 2060 stores the content recorded in the elapsed time log in the temporary buffer (S314), and is it the end of the elapsed time log? Determination is made (S317).

一方、判定した結果が周期時間未満であった場合(S313:YES)、埋め込み位置決定部2060は一時バッファに記録されているファイル名、分岐先ラベル、および該当する分岐先ラベルの通過回数を埋め込み位置テーブルに記録し(S315)、経過時間ログから読み込んだ現在のタイマの値を前回実行時の値として記録(更新)する(S316)。   On the other hand, if the determined result is less than the cycle time (S313: YES), the embedding position determination unit 2060 embeds the file name, the branch destination label, and the number of passages of the corresponding branch destination label recorded in the temporary buffer. It is recorded in the position table (S315), and the current timer value read from the elapsed time log is recorded (updated) as the previous execution value (S316).

最後に、埋め込み位置決定部2060は、読み込んだ行が経過時間ログ26の終端であるかを判定する(S317)。
判定の結果、経過時間ログの終端ではない場合(S317:NO)、埋め込み位置決定部2060は、経過時間ログの1行読み込み(S310)を再度実行し、次の1行を読み込む。
一方、判定の結果、経過時間ログの終端であった場合(S317:YES)、埋め込み位置決定部2060は何もせず終了する。
Finally, the embedding position determination unit 2060 determines whether the read line is the end of the elapsed time log 26 (S317).
As a result of the determination, if it is not the end of the elapsed time log (S317: NO), the embedding position determining unit 2060 executes one line reading of the elapsed time log (S310) again and reads the next one line.
On the other hand, as a result of the determination, if it is the end of the elapsed time log (S317: YES), the embedded position determination unit 2060 ends without doing anything.

以上のように、メインプログラムのソースコード21を変換したアセンブリコードの中から分岐先ラベルを探索する分岐先ラベル探索部2020と、埋め込み用時間計測処理コード24をアセンブリコードへ埋め込む処理を行う第1の周期処理埋め込み部205と、事前に出力したメインプログラムの経過時間ログ26を参照して、周期処理コード221を周期時間内に実行するうえで、最低限必要な埋め込み位置を決定し、アセンブリコードへ埋め込む処理を行う第2の周期処理埋め込み部206とを備えることにより、タイマ割り込みを利用せずとも周期処理を実行するバイナリ(周期処理埋め込みバイナリ28)を生成することが可能となる。   As described above, the branch destination label search unit 2020 for searching for the branch destination label from the assembly code obtained by converting the source code 21 of the main program, and the first processing for embedding the embedding time measurement processing code 24 in the assembly code. Referring to the periodic processing embedding unit 205 and the elapsed time log 26 of the main program output in advance, the minimum necessary embedding position is determined to execute the periodic processing code 221 within the periodic time, and the assembly code By including the second periodic process embedding unit 206 that performs the process of embedding in the binary, it is possible to generate a binary (periodic process embedded binary 28) that executes the periodic process without using the timer interrupt.

また、周期処理を埋め込む前に実行用装置30で動作可能な測定用周期処理埋め込みバイナリ25を生成しプログラムの実行時間を計測するため、実施の形態1のように全ての分岐先ラベル通過時に周期処理コード221を実行するべきか判定する必要がなくなる。
さらに、ループ処理のような複数回通過する分岐先ラベルの場合であっても特定の回数通過時にのみ周期処理コード221を実行するため、過度に実行されることもなくなる。
In addition, since the measurement cycle process embedded binary 25 operable by the execution apparatus 30 is generated before the cycle process is embedded and the execution time of the program is measured, the cycle is performed when all branch destination labels pass as in the first embodiment. There is no need to determine whether the processing code 221 should be executed.
Furthermore, even in the case of a branch destination label that passes a plurality of times such as a loop process, the periodic process code 221 is executed only when it passes a specific number of times, so that it is not excessively executed.

実施の形態3.
本実施の形態では、メインプログラムのソースコード21に対し、静的な解析を行うことによって、プログラムのおよその実行時間を算出し、周期時間に間に合うよう周期処理の実行命令を、メインプログラムのソースコード21に埋め込む場合について説明する。
Embodiment 3 FIG.
In the present embodiment, static analysis is performed on the source code 21 of the main program to calculate an approximate execution time of the program, and an execution instruction for periodic processing is issued in time for the periodic time. A case of embedding in the code 21 will be described.

図23は、本実施の形態におけるシステム構成図の一例である。実施の形態1と同様に、本実施の形態におけるシステムでは、開発用装置10、プログラム埋め込み装置20、実行用装置30で構成される。
また、実施の形態1と同様に、本実施の形態におけるシステムでは、開発用装置10からプログラム埋め込み装置20に対し、メインプログラムのソースコード21および埋め込み用周期処理コード22が渡され、プログラム埋め込み装置20から実行用装置30に対し、周期処理埋め込みバイナリ40が渡される。
FIG. 23 is an example of a system configuration diagram in the present embodiment. Similar to the first embodiment, the system according to the present embodiment includes a development device 10, a program embedding device 20, and an execution device 30.
Similarly to the first embodiment, in the system according to the present embodiment, the development program 10 passes the source code 21 of the main program and the periodic processing code 22 for embedding to the program embedding device 20, and the program embedding device. The periodic processing embedded binary 40 is transferred from the execution device 20 to the execution device 30.

本実施の形態では、実施の形態1と違い、プログラム埋め込み装置20が命令実行クロック数一覧29の参照を行っている。
なお、本実施の形態では、プログラム埋め込み装置20が直接命令実行クロック数一覧29を参照するような構成としたが、開発用装置10が命令実行クロック数一覧29を管理し、開発用装置10からプログラム埋め込み装置20へ渡すようにしてもよい。
In the present embodiment, unlike the first embodiment, the program embedding device 20 refers to the instruction execution clock number list 29.
In this embodiment, the program embedding apparatus 20 directly refers to the instruction execution clock number list 29. However, the development apparatus 10 manages the instruction execution clock number list 29, and the development apparatus 10 may be transferred to the program embedding device 20.

図24は、本実施の形態におけるプログラム埋め込み装置20上で動作するソフトウェアの全体構成図である。これらのソフトウェアは、プログラム埋め込み装置20のROM2またはRAM3上に記憶され、CPU1により実行される。   FIG. 24 is an overall configuration diagram of software operating on the program embedding device 20 according to the present embodiment. These software are stored on the ROM 2 or the RAM 3 of the program embedding device 20 and executed by the CPU 1.

図24において、命令実行クロック数一覧29は、命令の実行に必要なクロック数が記述されたものである。図25に命令実行クロック数一覧29の一例を示す。
本実施の形態における周期処理埋め込み部207は、命令実行時間算出部(分岐先探索部)2070と、プログラム埋め込み部2021を備えている。
In FIG. 24, the instruction execution clock number list 29 describes the number of clocks necessary for execution of instructions. FIG. 25 shows an example of the instruction execution clock number list 29.
The periodic processing embedding unit 207 according to the present embodiment includes an instruction execution time calculating unit (branch destination searching unit) 2070 and a program embedding unit 2021.

命令実行時間算出部2070は、アセンブリコード変換部201から渡されたアセンブリコードの中から命令を抽出し、命令実行クロック数一覧29を参照し、命令実行時間の算出を行う。
プログラム埋め込み部2021は、埋め込み用周期処理コードをアセンブリコードへ埋め込む処理を行う。
The instruction execution time calculation unit 2070 extracts an instruction from the assembly code passed from the assembly code conversion unit 201, refers to the instruction execution clock number list 29, and calculates the instruction execution time.
The program embedding unit 2021 performs a process of embedding the periodic processing code for embedding in the assembly code.

なお、図24において、図3と同一の符号は、同一または相当する部分を表しており、命令実行時間算出部2070および命令実行クロック数一覧29以外については、実施の形態1で用いた図3で記載したものと同じ動作をする。   In FIG. 24, the same reference numerals as those in FIG. 3 represent the same or corresponding parts, and those other than the instruction execution time calculation unit 2070 and the instruction execution clock number list 29 are the same as those used in the first embodiment. The same operation as described in 3 is performed.

次に図26を用いて、本実施の形態におけるプログラム埋め込み装置20の動作について説明する。   Next, the operation of the program embedding device 20 in the present embodiment will be described with reference to FIG.

まず、アセンブリコード変換部201が、開発用装置10から受け取ったメインプログラムのソースコード21をアセンブリコードに変換する(S101)。
アセンブリコード変換部201は、変換したアセンブリコードを周期処理埋め込み部207に渡す。
First, the assembly code conversion unit 201 converts the source code 21 of the main program received from the development device 10 into assembly code (S101).
The assembly code conversion unit 201 passes the converted assembly code to the periodic processing embedding unit 207.

アセンブリコード変換部201からアセンブリコードを受け取った命令実行時間算出部2070は、経過時間の初期化を行う(S501)。
次に命令実行時間算出部2070は、アセンブリコードの先頭から1行ずつ読み込み(S102)、ループ命令または関数呼び出し命令が記述されているかを判定する(S502)。
The instruction execution time calculation unit 2070 that has received the assembly code from the assembly code conversion unit 201 initializes the elapsed time (S501).
Next, the instruction execution time calculation unit 2070 reads line by line from the beginning of the assembly code (S102), and determines whether a loop instruction or a function call instruction is described (S502).

ループ命令または関数呼び出し命令ではなかった場合(S502:NO)、命令実行時間算出部2070は、命令実行クロック数一覧29を参照し、その命令を実行するのに必要なクロック数を獲得し、実行用装置30で用いられているCPU1のクロック周波数の逆数と掛け合わせることによって実行時間を算出する(S503)。
例えば、実行用装置30で用いられているCPU1のクロック周波数が1GHzであり、読み込んだ命令が「add(命令クロック数は4)」であった場合、実行時間は4ナノ秒となる。
When the instruction is not a loop instruction or a function call instruction (S502: NO), the instruction execution time calculation unit 2070 refers to the instruction execution clock number list 29, acquires the number of clocks necessary to execute the instruction, The execution time is calculated by multiplying the reciprocal of the clock frequency of the CPU 1 used in the execution apparatus 30 (S503).
For example, when the clock frequency of the CPU 1 used in the execution apparatus 30 is 1 GHz and the read instruction is “add (the number of instruction clocks is 4)”, the execution time is 4 nanoseconds.

命令実行時間算出部2070は、算出した実行時間を経過時間に加算し(S504)、周期時間の8割以上であるかを判定する(S505)。なお、実施の形態1の場合と同様、本実施の形態では、周期処理を周期時間内に確実に実行することを目的としているため、周期処理の実行条件を周期時間の8割経過時と定義としたが、周期時間を越えなければ特に8割以外であってもよい。   The instruction execution time calculation unit 2070 adds the calculated execution time to the elapsed time (S504), and determines whether it is 80% or more of the cycle time (S505). As in the case of the first embodiment, since the purpose of this embodiment is to execute the periodic processing within the periodic time, the execution condition of the periodic processing is defined as when 80% of the periodic time has elapsed. However, it may be other than 80% as long as the cycle time is not exceeded.

経過時間が周期時間の8割以上であった場合(S505:YES)命令実行時間算出部2070は、プログラム埋め込み部2021を呼び出す。
プログラム埋め込み部2021は、周期処理コード221を呼び出す命令を埋め込む(S506)。
その後、命令実行時間算出部2070は、経過時間を初期化する(S507)。
次に命令実行時間算出部2070は、現在読み込んだ1行が、アセンブリコードの終端であるかを確認する(S105)。
When the elapsed time is 80% or more of the cycle time (S505: YES), the instruction execution time calculation unit 2070 calls the program embedding unit 2021.
The program embedding unit 2021 embeds an instruction for calling the periodic process code 221 (S506).
Thereafter, the instruction execution time calculation unit 2070 initializes the elapsed time (S507).
Next, the instruction execution time calculation unit 2070 confirms whether the currently read line is the end of the assembly code (S105).

一方、経過時間が周期時間の8割以上では無かった場合(S505:NO)命令実行時間算出部2070は、現在読み込んだ1行が、アセンブリコードの終端であるかを確認する(S105)。
アセンブリコードの終端であった場合(S105:YES)、命令実行算出部2070は、オブジェクトコード変換部203を呼び出す。
On the other hand, when the elapsed time is not 80% or more of the cycle time (S505: NO), the instruction execution time calculation unit 2070 confirms whether the currently read one line is the end of the assembly code (S105).
If it is the end of the assembly code (S105: YES), the instruction execution calculation unit 2070 calls the object code conversion unit 203.

次にオブジェクトコード変換部203は、周期処理埋め込み部207が出力した埋め込み完了後アセンブリコードを、バイナリ形式であるオブジェクトコードに変換する(S107)。なお、本実施の形態では、周期処理コード221を埋め込み完了後アセンブリコードの一部となるよう埋め込みを行ったが、埋め込み完了後アセンブリコードとは別のファイルとし、埋め込み完了後アセンブリコードとは別にオブジェクトコードに変換しても良い。   Next, the object code conversion unit 203 converts the post-embedding assembly code output by the periodic processing embedding unit 207 into an object code in a binary format (S107). In this embodiment, the periodic processing code 221 is embedded so as to become a part of the assembly code after completion of embedding. However, the file is different from the assembly code after embedding and is separate from the assembly code after embedding. It may be converted into an object code.

ループ命令または関数呼び出し命令であった場合(S502:YES)、命令実行時間算出部2070は、プログラム埋め込み部2021を呼び出す。
プログラム埋め込み部2021は、命令の実行直前と命令の実行直後に周期処理コード221を読みだす命令を埋め込む。その後、命令実行時間算出部2070は、経過時間を初期化する(S506)。
If the instruction is a loop instruction or a function call instruction (S502: YES), the instruction execution time calculation unit 2070 calls the program embedding unit 2021.
The program embedding unit 2021 embeds an instruction for reading the periodic processing code 221 immediately before the execution of the instruction and immediately after the execution of the instruction. Thereafter, the instruction execution time calculation unit 2070 initializes the elapsed time (S506).

なお、ループ命令によって繰り返し実行される回数および、呼び出される関数の内部処理はプログラムが実行される条件によって変化するため、実行時間の算出が困難である。
このため、本実施の形態では、ループ命令によって繰り返し実行される周期時間内にループ命令または関数呼び出し命令による処理が終了することを前提とする。
Note that the number of times the loop instruction is repeatedly executed and the internal processing of the function to be called vary depending on the conditions under which the program is executed, so that it is difficult to calculate the execution time.
For this reason, in this embodiment, it is assumed that the processing by the loop instruction or the function call instruction is completed within the cycle time repeatedly executed by the loop instruction.

以上のように、アセンブリの命令種別に基づいて実行時間を算出し、周期処理を埋め込む位置を決定する命令実行時間算出部2070を備えることにより、経過時間計測処理コードを使用せずに周期処理埋め込みバイナリ40を生成することが可能となる。
これにより、実行用装置30にタイマ5が存在しないもしくは使用が制限されており利用できない場合においても、周期時間内に周期処理を実行することが可能となる。
As described above, the execution time is calculated based on the instruction type of the assembly and the instruction execution time calculation unit 2070 that determines the position where the periodic process is embedded is provided, so that the periodic process embedding can be performed without using the elapsed time measurement processing code. The binary 40 can be generated.
As a result, even when the timer 5 does not exist in the execution apparatus 30 or its use is restricted and cannot be used, the periodic process can be executed within the period time.

1 CPU、2 ROM、3 RAM、4 通信モジュール、5 タイマ、10 開発用装置、20 プログラム埋め込み装置、21 メインプログラムのソースコード、22 埋め込み用周期処理コード、23 周期処理埋め込みバイナリ、24 埋め込み用時間計測処理コード、25 測定用周期処理埋め込みバイナリ、26 経過時間ログ、27 埋め込み用周期処理コード、28 周期処理埋め込みバイナリ、30 実行用装置、40 周期処理埋め込みバイナリ、201 アセンブリコード変換部、202 周期処理埋め込み部、203 オブジェクトコード変換部、204 バイナリ変換部、205 第1の周期処理埋め込み部、206 第2の周期処理埋め込み部、207 周期処理埋め込み部、220 経過時間計測処理コード、221 周期処理コード、270 通過回数計測コード、2020 分岐先ラベル探索部、2021 プログラム埋め込み部、2050 プログラム埋め込み部、2060 埋め込み位置決定部、2070 命令実行時間算出部。   1 CPU, 2 ROM, 3 RAM, 4 communication module, 5 timer, 10 development device, 20 program embedding device, 21 source program source code, 22 periodic processing code for embedding, 23 periodic processing embedding binary, 24 embedding time Measurement processing code, 25 measurement periodic processing embedded binary, 26 elapsed time log, 27 embedded periodic processing code, 28 periodic processing embedded binary, 30 execution device, 40 periodic processing embedded binary, 201 assembly code conversion unit, 202 periodic processing Embedding unit, 203 Object code conversion unit, 204 Binary conversion unit, 205 First periodic processing embedding unit, 206 Second periodic processing embedding unit, 207 Periodic processing embedding unit, 220 Elapsed time measurement processing code, 221 cycles Processing code, 270 passage count measurement code, 2020 branch destination label search unit, 2021 program embedding unit, 2050 program embedding unit, 2060 embedding position determination unit, 2070 instruction execution time calculation unit.

Claims (4)

アセンブリコードに変換したプログラムソースの中から、一定間隔で繰り返し実行する周期処理を埋め込むための分岐先を探索する分岐先探索部と、
前記分岐先に対し、前記周期処理と前記周期処理の実行を前記周期処理が前回実行されてからの経過時間で判定する判定処理を埋め込む第1のプログラム埋め込み部と、
を備えることを特徴とするプログラム埋め込み装置。
A branch destination search unit for searching for a branch destination for embedding a periodic process to be repeatedly executed at regular intervals from the program source converted into assembly code;
A first program embedding unit that embeds a determination process for determining the execution of the periodic process and the periodic process based on an elapsed time from the previous execution of the periodic process for the branch destination;
A program embedding device comprising:
前記分岐先探索部は、前記アセンブリコードに記述された命令のうち、特定の命令を分岐先として探索することを特徴とする請求項1に記載のプログラム埋め込み装置。   2. The program embedding apparatus according to claim 1, wherein the branch destination search unit searches for a specific instruction among the instructions described in the assembly code as a branch destination. 前記分岐先探索部、前記分岐先探索部が探索した分岐先に対し、時刻を測定し経過時間をログに出力する処理を埋め込む第2のプログラム埋め込み部、を有する第1の周期処理埋め込み部と、
前記分岐先に対し、前記周期処理の実行を前記第1の周期処理埋め込み部が出力したプログラムを実行した結果得られる経過時間ログを参照し、前記周期処理を埋め込む位置を決定する位置決定部、前記位置決定部が決定した前記分岐先に、前記周期処理を埋め込む前記第1のプログラム埋め込み部、を有する第2の周期処理埋め込み部と、
を備えることを特徴とする請求項1または2に記載のプログラム埋め込み装置。
A first periodic processing embedding unit including a branch program searching unit, a second program embedding unit that embeds a process of measuring time and outputting an elapsed time to a log for the branch destination searched by the branch destination searching unit; ,
A position determination unit that refers to an elapsed time log obtained as a result of executing the program output by the first periodic processing embedding unit with respect to the branch destination, and determines a position where the periodic processing is embedded, A second periodic processing embedding unit having the first program embedding unit for embedding the periodic processing at the branch destination determined by the position determination unit;
The program embedding device according to claim 1, further comprising:
前記分岐先探索部は、前記アセンブリコードに記述された命令を判別し、前記命令のクロック数から前記命令の実行時間を算出し、前記判定処理は前記実行時間から前記周期処理の実行を判定することを特徴とする請求項1に記載のプログラム埋め込み装置。   The branch destination search unit determines an instruction described in the assembly code, calculates an execution time of the instruction from the number of clocks of the instruction, and the determination process determines execution of the periodic process from the execution time The program embedding apparatus according to claim 1.
JP2014182980A 2014-09-09 2014-09-09 Program embedding device Expired - Fee Related JP6287709B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2014182980A JP6287709B2 (en) 2014-09-09 2014-09-09 Program embedding device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2014182980A JP6287709B2 (en) 2014-09-09 2014-09-09 Program embedding device

Publications (2)

Publication Number Publication Date
JP2016057798A true JP2016057798A (en) 2016-04-21
JP6287709B2 JP6287709B2 (en) 2018-03-07

Family

ID=55758582

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2014182980A Expired - Fee Related JP6287709B2 (en) 2014-09-09 2014-09-09 Program embedding device

Country Status (1)

Country Link
JP (1) JP6287709B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20210062438A (en) * 2019-11-21 2021-05-31 국방과학연구소 Computer apparatus and binary program execution speed measure method of computer apparatus

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05120026A (en) * 1991-10-24 1993-05-18 Nec Corp Language processing program generation device
JP2009238051A (en) * 2008-03-28 2009-10-15 Hitachi Ltd Program conversion device and program conversion method
JP2010134494A (en) * 2008-12-02 2010-06-17 Hitachi Ltd Program conversion device, conversion method, program control method and program

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05120026A (en) * 1991-10-24 1993-05-18 Nec Corp Language processing program generation device
JP2009238051A (en) * 2008-03-28 2009-10-15 Hitachi Ltd Program conversion device and program conversion method
JP2010134494A (en) * 2008-12-02 2010-06-17 Hitachi Ltd Program conversion device, conversion method, program control method and program

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20210062438A (en) * 2019-11-21 2021-05-31 국방과학연구소 Computer apparatus and binary program execution speed measure method of computer apparatus
KR102319403B1 (en) 2019-11-21 2021-10-29 국방과학연구소 Computer apparatus and binary program execution speed measure method of computer apparatus

Also Published As

Publication number Publication date
JP6287709B2 (en) 2018-03-07

Similar Documents

Publication Publication Date Title
CN101957773B (en) method and system for multiple purpose dynamic analysis
CN109783161B (en) Method and device for determining running information of application program in iOS system
US9355003B2 (en) Capturing trace information using annotated trace output
US8578355B1 (en) Scenario based optimization
EP2673703A1 (en) Controlling the execution of adjacent instructions that are dependent upon a same data condition
US10466988B2 (en) Systems and methods for automatic computer code parallelization
KR20110070468A (en) Apparatus for executing instrumentation and method thereof
US10089088B2 (en) Computer that performs compiling, compiler program, and link program
JP6287709B2 (en) Program embedding device
US8904412B2 (en) Dynamic performance data collection in large computer servers
CN103838662A (en) Dynamic library profiling method and dynamic library profiling system
CN112740187A (en) Method and system for debugging program
CN107769987B (en) Message forwarding performance evaluation method and device
US8677335B1 (en) Performing on-stack replacement for outermost loops
JP2008250838A (en) Software generation device, method and program
US20180276106A1 (en) Trace data representation
US7774763B1 (en) Techniques for forming a multi-tasking executable program and using the same
JP2010140233A (en) Emulation system and emulation method
KR20140089044A (en) Method of detecting software similarity using feature information of executable files and apparatus therefor
CN110516445A (en) Recognition methods, device and the storage medium of reverse-examination survey malicious code
US11144238B1 (en) Background processing during remote memory access
JP2007323299A (en) Apparatus and program for determining review execution order, recording medium with the program stored, and method for determining review execution order
US8839207B2 (en) Debugging extensible markup language
JP2014002443A (en) Use amount calculation device, computer program and use amount calculation method
EP3547141B1 (en) Information processing apparatus, information processing method, and information processing program

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20161227

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20171005

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20171010

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20171117

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: 20180109

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20180122

R151 Written notification of patent or utility model registration

Ref document number: 6287709

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151

LAPS Cancellation because of no payment of annual fees