JP5465745B2 - Program processing method and system - Google Patents

Program processing method and system Download PDF

Info

Publication number
JP5465745B2
JP5465745B2 JP2012068033A JP2012068033A JP5465745B2 JP 5465745 B2 JP5465745 B2 JP 5465745B2 JP 2012068033 A JP2012068033 A JP 2012068033A JP 2012068033 A JP2012068033 A JP 2012068033A JP 5465745 B2 JP5465745 B2 JP 5465745B2
Authority
JP
Japan
Prior art keywords
task
program
function
timer
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2012068033A
Other languages
Japanese (ja)
Other versions
JP2013200666A (en
Inventor
顕次郎 山中
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NTT Data Group Corp
Original Assignee
NTT Data 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 NTT Data Corp filed Critical NTT Data Corp
Priority to JP2012068033A priority Critical patent/JP5465745B2/en
Publication of JP2013200666A publication Critical patent/JP2013200666A/en
Application granted granted Critical
Publication of JP5465745B2 publication Critical patent/JP5465745B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、プログラム処理方法およびそのシステムに関し、より詳細には、周期的なタイマーによりプログラムを処理する方法、およびそのシステムに関する。   The present invention relates to a program processing method and system, and more particularly, to a method and system for processing a program by a periodic timer.

クラウドコンピューティングは次世代のコンピューティング環境として期待を集めている。クラウドサービスを利用すると、システムの実行環境(サーバ、ストレージ、ネットワークなど)の調達・増強・縮退が短時間で可能であり、使った時間だけ利用料を払えばよい。従来、ソフトウェアシステムは、運用時にはごく稀にしか起きないピーク性能を基準に実行環境をサイジングし、その固定的な実行環境を前提に構築されてきた。その結果、低い平均負荷、高い運用コストを招いていた。クラウドでは、必要に応じて実行環境のサイズを変えられるので、運用コストの削減が期待できる。   Cloud computing is expected as a next-generation computing environment. By using cloud services, it is possible to procure, augment, and degenerate system execution environments (servers, storage, networks, etc.) in a short time, and you only have to pay the usage fee for the time you use them. Conventionally, software systems have been built on the premise of a fixed execution environment that is sized based on peak performance that occurs only rarely during operation. As a result, low average load and high operation cost were incurred. In the cloud, the size of the execution environment can be changed as needed, so reduction in operating costs can be expected.

また、従来、ソフトウェアシステムの開発段階において、マシンリソースの不足が開発スケジュール遅延の原因となることが多かった。例えば、試験工程では、マシンリソースの不足により、多くの期間を費やすこととなる。開発段階においてクラウドコンピューティングを利用することで、マシンリソースに制約されない開発が可能になり、開発期間の短縮、開発費の削減が期待できる。このようにクラウドコンピューティングは、従来のソフトウェアシステムの諸問題を解決できる可能性を秘めている。   Conventionally, in the development stage of a software system, lack of machine resources often causes development schedule delay. For example, in the test process, a lot of time is spent due to lack of machine resources. By using cloud computing at the development stage, development that is not restricted by machine resources becomes possible, and shortening of the development period and reduction of development costs can be expected. In this way, cloud computing has the potential to solve problems of conventional software systems.

クラウドコンピューティングには課題もある。一般に、ソフトウェアシステムは、機能要求に加えて、性能要求も満たす必要がある。従来、固定された実行環境において性能試験を行うことにより、一定の性能を保証してきた。従来型システムでは、実際に運用される実行環境が固定されるので、同実行環境における試験結果が、運用時に成り立つと類推可能だからである。一方、クラウドサービスでは、ベストエフォートで実行環境を提供する。   Cloud computing also has challenges. In general, a software system needs to satisfy performance requirements in addition to function requirements. Conventionally, a constant performance has been guaranteed by performing a performance test in a fixed execution environment. This is because in the conventional system, the execution environment actually operated is fixed, so that it can be inferred that the test result in the execution environment holds at the time of operation. On the other hand, the cloud service provides an execution environment at best effort.

ベストエフォート型では、例えば、CPUのクロック数に関して、あるユーザーがCPU負荷の高いプログラムを実行すると、同一環境を利用する別のユーザーの性能は劣化する。また、ストレージに関して、あるユーザーがストレージに過剰な負荷をかける大量のトランザクションを処理すると、同様に、同一環境を利用する別のユーザーのI/O性能は劣化する。ネットワークに関しても同様である。これでは、実行環境を特定することができず、従って、性能試験の結果が運用時にも成り立つとの類推はできない。   In the best effort type, for example, when a user executes a program with a high CPU load with respect to the number of clocks of the CPU, the performance of another user who uses the same environment deteriorates. Further, regarding a storage, when a certain user processes a large number of transactions that place an excessive load on the storage, similarly, the I / O performance of another user who uses the same environment deteriorates. The same applies to the network. In this case, the execution environment cannot be specified, and therefore it cannot be inferred that the result of the performance test is valid even during operation.

非特許文献1では、クラウドを用いたMapReduce environmentの貸出サービスにおいて、クラウドサービスの性能保証に関する問題点を指摘しているが、解決への道筋は示されていない。   Non-Patent Document 1 points out problems related to the performance guarantee of cloud services in a MapReduce environment lending service using the cloud, but does not show a route to solution.

L. Cherkasova. Performance modeling in mapreduce environments: challenges and opportunities. In Proceeding of the second joint WOSP/SIPEW international conference on Performance engineering, ICPE ’11, pages 5-6, New York, NY, USA, 2011. ACM.L. Cherkasova. Performance modeling in mapreduce environments: challenges and opportunities. In Proceeding of the second joint WOSP / SIPEW international conference on Performance engineering, ICPE '11, pages 5-6, New York, NY, USA, 2011. ACM.

上述したように、クラウドコンピューティングでは、試験による性能保証が困難である。すなわち、所定の性能を実現するために必要な実行環境のサイジングも困難である。   As described above, in cloud computing, it is difficult to guarantee performance by testing. That is, it is difficult to size the execution environment necessary for realizing the predetermined performance.

本発明は、このような問題に鑑みてなされたもので、その目的とするところは、実行環境を固定できないクラウドコンピューティングにおいて、システムとしての性能(スループット)を保証する手段を提供することにある。   The present invention has been made in view of such problems, and an object of the present invention is to provide a means for guaranteeing system performance (throughput) in cloud computing in which the execution environment cannot be fixed. .

本発明では、実行環境と独立してソフトウェアの性能を決定し得るプログラムを構成し、処理するために、デジタル回路の論理設計におけるクロック駆動の概念を参考とする。   In the present invention, in order to construct and process a program capable of determining the performance of software independently of the execution environment, the concept of clock driving in the logic design of the digital circuit is referred to.

周知のように、デジタル論理設計は、組み合わせ論理回路(Combinational logic)および順序論理回路(Sequential logic)の二つに分類される。前者は入力のみで出力が決まり、後者は、入力および現状態で出力(および次状態)が決まる。順序論理回路は、イベント駆動およびクロック駆動の二つに分類される。前者は、状態の変化が入力(Event)のタイミングで起きるのに対し、後者では、入力のタイミングにかかわらず、クロックと同期して状態の変化が起きる。イベント駆動とクロック駆動の比較を表1に示す。   As is well known, digital logic design is classified into two types: combinatorial logic and sequential logic. In the former, the output is determined only by the input, and in the latter, the output (and the next state) is determined by the input and the current state. Sequential logic circuits are classified into two types, event driven and clock driven. In the former, the state change occurs at the timing of the input (Event), while in the latter case, the state change occurs in synchronization with the clock regardless of the input timing. Table 1 shows a comparison between event driving and clock driving.

Figure 0005465745
Figure 0005465745

今日、デジタル回路は大規模集積回路(LSI)で作られることが通常である。LSIの各素子(トランジスターなど)は微細加工により作られるので、その特性にはバラつきがある。そのため、イベント駆動設計では、特性のバラつきを考慮して、十分なタイミングマージンをとった設計が要求される。バラつきがマージンより大きいと、回路は正常に動作しない。クロック駆動設計においても、周期以内に回路動作が終了せず、タイミングバイオレーションが起こると、回路は正常に動作しない。ただし、クロック駆動設計では、クロック周波数を下げて、マージンを大きくすることにより、タイミングバイオレーションの発生確率を下げることができる。   Today, digital circuits are usually made of large scale integrated circuits (LSIs). Since each element (such as a transistor) of LSI is manufactured by microfabrication, its characteristics vary. Therefore, event-driven design requires a design with a sufficient timing margin in consideration of characteristic variations. If the variation is larger than the margin, the circuit will not operate normally. Even in the clock drive design, if the circuit operation is not completed within a period and timing violation occurs, the circuit does not operate normally. However, in clock drive design, the probability of occurrence of timing violation can be lowered by lowering the clock frequency and increasing the margin.

さらに、イベント駆動設計では、素子特性のバラつきがそのまま、回路の性能差となって現れる。一方、クロック駆動設計では、クロック周波数が同一であれば、性能は同一になる。すなわち、クロック駆動設計では、イベント駆動設計と比較して、一定の性能保証を容易に行うことができる。   Furthermore, in event-driven design, variations in device characteristics appear as circuit performance differences as they are. On the other hand, in the clock drive design, the performance is the same if the clock frequency is the same. That is, in the clock drive design, a certain performance guarantee can be easily performed as compared with the event drive design.

そこで、本発明では、周期的にプログラムを駆動する、Timer interrupt、Timer Signal(POSIX/UNIX(登録商標)/Linux(登録商標))、Timer Event (Windows(登録商標))、などを利用することにより、プログラムをクロック駆動する。   Therefore, in the present invention, a timer interrupt, a timer signal (POSIX / UNIX (registered trademark) / Linux (registered trademark)), a timer event (Windows (registered trademark)), or the like that periodically drives a program is used. Thus, the program is clocked.

本発明のプログラムがタイマーにより駆動されると、定められた一定の処理を実行し、それが終了すると、次にタイマーによりプログラムが駆動されるまで休む。高速マシンを使うと、実行時間は減少するが、その分休止時間が増える。低速マシンを使うと、実行時間が増加し、その分休止時間が減少する。すなわち、高速マシンおよび低速マシンのいずれを用いても、時間当たりの実行ステップ数は同じになる。従って、性能(スループット)はハードウェアには依存せずに同一になる。   When the program of the present invention is driven by the timer, a predetermined process is executed, and when it is finished, the program is rested until the program is driven by the timer. Using a high-speed machine reduces the execution time, but increases the pause time accordingly. If you use a slow machine, the execution time increases and the pause time decreases accordingly. That is, the number of execution steps per hour is the same regardless of whether a high-speed machine or a low-speed machine is used. Therefore, the performance (throughput) is the same regardless of hardware.

以下に示すように、実行時間τと周期Tの比をデューティ率Dと呼ぶ。   As shown below, the ratio between the execution time τ and the period T is referred to as a duty ratio D.

Figure 0005465745
Figure 0005465745

デューティ率が100%未満、すなわち実行時間が周期を下回る場合、プログラムの性能は、マシンの性能ではなく、周期Tにより決まる。これにより、ハードウェアに依存しない性能設計が可能になる。   When the duty factor is less than 100%, that is, when the execution time is less than the period, the performance of the program is determined by the period T, not the performance of the machine. As a result, hardware-independent performance design is possible.

本発明は、タイマーにより、定められた一定の処理を実行し、それが終了すると、次にタイマーにより駆動されるまで休むよう動作するプログラムを処理することにより、実行環境を固定できないクラウドコンピューティングにおいて、システムとしての性能を保証することができる。   In the cloud computing in which the execution environment cannot be fixed by executing a program that operates to perform a certain fixed process by a timer, and when it finishes, the program operates to rest until it is driven by the timer next time. The system performance can be guaranteed.

また、本発明は、所定の条件を満たすプログラムを構成することにより性能保証を実現することができるので、クラウドサービスの提供者は、性能保証のために余分な設備を保持する必要はない。さらに、ソフトウェアの開発段階において本発明の特徴を有するプログラムを構成するだけで、求められる性能保証の変更にも、迅速に、的確に対応することができる。   Further, according to the present invention, performance guarantee can be realized by configuring a program that satisfies a predetermined condition, so that the provider of the cloud service does not need to maintain extra equipment for performance guarantee. Furthermore, it is possible to quickly and accurately respond to required changes in performance guarantees simply by configuring a program having the characteristics of the present invention at the software development stage.

本発明の一実施形態に係るネットワーク構成を示す図である。It is a figure which shows the network structure which concerns on one Embodiment of this invention. 本発明の一実施形態に係るタスクのプログラム記述例を示す図である。It is a figure which shows the example of a program description of the task which concerns on one Embodiment of this invention. 本発明の一実施形態に係る別のタスクを利用するタスクのプログラム記述例を示す図である。It is a figure which shows the example of a program description of the task which utilizes another task which concerns on one Embodiment of this invention. 本発明の一実施形態に係るタスク配列のプログラム記述例を示す図である。It is a figure which shows the example of a program description of the task arrangement | sequence which concerns on one Embodiment of this invention. 本発明の一実施形態に係るタスクのコールグラフを示す図である。It is a figure which shows the call graph of the task which concerns on one Embodiment of this invention. 本発明の一実施形態に係るタスクのPERT図である。It is a PERT figure of the task concerning one embodiment of the present invention. 本発明の一実施形態に係るタスクのコールグラフを示す図である。It is a figure which shows the call graph of the task which concerns on one Embodiment of this invention. ポーリングを用いたタスクのプログラム記述例を示す。An example of program description of a task using polling is shown. ポーリングを用いたタスクのプログラム記述例を示す。An example of program description of a task using polling is shown. 本発明の一実施形態に係るタスクのPERT図である。It is a PERT figure of the task concerning one embodiment of the present invention. 本発明の一実施形態に係るタスク間の先行関係を示す先行関係表である。It is a precedence relation table which shows precedence relation between tasks concerning one embodiment of the present invention. 変数リネーム技法を適用する前のプログラム記述例を示す図である。It is a figure which shows the example of a program description before applying a variable rename technique. 変数リネーム技法を適用する後のプログラム記述例を示す図である。It is a figure which shows the example of a program description after applying a variable rename technique. 個別化技法を適用する前後のコールグラフを示す図である。It is a figure which shows the call graph before and behind applying an individualization technique. 抽選化技法を適用したタスクのプログラム記述例を示す図である。It is a figure which shows the example of a program description of the task to which the lottery technique is applied. 抽選化技法を適用したタスクのプログラム記述例を示す図である。It is a figure which shows the example of a program description of the task to which the lottery technique is applied. 本発明の一実施形態に係るタスクのPERT図である。It is a PERT figure of the task concerning one embodiment of the present invention. 本発明の一実施形態に係るタスクを実行するプログラム記述例を示す図である。It is a figure which shows the example of a program description which performs the task which concerns on one Embodiment of this invention. 本発明の一実施形態に係るタスクを実行するプログラム記述例を示す図である。It is a figure which shows the example of a program description which performs the task which concerns on one Embodiment of this invention. 本発明の一実施形態に係るタスクを並列実行するシーケンス図である。It is a sequence diagram which performs the task which concerns on one Embodiment of this invention in parallel. 本発明の一実施形態に係る周期的なタイマーによりプログラムを処理する工程を示すフローチャートである。It is a flowchart which shows the process of processing a program with the periodic timer which concerns on one Embodiment of this invention. 本発明の一実施形態に係るタスクを実行するプログラム記述例を示す図である。It is a figure which shows the example of a program description which performs the task which concerns on one Embodiment of this invention.

(システム構成)
図1は、本発明の一実施形態に係るネットワーク構成を示す図である。複数のプログラム処理システム101a、101b、・・・、101n(以下、プログラム処理システム101と呼ぶ)が、インターネット102を介して、複数のクライアントコンピュータ103a、103b、・・・、103n(以下、クライアントコンピュータ103と呼ぶ)と相互に通信可能に接続される。
(System configuration)
FIG. 1 is a diagram showing a network configuration according to an embodiment of the present invention. A plurality of program processing systems 101a, 101b,..., 101n (hereinafter referred to as program processing system 101) are connected to a plurality of client computers 103a, 103b,. 103) and are communicably connected to each other.

