JP4857325B2 - Task switching device, method and program - Google Patents
Task switching device, method and program Download PDFInfo
- Publication number
- JP4857325B2 JP4857325B2 JP2008282507A JP2008282507A JP4857325B2 JP 4857325 B2 JP4857325 B2 JP 4857325B2 JP 2008282507 A JP2008282507 A JP 2008282507A JP 2008282507 A JP2008282507 A JP 2008282507A JP 4857325 B2 JP4857325 B2 JP 4857325B2
- Authority
- JP
- Japan
- Prior art keywords
- task
- time slot
- type
- time
- tasks
- 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.)
- Expired - Lifetime
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
- Mobile Radio Communication Systems (AREA)
Description
本発明は、オペレーティングシステムにおけるタスク切換に関し、特にタスクが割り当てられたタイムスロットを切り換えることによりプロセッサにおいて実行すべきタスクを切り換えるタスク切換装置に関する。 The present invention relates to task switching in an operating system, and more particularly to a task switching device that switches tasks to be executed in a processor by switching time slots to which tasks are assigned.
オペレーティングシステムの主な機能は、ハードウェア管理、タスク管理、データ管理及び入出力管理である。なかでもタスク管理はタスクの実行順序を管理するものであり、CPUやメモリ、入出力装置等を効率良く動作させるための重要な機能である。 The main functions of the operating system are hardware management, task management, data management and input / output management. In particular, task management manages task execution order, and is an important function for efficiently operating a CPU, memory, input / output device, and the like.
タスクとは、プログラムの起動とその実行、終了などの流れを一括管理する制御単位のことである。 オペレーティングシステムの管理下で動作するプログラムはタスクとして扱われ、プログラムの実行に関するオペレーティングシステムの操作はすべてタスクを単位として行われる。 A task is a control unit that collectively manages the flow of program activation, execution, and termination. A program operating under the management of the operating system is treated as a task, and all operations of the operating system relating to program execution are performed in units of tasks.
タスクの実行順序を決定するアルゴリズムの一つとして、時分割スケジューリング法や優先度による切換方法がある。時分割スケジューリング法は、タスクにある実行時間を割り当て、割り当てられた時間の間はプロセッサの実行権がタスクに与えられ、割り当てられた時間が過ぎると別のタスクに実行権を移す方法である。これによりすべてのタスクに平等かつ決められた時間で実行権が割り当てられる。 One of the algorithms for determining the task execution order is a time-sharing scheduling method or a switching method based on priority. The time-sharing scheduling method is a method in which an execution time in a task is assigned, the execution right of the processor is given to the task during the assigned time, and the execution right is transferred to another task after the assigned time has passed. As a result, execution rights are assigned to all tasks at an equal and determined time.
また、優先度による切換方法に関して、特許文献1及び2はいずれもタスクの優先度に従ってタスクを切り換えるスケジューリング装置を開示している。
しかしながら、上記従来技術によれば、各タスクの必要性能を確保するためにはプログラマが個々のタスク優先度を指定する点でプログラム設計が難しく、また一度設計してしまうと変更の柔軟性が乏しいという問題がある。 However, according to the above prior art, in order to ensure the required performance of each task, it is difficult to design a program in that the programmer specifies individual task priorities, and once it is designed, the flexibility of change is poor. There is a problem.
本発明では、上記問題を解決するために、各タスクの必要性能を満たすための優先度を指定するプログラム設計を容易にし、プログラム設計の柔軟性を有するタスク切換装置を提供することを目的とする。 In order to solve the above problems, an object of the present invention is to provide a task switching device that facilitates program design that specifies priorities for satisfying the required performance of each task and has flexibility in program design. .
上記の目的を達成するために、本発明のタスク切換装置は、プロセッサにおいてタイムスロットを切り換えることによりタイムスロットに割り当てられたタスクの実行を切り換えるタスク切換装置であって、タスクとタイムスロットを対応付けるポインタ及び割当時間の指定を有する第1タイプの複数のタスクのそれぞれの割当時間を記憶するタイムスロット情報記憶手段と、優先度を有する第2タイプの複数のタスクのそれぞれの優先度を記憶するタスク記憶手段と、一周期内の複数のタイムスロットに対して、前記第1タイプの複数のタスクのそれぞれを前記ポインタに基づいて1タスク対1タイムスロットで1つのタイムスロットに割り当て、前記第2タイプの複数のタスクを前記ポインタに基づいて多タスク対1タイムスロットで前記第1タイプのタスクが割り当てられていない1つの特定のタイムスロットに割り当てる割当手段と、前記タイムスロット情報記憶手段に記憶された前記第1タイプの複数のタスクのそれぞれに指定された割当時間に基づいてタイムスロットの切り換えを行うタイムスロット切換手段と、前記特定のタイムスロット以外のタイムスロットに切り換えられた場合に、当該タイムスロットに割り当てられたタスクを選択し、前記特定のタイムスロットに切り換えられた場合に、第2タイプの複数のタスクから前記タスク記憶手段に記憶された前記優先度に基づいて1つのタスクを選択するタスク選択手段とを備える。 In order to achieve the above object, a task switching device of the present invention is a task switching device that switches execution of a task assigned to a time slot by switching the time slot in a processor, and a pointer that associates a task with a time slot. And time slot information storage means for storing the allocation times of the plurality of first type tasks having designation of allocation time, and task storage for storing the priorities of the plurality of second type tasks having priority And for each of a plurality of time slots in one cycle, each of the plurality of tasks of the first type is assigned to one time slot in a one-task-to-one time slot based on the pointer, Multiple tasks ahead in multi-task vs. 1 time slot based on the pointer Based on an allocation unit allocated to one specific time slot to which a first type task is not allocated, and an allocation time specified for each of the plurality of first type tasks stored in the time slot information storage unit Time slot switching means for switching the time slot, and when the time slot is switched to a time slot other than the specific time slot, the task assigned to the time slot is selected and switched to the specific time slot. A task selecting unit that selects one task from a plurality of second type tasks based on the priority stored in the task storage unit.
この構成によれば、第1タイプのタスクは1対1でタイムスロットを割り当てられる結果、第1タイプのタスクについては全てのタイムスロットを含む一周期内で少なくとも1回は選択実行されるので、継続した処理性能が保証される。他方、第2タイプのタスクは多対1で1つのタイムスロットを割り当てられる結果、継続して処理性能が保証されない。その結果、プログラマは、継続して処理性能を満たす必要のあるタスクに対しては優先度を考慮する必要もなく第1タイプに分類するだけでよい。また、プログラマは、処理性能を要求しないタスクに対しては第2タイプに分類すればよい。これにより、全てのタスクに対して個別に優先度を付与する必要がなくなり、処理性能を確保するためのプログラム設計を容易にすることができ、プログラム設計の柔軟性を確保することができる。 According to this configuration, as a result of the first type task being assigned a one-to-one time slot, the first type task is selectively executed at least once within one period including all time slots. Continuous processing performance is guaranteed. On the other hand, the second type task is assigned many time-to-one and one time slot is allocated, so that the processing performance is not continuously guaranteed. As a result, the programmer need only classify the task into tasks of the first type that need to satisfy the processing performance without considering the priority. In addition, the programmer may classify tasks that do not require processing performance into the second type. As a result, it is not necessary to assign priorities to all tasks individually, program design for ensuring processing performance can be facilitated, and program design flexibility can be ensured.
ここで、前記第2タイプのタスクは優先度を有し、前記タスク選択手段は第2タイプの複数のタスクのうち優先度に従って1つのタスクを選択する構成としてもよい。 Here, the second type task may have a priority, and the task selection unit may select one task according to the priority among the plurality of second type tasks.
この構成によれば、第2タイプのタスクは優先度の高いものから実行されるので、プログラマは、第1タイプのタスクに対して優先度を考慮する必要がなく、継続した処理性能を要求しないタスクを第2タイプに分類して優先度を付与すればよいので、プログラム設計及び変更を容易にすることができる。 According to this configuration, since the second type task is executed from the highest priority, the programmer does not need to consider the priority for the first type task and does not require continuous processing performance. Since tasks may be classified into the second type and given priority, program design and modification can be facilitated.
また、前記割当手段は、予め定められた一周期の時間から第1タイプのタスクが割り当てられたタイムスロットの合計時間を引いた残り時間を前記特定のタイムスロットの時間とするように構成してもよい。 Further, the assigning means is configured so that a remaining time obtained by subtracting a total time of time slots to which the first type task is assigned from a predetermined period of time is used as the time of the specific time slot. Also good.
この構成によれば、第2タイプのタスクは上記の残り時間に実行されるので、第2タイプのタスクの実行により第1タイプの個々のタスクの処理性能に影響を及ぼすことを極力排除することができる。 According to this configuration, since the second type task is executed in the remaining time, it is possible to eliminate as much as possible that the execution of the second type task affects the processing performance of the individual tasks of the first type. Can do.
さらに、前記割当手段は、第1タイプの新たなタスクをタイムスロットを割り当てる毎に、前記残り時間を再計算して前記特定のタイムスロットの時間とする構成としてもよい。 Furthermore, the allocation means may be configured to recalculate the remaining time every time a new task of the first type is allocated to the time of the specific time slot.
この構成によれば、第1タイプの個々のタスクの処理性能を保証した上で、第2タイプのタスクに対して最大限の残り時間を動的に割り当てることができる。 According to this configuration, it is possible to dynamically allocate the maximum remaining time to the second type task while guaranteeing the processing performance of the individual tasks of the first type.
また、前記第1タイプのタスクは割当時間の指定を有するタスクであり、前記割当手段は、第1タイプの新たなタスクを追加しようとする場合、既に割当済のタスクの割当時間の合計と新たなタスクの割当時間との総和が一周期の時間を超えていれば、当該新たなタスクのタイムスロット割り当てを拒否する構成としてもよい。 In addition, the first type task is a task having designation of an allocation time, and when the allocation means intends to add a new task of the first type, the total allocation time of the tasks already allocated and the new allocation time are newly added. If the total sum with the allocation time of a task exceeds one cycle time, the time slot allocation of the new task may be rejected.
この構成によれば、第1タイプの新たなタスクの追加を排除してまで既存の第1タイプのタスクの処理性能を保証することができる。 According to this configuration, it is possible to guarantee the processing performance of the existing first type task until the addition of a new first type task is eliminated.
さらに、前記タスク切換装置は、タスクによりアクセス可能な資源について、何れかのタスクからのアクセスによって資源がロック状態にあるか否かを示すロック情報を記憶する記憶手段と、実行中のタスクがロック状態の資源をアクセスしようしたとき、当該タスクを実行可能状態から待ち状態に変更し、当該資源のロック状態が解除されたとき待ち状態のタスクを実行可能状態に変更する変更手段とを備え、前記タスク選択手段は、待ち状態にあるタスクを選択対象から除外する構成としてもよい。 In addition, the task switching device includes storage means for storing lock information indicating whether or not a resource is locked by access from any task, and a task being executed is locked. Change means for changing the task from an executable state to a waiting state when attempting to access a resource in a state, and changing the task in a waiting state to an executable state when the locked state of the resource is released, The task selection means may be configured to exclude a task in a waiting state from a selection target.
また、前記タスク切換装置は、さらに、第1タイプ及び第2タイプのタスクのうち実行可能状態のタスクが1つも存在しない場合に、前記プロセッサを省電力状態に移行させる移行手段を備える構成としてもよい。 The task switching device may further include a transition unit that shifts the processor to a power saving state when there is no task that is executable among the first type task and the second type task. Good.
ここで、前記プロセッサは、タスクのコンテキストを保持するためのレジスタセットを少なくとも2つ備え、前記タスク切換装置は、さらに、レジスタセットの1つを実行中のタスクの使用に供し、他の1つのレジスタセットに対して次に実行すべきタスクのコンテキストをバックグラウンド処理により復帰させ、タイムスロットの切換時にレジスタセットを切り換える切換手段を備える構成としてもよい。 Here, the processor includes at least two register sets for holding a context of a task, and the task switching device further provides one of the register sets for use of an executing task, and another one of the register sets. It is also possible to provide a switching means for returning the context of the task to be executed next to the register set by background processing and switching the register set when switching the time slot.
この構成によれば、コンテキストの退避及び復帰をプログラム的に実行する代わりにレジスタセットの切換を行えばよいので、タスク切換を高速化することができる。また、次に実行すべきタスクのコンテキストをバックグラウンド処理により復帰させるので、プロセッサ時間のアイドル処理などを効率よく利用してタスク切換の高速化を図ることができる。 According to this configuration, it is only necessary to switch register sets instead of programmatically saving and restoring contexts, so that task switching can be speeded up. Further, since the context of the task to be executed next is restored by background processing, it is possible to speed up task switching by efficiently using idle processing of processor time.
また、本発明のタスク切換方法およびそのプログラムについても、上記と同様の構成であり、同様の作用及び効果を有している。 Further, the task switching method and the program thereof according to the present invention have the same configuration as described above and have the same operations and effects.
以上説明してきたように本発明のタスク切換装置によれば、プログラマは、継続して処理性能を満たす必要のあるタスクに対しては優先度を考慮する必要もなく第1タイプに分類するだけでよく、処理性能を要求しないタスクに対しては第2タイプに分類すればよい。これにより、全てのタスクに対して個別に優先度を付与する必要がなくなり、処理性能を確保するためのプログラム設計を容易にすることができ、プログラム設計の柔軟性を確保することができるという効果がある。 As described above, according to the task switching device of the present invention, the programmer only needs to classify the task into tasks of the first type that need to satisfy the processing performance without considering the priority. Well, tasks that do not require processing performance may be classified into the second type. This eliminates the need to assign priorities to all tasks individually, facilitates program design to ensure processing performance, and ensures program design flexibility. There is.
また、第2タイプのタスクは優先度の高いものから実行されるので、プログラマは、第1タイプのタスクに対して優先度を考慮する必要がなく、継続した処理性能を要求しないタスクを第2タイプに分類して優先度を付与すればよく、プログラム設計及び変更を容易にすることができる。 Further, since the second type task is executed from the task with the highest priority, the programmer does not need to consider the priority with respect to the first type task, and the task that does not require continuous processing performance is the second. What is necessary is just to classify | categorize into a type and to give a priority, and program design and a change can be made easy.
〔全体構成〕
図1は本発明の実施の形態におけるタスク切換を行うプログラム実行装置の主要部の構成を示すブロック図である。同図は、プロセッサにおいてオペレーティングシステムの一部の機能としてタスク切換を行うソフトウェアを実行することにより実現される機能を模式的に表している。プロセッサのハードウェア構成は、一般的なものでよい。
〔overall structure〕
FIG. 1 is a block diagram showing a configuration of a main part of a program execution device that performs task switching according to an embodiment of the present invention. This figure schematically shows functions realized by executing software for performing task switching as a part of functions of the operating system in the processor. The hardware configuration of the processor may be a general one.
このプログラム実行装置は、割当時間の指定を有するタスクと優先度を有するタスクの2種類のタスクを1つのプロセッサ内で扱い、前者のタスクの必要性能を確保し、後者のタスクを優先度に従って選択実行するよう構成されている。 This program execution device handles two types of tasks, a task with an assigned time and a task with a priority, in one processor, ensuring the required performance of the former task, and selecting the latter task according to the priority Configured to run.
同図のようにプログラム実行装置は、タスクスケジューリング部10、プログラム記憶部20、タイマ制御部30及び実行制御部40より構成される。
As shown in the figure, the program execution device includes a
タスクスケジューリング部10は、2種類のタスクのスケジューリングを行う。すなわち、前者のタスクに対して、タスクスケジューリング部10は、割当時間の指定を有するタスクのそれぞれに1つのタイムスロットを割り当て、予め定められた周期内において各タスクを少なくとも1回選択する時分割スケジューリングを行う。後者のタスクに対して、タスクスケジューリング部10は、一周期内における上記のタイムスロットの合計時間の残り時間において、優先度を有する複数タスクのうち1つのタスクを選択するスケジューリングを行う。ここで、タイムスロットとは、プロセッサにおけるプログラムを実行する時間を周期内において割当時間ごとに区切ったものである。
The task scheduling
プログラム記憶部20は、タスクスケジューリング部10によるスケジューリング対象となるタスクの本体であるプログラムとプログラムに関する情報とを記憶する。
The
タイマ制御部30は、タスクスケジューリング部10から割当時間を設定される毎に、時間のカウントを開始し当該割当時間に達したときにタイムアウトを出力する。このタイムアウトは、タイムスロットの切り換えタイミングを知らせるために、タスクスケジューリング部10に通知される。
Each time the allocation time is set by the
実行制御部40は、タスクスケジューリング部10に選択されたタスクを実行する。実行制御部40はプロセッサのタスクを実行するハードウェアに相当する。
The
〔タスクスケジューリング部10の構成〕
タスクスケジューリング部10は、タスク受付部11、タイムスロット記憶部12、タスク記憶部13、タイムスロット切換部14、タスク選択部15、mutex記憶部16及びmutex制御部17から構成される。
[Configuration of Task Scheduling Unit 10]
The
<1.タスク受付部11>
タスク受付部11は、ユーザ操作やユーザプログラム等からの指示に従ってタスクの追加要求を受け付け、プログラム記憶部20から当該タスクに関する情報として、「タスク情報」、「優先度」及び「割当時間」を読み出して、当該タスクがスケジューリングの対象となるようにタイムスロット情報やタスク管理ブロックを生成し、タイムスロット記憶部12、タスク記憶部13に設定する。
<1.
The
ここで、「タスク情報」は、プログラム開始アドレスとスタックポインタからなる。プログラム開始アドレスは、タスクが書き込まれた先頭のアドレスである。スタックポインタは、タスクの切換が生じた際にタスクの状態を一時的に退避する格納場所を示す位置情報である。 Here, “task information” includes a program start address and a stack pointer. The program start address is the first address where the task is written. The stack pointer is position information indicating a storage location for temporarily saving the task state when the task is switched.
「優先度」は、割当時間の指定を有するタスクか優先度を有するタスクかを区別する基準であり、且つ後者の場合の優先度を示すという2つの意味を持つ。 The “priority” is a standard for distinguishing between a task having an assigned time designation and a task having a priority, and has two meanings indicating the priority in the latter case.
すなわち、優先度0のタスクは割当時間を有するタスク(以下種別Aのタスクと呼ぶ)、優先度が0でないタスクは優先度を有するタスク(以下種別Bのタスクと呼ぶ)であり、以下の意味を持つ。
In other words, a task with
種別Aのタスクは、割当時間の指定を有するタスクであり、タスクスケジューリング部10において、タイムスロットに1対1で対応して割り当てられ、当該タイムスロットの割当時間の間は確実に実行される。実行時間の長さで処理性能が定まるので、いわゆるタイムドリブン型と呼ばれるタスクを種別Aとすべきである。例えば、動画データのデコード/エンコード処理、音声データのデコード/エンコード処理など継続して一定の処理性能を必要とするタスクを種別Aとすることが望ましい。
The type A task is a task having designation of an allocation time, and is allocated in a one-to-one correspondence with the time slot in the
種別Bのタスクは、他の種別Bのタスクと共に1つのタイムスロットに割り当てられ、当該タイムスロットが保持する割当時間の間、優先度の高いタスクが実行される。ここでは、優先度は、高い方から順に1、2、3、・・・という値をとるものとする。いわゆるイベントドリブン型と呼ばれるタスクを種別Bとすべきである。例えば、ユーザ操作をイベントとして文字や静止画からなるメニュー表示を行う処理など継続して一定の処理性能を必要としないが不定期に随時発生するタスクを種別Bとすることが望ましい。この場合、優先度は例えば厳しい応答速度を要求されるイベントを処理するタスクほど高くすればよい。 A type B task is assigned to one time slot together with other type B tasks, and a task with a higher priority is executed during the assigned time held by the time slot. Here, the priority is assumed to take values of 1, 2, 3,. A so-called event-driven type task should be type B. For example, it is desirable that a task that does not require constant processing performance, such as a process of displaying a menu consisting of characters and still images with a user operation as an event, but that occurs occasionally and occasionally occurs is type B. In this case, the priority may be set higher for a task that processes an event that requires a strict response speed, for example.
「割当時間」は、タスクが種別Aのときにのみ有効で、タスクに対応するタイムスロットの割当時間を指定する値である。この割当時間と優先度とは、プログラムによって指定されたものとする。 “Allocation time” is valid only when the task is type A, and is a value that specifies the allocation time of the time slot corresponding to the task. It is assumed that the allocation time and the priority are specified by the program.
また、タスク受付部11は、ユーザ操作やユーザプログラム等からの指示があった場合や、タスクの実行が終了した場合に、タイムスロット記憶部12、タスク記憶部13に記憶されている当該タスクのタイムスロット情報やタスク管理ブロックを削除する。
In addition, the
<2.タイムスロット記憶部12>
タイムスロット記憶部12は、タスクの切り換えの基準となるタイムスロットを生成するためのタイムスロット情報を記憶する。
<2. Time
The time
図2は、タイムスロット記憶部12内のタイムスロット情報と、タスク記憶部13内のタスク管理ブロックの具体例を示す図である。同図のように、タイムスロット記憶部12は、複数のタイムスロット情報100、110、120、・・・を記憶する。タイムスロット情報100は、種別Bの複数のタスクが割り当てられたタイムスロットを示す。このタイムスロット情報100は、種別Bのタスクが存在しなくても予め生成しておいてもよい。これ以外のタイムスロット情報110、120、・・・は、種別Aのタスクが割り当てられたタイムスロットを示す。
FIG. 2 is a diagram showing a specific example of time slot information in the time
タイムスロット情報100は、タイムスロットの1つに対応し、割当時間100a、実行フラグ100b及びポインタ100cからなる。他のタイムスロット情報も同様である。
The
割当時間は、当該タイムスロットに対応するタスクが実行することができる時間を示す。タスクが実際に実行された時間が割当時間に達すると次のタイムスロットに切り換られる。種別Aのタスクに対応する割当時間110a、120aは、タイムスロット情報の生成と同時に設定される。種別Bの複数タスクに対応する割当時間100aは、周期レジスタ18に保持された一周期の時間から、他のタイムスロットの割当時間110a、120a・・・の合計時間を引いた残り時間としている。この残り時間はタスクの追加、削除がある毎に変化する。
The allocated time indicates the time that the task corresponding to the time slot can be executed. When the time when the task is actually executed reaches the allocated time, it is switched to the next time slot. The
実行フラグは、当該タイムスロットが有効か無効かを示す。タイムスロット情報の生成時には有効と設定され、タスク実行中にアクセス先の資源がロック状態にあって待ち状態になった時に無効と設定され、その後待ち状態から実行可能状態に戻った時に有効と設定される。実行フラグが無効を示す場合は、タイムスロット切換部14によってタイムスロット情報が存在しないものとみなされる。
The execution flag indicates whether the time slot is valid or invalid. It is set to valid when generating time slot information, set to invalid when the resource being accessed is locked and waiting during task execution, and set to valid when returning from the wait state to the ready state. Is done. When the execution flag indicates invalidity, the time
ポインタは、当該タイムスロットに対応するタスク管理ブロックを示している。
これらのタイムスロット情報100、110、120・・・は配列を構成し、その順序はタイムスロットの生成順を表すものとする。
The pointer indicates a task management block corresponding to the time slot.
These
<3.タスク記憶部13>
タスク記憶部13は、タイムスロットに割り当てられたタスクに対応するタスク管理ブロック200、201、・・・を記憶する。タスク管理ブロック200、201、・・・は、それぞれ1つのタスクに対応し、当該タスクを管理するための情報である。
<3.
The
タスク管理ブロック200は、タスク情報200a、優先度200b、リンクアドレス200cからなる。
The
タスク情報200aは、プログラム開始アドレス(又はプログラムを再開すべきアドレス)及びスタックポインタを含む。タスク管理ブロックの生成時には、タスク受付部によって入力された前記タスク情報を保持する。タスク切換時には、中断されたタスクの実行アドレス及び当該時点でのスタックポインタの値を示す。 The task information 200a includes a program start address (or an address at which the program should be resumed) and a stack pointer. When the task management block is generated, the task information input by the task reception unit is held. When switching tasks, the execution address of the interrupted task and the value of the stack pointer at that time are shown.
優先度200bは、当該タスクの優先度を示す。
リンクアドレス200cは、当該タスクが要素として実行キュー又は待ちキューに接続された場合に、実行キュー又は待ちキューにおける次の要素であるタスク管理ブロックへのポインタを保持する。
The priority 200b indicates the priority of the task.
The link address 200c holds a pointer to a task management block which is the next element in the execution queue or wait queue when the task is connected as an element to the execution queue or wait queue.
具体的には、種別Aのタスクに対応するタスク管理ブロックでは、リンクアドレス(210c等)は、当該タスクが実行可能状態である場合はnull(無効)であり、当該タスクが待ち状態である場合は待ちキューの次の要素を指すポインタである。種別Bのタスクに対応するタスク管理ブロックでは、リンクアドレス200cは、当該タスクが実行可能状態である場合は実行キューを形成する次の要素を指すポインタであり、当該タスクが待ち状態である場合は待ちキューを形成する次の要素を指すポインタである。 Specifically, in the task management block corresponding to the type A task, the link address (210c, etc.) is null (invalid) when the task is in an executable state, and the task is in a waiting state. Is a pointer to the next element in the wait queue. In the task management block corresponding to the type B task, the link address 200c is a pointer indicating the next element forming the execution queue when the task is in an executable state, and when the task is in a wait state. A pointer to the next element that forms the wait queue.
<4. タイムスロット切換部14>
タイムスロット切換部14は、現在のタイムスロットにおいてタスクの実行時間が割当時間に達したときに、タイムスロットの切換を行う。割当時間に達したかどうかはタイマ制御部30によるタイムアウトによって通知される。通知を受けたタイムスロット切換部14は、次のタイムスロット情報を選択する。本実施例では、次に選択されるタイムスロット情報は、その配列順による。タイムスロット切換部14は、選択したタイムスロット情報から割当時間を取得してタイマ制御部30に設定する。これにより次のタイムスロットの割当時間のカウントが開始される。
<4. Time
The time
<5. タスク選択部15>
タスク選択部15は、前記タイムスロット切換部14のタイムスロット切り換え時に、及び実行中のプログラムからの指示があった時に、現在実行中のタスクの実行アドレス、スタックポインタ等を当該タスクのタスク管理ブロックにタスク情報として退避し、次に実行すべきタスクのタスク管理ブロックからタスク情報を取り出して、実行制御部40へ出力する。これと同時に、実行中のタスクのコンテキスト(レジスタデータ等)の退避と、次に実行すべきタスクのコンテキストの復帰もなされる。これにより次に実行すべきタスクが実行状態になる。
<5.
When the time
図4は、タイムスロット切換部14及びタスク選択部15によるタスク切換の様子を示す説明図である。同図において、Tは周期レジスタ18に保持された周期、t0は種別Bのタスクに対応するタイムスロット情報100に対応するタイムスロットであり、その長さは割当時間を示す。t1〜tnはそれぞれ種別Aのn個のタスクに対応するn個のタイムスロット情報110、120・・・に対応するタイムスロットであり、その長さは割当時間を示す。Sは、タイムスロット切換部14及びタスク選択部15によってタスク切換を行うスケジューリング処理を示す。同図のように、タイムスロットt0を開始時のスケジューリング処理では、種別Bの複数のタスクB1、B2、B3のうち優先度の最も高いタスクB1が選択され実行される。タイムスロットt1の開始時のスケジューリング処理では、タイムスロット情報110に対応するタスクA1が実行される。タイムスロットt2〜tnについても同様である。このように種別Aのタスクは1つの周期Tの間に1回は必ず実行される。
FIG. 4 is an explanatory diagram showing how tasks are switched by the time
また、図5は、タイムスロットt0において実行中のタスクが終了した場合のタスク切換の様子を示す説明図である。同図においてタスクB1は、自身の処理を完了し場合、タスク選択部15にその旨を通知する。この通知によって、タスクB1の削除処理(図中のE)と、タスクの切換処理(同S1)とがなされる。削除処理Eでは、タスクB1が終了したので、タスクB1のタスク管理ブロックが削除される。切換処理S1では、タスクB1のタスク管理ブロック削除後に最も優先度の高いタスクB2がタスク選択部15によって選択され、実行される。このように、種別Bの複数のタスクが割り当てられたタイムスロットt0では、優先度の高いタスクから順に実行される。
FIG. 5 is an explanatory diagram showing task switching when a task being executed in time slot t0 ends. In the figure, when the task B1 completes its own processing, the task B1 notifies the
<6. mutex記憶部16>
mutex(mutual exclusion:相互排除)は、2つ以上のタスクが1つの資源を競合してアクセスする場合に調停を行う機構をいい、mutex制御部17に含まれる機能であり、資源のロック状態及びロック解除状態を管理するオブジェクト(プログラム)によって実現される。この機構は、2つ以上のタスクからのアクセスが競合する可能性のある資源毎に設けられる。あるタスクがmutexのロック操作に成功すると、mutexは(又は資源は)ロック状態になり他のタスクがロック操作を行ってもロック解除状態になるまで待たされることになる。これによりロック操作に成功しタスクは対応する資源を専有することができる。ロック操作を行ったタスクがロック解除操作を行うと、他のタスクがロック操作を行うことができるようになる。実行中のタスクは、資源をアクセスする場合、当該資源に対応するmutexをロック操作に成功した場合のみ資源をアクセスすることができる。既にロック状態になっている場合には、ロック解除状態になるまで待たされることになる。
<6.
Mutex (mutual exclusion) refers to a mechanism that performs arbitration when two or more tasks access one resource by competing, and is a function included in the
図3は、mutex記憶部16に記憶されるmutex管理ブロック300、301・・・と、タスク記憶部13に記憶される待ちキューとを示す図である。
FIG. 3 is a diagram showing mutex management blocks 300, 301... Stored in the
同図においてmutex管理ブロック300、301・・・は、2つ以上のタスクからのアクセスが競合する可能性のある個々の資源に対応して設けられる。 In the figure, mutex management blocks 300, 301,... Are provided corresponding to individual resources with which access from two or more tasks may compete.
mutex管理ブロック300はロック変数300a及びポインタ300bを含む。
ロック変数300aは、2つの状態(1:ロック状態、0:ロック解除状態)の何れかを示す。初期値は0であり、ロック解除状態からロック状態にするにはタスクがロック操作を行う必要がある。ロック状態からロック解除状態にするには、ロック操作を行ったタスクのみが操作を許される。
The
The
ポインタ300bは、ロック状態においてロック操作を行ったタスク(ロック操作に失敗したタスク)を示す待ちキューの先頭のタスク管理ブロックを指す。待ちキューに接続されたタスク管理ブロック200'、201'・・・は、ロック操作に失敗したタスクに対応し、それぞれリンクアドレス200'c、201'c・・・によって順に接続された待ちキューを形成する。 The pointer 300b points to the task management block at the head of the wait queue indicating the task that performed the lock operation in the lock state (the task that failed the lock operation). The task management blocks 200 ′, 201 ′,... Connected to the wait queue correspond to the tasks for which the lock operation has failed, and wait queues connected in order by the link addresses 200′c, 201′c,. Form.
<7. mutex制御部17>
mutex制御部17は、mutexのロック操作及びロック解除操作が行われるときに、ロック変数の操作を行うとともに、タスク選択部15へのタスク管理ブロックの操作要求やタイムスロット切換部14への通知及び実行フラグの操作要求を行う。
<7.
The
図6は、種別Bのタスクがロック操作に失敗した場合の様子を示す説明図である。同図では、タイムスロットt0において実行中のタスクB1がアクセスしようとする資源に対応するmutexに対してロック操作(図中のL:ロック処理)を行って、失敗した場合を示している。当該mutexが既にロック状態である場合にタスクB1はロック操作に失敗することから、同図のようにロック処理Lによってタスク記憶部13の実行キューから待ちキューに移動させられ、さらに、タスク切換処理S1により、タスクB2に切り換えられる。タスクB1は、当該mutexがロック状態からロック解除状態になるまで、実行キューから除外されるので、スケジューリングの対象から除外される。
FIG. 6 is an explanatory diagram showing a state where the type B task has failed in the lock operation. This figure shows a case where a lock operation (L: lock process in the figure) is performed on the mutex corresponding to the resource to be accessed by the task B1 being executed in the time slot t0 and fails. If the mutex is already locked, the task B1 fails to perform the lock operation. Therefore, the task B1 is moved from the execution queue of the
このように種別Bのタスクに対応するタイムスロットt0では、実行中のタスクが待ち状態になった場合に、次順位のタスクに切り換えられる。 In this way, in the time slot t0 corresponding to the type B task, when the task being executed is in a waiting state, the task is switched to the next task.
また、タスクB1がロック処理においてロック操作に成功した場合は、タスクB2に切り換えられることなく、タイムスロットt0の間、実行を続ける(資源にアクセスする)ことになる。 When task B1 succeeds in the lock operation in the lock process, execution is continued (accessing resources) during time slot t0 without switching to task B2.
図7は、種別Aのタスクがロック操作に失敗した場合の様子を示す説明図である。同図では種別AのタスクA2がロック操作に失敗して待ちキューに移動させられ場合、タイムスロットt2の割当時間に達していなくても、スケジューリング処理(同図S)によりタイムスロットが切り換えられる。種別Aのタスクに対応するタイムスロットにはタスクが1つしか割り当てられていないから、タイムスロットの残り時間があってもタイムスロットを切り換えている。 FIG. 7 is an explanatory diagram showing a state when the type A task fails in the lock operation. In the figure, when the type A task A2 fails in the lock operation and is moved to the waiting queue, the time slot is switched by the scheduling process (S in the figure) even if the allocation time of the time slot t2 has not been reached. Since only one task is assigned to the time slot corresponding to the type A task, the time slot is switched even if there is a remaining time slot.
また、タスクA2がロック操作に成功した場合には、タイムスロットt2の割当時間に達した時に次のタイムスロットに切り換えられる。 Further, when the task A2 succeeds in the lock operation, the task A2 is switched to the next time slot when the allocation time of the time slot t2 is reached.
図8は、タスクがロック解除する場合の様子を示す説明図である。同図に示すように実行中のタスクA1がロック状態にあるmutexをロック解除した場合、ロック解除処理Rによって当該mutexに対応する待ちキューRのタスクB1は実行キューBに戻される。これによりタスクB1は、それ以後に対応するタイムスロットt0が選択された場合に実行されることになる。 FIG. 8 is an explanatory diagram showing a situation when a task unlocks. As shown in the figure, when the currently executing task A1 unlocks the locked mutex, the task B1 in the waiting queue R corresponding to the mutex is returned to the execution queue B by the unlocking process R. As a result, task B1 is executed when the corresponding time slot t0 is selected thereafter.
図9は、タスクがロック解除する場合の様子を示す他の説明図である。同図では実行中のタスクA2がロック状態にあるmutexをロック解除した場合、ロック解除処理Rによって当該mutexに対応する待ちキューSのタスクB2は実行キューBに戻される。図8とは異なり、タスクB2は、タスクB1とB3の間に戻されている。これは、優先度の順に並ぶように実行キューに戻しているからである。このケースは、タスクB2が待ちキューにある間に、それよりも優先度の高いタスクB1が生成された場合などにあたる。これ以降にタイムスロットt0が選択された場合、優先度の最も高いタスクB1が選択されて実行されることになる。 FIG. 9 is another explanatory diagram showing a situation when the task unlocks. In the figure, when the task A2 being executed unlocks the mutex that is in the locked state, the task B2 in the waiting queue S corresponding to the mutex is returned to the execution queue B by the unlock process R. Unlike FIG. 8, task B2 is returned between tasks B1 and B3. This is because they are returned to the execution queue so that they are arranged in order of priority. This is the case, for example, when task B1 with higher priority is generated while task B2 is in the waiting queue. Thereafter, when the time slot t0 is selected, the task B1 having the highest priority is selected and executed.
〔処理の詳細〕
以下、本発明のプログラム実行装置における処理の詳細として、スケジューリング処理(図4〜図9中のS)、mutexロック処理(図6、図7中のL)及びmutexロック解除処理(図8、9中のR)、タスク切換処理(図5、図6中のS1)、タスク追加処理、タスク終了処理(図5中のE)について詳細に説明する。
[Details of processing]
Hereinafter, as details of processing in the program execution device of the present invention, scheduling processing (S in FIGS. 4 to 9), mutex lock processing (L in FIGS. 6 and 7), and mutex lock release processing (FIGS. 8 and 9). R), task switching processing (S1 in FIGS. 5 and 6), task addition processing, and task end processing (E in FIG. 5) will be described in detail.
<1. スケジューリング処理>
図10は、スケジューリング処理の詳細を示すフローチャートである。同図のスケジューリング処理は、タイマ制御部30がタイムアウトをタイムスロット切換部14に通知したとき、及び、実行中のタスクがロック操作に失敗したとき(図7参照)に呼び出されて開始する。図中、iは実行フラグが無効になっているタイムスロット情報をカウントするための変数、(n+1)は存在するタイムスロット情報の数を表す。
<1. Scheduling process>
FIG. 10 is a flowchart showing details of the scheduling process. The scheduling process of FIG. 6 is called and started when the
まず、タイムスロット切換部14は、カウンタとして用いる変数iを0に初期化し(S401)、現在実行しているタスクの状態をタスク管理ブロックに退避する(S402)。
First, the time
次に、タスク選択部15は、変数iに1を加算し(S403)、タイムスロット情報の配列における次順のタイムスロット情報を選択し、次の要素がない場合は、タイムスロット情報配列の先頭の要素を選択し、選択したタイムスロット情報を取得する(S404)。さらに、タイムスロット切換部14は、選択したタイムスロット情報に含まれる割当時間を取り出し、タイマ制御部30に設定する(S405)。これにより、タイマ制御部30はカウントを開始し、割当時間に達しタイムアウトするまでカウントする。
Next, the
さらに、タイムスロット切換部14は、取得したタイムスロット情報がタイムスロット情報100であるか否かを判定する。つまり次に実行すべきタスクが種別Bであるか種別Aであるかを判定する(S406)。
Further, the time
判定の結果が種別Aである場合には、当該タイムスロット情報中のポインタが指すタスク管理ブロックを取得し(S407)、タイムスロット情報中の実行フラグが1(有効)であれば(S408)、タスク管理ブロック中のタスク情報に従って、当該タスクの状態を復帰させる(S411)。これにより種別Aのタスクに切り換えられる。 If the determination result is type A, the task management block pointed to by the pointer in the time slot information is acquired (S407). If the execution flag in the time slot information is 1 (valid) (S408), According to the task information in the task management block, the state of the task is restored (S411). Thereby, the task is switched to the type A task.
また、判定の結果が種別Bである場合には、タイムスロット切換部14は、タイムスロット情報100中のポインタにタスク管理ブロックの実行キューが接続されているか否か(ポインタが有効か無効か)を判定する(S412)。実行キューが接続されていると判定された場合には、優先度が最も高い先頭のタスク管理ブロックを取得し(S413)、当該タスク管理ブロック中のタスク情報に従って、当該タスクの状態を復帰させる(S411)。これにより種別Bのタスクのうち最も高い優先度のタスクに切り換えられる。また、実行キューが接続されていないと判定された場合は、実行可能な種別Bのタスクが存在しない。この場合、次のタイムスロット情報を選択するためにS403へ戻る。
When the determination result is type B, the time
上記S408において実行フラグが無効であれば(S408:no)、タイムスロット切換部14は再度S403、S404に戻って(S409:no)次のタイムスロットを選択する。さらに、この繰り返しによりn+1個のタスク管理情報が無効であった場合(S409:yes)、つまり、実行可能なタスクが1つも存在しない場合には、プログラム実行装置を省電力状態に移行させる(S410)。
If the execution flag is invalid in S408 (S408: no), the time
このように、タスクスケジューリング部10によるスケジューリング処理では、種別Aのタスクと種別Bのタスクとでは異なるスケジューリングをしている。すなわち、タスクスケジューリング部10は、種別Aのタイムスロット(タイムスロット情報1、2、・・に対応するタイムスロット)が選択された場合、当該タイムスロットに1つだけ割り当てられた種別Aのタスクに切り換える。また、タスクスケジューリング部10は、種別Bのタスクが割り当てられているタイムスロット(タイムスロット情報100に対応するタイムスロット)が選択された場合、種別Bの複数のタスクのうち優先度の最も高いタスクに切り換える。
As described above, in the scheduling process by the
また、図5及び図6に示した切換処理S1は、図10のスケジューリング処理とほぼ同様とすればよい。例えば、切換処理S1では図10スケジューリング処理におけるS412から開始するようにしてもよい。 Further, the switching process S1 shown in FIGS. 5 and 6 may be substantially the same as the scheduling process of FIG. For example, the switching process S1 may start from S412 in the scheduling process of FIG.
<2. タスク追加処理>
図11は、タスクスケジューリング部10におけるタスク追加処理の詳細を示すフローチャートである。このタスク追加処理はユーザ操作やユーザプログラム等からのタスク追加要求が発生した時点で開始される。
<2. Task addition processing>
FIG. 11 is a flowchart showing details of the task addition processing in the
タスク追加の要求を受けて、タスク受付部11は、追加すべきタスクのタスク情報、優先度及び割当時間を取得し(S501)、追加すべきタスクの種別が種別Aであるか種別Bであるか(当該優先度が0であるか0でないか)を判定する(S502)。
In response to the task addition request, the
追加すべきタスクが種別Aであると判定された場合、タスク受付部11は、タイムスロットの追加が可能かどうかを検査する。すなわち、タスク受付部11は、タイムスロット記憶部12から種別Aのタスクに対応するタイムスロット情報110、120、・・・内の割当時間を読み出して、その合計を算出し、当該合計に追加すべきタスクの割当時間を加えた総和が、周期レジスタ18に保持された周期値を超えていなければ、当該タスクに対応するタイムスロットの追加が可能であると判定する(S503)。当該周期値を超えている場合は、追加要求に対するエラーを返す(S504)。
When it is determined that the task to be added is type A, the
追加可能と判定されたならば、タスク受付部11は、割当時間と実行フラグ(この時点では0)とを設定したタイムスロット情報を生成して(S505)、タスク情報と優先度とを含むタスク管理ブロックを生成する(S506)。
If it is determined that the task can be added, the
タイムスロット情報とタスク管理ブロックが生成した後、タスク受付部11は、その対応関係を示すためにタスク管理ブロックの格納位置をタイムスロット情報のポインタにセットする(S507)。最後に当該タイムスロットの実行フラグを有効にする(S508)。
After the time slot information and the task management block are generated, the
上記S502において追加すべきタスクが種別Bであると判定された場合、タスク受付部11は、追加すべきタスクのタスク管理ブロックを生成し(S509)、タイムスロット情報100に対応する実行キューに追加する。実行キューへの追加は、実行キューの先頭から優先度の高い順に並ぶように、追加すべき位置を探索して当該タスク管理ブロックを追加する(S510)。また、タイムスロット情報100内の実行フラグに1をセットする(S508)。
If it is determined in S502 that the task to be added is type B, the
このように、追加処理では、既に存在するタイムスロット情報及びタスク管理ブロック(図2参照)に対して、追加すべきタスクが種別Aである場合は新たなタイムスロット情報と新たなタスク管理ブロックを追加し、追加すべきタスクが種別Bである場合は実行キューの優先度に応じた位置に新たなタスク管理ブロックを追加する。 As described above, in the addition process, when the task to be added is type A with respect to the existing time slot information and task management block (see FIG. 2), new time slot information and a new task management block are added. If the task to be added is type B, a new task management block is added at a position corresponding to the priority of the execution queue.
また、図5に示したタスク削除処理Eは、削除すべきタスクが種別Aである場合は、当該タスクに対応するタイムスロット情報とタスク管理ブロックを削除し、削除すべきタスクが種別Bである場合は、当該タスクに対応するタスク管理ブロック実行キューから削除する。 In the task deletion process E shown in FIG. 5, when the task to be deleted is type A, the time slot information and the task management block corresponding to the task are deleted, and the task to be deleted is type B. In this case, the task is deleted from the task management block execution queue corresponding to the task.
<3.mutexロック処理>
図12は、mutex制御部17によるロック処理の詳細を示すフローチャートである。このロック処理は、図6及び図7のロック処理Lであり、実行中のタスクが資源の1つをアクセスする直前に当該資源に対応するmutexをロックするために、実行中のタスクによって呼び出される処理である。
<3. mutex lock processing>
FIG. 12 is a flowchart showing details of the lock processing by the
実行中のタスクに呼び出されるとmutex制御部17は、資源に対応するmutex管理ブロックに対してロック変数の読み出しと有効値“1”の書き込みを行う(S601)。この読み出しと書き込みとの間に、他のタスクが同じ処理を行うことによって値に矛盾が生じることを防ぐために、読み出しと書き込みを一命令で行っている。これは、プロセッサに実装されている read-modify-write 命令により実現可能である。
When called by the task being executed, the
読み出されたロック変数が0(ロック解除状態)ならば(S602:yes)、ロック操作の成功であり、上記書き込みにより“1”をセット済であるのでロック処理を終了する。これにより、ロック処理を呼び出したタスクに実行制御が復帰し、当該タスクはmutexに対応する資源を専有してアクセスすることが可能になる。 If the read lock variable is 0 (unlocked state) (S602: yes), the lock operation is successful, and “1” has already been set by the above writing, and the lock process is terminated. As a result, execution control returns to the task that called the lock process, and the task can access the resource corresponding to the mutex exclusively.
読み出されたロック変数が1(ロック状態)ならば(S602:no)、すでに他のタスクにより資源が専有されているため、呼び出し元のタスクはロック解除状態になるまで、当該資源をアクセスすることができない。この場合、mutex制御部17は、呼び出し元のタスクが種別Aであるか種別Bであるかを判定する。
If the read lock variable is 1 (locked state) (S602: no), the resource is already occupied by another task, so the calling task accesses the resource until it is unlocked. I can't. In this case, the
判定結果が種別A(優先度が0)ならば(S603:yes)、対応するタイムスロット情報の実行フラグを無効にする(S604)。これにより当該タイムスロット情報はスケジューリング対象から除外される。加えて、mutex制御部17は呼び出し元のタスクのタスク管理ブロックを実行キューから外して、当該mutex管理ブロックの待ちキューにつなぐ(S605)。待ちキューにつなぐのは、どのmutexのロック解除待ち(どの資源の専有状態解除待ち)になっているかを示すためである。さらに、mutex制御部17は、スケジューリング処理Sを呼び出す(S606)。これにより当該タイムスロットは割当時間の途中でも強制的に次のタイムスロットに切り換わる(図7参照)。
If the determination result is type A (priority is 0) (S603: yes), the execution flag of the corresponding time slot information is invalidated (S604). As a result, the time slot information is excluded from the scheduling target. In addition, the
なお、S604において実行フラグを無効にする代わりに、タイムスロット情報のポインタが、種別Bのタスクの実行キューの先頭を指すように変更してもよい。これにより、種別Bのタスクが当該タイムスロットでも実行されることになる。 Instead of invalidating the execution flag in S604, the time slot information pointer may be changed to point to the head of the type B task execution queue. As a result, the type B task is also executed in the time slot.
判定結果が種別B(優先度が0でない)ならば(S603:no)、mutex制御部17は、呼び出し元のタスクのタスク管理ブロックを実行キューから外す(S607)。これにより当該タスクはスケジューリング対象から除外される。さらに、どの資源の専有状態が解除されるのを待っていることを示すために、前記タスク管理ブロックを mutex 管理ブロックの待ちキューに追加する(S608)。さらに、タスクの切換処理S1を呼び出すことにより次順位のタスクに切り換える(S609)。これによりタイムスロットの割当時間の残り時間において次順位のタスクが実行される(図6参照)。
If the determination result is type B (priority is not 0) (S603: no), the
<4.mutexロック解除処理>
図13は、mutex制御部17によるmutexロック解除処理の詳細を示すフローチャートである。この処理は、図8及び図9に示したロック解除処理Rであり、実行中のタスクが1つ資源のアクセスを終えたときに、当該実行中のタスクによって呼び出される処理である。
<4. Mutex unlock processing>
FIG. 13 is a flowchart showing details of the mutex lock release processing by the
呼び出されると、mutex制御部17は、当該資源に対応するmutex管理ブロックの待ちキューから先頭のタスク管理ブロックを取り出し(S701)、取り出したタスク管理ブロック内の優先度から待ち状態にあったタスクの種別を判定する(S702)。mutex制御部17は、優先度が0(種別A)ならば、取り出したタスク管理ブロックに対応するタイムスロット情報中の実行フラグを1(有効)にする(S703)。取り出したタスク管理ブロックに対応するタイムスロット情報は、例えば、実行フラグが0になっているタイムスロット情報に接続されているタスク管理ブロックのうち、取り出したタスク管理情報と同じタスク情報をもつタスク管理ブロックを検索することにより特定すればよい。さらに、mutex制御部17は、当該mutex管理ブロック内のロック変数に0を書き込む(ロック解除状態にする)(S705)。
When called, the
また、待ちキューから取り出したタスク管理ブロックの優先度が0でない(種別B)ならば、mutex制御部17は、当該タスク管理ブロックを種別Bのタスクの実行キューに追加する。実行キューへの追加は、先頭から優先度の高い順に並ぶ位置に追加し(S704)、当該mutex管理ブロック内のロック変数に0を書き込む。
If the priority of the task management block taken out from the waiting queue is not 0 (type B), the
このように、待ち状態になっていたタスクは、実行可能状態に戻るので、スケジューリングの対象となり、次に実行状態になったとき再度資源のロック操作を行うことができる。 In this way, the task that has been in the waiting state returns to the executable state, so that it becomes a target of scheduling, and the resource lock operation can be performed again when it enters the executing state next time.
以上説明してきたように本実施の形態におけるプログラム実行装置によれば、種別Aのタスクは1対1でタイムスロットを割り当てられる結果、一周期内で必ず選択実行されるので継続して処理性能を保証することができる。他方、種別Bのタスクは多対1で1つのタイムスロットを割り当てられる結果、継続して処理性能が保証されないが、優先度の高いものから実行されることになる。その結果、プログラマは、継続して処理性能を満たす必要のあるタスクに対しては優先度を考慮する必要もなく種別Aに分類するだけでよく、処理性能を要求しないタスクに対しては種別Bに分類すればよい。これにより、全てのタスクに対して個別に優先度を付与する必要がなくなり、処理性能を確保するためのプログラム設計を容易にすることができ、プログラム設計の柔軟性を確保することができる。 As described above, according to the program execution device of the present embodiment, the type A task is assigned one-to-one time slots, so that it is always selected and executed within one cycle, so that the processing performance is continuously improved. Can be guaranteed. On the other hand, a type B task is assigned one time slot in a many-to-one manner. As a result, the processing performance is not guaranteed continuously, but the task is executed from the one with the highest priority. As a result, the programmer does not need to consider the priority for tasks that need to continuously satisfy processing performance, and only needs to classify them as type A. For tasks that do not require processing performance, type B What is necessary is just to classify. As a result, it is not necessary to assign priorities to all tasks individually, program design for ensuring processing performance can be facilitated, and program design flexibility can be ensured.
なお、上記実施の形態では割当時間の指定はタスク情報に含まれている例を説明したが、タスク受付部11が外部から割当時間の指定を受ける構成としてもよい。また、割当時間の指定ない場合は既定の割当時間としてもよい。
In the above embodiment, the example in which the designation of the allocation time is included in the task information has been described. However, the
また、種別Aのタスクには1つのタスクに1つのタイムスロットが割り当てられているが、1つのタスクに2つ以上のタイムスロットを割り当てる構成としてもよい。 In addition, although one time slot is assigned to one task for a type A task, two or more time slots may be assigned to one task.
さらに、種別Bのタスクに対して、複数のタスクに1つのタイムスロットが割り当てられているが、固定された2つ以上のタイムスロットの何れかに割り当てるようにしてもよい。例えば、優先度が奇数のタスクをタイムスロットAに、偶数のタスクをタイムスロットBに割り当てる構成としてもよい。 Furthermore, although one time slot is assigned to a plurality of tasks for the type B task, it may be assigned to any one of two or more fixed time slots. For example, a task with an odd priority may be assigned to time slot A and an even task may be assigned to time slot B.
また、mutex管理ブロック内にロックしたタスク名を記録する所有タスク欄を設け、ロック解除されたとき、所有タスク欄を待ちキューから取り出したタスク名に書き換えて、ロック変数を有効なままにしてもよい。この場合、所有タスク欄に記憶されたタスクはロック操作を行わなくてもよく、確実に資源を使用することができるようになる。 In addition, an owned task column that records the name of the locked task is provided in the mutex management block, and when the lock is released, the owned task column is rewritten with the task name taken from the wait queue, and the lock variable remains valid. Good. In this case, the task stored in the owned task column does not need to be locked, and the resources can be used reliably.
最後に、プログラム実行装置の変形例を図14に示す。図1に示したプログラム実行装置の構成と比較して、タイムスロット切換と同時に切換可能な8つのレジスタセットRS0〜RS7を追加した点が異なっている。 Finally, a modification of the program execution device is shown in FIG. Compared with the configuration of the program execution apparatus shown in FIG. 1, the difference is that eight register sets RS0 to RS7 that can be switched simultaneously with time slot switching are added.
1つのレジスタセットは1つのタイムスロットに対応させて、タスクのコンテキストを保持する。 One register set corresponds to one time slot and holds a task context.
種別Bの複数のタスクは1つのレジスタセットに対応するので、種別Aのタスクのタイムスロットに切り換える際に、タスクスケジューリング部10は、上記実施の形態と同様にレジスタセットRS0に対する退避及び復帰を行う。
Since the plurality of type B tasks correspond to one register set, when switching to the time slot of the type A task, the
種別Aのタスクは1つのレジスタセットに対応するので、種別Aのタスクのタイムスロットに切り換える際に、タスクスケジューリング部10は、コンテキストの退避及び復帰の代わりにレジスタセットの切換を行う。この場合、コンテキストの退避及び復帰が不要となるので、タスク切換を高速化することができる。このことから、周期レジスタ18の周期及びタイムスロットの割当時間を極端に短くすることができる。例えば、種別Aのタイムスロット時間を退避及び復帰に要していた時間程度まで短くすることができ、一周期を短縮することができる。
Since the type A task corresponds to one register set, when switching to the time slot of the type A task, the
なお、図14におけるレジスタセットの数は任意の個数でよく、タイムスロットの数がレジスタセットの数よりも多い場合は、例えば、レジスタセットの何れかを複数のタイムスロットが兼用し、当該レジスタセットに対しては、タイムスロット切り換え時にコンテキストの退避及び復帰を行う構成とすればよい。 Note that the number of register sets in FIG. 14 may be an arbitrary number. When the number of time slots is larger than the number of register sets, for example, one of the register sets is shared by a plurality of time slots, and the register set On the other hand, the context may be saved and restored when switching the time slot.
また、図14においてレジスタセットの数を2としてもよい。その場合、レジスタセットの1つを実行中のタスクが使用する表レジスタセットとし、他の1つを次に実行されるタスクのコンテキストをバックグラウンド処理により復帰させておくための裏レジスタセットとしてもよい。この構成によれば、アイドル状態を利用してバックグラウンド処理によりコンテキストの復帰をすることができ、裏と表の2つのレジスタセットを効率よく切り換えることによる高速化を図ることができる。 In FIG. 14, the number of register sets may be two. In that case, one of the register sets may be a table register set used by the task being executed, and the other one may be a back register set for restoring the context of the task to be executed next by background processing. Good. According to this configuration, the context can be restored by background processing using the idle state, and the speed can be increased by efficiently switching between the two register sets of the back side and the front side.
さらに、レジスタセットの数が2のとき、ロック解除によって待ち状態から実行可能状態に復帰したタスクが存在し 当該タスクが次に実行されるタスクである場合には、裏レジスタセットに復帰したコンテキストが次に実行されるタスクのコンテキストと食い違う可能性がある。これに対しては以下の構成とすればよい。すなわち、ロック解除処理(図13参照)においてS705の直前に、待ち状態から実行可能状態に復帰したタスクが存在することを知らせる通知フラグを当該タスクのタスク管理ブロック内に設定するステップを追加し、スケジューリング処理(図10参照)において、S411の直前に、通知フラグが待ち状態から復帰したタスクであることを示していれば、当該タスクのコンテキストを裏レジスタセットに復帰してから、レジスタセットの裏と表とを切り換えるステップを追加した構成とすればよい。 Furthermore, when the number of register sets is 2, if there is a task that has returned from the wait state to the executable state due to unlocking, and that task is the next task to be executed, the context that has returned to the back register set is It may conflict with the context of the next task to be executed. The following configuration may be used for this. That is, a step of setting a notification flag in the task management block of the task informing that there is a task that has returned from the waiting state to the executable state immediately before S705 in the unlock processing (see FIG. 13), In the scheduling process (see FIG. 10), if the notification flag indicates that the task has returned from the wait state immediately before S411, the context of the task is returned to the back register set and then the back of the register set. And a step for switching between the table and the table may be added.
10 タスクスケジューリング部
11 タスク受付部
12 タイムスロット記憶部
13 タスク記憶部
14 タイムスロット切換部
15 タスク選択部
16 mutex記憶部
17 mutex制御部
18 周期レジスタ
20 プログラム記憶部
30 タイマ制御部
40 実行制御部
100、110、120 タイムスロット情報
100a、110a、120a 割当時間
100b、110b、120b 実行フラグ
100c、110c、120c ポインタ
200、201、202、210、220 タスク管理ブロック
200a、201a、202a、210a、220a タスク情報
200b、201b、202b、210b、220b 優先度
200c、201c、202c、210c、220c リンクアドレス
300、301 mutex管理ブロック
300a、301a ロック変数
300b、301b ポインタ
DESCRIPTION OF
Claims (19)
タスクとタイムスロットを対応付けるポインタ及び割当時間の指定を有する第1タイプの複数のタスクのそれぞれの割当時間を記憶するタイムスロット情報記憶手段と、
優先度を有する第2タイプの複数のタスクのそれぞれの優先度を記憶するタスク記憶手段と、
一周期内の複数のタイムスロットに対して、前記第1タイプの複数のタスクのそれぞれを前記ポインタに基づいて1タスク対1タイムスロットで1つのタイムスロットに割り当て、前記第2タイプの複数のタスクを前記ポインタに基づいて多タスク対1タイムスロットで前記第1タイプのタスクが割り当てられていない1つの特定のタイムスロットに割り当てる割当手段と、
前記タイムスロット情報記憶手段に記憶された前記第1タイプの複数のタスクのそれぞれに指定された割当時間に基づいてタイムスロットの切り換えを行うタイムスロット切換手段と、
前記特定のタイムスロット以外のタイムスロットに切り換えられた場合に、当該タイムスロットに割り当てられたタスクを選択し、前記特定のタイムスロットに切り換えられた場合に、第2タイプの複数のタスクから前記タスク記憶手段に記憶された前記優先度に基づいて1つのタスクを選択するタスク選択手段と
を備えることを特徴とするタスク切換装置。 A task switching device for switching execution of a task assigned to a time slot by switching the time slot in a processor,
Time slot information storage means for storing the allocation time of each of a plurality of tasks of the first type having a designation for associating a task with a time slot and an allocation time;
Task storage means for storing priorities of a plurality of second type tasks having priorities;
For each of a plurality of time slots in one cycle, each of the plurality of tasks of the first type is assigned to one time slot by one task vs. one time slot based on the pointer, and the plurality of tasks of the second type Assigning means to one specific time slot in which the first type task is not assigned in a multi-task vs. one time slot based on the pointer;
Time slot switching means for switching time slots based on the assigned time specified for each of the plurality of tasks of the first type stored in the time slot information storage means;
When the time slot is switched to a time slot other than the specific time slot, the task assigned to the time slot is selected, and when the time slot is switched to the specific time slot, the task is selected from a plurality of second type tasks. A task switching device comprising: task selection means for selecting one task based on the priority stored in the storage means.
前記タスク選択手段は、第2タイプの複数のタスクのうち優先度に従って1つのタスクを選択する
ことを特徴とする請求項1記載のタスク切換装置。 The second type of task has a priority;
The task switching device according to claim 1, wherein the task selecting unit selects one task according to a priority among a plurality of tasks of the second type.
ことを特徴とする請求項1又は2記載のタスク切換装置。 The allocating means sets a remaining time obtained by subtracting a total time of time slots to which a first type task is allocated from a predetermined period of time as a time of the specific time slot. The task switching device according to 1 or 2.
ことを特徴とする請求項3記載のタスク切換装置。 4. The task switching device according to claim 3, wherein the assigning unit recalculates the remaining time each time a new task of the first type is assigned to a time slot , and sets the time as the specific time slot. .
前記割当手段は、第1タイプの新たなタスクを追加しようとする場合、既に割当済のタスクの割当時間の合計と新たなタスクの割当時間との総和が一周期の時間を超えていれば、当該新たなタスクのタイムスロット割り当てを拒否する
ことを特徴とする請求項1記載のタスク切換装置。 The first type of task is a task having an assigned time designation;
When the allocation means intends to add a new task of the first type, if the sum of the allocation time of the tasks already allocated and the allocation time of the new task exceeds the time of one cycle, The task switching device according to claim 1, wherein the time slot assignment of the new task is rejected.
タスクによりアクセス可能な資源について、何れかのタスクからのアクセスによって資源がロック状態にあるか否かを示すロック情報を記憶する記憶手段と、
実行中のタスクがロック状態の資源をアクセスしようとしたとき、当該タスクを実行可能状態から待ち状態に変更し、当該資源のロック状態が解除されたとき待ち状態のタスクを実行可能状態に変更する変更手段と
を備え、
前記タスク選択手段は、待ち状態にあるタスクを選択対象から除外する
ことを特徴とする請求項1記載のタスク切換装置。 The task switching device further includes:
Storage means for storing lock information indicating whether or not the resource is locked by access from any task for the resource accessible by the task;
Running task when trying to access the resource in a locked state, to change the task from READY state to the waiting state, changes the task wait state when the lock state of the resource is released into the executable state Change means and
The task switching device according to claim 1, wherein the task selecting unit excludes a task in a waiting state from selection targets.
第1タイプ及び第2タイプのタスクのうち実行可能状態のタスクが1つも存在しない場合に、前記プロセッサを省電力状態に移行させる移行手段を備える
ことを特徴とする請求項6記載のタスク切換装置。 The task switching device further includes:
The task switching device according to claim 6, further comprising: a transition unit that shifts the processor to a power saving state when no task in an executable state among the first type task and the second type task exists. .
前記タスク切換装置は、さらに、
レジスタセットの1つを実行中のタスクの使用に供し、他の1つのレジスタセットに対して次に実行すべきタスクのコンテキストをバックグラウンド処理により復帰させ、タイムスロットの切換時にレジスタセットを切り換える切換手段を備える
こと特徴とする請求項1から7の何れかに記載のタスク切換装置。 The processor includes at least two register sets for holding a task context;
The task switching device further includes:
Switching one register set to use a running task, returning the context of the next task to be executed to another register set by background processing, and switching the register set when switching time slots The task switching device according to claim 1, further comprising: means.
一周期内のタイムスロットに対して、割当時間の指定を有する第1タイプのタスクに対して1タスク対1タイムスロットで1つのタスクに1つのタイムスロットを割り当て、当該タイムスロット毎に対応するタスクの割当時間を含むタイムスロット情報を生成する第1生成手段と、
優先度を有する第2タイプのタスクに対して複数のタスクを多タスク対1タイムスロットで前記周期内の前記第1タイプのタスクが割り当てられていない特定の1つのタイムスロットに割り当て、特定のタイムスロットの割当時間を含む1つのタイムスロット情報を生成する第2生成手段と、
タイムスロットに割り当てられたタスク毎にタスクのアドレスを含むタスク管理情報を生成する第3生成手段と、
生成されたタイムスロット情報とタスク管理情報とをポインタにより対応させて記憶する記憶手段と、
前記記憶手段に記憶されたタイムスロット情報の割当時間に基づいて一周期内で少なくとも1つずつタイムスロットを選択する選択手段と、
第1タイプのタスクが割り当てられているタイムスロット情報が選択された場合に、前記ポインタにより当該タイムスロット情報に対応するタスク管理情報が示すタスクを実行させ、第2タイプのタスクが割り当てられているタイムスロット情報が選択された場合に、前記ポインタにより当該タイムスロット情報に対応する複数のタスク管理情報から優先度に従って1つを選択して、選択したタスク管理情報が示すタスクを実行させる制御手段と
を備えることを特徴とするタスク切換装置。 A task switching device for switching a task to be executed in a processor by switching a time slot to which a task is assigned,
For a time slot within one period, one time slot is assigned to one task with one task vs. one time slot for a first type task having an assigned time designation, and a task corresponding to each time slot. First generation means for generating time slot information including the allocated time of:
A plurality of tasks for a second type task having priority are assigned to a specific one time slot in which the first type task in the cycle is not assigned in a multi-task vs. one time slot, and a specific time a second generating means for generating a single time slot information including between time assignment slots,
A third generating means for generating a task management information including the address of the task for each task assigned to the time slot,
Storage means for storing the generated time slot information and task management information in correspondence with each other by a pointer;
Selecting means for selecting at least one time slot within one period based on the allocated time of the time slot information stored in the storage means;
When the time slot information to which the first type task is assigned is selected, the task indicated by the task management information corresponding to the time slot information is executed by the pointer, and the second type task is assigned. Control means for selecting one of a plurality of task management information corresponding to the time slot information according to the priority by the pointer and executing a task indicated by the selected task management information when the time slot information is selected; A task switching device comprising:
前記制御手段は、キューの先頭のタスク管理情報に対応するタスクを選択する
ことを特徴とする請求項9記載のタスク切換装置。 The storage means stores task management information of the second type task as a queue arranged in order of priority,
The task switching device according to claim 9, wherein the control means selects a task corresponding to the task management information at the head of the queue.
ことを特徴とする請求項10記載のタスク切換装置。 The second generation means sets the difference between the period and the total of the allocation time of all tasks of the first type in the time slot information corresponding to the specific time slot as the allocation time of the specific time slot. The task switching device according to claim 10.
ことを特徴とする請求項11記載のタスク切換装置。 The second generation means recalculates the remaining time as the difference every time a time slot is assigned to a new task of the first type by the first generation means to obtain the assigned time of the specific time slot. The task switching device according to claim 11.
前記タスク切換装置は、さらに、
実行中のタスクがロック状態の資源をアクセスしようとしたとき、記憶手段に記憶された当該タスクのタスク管理情報とタイムスロット情報との対応関係を切り離し、当該タスク管理情報を待ちキューとして記憶させ、当該資源がロック状態を解除されたとき待ちキュー内のタスク管理情報をタイムスロット情報に対応させて記憶させるキュー管理手段を有する
ことを特徴とする請求項12記載のタスク切換装置。 The storage means further stores lock information indicating whether or not a resource accessible by a task is locked by access from any task,
The task switching device further includes:
When an executing task tries to access a resource in a locked state, the correspondence between the task management information and the time slot information of the task stored in the storage unit is disconnected, and the task management information is stored as a wait queue. The task switching device according to claim 12, further comprising queue management means for storing task management information in the waiting queue in association with time slot information when the resource is released from the locked state.
前記タスク切換装置は、さらに、
レジスタセットの1つを実行中のタスクの使用に供し、他の1つのレジスタセットに対して次に実行すべきタスクのコンテキストをバックグラウンド処理により復帰させ、タイムスロットの切換時にレジスタセットを切り換えるレジスタセット切換手段を備える
こと特徴とする請求項13記載のタスク切換装置。 The processor includes at least two register sets for holding a task context;
The task switching device further includes:
A register that uses one of the register sets for the task being executed, restores the context of the next task to be executed to the other one register set by background processing, and switches the register set when the time slot is switched The task switching device according to claim 13, further comprising set switching means.
タスクとタイムスロットを対応付けるポインタ及び割当時間の指定を有する第1タイプの複数のタスクのそれぞれの割当時間を記憶する割当時間記憶ステップと、
優先度を有する第2タイプの複数のタスクのそれぞれの優先度を記憶する優先度記憶ステップと、
一周期内のタイムスロットに対して、前記第1タイプの複数のタスクのそれぞれを前記ポインタに基づいて1タスク対1タイムスロットで1つのタイムスロットに割り当て、第1タイプとは異なる前記第2タイプの複数のタスクを前記ポインタに基づいて多タスク対1タイムスロットで前記第1タイプのタスクが割り当てられていない1つの特定のタイムスロットに割り当てる割当ステップと、
前記割当時間記憶ステップ記憶された前記第1タイプの複数のタスクのそれぞれに指定された割当時間に基づいてタイムスロットの切り換えを行うタイムスロット切換ステップと、
前記特定のタイムスロット以外のタイムスロットに切り換えられた場合に、当該タイムスロットに割り当てられたタスクを選択し、前記特定のタイムスロットに切り換えられた場合に、第2タイプの複数のタスクから前記優先度記憶ステップで記憶された前記優先度に基づいて1つのタスクを選択するタスク選択ステップと
を有することを特徴とするタスク切換方法。 A task switching method for switching execution of a task assigned to a time slot by switching the time slot in a processor,
An allocation time storage step of storing each allocation time of a plurality of tasks of the first type having a designation for associating a task with a time slot and an allocation time;
A priority storing step for storing the priority of each of the plurality of tasks of the second type having priority;
For each time slot within one period, each of the plurality of tasks of the first type is assigned to one time slot in one task vs. one time slot based on the pointer, and the second type is different from the first type. Assigning a plurality of tasks to one specific time slot in which the first type task is not assigned in a multi-task versus one time slot based on the pointer;
A time slot switching step for switching a time slot based on the assigned time designated for each of the plurality of tasks of the first type stored in the assigned time storage step;
When the time slot is switched to a time slot other than the specific time slot, the task assigned to the time slot is selected, and when the time slot is switched to the specific time slot, the priority is given to a plurality of second type tasks. A task selection step of selecting one task based on the priority stored in the degree storage step.
前記プログラムは、
タスクとタイムスロットを対応付けるポインタ及び割当時間の指定を有する第1タイプの複数のタスクのそれぞれの割当時間を記憶する割当時間記憶ステップと、
優先度を有する第2タイプの複数のタスクのそれぞれの優先度を記憶する優先度記憶ステップと、
一周期内のタイムスロットに対して、前記第1タイプの複数のタスクのそれぞれを前記ポインタに基づいて1タスク対1タイムスロットで1つのタイムスロットに割り当て、第1タイプとは異なる前記第2タイプの複数のタスクを前記ポインタに基づいて多タスク対1タイムスロットで前記第1タイプのタスクが割り当てられていない1つの特定のタイムスロットに割り当てる割当ステップと、
前記割当時間記憶ステップ記憶された前記第1タイプの複数のタスクのそれぞれに指定された割当時間に基づいてタイムスロットの切り換えを行うタイムスロット切換ステップと、
切り換え後のタイムスロットが前記特定のタイムスロットでない場合、当該タイムスロットに割り当てられたタスクを選択し、切り換え後のタイムスロットが前記特定のタイムスロットである場合、第2タイプの複数のタスクから前記優先度記憶ステップで記憶された前記優先度に基づいて1つのタスクを選択して実行させるタスク選択ステップと
を前記プロセッサに実行させることを特徴とするプログラム。 A program for switching execution of a task assigned to a time slot by switching the time slot in a processor,
The program is
An allocation time storage step of storing each allocation time of a plurality of tasks of the first type having a designation for associating a task with a time slot and an allocation time;
A priority storing step for storing the priority of each of the plurality of tasks of the second type having priority;
For each time slot within one period, each of the plurality of tasks of the first type is assigned to one time slot in one task vs. one time slot based on the pointer, and the second type is different from the first type. Assigning a plurality of tasks to one specific time slot in which the first type task is not assigned in a multi-task versus one time slot based on the pointer;
A time slot switching step for switching a time slot based on the assigned time designated for each of the plurality of tasks of the first type stored in the assigned time storage step;
When the time slot after switching is not the specific time slot, the task assigned to the time slot is selected, and when the time slot after switching is the specific time slot, the plurality of tasks of the second type A program that causes the processor to execute a task selection step of selecting and executing one task based on the priority stored in the priority storage step.
タスクとタイムスロットを対応付けるポインタ及び割当時間の指定を有する第1タイプの複数のタスクのそれぞれの割当時間及び優先度を有する第2タイプの複数のタスクのそれぞれの優先度を記憶する記憶手段と、
一周期内の複数のタイムスロットに対して、前記第1タイプの複数のタスクのそれぞれを前記ポインタに基づいて1タスク対1タイムスロットで1つのタイムスロットに割り当て、前記第2タイプの複数のタスクを前記ポインタに基づいて多タスク対1タイムスロットで前記第1タイプのタスクが割り当てられていない1つの特定のタイムスロットに割り当てる割当手段と、
前記記憶手段に記憶された前記第1タイプの複数のタスクのそれぞれに指定された割当時間に基づいてタイムスロットの切り換えを行うタイムスロット切換手段と、
前記特定のタイムスロット以外のタイムスロットに切り換えられた場合に、当該タイムスロットに割り当てられたタスクを選択し、前記特定のタイムスロットに切り換えられた場合に、第2タイプの複数のタスクから前記記憶手段に記憶された前記優先度に基づいて1つのタスクを選択するタスク選択手段と
を備えることを特徴とするタスク切換装置。 A task switching device for switching execution of a task assigned to a time slot by switching the time slot in a processor,
Storage means for storing the priority of each of the plurality of tasks of the second type having the allocation time and priority of each of the plurality of tasks of the first type having a pointer that associates the task with the time slot and designation of the allocation time;
For each of a plurality of time slots in one cycle, each of the plurality of tasks of the first type is assigned to one time slot by one task vs. one time slot based on the pointer, and the plurality of tasks of the second type Assigning means to one specific time slot in which the first type task is not assigned in a multi-task vs. one time slot based on the pointer;
Time slot switching means for switching time slots based on an assigned time specified for each of the plurality of tasks of the first type stored in the storage means;
When the time slot is switched to a time slot other than the specific time slot, the task assigned to the time slot is selected, and when the time slot is switched to the specific time slot, the plurality of tasks of the second type store the memory. A task switching device comprising: task selection means for selecting one task based on the priority stored in the means.
割当時間の指定を有する第1タイプの複数のタスクのそれぞれの割当時間及び優先度を有する第2タイプの複数のタスクのそれぞれの優先度を記憶する記憶手段と、
一周期内の複数のタイムスロットに対して、前記第1タイプの複数のタスクのそれぞれを1タスク対1タイムスロットで1つのタイムスロットに割り当て、前記第2タイプの複数のタスクを多タスク対1タイムスロットで前記第1タイプのタスクが割り当てられていない1つの特定のタイムスロットに割り当てる割当手段と、
前記記憶手段に記憶された前記第1タイプの複数のタスクのそれぞれに指定された割当時間に基づいてタイムスロットの切り換えを行うタイムスロット切換手段と、
前記特定のタイムスロット以外のタイムスロットに切り換えられた場合に、当該タイムスロットに割り当てられたタスクを選択し、前記特定のタイムスロットに切り換えられた場合に、第2タイプの複数のタスクから前記記憶手段に記憶された前記優先度に基づいて1つのタスクを選択するタスク選択手段と
を備えることを特徴とするタスク切換装置。 A task switching device for switching execution of a task assigned to a time slot by switching the time slot in a processor,
Storage means for storing respective allocation times and priorities of a plurality of second type tasks having priorities of a plurality of first type tasks having an allocation time designation;
For each of a plurality of time slots in one cycle, each of the plurality of tasks of the first type is assigned to one time slot by one task to one time slot, and the plurality of tasks of the second type are assigned to a multitask pair. Allocating means for allocating to one specific time slot to which the first type task is not allocated in a time slot;
Time slot switching means for switching time slots based on an assigned time specified for each of the plurality of tasks of the first type stored in the storage means;
When the time slot is switched to a time slot other than the specific time slot, the task assigned to the time slot is selected, and when the time slot is switched to the specific time slot, the plurality of tasks of the second type store the memory. A task switching device comprising: task selection means for selecting one task based on the priority stored in the means.
割当時間の指定を有する第1タイプの複数のタスク及び優先度を有する第2タイプの複数のタスクとを受け付け、前記第1タイプの複数のタスクのそれぞれの割当時間及び前記第2タイプの複数のタスクのそれぞれの優先度とを取得するタスク受付手段と、
一周期内の複数のタイムスロットに対して、前記第1タイプの複数のタスクのそれぞれを1タスク対1タイムスロットで1つのタイムスロットに割り当て、前記第2タイプの複数のタスクを多タスク対1タイムスロットで前記第1タイプのタスクが割り当てられていない1つの特定のタイムスロットに割り当てる割当手段と、
前記タスク受付手段で取得された前記第1タイプの複数のタスクのそれぞれに指定された割当時間に基づいてタイムスロットの切り換えを行うタイムスロット切換手段と、
前記特定のタイムスロット以外のタイムスロットに切り換えられた場合に、当該タイムスロットに割り当てられたタスクを選択し、前記特定のタイムスロットに切り換えられた場合に、第2タイプの複数のタスクから前記優先度に基づいて1つのタスクを選択するタスク選択手段と
を備えることを特徴とするタスク切換装置。 A task switching device for switching execution of a task assigned to a time slot by switching the time slot in a processor,
Receiving a plurality of first type tasks having designation of allocation time and a plurality of second type tasks having priority, and assigning each of the plurality of first type tasks and a plurality of second type tasks Task accepting means for obtaining the priority of each task;
For each of a plurality of time slots in one cycle, each of the plurality of tasks of the first type is assigned to one time slot by one task to one time slot, and the plurality of tasks of the second type are assigned to a multitask pair. Allocating means for allocating to one specific time slot to which the first type task is not allocated in a time slot;
Time slot switching means for switching time slots based on the assigned time specified for each of the plurality of tasks of the first type acquired by the task receiving means;
When the time slot is switched to a time slot other than the specific time slot, the task assigned to the time slot is selected, and when the time slot is switched to the specific time slot, the priority is given to a plurality of second type tasks. And a task selection means for selecting one task based on the degree.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2008282507A JP4857325B2 (en) | 2008-10-31 | 2008-10-31 | Task switching device, method and program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2008282507A JP4857325B2 (en) | 2008-10-31 | 2008-10-31 | Task switching device, method and program |
Related Parent Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2003068831A Division JP4750350B2 (en) | 2003-03-13 | 2003-03-13 | Task switching device, method and program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2009080820A JP2009080820A (en) | 2009-04-16 |
JP4857325B2 true JP4857325B2 (en) | 2012-01-18 |
Family
ID=40655480
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2008282507A Expired - Lifetime JP4857325B2 (en) | 2008-10-31 | 2008-10-31 | Task switching device, method and program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP4857325B2 (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5721664B2 (en) * | 2012-05-28 | 2015-05-20 | 京セラドキュメントソリューションズ株式会社 | Image forming apparatus |
JP5868535B2 (en) * | 2015-03-17 | 2016-02-24 | 京セラドキュメントソリューションズ株式会社 | Image forming apparatus |
WO2018061459A1 (en) * | 2016-09-30 | 2018-04-05 | 株式会社日立製作所 | Wireless battery system |
US11809219B2 (en) * | 2018-07-02 | 2023-11-07 | Drivenets Ltd. | System implementing multi-threaded applications |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2866241B2 (en) * | 1992-01-30 | 1999-03-08 | 株式会社東芝 | Computer system and scheduling method |
JP2760721B2 (en) * | 1992-11-12 | 1998-06-04 | 三菱電機株式会社 | Computer system |
JPH07295694A (en) * | 1994-04-25 | 1995-11-10 | Matsushita Electric Ind Co Ltd | Power saving method for arithmetic processor |
JPH1011301A (en) * | 1996-06-25 | 1998-01-16 | Masaharu Imai | Multitask processor and multitask processing control method |
JPH10240548A (en) * | 1997-03-03 | 1998-09-11 | Toshiba Corp | Task scheduling device and method |
JP2000056989A (en) * | 1998-08-03 | 2000-02-25 | Chokosoku Network Computer Gijutsu Kenkyusho:Kk | Task designing method |
JP2001202258A (en) * | 2000-01-20 | 2001-07-27 | Yaskawa Electric Corp | Rear time processor |
JP4292705B2 (en) * | 2000-11-24 | 2009-07-08 | パナソニック株式会社 | Task scheduling device |
-
2008
- 2008-10-31 JP JP2008282507A patent/JP4857325B2/en not_active Expired - Lifetime
Also Published As
Publication number | Publication date |
---|---|
JP2009080820A (en) | 2009-04-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4750350B2 (en) | Task switching device, method and program | |
US9678497B2 (en) | Parallel processing with cooperative multitasking | |
JP6897574B2 (en) | Accelerator controller, accelerator control method and program | |
CN106371894B (en) | Configuration method and device and data processing server | |
EP2288990B1 (en) | Scheduling collections in a scheduler | |
WO2017166777A1 (en) | Task scheduling method and device | |
US7596788B1 (en) | Support of non-trivial scheduling policies along with topological properties | |
JP5643190B2 (en) | Method and computer-readable recording medium for assigning tasks in a local set to a general set | |
EP0969380A2 (en) | Method for efficient non-virtual main memory management | |
US20050097384A1 (en) | Data processing system with fabric for sharing an I/O device between logical partitions | |
JP2006515690A (en) | Data processing system having a plurality of processors, task scheduler for a data processing system having a plurality of processors, and a corresponding method of task scheduling | |
JP2511397B2 (en) | Multiprocessor data processing system and operating method thereof | |
JPH0533410B2 (en) | ||
EP1923784A1 (en) | Scheduling method, and scheduling device | |
EP2581833A1 (en) | Multi-core processor system, control program, and method of control | |
JP2009059310A (en) | Program controller | |
JP4857325B2 (en) | Task switching device, method and program | |
CN108990422B (en) | Lock distribution method and device and computing equipment | |
JP5158576B2 (en) | I / O control system, I / O control method, and I / O control program | |
CN115408117A (en) | Coroutine operation method and device, computer equipment and storage medium | |
WO2007039933A1 (en) | Operation processing device | |
JP2007241922A (en) | Arbitration method for use of shared resource, and arbitration device therefor | |
JP2011248469A (en) | Information processing apparatus and information processing method | |
JP2023179057A (en) | Arithmetic processing unit and arithmetic processing method | |
KR0170197B1 (en) | Virtual system for parallel processing of desk in high speed parallel computer |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20110613 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20110621 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20110808 |
|
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: 20111025 |
|
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20111031 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20141104 Year of fee payment: 3 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 4857325 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
S111 | Request for change of ownership or part of ownership |
Free format text: JAPANESE INTERMEDIATE CODE: R313111 |
|
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 |
|
EXPY | Cancellation because of completion of term |