プログラム処理システム101は、利用者に提供するサービスを実現するためのプログラムを格納するメモリを有し、利用者の要求に応答して、ストレージに格納されたプログラムを処理するために必要なデータを用いて、サービスを提供する。本発明のプログラム処理システム101により実行されるプログラムは、所定の条件を満たすよう構成されたクロック駆動プログラミング(CDP)プログラムである。   The program processing system 101 has a memory for storing a program for realizing a service provided to the user, and in response to a user request, the program processing system 101 stores data necessary for processing the program stored in the storage. Use to provide services. The program executed by the program processing system 101 of the present invention is a clock driven programming (CDP) program configured to satisfy a predetermined condition.

クライアントコンピュータ103は、クラウドサービスの利用者によって使用される端末である。利用者は、クライアントコンピュータ103を介して、プログラム処理システム101が提供するサービスを、サーバ群を意識することなしに利用する。本実施形態では、クライアントコンピュータ103は、一般的なパーソナルコンピュータである。   The client computer 103 is a terminal used by a cloud service user. The user uses the service provided by the program processing system 101 via the client computer 103 without being aware of the server group. In this embodiment, the client computer 103 is a general personal computer.

(CDPプログラム)
CDPは、イベント駆動プログラミング(EDP)の一部である。従って、CDPは、EDPをサポートする任意のプログラミング言語、およびOSで実践できる。本実施形態では、C言語、およびWindowsを用いるが、これに限定されるものではない。
(CDP program)
CDP is part of Event Driven Programming (EDP). Thus, CDP can be practiced with any programming language and OS that supports EDP. In this embodiment, C language and Windows are used, but the present invention is not limited to this.

CDPとEDPとの違いは、イベントハンドラーの使い方にある。EDPでは、任意の数のタイマーを利用することができるのに対し、CDPでは、タイマーイベントハンドラーを提供するタイマーを、必ず1つ利用することが要求される。   The difference between CDP and EDP is in the use of event handlers. In EDP, an arbitrary number of timers can be used, whereas in CDP, it is required to always use one timer that provides a timer event handler.

また、EDPでは、タイマーイベントハンドラーを含むすべてのイベントハンドラーにおいて、イベントに対応する処理を行う。一方、CDPでは、タイマーイベントハンドラー以外のイベントハンドラーにおいて、状態を示すフラグをセットすることにより、イベントの発生を記録するのみで、イベントに対応する処理は、ここでは行わない。CDPでは、タイマーイベントハンドラーにおいて、状態を示すフラグに基づいて、イベントの発生に対応するタスクを実行する。   In EDP, processing corresponding to an event is performed in all event handlers including a timer event handler. On the other hand, in CDP, in the event handlers other than the timer event handler, by setting a flag indicating the state, only the occurrence of the event is recorded, and the processing corresponding to the event is not performed here. In CDP, a timer event handler executes a task corresponding to the occurrence of an event based on a flag indicating a state.

CDPプログラムは、以下の手順で作成される。1)タスクを洗い出し、記述する。2)タスク間の先行関係を把握し、PERT図を作成する。3)PERT図によって与えられた先行関係の制約を満たすスケジュールを作成する。タスクの記述、PERT図の作成、スケジュールの作成を順に説明する。   The CDP program is created by the following procedure. 1) Identify and describe the task. 2) Understand the prior relationship between tasks and create a PERT diagram. 3) Create a schedule that satisfies the precedence relationship given by the PERT diagram. Task description, PERT diagram creation, and schedule creation will be described in this order.

(タスクの記述)
本発明のCDPのタスクを、図2のプログラム記述例に基づいて説明する。本発明では、CDPのタスクを以下の要素を用いて定義する。
内部変数:ステート間で値を引継ぐために使用する1以上の変数
インタフェース関数:内部変数を他のタスクが参照または更新するための0以上の関数
リセット関数:内部変数を初期化するための関数
タスク本体関数:タイマーイベントハンドラーによって呼び出される関数
(Task description)
The task of the CDP of the present invention will be described based on the program description example of FIG. In the present invention, a CDP task is defined using the following elements.
Internal variable: One or more variable interface functions used to take over values between states: Zero or more function reset functions for other tasks to reference or update internal variables Function: Function task body for initializing internal variables Function: Function called by timer event handler

CDPのタスクは、状態により、実行する動作が変化するステートマシンである。ステート間で値を引継ぐために、内部変数を用いる。図2の例では、行番号L5に、taskA_data_t構造体型の内部変数taskA_dataが定義されている。なお、taskA_data_t構造体型は、同図の行番号L2からL4により示されるように、taskA_state_t列挙型の変数state、int型のx、y、resultをメンバとして含む。   The CDP task is a state machine whose operation to be executed changes depending on the state. Use internal variables to transfer values between states. In the example of FIG. 2, an internal variable taskA_data of the taskA_data_t structure type is defined at line number L5. Note that the taskA_data_t structure type includes, as members, taskA_state_t enumerated variable state, int type x, y, and result, as indicated by line numbers L2 to L4 in FIG.

CDPのタスクは、前述の内部変数を他のタスクが参照または更新するためのインタフェース関数を必要に応じて定義する。図2の例では、行番号L13からL31で定義されるcalcメソッド、行番号L33からL43で定義されるget_resultメソッドがインタフェース関数である。calcメソッドは、図2に記述されるTaskAに処理を要求するための関数、get_resultメソッドは、処理結果を要求するための関数である。   The CDP task defines an interface function for other tasks to refer to or update the internal variables as necessary. In the example of FIG. 2, the calc method defined by line numbers L13 to L31 and the get_result method defined by line numbers L33 to L43 are interface functions. The calc method is a function for requesting processing to TaskA described in FIG. 2, and the get_result method is a function for requesting a processing result.

CDPのタスクはまた、内部変数を初期化するためのリセット関数を定義する。図2の例では、行番号L45からL48で定義されるtaskA_RSTメソッドがリセット関数である。本実施形態では、リセット関数において内部変数taskA_dataのメンバ変数stateを初期化している。   The CDP task also defines a reset function to initialize internal variables. In the example of FIG. 2, the taskA_RST method defined by line numbers L45 to L48 is a reset function. In this embodiment, the member variable state of the internal variable taskA_data is initialized in the reset function.

そして、CDPのタスクは、タイマーイベントハンドラーによって呼び出されるタスク本体関数を定義する。図2の例では、行番号L50からL84で定義されるtaskA_CLKメソッドがタスク本体関数である。図2に示されるように、タスク本体関数は、taskA_data.stateの値に従って計算を実行する。stateがcalc1の場合、F(x)を計算する。ここで、関数Fは、行番号L11で定義されるように、標準ライブラリなどの他のモジュールで定義される外部関数である。stateがcalc2の場合、定数LIMITを上限として、F(x)yを計算する。 The CDP task defines a task body function called by the timer event handler. In the example of FIG. 2, the taskA_CLK method defined by line numbers L50 to L84 is a task body function. As shown in FIG. 2, the task body function executes calculation according to the value of taskA_data.state. When state is calc1, F (x) is calculated. Here, the function F is an external function defined in another module such as a standard library, as defined by the line number L11. When state is calc2, F (x) y is calculated with the constant LIMIT as the upper limit.

ここで、タスクの実行時間は、タイマーの周期より短い必要がある。そのため、タスクは次の2つの要求を満たす必要がある。1)タスクは、実行ステップの上限を有する。2)タスクの各ステートメントは、実行時間の上限を有する。   Here, the task execution time needs to be shorter than the timer period. Therefore, the task needs to satisfy the following two requirements. 1) A task has an upper limit of execution steps. 2) Each statement of a task has an upper limit on execution time.

要求1)を満たすために、各関数は、構文的に停止性が保証される形で書く。すなわち、選択(if then else)および順次(;) の組み合わせに展開可能となるように記述する。ループに関しては、反復回数に上限があるものだけが記述可能であり、実行時に反復回数が決まるループを書くことは許されない。不定回数のループは、図2のtaskA_CLKメソッドのように、固定回数のループを周期的に実行することにより実現する。この場合、選択(if then else)によりステップ数は変化するが、1周期で実行されるステップ数には上限が存在するので、要求1)が満たされる。   In order to satisfy the requirement 1), each function is written in a form that syntactically guarantees termination. That is, it is described so that it can be expanded into a combination of selection (if then else) and sequential (;). Regarding loops, only loops with an upper limit on the number of iterations can be described, and it is not allowed to write a loop whose number of iterations is determined at execution time. The indefinite number of loops is realized by periodically executing a fixed number of loops as in the taskA_CLK method of FIG. In this case, although the number of steps varies depending on the selection (if then else), there is an upper limit to the number of steps executed in one cycle, so that the requirement 1) is satisfied.

要求2)を満たすために問題となるのは、ステートメントが関数呼び出しを含む場合である。呼び出す関数が他のタスクのインタフェース関数である場合は、呼び出し先の関数についても実行ステップ数に上限があり、結果として実行時間に上限があるので、問題はない。一方、呼び出す関数が、ライブラリ関数やOSの機能を呼び出すAPIなど、CDPに従わない関数である場合、実行時間に上限がない場合がある。   The problem in meeting requirement 2) is when the statement contains a function call. When the function to be called is an interface function of another task, there is no problem because there is an upper limit on the number of execution steps for the call destination function, resulting in an upper limit on execution time. On the other hand, if the function to be called is a function that does not conform to CDP, such as an API that calls a library function or an OS function, there may be no upper limit on the execution time.

特に問題となるのが、OSのAPIに存在するblocking I/Oである。例えば、blocking I/OのREAD関数を用いてファイルの読み出しをする場合、ファイルの読み出しが完了するまで、呼び出し側プログラムに制御を戻さない。これでは、要求2)を満たすことができない。そこで、CDPのタスクでは、原則としてblocking I/Oの代わりに、non-blocking I/Oを用いる。あるいは、select関数等を用いてブロックされないことを確認した上でblocking I/Oを用いる。   Particularly problematic is blocking I / O existing in the OS API. For example, when a file is read using the blocking I / O READ function, control is not returned to the calling program until the file reading is completed. This cannot satisfy the requirement 2). Thus, in principle, CDP tasks use non-blocking I / O instead of blocking I / O. Alternatively, blocking I / O is used after confirming that the block is not blocked using a select function or the like.

続いて、図3に、図2に記載のtaskAを利用するtaskBのプログラム記述例を示す。taskBは、列挙型の変数state、int型のa、b、zをメンバとして含む構造体型の内部変数taskB_dataを持つ。taskBのタスク本体関数では、図3の行番号L34に示されるように、stateがstate_10の場合、calcメソッドを呼ぶことによりtaskAに処理を要求する。図2の行番号L23に示されるように、taskAの状態に従って要求が受け入れられる場合のみ、戻り値として0が返される。従って、taskBは、要求が受け入れられるまでリトライし、要求が受け入れられると、state_11に遷移する。   Next, FIG. 3 shows a program description example of taskB that uses taskA shown in FIG. taskB has a structure type internal variable taskB_data including enumeration type variable state and int type a, b, and z as members. In the task body function of taskB, as indicated by the line number L34 in FIG. 3, when the state is state_10, processing is requested to taskA by calling the calc method. As shown in line number L23 of FIG. 2, 0 is returned as a return value only when the request is accepted according to the state of taskA. Therefore, taskB retries until the request is accepted, and transitions to state_11 when the request is accepted.

また、図3の行番号L40に示されるように、stateがstate_11の場合、get_resultメソッドを呼ぶことにより処理結果の取得を試みる。ここでも、図2の行番号L40に示されるように、taskAの状態に従って計算が終わっている場合のみ、戻り値として0が返される。従って、taskBは、戻り値として0が得られるまで、クロック毎にget_resultメソッドを呼び出し、処理結果を取得すると、state_12に遷移する。   Also, as indicated by the line number L40 in FIG. 3, when the state is state_11, an attempt is made to acquire the processing result by calling the get_result method. Again, as indicated by line number L40 in FIG. 2, 0 is returned as the return value only when the calculation is completed according to the state of taskA. Therefore, taskB calls the get_result method for each clock until a return value of 0 is obtained, and transitions to state_12 when the processing result is acquired.

(タスクの配列化)
図2の行番号L18に示されるように、taskAはstateがfreeである場合のみ、計算要求を受け入れる。つまり、taskAが先行する計算要求を受け入れ、計算を実行している間は、他のタスクからの計算要求を受け入れることはできない。そこで、同時に複数の計算要求を処理したい場合には、同一機能を持つ複数のタスクを用意するために、タスクを配列化したタスク配列を定義する。図4に、図2に記載のtaskAを配列化したタスク配列のプログラム記述例を示す。
(Task arrangement)
As shown in line number L18 in FIG. 2, taskA accepts a calculation request only when state is free. In other words, while taskA accepts a preceding calculation request and executes a calculation, it cannot accept a calculation request from another task. Therefore, in order to process a plurality of calculation requests at the same time, a task array in which tasks are arrayed is defined in order to prepare a plurality of tasks having the same function. FIG. 4 shows a program description example of a task array in which taskA shown in FIG. 2 is arrayed.

図4の行番号L4に示されるように、タスク配列では、内部変数を配列化する。そして、行番号L7に示されるように、インタフェース関数calcの引数としてインデクスを受け取り、内部変数の参照、更新時には受け取ったインデクスを指定して行う。他の関数においても、同様に引数としてインデクスを受け取り、受け取ったインデクスを指定して内部変数の参照更新を行うことにより、タスクを配列化することができる。内部変数配列の要素数をタスク配列の多重度と呼び、配列化されていないタスク(例えば、図2のtaskA)の多重度は1である。   As indicated by line number L4 in FIG. 4, in the task array, internal variables are arrayed. Then, as indicated by the line number L7, an index is received as an argument of the interface function calc, and the received index is designated when referring to or updating the internal variable. In other functions as well, tasks can be arranged by receiving an index as an argument, and specifying the received index and updating the reference of the internal variable. The number of elements in the internal variable array is referred to as task array multiplicity, and the multiplicity of unarranged tasks (for example, taskA in FIG. 2) is 1.

(PERT図の作成)
タスクを記述したら、次にタスク間の先行関係を把握しPERT図を作成する。タイマーイベントハンドラーが呼び出すのは、タスク本体関数であり、タスク間の先行関係とは、タスク本体関数間の先行関係である。あるタスクは、そのタスク本体関数において、他のタスクのインタフェース関数を呼び出して、他のタスクの処理結果を取得する。例えば、図3に示すtaskBは、タスク本体関数において、taskAのget_resultメソッドを呼び出して、taskAの処理結果F(x)yを取得する。このインタフェース関数の静的呼び出し関係を示したものが、図5のコールグラフである。
(Create a PERT diagram)
After the task is described, the prior relationship between the tasks is grasped and a PERT diagram is created. The timer event handler calls a task body function, and the precedence relationship between tasks is a precedence relationship between task body functions. A certain task calls an interface function of another task in its task body function, and acquires a processing result of the other task. For example, taskB shown in FIG. 3 calls the get_result method of taskA in the task body function, and acquires the processing result F (x) y of taskA. The call graph of FIG. 5 shows the static call relationship of this interface function.

ここで、taskBが処理結果を得るためには、taskAのタスク本体関数がtaskBのタスク本体関数の実行の前に完了している必要がある。この場合、taskAはtaskBに先行する。完了順序を示すPERT図は、コールグラフの矢印の向きを逆転することにより得ることができる(図6)。しかし、全てのコールグラフからPERT図を得ることができるわけではない。   Here, in order for taskB to obtain a processing result, the task body function of taskA needs to be completed before the task body function of taskB is executed. In this case, taskA precedes taskB. A PERT diagram showing the completion order can be obtained by reversing the direction of the arrows in the call graph (FIG. 6). However, PERT diagrams cannot be obtained from all call graphs.

PERT図を得るためには、コールグラフがacyclicである(ループがない)必要がある。図7に示すように、コールグラフがacyclicでない場合は、ポーリング(polling)を用いてタスク間のインタフェースの向きを入れ替える必要がある。taskAとtaskBとのコールグラフはacyclicであるので、タスク間のインタフェースの向きを入れ替える必要はない。ポーリングを用いる参考例として、図8Aおよび図8Bに、インタフェース方向を変えたtaskAおよびtaskBのプログラム記述例を示す。   In order to obtain a PERT diagram, the call graph needs to be acyclic (no loop). As shown in FIG. 7, when the call graph is not acyclic, it is necessary to change the interface direction between tasks by using polling. Since the call graph between taskA and taskB is acyclic, there is no need to change the interface direction between tasks. As a reference example using polling, FIGS. 8A and 8B show program description examples of taskA and taskB with the interface direction changed.

得られたPERT図から、同時実行され得るタスクを判断することができる。コールグラフに基づいて、図9に示すPERT図が得られたものとする。ここで、図9に示すPERT図のグラフGは、1から9のタスクに対応するノードの集合、およびタスク間の先行関係を表す矢印の集合により構成される。PERT図には、本来のタスク1から9に対応するノードに加えて、プログラム全体のスタートとフィニッシュをそれぞれ表す端点sと端点tが記されている。   Tasks that can be executed simultaneously can be determined from the obtained PERT diagram. Assume that the PERT diagram shown in FIG. 9 is obtained based on the call graph. Here, the graph G in the PERT diagram shown in FIG. 9 is composed of a set of nodes corresponding to tasks 1 to 9 and a set of arrows representing the preceding relationship between tasks. In the PERT diagram, in addition to the nodes corresponding to the original tasks 1 to 9, end points s and t representing the start and finish of the entire program are described.

図10に、図9のPERT図に含まれるタスク間の先行関係を示す先行関係表を示す。図中の◎は、2つのタスクが、直接の先行関係を有することを示す。例えば、タスク1と(タスク1のインタフェース関数を呼び出す)タスク4、タスク1と(タスク1のインタフェース関数を呼び出す)タスク6などは、直接の先行関係を有する。図中の○は、2つのタスクが、間接の先行関係を有することを示す。例えば、タスク1とタスク7、タスク1とタスク8、タスク1とタスク9などは、間接の先行関係を有する。図中の×は、2つのタスクが、先行関係を有し得ないことを示す。   FIG. 10 shows a prior relationship table showing the prior relationship between tasks included in the PERT diagram of FIG. In the figure, ◎ indicates that two tasks have a direct preceding relationship. For example, task 1 and task 4 (calling the interface function of task 1), task 1 and task 6 (calling the interface function of task 1) have a direct precedence relationship. ○ in the figure indicates that the two tasks have an indirect precedence relationship. For example, task 1 and task 7, task 1 and task 8, task 1 and task 9, etc. have an indirect precedence relationship. X in the figure indicates that two tasks cannot have a preceding relationship.

間接の先行関係は、直接の先行関係を有さないが、1または複数のタスクを経由して先行関係を有する2つのタスク間において生じる。例えば、タスク1とタスク7は、タスク1のインタフェース関数を呼び出し、かつタスク7によりそのインタフェース関数を呼び出されるタスク4を経由して、先行関係を有する。同様に、タスク1とタスク8も、タスク4を経由して先行関係を有する。また、タスク1とタスク9は、タスク4およびタスク7を経由して、あるいはタスク6を経由して、先行関係を有する。   An indirect predecessor relationship occurs between two tasks that do not have a direct predecessor relationship but have a predecessor relationship via one or more tasks. For example, task 1 and task 7 have a leading relationship via task 4 that calls the interface function of task 1 and that interface function is called by task 7. Similarly, task 1 and task 8 have a preceding relationship via task 4. Task 1 and task 9 have a preceding relationship via task 4 and task 7, or via task 6.

ここで、特定のタスクvのインタフェース関数を呼び出すタスクu、およびタスクwが、直接または間接の先行関係を有する場合、タスクuとタスクwとは、同時実行されることはない。例えば、タスク1のインタフェース関数を呼び出すタスク4およびタスク6は、図10に示されるように直接の先行関係を有するので、同時実行されることはない。一方、タスク3のインタフェース関数を呼び出すタスク5およびタスク8は、図10に示されるように先行関係を有さないので、同時実行され得る。   Here, when the task u calling the interface function of the specific task v and the task w have a direct or indirect precedence relationship, the task u and the task w are not executed simultaneously. For example, the task 4 and the task 6 that call the interface function of the task 1 have a direct precedence relationship as shown in FIG. On the other hand, the task 5 and the task 8 that call the interface function of the task 3 do not have a preceding relationship as shown in FIG.

複数のタスクが同時に同じタスクのインタフェース関数を呼び出す場合、タスクの実行される順序やインタフェース関数の実行される順序により、結果が変わってしまう可能性がある。そこで、複数のタスクから同時に呼び出され得るインタフェース関数は、Bernstein’s conditionsを満たす必要がある。Bernstein’s conditionsは、プログラムの断片が並列実行できるための、周知の十分条件である。   When multiple tasks call the interface function of the same task at the same time, the result may change depending on the order in which the tasks are executed or the order in which the interface functions are executed. Therefore, an interface function that can be called simultaneously from a plurality of tasks needs to satisfy Bernstein's conditions. Bernstein's conditions are well-known sufficient conditions that allow program fragments to be executed in parallel.

例えば、タスク5およびタスク8から同時に呼び出され得る、タスク3に含まれる関数f、gは、関数fの中で構文的に参照される内部変数の集合(R(f))、関数fの中で構文的に代入される内部変数の集合(W(f))、関数gの中で構文的に参照される内部変数の集合(R(g))、および関数gの中で構文的に代入される内部変数の集合(W(g))について以下の(1)から(3)が成り立つ場合、Bernstein’s conditionsを満たし、並列実行することができる。
R(f) ∩ W(g) = φ・・・(1)
R(g) ∩ W(f) = φ・・・(2)
W(f) ∩ W(g) = φ・・・(3)
For example, functions f and g included in task 3 that can be called from task 5 and task 8 at the same time are a set of internal variables (R (f)) syntactically referenced in function f, in function f. A set of internal variables (W (f)) that are syntactically assigned in, a set of internal variables that are syntactically referenced in function g (R (g)), and a syntactic assignment in function g When the following (1) to (3) are satisfied for the set of internal variables (W (g)), Bernstein's conditions are satisfied and parallel execution can be performed.
R (f) ∩ W (g) = φ ・ ・ ・ (1)
R (g) ∩ W (f) = φ ・ ・ ・ (2)
W (f) ∩ W (g) = φ ・ ・ ・ (3)

(Bernstein’s conditionsを満たすプログラムへの書き換え技法)
同時実行され得るタスクがBernstein’s conditionsを満たさない場合、書き替え技法を用いてプログラムを修正する必要がある。代表的な3つの書き換え技法を以下で紹介する。
(Rewriting technique to a program that satisfies Bernstein's conditions)
If tasks that can be executed simultaneously do not meet Bernstein's conditions, the program must be modified using rewrite techniques. Three typical rewriting techniques are introduced below.

第1の書き替え技法として、変数リネーム技法がある。図11Aおよび図11Bに、変数リネーム技法を適用する前後のプログラム記述例を示す。適用前のプログラム記述例では、図11Aに示されるように、インタフェース関数read、writeにおいて、R(read) ∩ W(write) = {taskA_x} ≠ φであり、Bernstein’s conditionsを満たさない。一方、適用後のプログラム記述例では、図11Bに示されるように、別途内部変数を用いてプログラムを修正することにより、R(read) ∩ W(write) =φとなり、Bernstein’s conditionsを満たすことができる。   There is a variable renaming technique as the first rewriting technique. 11A and 11B show program description examples before and after applying the variable renaming technique. In the program description example before application, as shown in FIG. 11A, in the interface functions read and write, R (read) {W (write) = {taskA_x} ≠ φ, and Bernstein's conditions are not satisfied. On the other hand, in the example of the program description after application, as shown in FIG. 11B, R (read) ∩W (write) = φ is satisfied by separately modifying the program using internal variables, and Bernstein's conditions are satisfied. it can.

第2の書き替え技法として、個別化技法がある。個別化技法では、Bernstein’s conditionsを満たさないインタフェース関数を有するタスクを、配列化する。図12に、個別化技法を適用する前後のコールグラフを示す。適用前のコールグラフでは、図12(左)に示されるように、インタフェース関数calc_Fの競合がおき、R(calc_F) ∩ W(calc_F) = {taskB_data} ≠ φであり、Bernstein’s conditionsを満たさない。一方、適用後のコールグラフでは、図12(右)に示されるように、taskBを配列化することにより、R(calc_F(0)) ∩ )W(calc_F(1)) = {taskB_data[0]} ∩ {taskB_data[1]} = φとなり、Bernstein’s conditionsを満たすことができる。   As a second rewriting technique, there is an individualization technique. In the individualization technique, tasks having interface functions that do not satisfy Bernstein's conditions are arranged. FIG. 12 shows call graphs before and after applying the individualization technique. In the call graph before application, as shown in FIG. 12 (left), competition of the interface function calc_F occurs, R (calc_F)) W (calc_F) = {taskB_data} ≠ φ, and Bernstein ’s conditions are not satisfied. On the other hand, in the call graph after application, as shown in FIG. 12 (right), by arranging taskB, R (calc_F (0)) ∩) W (calc_F (1)) = {taskB_data [0] } ∩ {taskB_data [1]} = φ, and Bernstein's conditions can be satisfied.

第3の書き替え技法として、抽選化技法がある。前述した個別化技法は、唯一のリソースを使用する場合には適用することができない。この場合、内部変数のみを配列化し、タスクは配列化しない抽選化技法により、インタフェース関数の競合を防ぐ。具体的には、図13Aに示されるように、競合対象であるtaskBのタスク本体関数において、複数のインタフェース関数呼び出しのうちの1つを選択し(抽選)、選択された(当選した)呼び出しのみ処理を実行し、選択されなかった(落選した)呼び出しについてはエラーを返す。また、図13Bに示されるように、呼び出し側タスクであるtaskC(およびtaskD(図示せず))では、当選するまでインタフェース関数の呼び出しを繰り返す。   As a third rewriting technique, there is a lottery technique. The personalization technique described above cannot be applied when only one resource is used. In this case, competition of interface functions is prevented by a lottery technique in which only internal variables are arranged and tasks are not arranged. Specifically, as shown in FIG. 13A, in the task body function of taskB that is the target of competition, one of a plurality of interface function calls is selected (lottery), and only the selected (winned) call is selected. Execute the process and return an error for calls that were not selected (declined). Further, as shown in FIG. 13B, in the task C (and task D (not shown)) which is the calling task, the interface function is repeatedly called until it is won.

(スケジュールの作成)
PERT図が得られたら、次にスケジュールを作成する。スケジュールは、どのタイミングでどのリソースにタスクを割り当てるかを、PERT図で与えられた先行関係を満たすように定めたものである。利用可能なリソースの制約の元で、完了時間が最小となるスケジュールを作成することが望ましい。図14に示すPERT図に基づいて、スケジュールを作成する。
(Create schedule)
Once the PERT diagram is obtained, a schedule is created next. The schedule defines which task is assigned to which resource at which timing so as to satisfy the preceding relationship given in the PERT diagram. It is desirable to create a schedule that minimizes the completion time under the constraints of available resources. A schedule is created based on the PERT diagram shown in FIG.

(スケジュールの作成−逐次実行)
逐次実行する場合、PERT図を既知のアルゴリズムでトポロジカルソートすることにより、容易にスケジュールを作成することができる。図14のPERT図の場合、以下の3つのスケジュールが作成される。taskX、taskY、taskZ、taskWのタスク本体関数が、それぞれ、taskX_CLK()、taskY_CLK()、taskZ_CLK()、taskW_CLK()であるものとする。
スケジュール1=taskX_CLK(); taskY_CLK(); taskW_CLK(); taskZ_CLK();
スケジュール2=taskX_CLK(); taskY_CLK(); taskZ_CLK(); taskW_CLK();
スケジュール3=taskX_CLK(); taskZ_CLK(); taskY_CLK(); taskZ_CLK();
(Schedule creation-sequential execution)
In the case of sequential execution, a schedule can be easily created by topologically sorting the PERT diagrams using a known algorithm. In the case of the PERT diagram of FIG. 14, the following three schedules are created. It is assumed that task body functions of taskX, taskY, taskZ, and taskW are taskX_CLK (), taskY_CLK (), taskZ_CLK (), and taskW_CLK (), respectively.
Schedule 1 = taskX_CLK (); taskY_CLK (); taskW_CLK (); taskZ_CLK ();
Schedule 2 = taskX_CLK (); taskY_CLK (); taskZ_CLK (); taskW_CLK ();
Schedule 3 = taskX_CLK (); taskZ_CLK (); taskY_CLK (); taskZ_CLK ();

PERT図の先行関係を満たす限り、どの順序で実行しても同一の結果を得ることができ、また、同一の完了時間となる。従って、任意のスケジュールを選択することができる。図15に、スケジュール1でタスクを実行するプログラム記述例を示す。図15の行番号L25において、第3引数(presiod)で指定した100ミリ秒ごとに、第4引数(OnTimer)で指定した関数が呼ばれるよう、タイマーの設定が行われている。本実施形態ではスケジュール1を実行するために、図15の行番号L6からL9に示されるように、タスクの実行順序を定義する。   As long as the preceding relationship in the PERT diagram is satisfied, the same result can be obtained in any order, and the same completion time can be obtained. Therefore, an arbitrary schedule can be selected. FIG. 15 shows an example of a program description for executing a task according to schedule 1. In line number L25 in FIG. 15, the timer is set so that the function specified by the fourth argument (OnTimer) is called every 100 milliseconds specified by the third argument (presiod). In this embodiment, in order to execute the schedule 1, the task execution order is defined as indicated by line numbers L6 to L9 in FIG.

(スケジュールの作成−並列実行)
並列実行する場合、タスク間の先行関係は同期プリミティブを用いて実現する。本実施形態では、同期プリミティブとして、Windowsの提供するEvent Objectを用いる。Event Objectは、2つの状態(シグナル状態/非シグナル状態)を持つ。SetEvent(e)を呼び出すことにより、引数eのハンドルにより特定されるEvent Objectはシグナル状態になる。WaitForSingleObject(e)を呼び出すと、引数eのハンドルにより特定されるEvent Objectが非シグナル状態である場合、シグナル状態になるまでWaitForSingleObject(e)の呼び出し側スレッドは待機し続ける。他のスレッドによりSetEvent(e)が呼ばれ、eにより特定されるEvent Objectがシグナル状態になると、制御が戻され、呼び出し側スレッドは後続の処理を実行することができる。
(Schedule creation-parallel execution)
When executing in parallel, the precedence relationship between tasks is realized using synchronization primitives. In this embodiment, an Event Object provided by Windows is used as a synchronization primitive. The Event Object has two states (signal state / non-signal state). By calling SetEvent (e), the Event Object specified by the handle of the argument e becomes a signal state. When WaitForSingleObject (e) is called, if the Event Object specified by the handle of the argument e is in a non-signal state, the calling thread of WaitForSingleObject (e) continues to wait until it becomes a signal state. When SetEvent (e) is called by another thread and the Event Object specified by e is in a signal state, control is returned and the calling thread can execute the subsequent processing.

例えば、図14のPERT図を、並列度4で実行する場合を考える。
スケジュール4−0=taskX_CLK(); SetEvent(e1); SetEvent(e2);
スケジュール4−1=WaitForSingleObject(e1); taskZ_CLK();
スケジュール4−2=WaitForSingleObject(e2); taskY_CLK(); SetEvent(e3);
スケジュール4−3=WaitForSingleObject(e3); taskW_CLK();
For example, consider a case where the PERT diagram of FIG.
Schedule 4-0 = taskX_CLK (); SetEvent (e1); SetEvent (e2);
Schedule 4-1 = WaitForSingleObject (e1); taskZ_CLK ();
Schedule 4-2 = WaitForSingleObject (e2); taskY_CLK (); SetEvent (e3);
Schedule 4-3 = WaitForSingleObject (e3); taskW_CLK ();

スケジュール4−0では、taskX_CLKメソッドが完了すると、e1およびe2により特定されるEvent Objectをシグナル状態にする。スケジュール4−1では、WaitForSingleObject(e1)を呼び出し、e1により特定されるEvent Objectがシグナル状態になるまで、待機し続ける。taskX_CLKメソッドの完了によりSetEvent(e1)が呼ばれると、スケジュール4−1に対応するスレッドに制御が戻され、taskZ_CLKメソッドが実行される。同様に、スケジュール4−2では、WaitForSingleObject(e2)を呼び出し、e2により特定されるEvent Objectがシグナル状態になるまで、待機し続ける。taskX_CLKメソッドの完了によりSetEvent(e2)が呼ばれると、スケジュール4−2に対応するスレッド制御が戻され、taskY_CLKメソッドが実行される。スケジュール4−2では、taskY_CLKメソッドが完了すると、e3により特定されるEvent Objectをシグナル状態にする。スケジュール4−3も、WaitForSingleObject(e3)を呼び出し、e3により特定されるEvent Objectがシグナル状態になるまで、待機し続ける。taskY_CLKメソッドの完了によりSetEvent(e3)が呼ばれると、スケジュール4−3に対応するスレッドに制御が戻され、taskW_CLKメソッドが実行される。   In the schedule 4-0, when the taskX_CLK method is completed, the Event Object specified by e1 and e2 is set in the signal state. In the schedule 4-1, WaitForSingleObject (e1) is called, and it waits until the Event Object specified by e1 becomes a signal state. When SetEvent (e1) is called upon completion of the taskX_CLK method, control is returned to the thread corresponding to the schedule 4-1, and the taskZ_CLK method is executed. Similarly, in schedule 4-2, WaitForSingleObject (e 2) is called, and the process continues to wait until the Event Object specified by e 2 becomes a signal state. When SetEvent (e2) is called by completing the taskX_CLK method, the thread control corresponding to the schedule 4-2 is returned, and the taskY_CLK method is executed. In the schedule 4-2, when the taskY_CLK method is completed, the Event Object specified by e3 is set in the signal state. The schedule 4-3 also calls WaitForSingleObject (e3) and keeps waiting until the Event Object specified by e3 becomes a signal state. When SetEvent (e3) is called upon completion of the taskY_CLK method, control is returned to the thread corresponding to the schedule 4-3, and the taskW_CLK method is executed.

図16に、スケジュール4−0から4−3でタスクを実行するプログラム記述例を示す。図16の行番号L43において、第3引数(presiod)で指定した100ミリ秒ごとに、第4引数(OnTimer)で指定した関数が呼ばれるよう、タイマーの設定が行われている。本実施形態では、図16の行番号L3からL14に示されるように、スケジュール4−1から4−3に対応するスレッドを用意する。   FIG. 16 shows an example of a program description for executing tasks according to schedules 4-0 to 4-3. In line number L43 in FIG. 16, the timer is set so that the function specified by the fourth argument (OnTimer) is called every 100 milliseconds specified by the third argument (presiod). In this embodiment, threads corresponding to schedules 4-1 to 4-3 are prepared as indicated by line numbers L3 to L14 in FIG.

OnTimerメソッドでは、まず、スレッド1、スレッド2、スレッド3にそれぞれ対応するs[0]、s[1]、s[2]により特定されるEvent Objectをシグナル状態にする。その後、メインスレッドでスケジュール4−0を実行し、スレッド1、スレッド2、スレッド3にそれぞれ対応するt[0]、t[1]、t[2]により特定されるEvent Object のWaitForSingleObjectメソッドを呼び出すことで、Event Objectがシグナル状態になるまで、すなわち該当のスレッドが完了するまで待機し続ける。図17に、並列実行のシーケンス図を示す。   In the OnTimer method, first, Event Objects specified by s [0], s [1], and s [2] corresponding to the thread 1, thread 2, and thread 3 are set in a signal state. Thereafter, schedule 4-0 is executed in the main thread, and the WaitForSingleObject method of the Event Object specified by t [0], t [1], and t [2] corresponding to thread 1, thread 2, and thread 3 is called. Thus, it continues to wait until the Event Object becomes a signal state, that is, until the corresponding thread is completed. FIG. 17 shows a sequence diagram of parallel execution.

スケジュール4−1に対応するスレッド1では、WaitForSingleObject(s[0])を呼び出し、s[0]により特定されるEvent Objectがシグナル状態になるまで、待機し続ける。図16の行番号L18に示されるように、OnTimerメソッド内でSetEvent(s[0])が呼ばれると、スレッド1に制御が戻され、WaitForSingleObject(e1)を呼び出す。その後、e1により特定されるEvent Objectがシグナル状態になるまで、待機し続ける。taskX_CLKメソッドの完了によりSetEvent(e1)が呼ばれると、スレッド1に制御が戻され、taskZ_CLKメソッドが実行される。スレッド1では、taskZ_CLKメソッドが完了すると、t[0]により特定されるEvent Objectをシグナル状態にすることで、スレッドの完了を通知する。   The thread 1 corresponding to the schedule 4-1 calls WaitForSingleObject (s [0]) and keeps waiting until the Event Object specified by s [0] becomes a signal state. As indicated by the line number L18 in FIG. 16, when SetEvent (s [0]) is called in the OnTimer method, control is returned to the thread 1 and WaitForSingleObject (e1) is called. After that, it continues to wait until the Event Object specified by e1 becomes a signal state. When SetEvent (e1) is called upon completion of the taskX_CLK method, control is returned to the thread 1 and the taskZ_CLK method is executed. When the taskZ_CLK method is completed, the thread 1 notifies the completion of the thread by setting the Event Object specified by t [0] to the signal state.

スケジュール4−2に対応するスレッド2(図示せず)においても、スレッド1同様、WaitForSingleObject(s[1])を呼び出し、s[1]により特定されるEvent Objectがシグナル状態になるまで、待機し続ける。図16の行番号L19に示されるように、OnTimerメソッド内でSetEvent(s[1])が呼ばれると、スレッド2に制御が戻され、WaitForSingleObject(e2)を呼び出す。その後、e2により特定されるEvent Objectがシグナル状態になるまで、待機し続ける。taskX_CLKメソッドの完了によりSetEvent(e2)が呼ばれると、スレッド2に制御が戻され、taskY_CLKメソッドが実行される。スレッド2では、taskY_CLKメソッドが完了すると、taskYの完了を通知するSetEvent(e3)を呼び出し、その後、t[1]により特定されるEvent Objectをシグナル状態にすることで、スレッドの完了を通知する。   Similarly to thread 1, thread 2 (not shown) corresponding to schedule 4-2 calls WaitForSingleObject (s [1]) and waits until the Event Object specified by s [1] becomes a signal state. to continue. As indicated by the line number L19 in FIG. 16, when SetEvent (s [1]) is called in the OnTimer method, control is returned to the thread 2 and WaitForSingleObject (e2) is called. After that, it continues to wait until the Event Object specified by e2 becomes a signal state. When SetEvent (e2) is called upon completion of the taskX_CLK method, control is returned to the thread 2 and the taskY_CLK method is executed. When the taskY_CLK method is completed, the thread 2 calls SetEvent (e3) that notifies the completion of taskY, and then notifies the completion of the thread by setting the Event Object specified by t [1] as a signal state.

スケジュール4−3に対応するスレッド3(図示せず)においても、スレッド1同様、WaitForSingleObject(s[2])を呼び出し、s[2]により特定されるEvent Objectがシグナル状態になるまで、待機し続ける。図16の行番号L20に示されるように、OnTimerメソッド内でSetEvent(s[2])が呼ばれると、スレッド3に制御が戻され、WaitForSingleObject(e3)を呼び出す。その後、e3により特定されるEvent Objectがシグナル状態になるまで、待機し続ける。taskY_CLKメソッドの完了によりSetEvent(e3)が呼ばれると、スレッド3に制御が戻され、taskW_CLKメソッドが実行される。スレッド3では、taskW_CLKメソッドが完了すると、t[2]により特定されるEvent Objectをシグナル状態にすることで、スレッドの完了を通知する。   Similarly to thread 1, thread 3 (not shown) corresponding to schedule 4-3 calls WaitForSingleObject (s [2]) and waits until the Event Object specified by s [2] becomes a signal state. to continue. As indicated by the line number L20 in FIG. 16, when SetEvent (s [2]) is called in the OnTimer method, control is returned to the thread 3 and WaitForSingleObject (e3) is called. After that, it continues to wait until the Event Object specified by e3 becomes a signal state. When SetEvent (e3) is called upon completion of the taskY_CLK method, control is returned to the thread 3 and the taskW_CLK method is executed. In the thread 3, when the taskW_CLK method is completed, the completion of the thread is notified by setting the Event Object specified by t [2] to the signal state.

(スケジュールの作成−タスク配列)
タスク配列内の各タスク間に先行関係は存在しない。そのため、各タスクをどのような順序でスケジューリングしてもよい。また、タスク配列は、コードは全て同じで、内部変数の場所だけが異なるので、タスク配列内の各タスクの平均の実行時間は、同一であることが期待できる。従って、タスクの多重度がm、利用可能なCPU数がnである場合、各CPUにm/n個ずつタスクを分配する。
(Schedule creation-Task arrangement)
There is no predecessor relationship between each task in the task array. Therefore, each task may be scheduled in any order. In addition, since all codes of the task array are the same and only the location of the internal variable is different, it can be expected that the average execution time of each task in the task array is the same. Therefore, when the multiplicity of tasks is m and the number of available CPUs is n, m / n tasks are distributed to each CPU.

図14に示すPERT図のtaskYが多重度4のタスク配列で、利用可能なCPU数が5である場合、以下のスケジュールを作成することができる。
スケジュール5−0=taskX_CLK(); SetEvent(e1); SetEvent(e21); SetEvent(e22);
スケジュール5−1=WaitForSingleObject(e1); taskZ_CLK();
スケジュール5−2=WaitForSingleObject(e21); taskY_CLK(0); taskY_CLK(2);
SetEvent(e31);
スケジュール5−3=WaitForSingleObject(e22); taskY_CLK(1); taskY_CLK(3);
SetEvent(e32);
スケジュール5−4=WaitForSingleObject(e31); WaitForSingleObject(e32);
taskW_CLK();
If taskY in the PERT diagram shown in FIG. 14 is a task array with a multiplicity of 4, and the number of available CPUs is 5, the following schedule can be created.
Schedule 5-0 = taskX_CLK (); SetEvent (e1); SetEvent (e21); SetEvent (e22);
Schedule 5-1 = WaitForSingleObject (e1); taskZ_CLK ();
Schedule 5-2 = WaitForSingleObject (e21); taskY_CLK (0); taskY_CLK (2);
SetEvent (e31);
Schedule 5-3 = WaitForSingleObject (e22); taskY_CLK (1); taskY_CLK (3);
SetEvent (e32);
Schedule 5-4 = WaitForSingleObject (e31); WaitForSingleObject (e32);
taskW_CLK ();

このように、多重度の数だけ存在するタスク本体関数をインデックス指定して、各CPUに分配することにより、利用可能なCPU数に応じてスケジュールを作成することができる。   In this way, a task body function that exists in the number of multiplicity can be indexed and distributed to each CPU, whereby a schedule can be created according to the number of available CPUs.

(CDPプログラムの性能)
上述のCDPプログラムの性能は、プログラムを代表するタスクのスループットP(tps)として、以下の式で求めることができる。
(CDP program performance)
The performance of the above-described CDP program can be obtained by the following equation as the throughput P (tps) of a task representing the program.

Figure 0005465745
Figure 0005465745

mはタスクの多重度(同一機能を有するタスクの数)、cは一単位処理あたりに呼ばれるタスク本体関数の数(Clocks Per Transaction:CPT)、fはプログラム駆動周波数(タイマーの周期Tの逆数)であり、ここで、周期Tを保ってタスク本体関数を呼び出すために、デューティ率は1未満である必要がある。   m is the multiplicity of tasks (the number of tasks having the same function), c is the number of task body functions called per unit processing (Clocks Per Transaction: CPT), and f is the program driving frequency (the reciprocal of timer period T) Here, in order to call the task body function while maintaining the period T, the duty ratio needs to be less than 1.

図2に記述されるtaskAのように、CPTが変動する場合、平均値を用いる。taskAは、前述のように、固定回数のループを周期的に実行することにより、不定回数のループを実現する。本実施形態では、stateがcalc2の場合にF(x)yを計算するが、図2の行番号L62に示されるように、calcメソッドの第2引数yにより指定される不定回数のループを、定数LIMITにより指定される上限で周期的に実行する。 When CPT varies as in task A described in FIG. 2, an average value is used. As described above, taskA executes an indefinite number of loops by periodically executing a fixed number of loops. In this embodiment, F (x) y is calculated when the state is calc2. As indicated by the line number L62 in FIG. 2, a loop of an indefinite number of times specified by the second argument y of the calc method is Executes periodically at the upper limit specified by the constant LIMIT.

従って、1≦y≦101の場合、タスク本体関数は、stateがcalc1で1回、stateがcalc2で1回、合計2回呼ばれ、CPTは2となる。101≦y≦201の場合、タスク本体関数は、stateがcalc1で1回、stateがcalc2で2回、合計3回呼ばれ、CPTは3となる。例えば、CPTが2となる確率が50%、CPTが3となる確率が50%の場合、CPTは2.5となる。   Therefore, in the case of 1 ≦ y ≦ 101, the task body function is called twice in total, once in state is calc1 and once in state is calc2, and the CPT is 2. In the case of 101 ≦ y ≦ 201, the task body function is called three times in total, with the state being calc1 once and the state being calc2 twice, and the CPT is 3. For example, when the probability that the CPT is 2 is 50% and the probability that the CPT is 3 is 50%, the CPT is 2.5.

CDPでは、デューティ率が1未満である限り、プログラム駆動周波数fに比例するスループットを保証することができる。CDPでの実行環境の性能差は、デューティ率の差として現れる。プログラムを同一のプログラム駆動周波数で実行する場合、低速CPUでは、高速CPUと比べてデューティ率が高くなる。しかし、デューティ率に差はあっても、同一のプログラム駆動周波数であれば、性能は同じである。   In CDP, as long as the duty ratio is less than 1, a throughput proportional to the program driving frequency f can be guaranteed. The performance difference of the execution environment in CDP appears as a difference in duty ratio. When the program is executed at the same program driving frequency, the low-speed CPU has a higher duty ratio than the high-speed CPU. However, even if there is a difference in duty ratio, the performance is the same if the program driving frequency is the same.

(周期的なタイマーによりプログラムを処理する方法)
次に、図18のフローチャートを参照して、本実施形態に係る周期的なタイマーによりプログラムを処理する工程を説明する。周期的なタイマーによりプログラムを処理するための事前準備として、前述したCDPプログラムを作成し、当該CDPプログラムを処理するコンピュータのメモリに格納する必要がある。CDPプログラムは、(タスクの記述)の章で詳述したタスクプログラムと、(スケジュールの作成)の章で詳述した実行プログラムとを含む。
(Method of processing a program with a periodic timer)
Next, with reference to a flowchart of FIG. 18, a process of processing a program by a periodic timer according to the present embodiment will be described. As advance preparation for processing a program by a periodic timer, it is necessary to create the CDP program described above and store it in the memory of a computer that processes the CDP program. The CDP program includes the task program detailed in the (task description) chapter and the execution program detailed in the (schedule creation) chapter.

本実施形態では、図2のタスクプログラムtaskAおよび図3のtaskBと、図19に示される、taskAおよびtaskBを実行する実行プログラムがメモリに格納されているものとする。   In the present embodiment, it is assumed that the task program taskA in FIG. 2 and taskB in FIG. 3 and the execution program for executing taskA and taskB shown in FIG. 19 are stored in the memory.

ステップS1で、リセット関数の呼び出しを実行プログラムから受け取り、タスクプログラムの内部変数を初期化する。本実施形態では、図19の行番号L21に示されるtaskAのリセット関数の呼び出しを受け、taskAの状態を示す内部変数taskA_data.stateをfreeに初期化する。また、同図の行番号L22に示されるtaskBのリセット関数呼び出しを受け、taskBの状態を示す内部変数taskB_data.stateをstate_10に初期化し、計算に用いる内部変数taskB_data.aおよびtaskB_data.bに実行プログラムの引数で指定されたxおよびyを格納する。   In step S1, a call to the reset function is received from the execution program, and internal variables of the task program are initialized. In the present embodiment, upon receiving a call to the taskA reset function indicated by the line number L21 in FIG. 19, the internal variable taskA_data.state indicating the state of taskA is initialized to free. Also, it receives the taskB reset function call shown in line L22 in the figure, initializes the internal variable taskB_data.state indicating the state of taskB to state_10, and executes the internal variable taskB_data.a and taskB_data.b used for calculation in the execution program Stores x and y specified by the arguments.

ステップS2で、タイマーの周期、およびタスクプログラムのタスク本体関数を呼び出す第1の関数を含むタイマー設定要求を実行プログラムから受け取り、タイマーの周期およびタイマーイベントハンドラーを設定する。本実施形態では、図19の行番号L24に示されるように、タイマーの周期を100ミリ秒に設定し、タイマーイベントハンドラーとしてOnTimer関数を登録する。   In step S2, a timer setting request including a timer period and a first function that calls a task body function of the task program is received from the execution program, and a timer period and a timer event handler are set. In the present embodiment, as indicated by the line number L24 in FIG. 19, the timer period is set to 100 milliseconds, and the OnTimer function is registered as a timer event handler.

OnTimer関数では、図6のPERT図の先行関係に基づいて、taskA、taskBの順でタスク本体関数を呼び出す。   In the OnTimer function, task body functions are called in the order of taskA and taskB based on the preceding relationship in the PERT diagram of FIG.

ステップS3で、タイマーの周期で第1の関数を呼び出すことにより、タスク本体関数を呼び出し、呼び出されたタスク本体関数において、状態を示す内部変数に対応する処理を実行する。本実施形態では、taskBのリセット関数呼び出し時に、実行プログラムの引数により、x=5、y=3が指定されているものとする。   In step S3, the task body function is called by calling the first function at a timer cycle, and the process corresponding to the internal variable indicating the state is executed in the called task body function. In this embodiment, it is assumed that x = 5 and y = 3 are designated by the argument of the execution program when the reset function of taskB is called.

(タイマー周期1回目)第1の関数であるOnTimer関数を呼び出すことにより、まず、taskAの本体関数を実行する。taskA_data.stateはfreeなので、何もすることなくtaskAの本体関数は終了する。次にTaskBの本体関数を実行する。taskB_data.stateはリセット関数により、state_10に初期化されているので、taskAに処理を要求するインタフェース関数calcを呼び出す。taskAのインタフェース関数calc呼び出し時に、本実施形態では、taskA_data.stateはfreeである。したがって、taskAのインタフェース関数calcにおいて、taskA_data.stateにcalc1が設定され、taskA_data.xおよびtaskA_data.yに、それぞれ5、3が格納される。そして、taskAに対する処理要求の受け入れにより、taskB_data.stateにstate_11が設定される。   (Timer cycle 1st time) First, the main function of taskA is executed by calling the OnTimer function which is the first function. Since taskA_data.state is free, the main function of taskA ends without doing anything. Next, the main function of TaskB is executed. Since taskB_data.state is initialized to state_10 by the reset function, the interface function calc that requests processing to taskA is called. In this embodiment, taskA_data.state is free when the taskA interface function calc is called. Therefore, in the interface function calc of taskA, calc1 is set in taskA_data.state, and 5, 3 are stored in taskA_data.x and taskA_data.y, respectively. Then, by accepting the processing request for taskA, state_11 is set in taskB_data.state.

(タイマー周期2回目)再度、第1の関数であるOnTimer関数を呼び出す。taskAのタスク本体関数が呼び出され、taskA_data.stateがcalc1であるので、F(x)が計算され、taskA_data.stateにcalc2が設定される。次に、taskBのタスク本体関数が呼び出され、taskB_data.stateがstate_11であるので、taskAに処理結果を要求するインタフェース関数get_resultを呼び出す。taskAのインタフェース関数get_result呼び出し時に、taskA_data.stateがcalc2であるので、処理が終わっていないことを示す戻り値が返される。   (Timer period second time) The OnTimer function which is the first function is called again. Since the task body function of taskA is called and taskA_data.state is calc1, F (x) is calculated and calc2 is set in taskA_data.state. Next, the task body function of taskB is called, and taskB_data.state is state_11. Therefore, an interface function get_result that requests a processing result from taskA is called. When taskA's interface function get_result is called, taskA_data.state is calc2, so a return value indicating that processing has not ended is returned.

(タイマー周期3回目)再度、第1の関数であるOnTimer関数を呼び出す。taskAのタスク本体関数が呼び出され、taskA_data.stateがcalc2であるので、F(x)yが計算される。ここでは、y=3であるので、本タイマー周期でcalc2に対応する処理は完了し、taskA_data.stateにfinが設定される。次に、taskBのタスク本体関数が呼び出され、taskB_data.stateがstate_11であるので、taskAに処理結果を要求するインタフェース関数get_resultを呼び出す。taskAのインタフェース関数get_result呼び出し時に、taskA_data.stateはfinである。したがって、taskAのインタフェース関数get_resultにおいて、taskA_data.stateにfreeを設定する。そして、taskBの本体関数では、taskAからの処理結果の受け取りにより、taskB_data.stateにstate_12が設定され、周期実行の終了を指示するために、endにより特定されるEvent Objectをシグナル状態にする。 (Timer cycle 3rd) The OnTimer function which is the first function is called again. Since the task body function of taskA is called and taskA_data.state is calc2, F (x) y is calculated. Here, since y = 3, the processing corresponding to calc2 is completed in this timer cycle, and fin is set to taskA_data.state. Next, the task body function of taskB is called, and taskB_data.state is state_11. Therefore, an interface function get_result that requests a processing result from taskA is called. When the taskA interface function get_result is called, taskA_data.state is fin. Therefore, taskA_data.state is set to free in the taskA interface function get_result. In the main function of taskB, upon reception of the processing result from taskA, state_12 is set in taskB_data.state, and the Event Object specified by end is set to the signal state in order to instruct the end of the periodic execution.

タイマー周期3回目の結果、図19の行番号L25のループ継続条件が偽になり、main関数の制御は、L31に移る。最後に、ステップS4で、タスクプログラムに処理結果を要求するインタフェース関数の呼び出しを実行プログラムから受け取り、処理結果を取得する。本実施形態では、taskBに処理結果を要求するインタフェース関数get_resultBの呼び出しを実行プログラムから受け取る。taskBのインタフェース関数get_resultB呼び出し時に、taskB_data.stateはstate_12である。したがって、実行プログラムはtaskBから計算結果を取得することができる。   As a result of the third timer cycle, the loop continuation condition of line number L25 in FIG. 19 becomes false, and the control of the main function shifts to L31. Finally, in step S4, a call to an interface function that requests a processing result from the task program is received from the execution program, and the processing result is acquired. In this embodiment, a call to an interface function get_resultB that requests a processing result from taskB is received from the execution program. When the interface function get_resultB of taskB is called, taskB_data.state is state_12. Therefore, the execution program can acquire the calculation result from taskB.

このように、タイマーにより、定められた一定の処理を実行し、それが終了すると、次にタイマーにより駆動されるまで休むよう動作するプログラムを処理する。上述した実施形態において、1≦y≦101の制約を課した場合、CPTは3となり、デューティ率が1未満である限り、数2の式より、1/3×f(タイマーの周期Tの逆数)のスループットを保証することができる。システムとしての性能保証を実現することができるので、サービスの提供者は、性能保証のために余分な設備を保持する必要はない。さらに、ソフトウェアの開発段階において本発明の特徴を有するプログラムを構成するだけで、求められる性能保証の変更にも、迅速に、的確に対応することができる。   In this manner, a predetermined fixed process is executed by the timer, and when the process ends, a program that operates to rest until it is driven by the timer is processed. In the above-described embodiment, when the constraint of 1 ≦ y ≦ 101 is imposed, the CPT is 3, and as long as the duty ratio is less than 1, according to the equation (2), 1/3 × f (the reciprocal of the timer period T) ) Throughput can be guaranteed. Since the performance guarantee as a system can be realized, the service provider does not need to maintain an extra facility for the performance guarantee. Furthermore, it is possible to quickly and accurately respond to required changes in performance guarantees simply by configuring a program having the characteristics of the present invention at the software development stage.

Claims (7)

クロック駆動プログラミング(CDP)プログラムを格納するメモリを有するコンピュータが、周期的なタイマーによりプログラムを処理する方法であって、前記CDPプログラムは、内部変数、インタフェース関数、リセット関数、タスク本体関数を記述するタスクプログラムと、前記タスク本体関数を周期的に実行するためのタイマーを有する実行プログラムとを含み、前記コンピュータは、
前記リセット関数の呼び出しを前記実行プログラムから受け取り、前記タスクプログラムの前記内部変数を初期化するステップと、
前記タイマーの周期、および第1の関数を含むタイマー設定要求を前記実行プログラムから受け取り、前記実行プログラムのタイマーの周期を前記タイマー設定要求に含まれる周期に設定し、前記実行プログラムのタイマーのタイマーイベントハンドラーとして前記タイマー設定要求に含まれる前記第1の関数を登録するステップであって、前記第1の関数は、前記タスクプログラムの前記タスク本体関数の呼び出しを含む、ステップと、
前記タイマーの周期で前記第1の関数を呼び出すことにより、前記タスク本体関数を呼び出すステップであって、前記タスク本体関数において、前記内部変数のうち当該タスクプログラムの状態を示す状態内部変数に基づいて、当該タスクプログラムの状態に対応する処理を実行し、当該対応する処理の実行の進捗に応じて、前記状態内部変数を更新する、ステップと、
前記タスクプログラムに処理結果を要求する前記インタフェース関数の呼び出しを前記実行プログラムから受け取り、前記状態内部変数に基づいて処理結果要求を受け入れるか否かを判定する、ステップと
を含むことを特徴とする方法。
A computer having a memory for storing a clock driven programming (CDP) program, which processes the program with a periodic timer, wherein the CDP program describes internal variables, interface functions, reset functions, and task body functions A task program, and an execution program having a timer for periodically executing the task body function,
Receiving a call to the reset function from the execution program and initializing the internal variables of the task program;
A timer setting request including a cycle of the timer and a first function is received from the execution program, a timer cycle of the execution program is set to a cycle included in the timer setting request, and a timer event of the timer of the execution program Registering the first function included in the timer setting request as a handler, the first function including calling the task body function of the task program;
Invoking the task body function by calling the first function at a period of the timer, wherein the task body function is based on a state internal variable indicating the state of the task program among the internal variables. Executing a process corresponding to the state of the task program and updating the state internal variable in accordance with the progress of the execution of the corresponding process,
Receiving a call to the interface function that requests a processing result from the task program from the execution program, and determining whether to accept the processing result request based on the state internal variable. .
前記タスクプログラムは複数であり、前記第1の関数において、複数のタスクプログラムの各タスク本体関数を呼び出すスケジュールを指定することを特徴とする請求項1に記載の方法。   2. The method according to claim 1, wherein a plurality of the task programs are provided, and a schedule for calling each task body function of the plurality of task programs is specified in the first function. 前記複数のタスクプログラムから同時に呼び出され得るインタフェース関数は、Bernstein’s conditionを満たすことを特徴とする請求項2に記載の方法。   The method according to claim 2, wherein the interface functions that can be called simultaneously from the plurality of task programs satisfy Bernstein's condition. 前記タスクプログラムは配列化されており、前記第1の関数において、配列化されたタスクプログラムの各タスク本体関数を呼び出すスケジュールを指定することを特徴とする請求項1に記載の方法。   2. The method according to claim 1, wherein the task program is arranged, and a schedule for calling each task body function of the arranged task program is designated in the first function. 前記インタフェース関数、前記リセット関数、および前記タスク本体関数は、不定回数ループを含まないことを特徴とする請求項1に記載の方法。   The method according to claim 1, wherein the interface function, the reset function, and the task body function do not include an indefinite number of loops. 前記インタフェース関数、前記リセット関数、および前記タスク本体関数において、Blocking I/Oを用いないことを特徴とする請求項1に記載の方法。   The method according to claim 1, wherein Blocking I / O is not used in the interface function, the reset function, and the task body function. クロック駆動プログラミング(CDP)プログラムを格納するメモリと、
プロセッサと
を備えたプログラム処理システムであって、
前記CDPプログラムは、内部変数、インタフェース関数、リセット関数、タスク本体関数を記述するタスクプログラムと、前記タスク本体関数を周期的に実行するためのタイマーを有する実行プログラムとを含み、
前記プロセッサは、
前記リセット関数の呼び出しを前記実行プログラムから受け取り、前記タスクプログラムの前記内部変数を初期化するステップと、
前記タイマーの周期、および第1の関数を含むタイマー設定要求を前記実行プログラムから受け取り、前記実行プログラムのタイマーの周期を前記タイマー設定要求に含まれる周期に設定し、前記実行プログラムのタイマーのタイマーイベントハンドラーとして前記タイマー設定要求に含まれる前記第1の関数を登録するステップであって、前記第1の関数は、前記タスクプログラムの前記タスク本体関数の呼び出しを含む、ステップと、
前記タイマーの周期で前記第1の関数を呼び出すことにより、前記タスク本体関数を呼び出すステップであって、前記タスク本体関数において、前記内部変数のうち当該タスクプログラムの状態を示す状態内部変数に基づいて、当該タスクプログラムの状態に対応する処理を実行し、当該対応する処理の実行の進捗に応じて、前記状態内部変数を更新する、ステップと、
前記タスクプログラムに処理結果を要求する前記インタフェース関数の呼び出しを前記実行プログラムから受け取り、前記状態内部変数に基づいて処理結果要求を受け入れるか否かを判定する、ステップと
を実行するよう構成されることを特徴とするプログラム処理システム。
A memory for storing a clock driven programming (CDP) program;
A program processing system comprising a processor,
The CDP program includes an internal variable, an interface function, a reset function, a task program describing a task body function, and an execution program having a timer for periodically executing the task body function,
The processor is
Receiving a call to the reset function from the execution program and initializing the internal variables of the task program;
A timer setting request including a cycle of the timer and a first function is received from the execution program, a timer cycle of the execution program is set to a cycle included in the timer setting request, and a timer event of the timer of the execution program Registering the first function included in the timer setting request as a handler, the first function including calling the task body function of the task program;
Invoking the task body function by calling the first function at a period of the timer, wherein the task body function is based on a state internal variable indicating the state of the task program among the internal variables. Executing a process corresponding to the state of the task program and updating the state internal variable in accordance with the progress of the execution of the corresponding process,
Receiving a call to the interface function that requests a processing result from the task program from the execution program, and determining whether to accept the processing result request based on the state internal variable. A program processing system.
JP2012068033A 2012-03-23 2012-03-23 Program processing method and system Active JP5465745B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2012068033A JP5465745B2 (en) 2012-03-23 2012-03-23 Program processing method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2012068033A JP5465745B2 (en) 2012-03-23 2012-03-23 Program processing method and system

Publications (2)

Publication Number Publication Date
JP2013200666A JP2013200666A (en) 2013-10-03
JP5465745B2 true JP5465745B2 (en) 2014-04-09

Family

ID=49520879

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2012068033A Active JP5465745B2 (en) 2012-03-23 2012-03-23 Program processing method and system

Country Status (1)

Country Link
JP (1) JP5465745B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107153626A (en) * 2017-04-14 2017-09-12 河南思维轨道交通技术研究院有限公司 A kind of access method of low speed bus device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06103082A (en) * 1992-04-24 1994-04-15 Nec Corp Synchronous input/output statement analytic processing system
JP2002268879A (en) * 2001-03-07 2002-09-20 Mitsubishi Electric Corp Device and method for supporting program design and program for performing program design support method by computer
US20080092114A1 (en) * 2004-10-19 2008-04-17 Winz Coroporation Computer Program, Program Executing Device, Program Generation Processing Program, Status Display Processing Program, And The Like

Also Published As

Publication number Publication date
JP2013200666A (en) 2013-10-03

Similar Documents

Publication Publication Date Title
Rolia et al. The method of layers
US9690630B2 (en) Hardware accelerator test harness generation
JP5116442B2 (en) Lock-free simultaneous FIFO queue, method, apparatus and computer program for implementing queue
US9009711B2 (en) Grouping and parallel execution of tasks based on functional dependencies and immediate transmission of data results upon availability
CN113535367B (en) Task scheduling method and related device
US5551041A (en) Wait for service request in an iconic programming system
US20040255296A1 (en) Time-bounded program execution
US20070033640A1 (en) Generic context service in a distributed object environment
US10514949B1 (en) Efficient data processing in a serverless environment
Becker et al. Scheduling multi-rate real-time applications on clustered many-core architectures with memory constraints
Nakano et al. Full hardware implementation of FreeRTOS-based real-time systems
US11422847B2 (en) Synchronous business process execution engine for action orchestration in a single execution transaction context
JP5465745B2 (en) Program processing method and system
WO2002063485A1 (en) Load balancing system and method
JP5480322B2 (en) Performance control method, system and program thereof
JP5486034B2 (en) Schedule creation method, system and program thereof
JP2023544911A (en) Method and apparatus for parallel quantum computing
EP0508632B1 (en) Wait for service request in an iconic programming system
Subramonian et al. Reusable models for timing and liveness analysis of middleware for distributed real-time and embedded systems
Kakkar Scheduling techniques for operating systems for medical and IoT devices: A review
De Munck et al. Design and performance evaluation of a conservative parallel discrete event core for GES
Isovic Handling sporadic tasks in real-time systems: Combined offline and online approach
Boukerche et al. Design and performance evaluation of a real-time RTI infrastructure for large-scale distributed simulations
CN115033251A (en) Software deployment method and device, electronic equipment and storage medium
CN115632993A (en) Flow control method and device

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20130827

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20131010

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20140122

R150 Certificate of patent or registration of utility model

Ref document number: 5465745

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

S533 Written request for registration of change of name

Free format text: JAPANESE INTERMEDIATE CODE: R313533

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250