JP4156148B2 - Task scheduling device - Google Patents
Task scheduling device Download PDFInfo
- Publication number
- JP4156148B2 JP4156148B2 JP30213599A JP30213599A JP4156148B2 JP 4156148 B2 JP4156148 B2 JP 4156148B2 JP 30213599 A JP30213599 A JP 30213599A JP 30213599 A JP30213599 A JP 30213599A JP 4156148 B2 JP4156148 B2 JP 4156148B2
- Authority
- JP
- Japan
- Prior art keywords
- task
- switching
- value
- instruction
- output
- 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 - Fee Related
Links
Images
Description
【0001】
【発明の属する技術分野】
本発明は、マルチタスキング機能を備えたタスクスケジューリング装置およびタスク切り替え方法に関するものである。
【0002】
【従来の技術】
マルチタスキング機能を備えたマイクロコントローラにおいて、プロセッサが単一の場合、複数のタスクの中から1つのタスクが選択され、その選択されたタスクがプロセッサによって実行される。
【0003】
処理サイクル数が異なる複数のハードウェアエンジンをマルチタスクによって制御しようとする場合、複数のハードウェアエンジンのそれぞれに複数のタスクを対応させ、ハードウェアエンジンの実行処理が終了すると、タスクの切り替えが行なわれる。
【0004】
【発明が解決しようとする課題】
しかしながら、上記従来のマイクロコントローラでは、タスク切り替えをハードウェアエンジンの実行終了によって行なうため、マイクロコントローラのプログラム上から、タスク切り替えが起きるタイミングを制御することが非常に困難である。
【0005】
そのため、マルチタスクを用いたコントローラでは、タスク切り替えのタイミングに依存したハードウェアの機能テストおよびプログラムの開発には手間が掛かるという課題があった。
【0006】
本発明は、上記従来の課題を解決するもので、タスク切り替えのタイミング制御を容易に行なうことができるタスクスケジューリング装置およびタスク切り替え方法を提供することを目的とする。
【0007】
【課題を解決するための手段】
この目的を達成するために、本発明のタスクスケジューリング装置は、命令によって設定されたサイクル数後にタスク切り替えが発生する機構を設けた構成をとっている。
【0008】
すなわち、本発明のタスクスケジューリング装置は、複数のタスクから一つのタスクを選択し、シーケンシャルに実行するマイクロコントローラを有し、実行中のタスクで命令を発行すると所定サイクル後に、タスク切り替えを行なうことを特徴とする。
【0009】
また、本発明のタスクの切り替え方法は、実行中のタスクでの命令によって設定値を指定する第1のステップと、値をカウントする第2のステップと、前記カウントされた値と前記設定値とを比較する第3のステップと、次に実行すべきタスクを選択する第4のステップとを含み、前記第3のステップにおいて、前記カウントされた値と前記設定値とが等しい場合にタスク切り替えを発生することを特徴とする。
【0010】
【発明の実施の形態】
以下、本発明の実施形態について、図面を参照しながら説明する。
【0011】
(実施の形態1)
図1は、本発明の実施形態1に係るタスクスケジューリング装置の構成を示すものである。
【0012】
図1において、101はプロセッサであり、タスクのプログラムが解読され、命令が実行される。
【0013】
120〜122はハードウェアエンジン0、1、2であり、プロセッサ101からの起動信号130、131、132によって起動され、それぞれの処理実行が開始され、処理が終了すると、終了信号140、141、142が生成される。
【0014】
102はスケジューラであり、タスク切り替え時にタスクの選択が行なわれる。
110、111、112はタスク0、1、2であり、各タスクについてのプログラムのどの位置まで実行されたなどの情報が退避される。
【0015】
103はカウンタであり、プロセッサ101からの命令134により、カウントが開始され、そのカウント値がカウンタ出力135として出力される。
【0016】
104は比較器であり、カウンタ出力135と所定の値とが比較され、その結果が比較出力136として出力される。
【0017】
105は、論理和であり、終了信号140〜142、比較出力136の論理和を生成し、タスク切り替え信号137として出力される。
【0018】
以上のように構成された本実施形態について、以下に、タスク切り替え時の動作を説明する。
【0019】
プロセッサ101においてタスク0が実行されており、タスク0のプログラムによって命令134が発行されたとする。
【0020】
カウンタ103では、命令134が発行されると、0を初期値としてサイクル毎に、0,1,2,3,...とインクリメントが行なわれ、それがカウンタ出力135として出力される。
【0021】
比較器104では、カウンタ出力135が入力されると、所定の値、例えば、"10"と比較される。
【0022】
カウンタ出力135が"10"でない場合、比較出力136として、"0"が出力される。カウンタ出力135が"10"である場合、比較出力136として、"1"が出力される。比較出力136は、論理和105で、終了信号140〜142との論理がとられ、タスク切り替え信号137が生成される。
【0023】
スケジューラ102では、タスク切り替え信号137が入力されると、それまで実行されていたタスク0のプログラム上の実行位置がタスク0(110)に退避され、次に実行すべきタスクが選択される。
【0024】
例えば、タスク1が選択されたとすると、タスク1(111)に退避されているタスク1の実行位置がプロセッサに送られ、タスク1のプログラム実行が開始される。
【0025】
以上、説明したように、本実施形態によれば、タスク0に記述された命令の発行から、所定値"10"サイクル後にタスク切り替えを発生することができる。
【0026】
(実施の形態2)
図2は、本発明の実施形態2に係るタスクスケジューリング装置の構成を示すものである。
【0027】
図2において、203はカウンタであり、プロセッサ101からの初期値設定命令234により、カウントの初期の設定がされると、カウントが開始され、そのカウント値がカウンタ出力235として出力される。
【0028】
104は比較器であり、カウンタ出力235と所定の値とが比較され、その結果が比較出力236として出力される。
【0029】
以上のように構成された本実施形態について、以下に、タスク切り替え時の動作を説明する。
【0030】
プロセッサ101においてタスク0が実行されており、タスク0のプログラムによって初期値設定命令234が発行されたとする。
【0031】
カウンタ203では、初期値設定命令234が発行されると、初期値設定命令234で指定された値を初期値として、サイクル毎に、デクリメントが行なわれる。
【0032】
例えば、初期値が"10"である場合、サイクル毎に、10,9,8,7,...とデクリメントが行なわれ、それがカウンタ出力235として出力される。
【0033】
比較器204では、カウンタ出力235が入力されると、所定の値、例えば、"0"と比較される。
【0034】
カウンタ出力235が"0"でない場合、比較出力236として、"0"が出力される。カウンタ出力235が"0"である場合、比較出力236として、"1"が出力される。以下、同様に、タスク切り替え信号137が生成され、タスク切り替えが行なわれる。
【0035】
以上、説明したように、タスク0に記述された命令によって、設定されたサイクル後にタスク切り替えを発生することができる。
【0036】
(実施の形態3)
図3は、本発明の実施形態3に係るタスクスケジューリング装置の構成を示すものである。
【0037】
図3において、322はハードウェアエンジン3であり、プロセッサ101からの起動信号334によって起動され、それぞれの処理実行が開始され、処理が終了すると、終了信号343が生成される。
【0038】
論理和105では、終了信号343と終了信号140〜142との論理和が生成され、タスク切り替え信号107として出力される。
【0039】
以上のように構成された本実施形態について、以下に、タスク切り替え時の動作を説明する。
【0040】
プロセッサ101においてタスク0が実行されており、タスク0のプログラムによってハードウェアエンジン3の起動命令が発行されたとする。
【0041】
ハードウェアエンジン3の起動命令が発行されると、起動信号3(334)が生成され、同時にカウンタ初期値がハードウェアエンジン3(322)に送られる。
【0042】
ハードウェアエンジン3(322)では、送られてきたカウンタ初期値から、サイクル毎にデクリメントが行なわれ、カウント値が、"0"である場合、終了信号3(343)が生成される。以下、同様に、タスク切り替え信号107が生成され、タスク切り替えが行なわれる。
【0043】
以上、説明したように、タスク0に記述された命令によって設定されたサイクル後にタスク切り替えを発生することができる。
【0044】
(実施の形態4)
図4は、本発明の実施形態4に係るタスク切り替え方法のフローチャートである。
【0045】
図4において、第1のステップS1において、実行中のタスクのプログラム中の命令によって設定値が指定される。この設定値は、命令が発行されてからタスク切り替えが行なわれるまでのサイクル数を指定するものである。
【0046】
第2のステップS2において、カウントが開始される。カウントの初期値は"0"とし、毎サイクルごとにカウント値をインクリメントされる。
【0047】
第3のステップS3において、第1のステップS1で指定された設定値と第2のステップでカウントされたカウント値とが比較される。
【0048】
設定値とカウント値が等しくない場合、第2のステップS2へ戻る。設定値とカウント値が等しい場合、第4のステップS4へ進む。
【0049】
第4のステップS4において、次に実行すべきタスクの選択が行なわれる。
【0050】
以上のように、本実施形態によれば、実行中のタスクに記述された命令によって設定されたサイクル後にタスク切り替えを発生することができる。
【0051】
【発明の効果】
本発明は、命令によって設定されたサイクル数後にタスク切り替えが発生する機構を設けることにより、タスク切り替えのタイミング制御を容易に行なうことができる。
【図面の簡単な説明】
【図1】本発明の実施の形態1におけるタスクスケジューリング装置を示すブロック図
【図2】本発明の実施の形態2におけるタスクスケジューリング装置を示すブロック図
【図3】本発明の実施の形態3におけるタスクスケジューリング装置を示すブロック図
【図4】本発明の実施の形態4におけるタスク切り替え方法のフローチャート
【符号の説明】
100 マイクロコントローラ
101 プロセッサ
102 スケジューラ
103 カウンタ
104 比較器
105 論理和
110 タスク0
111 タスク1
112 タスク2
120 ハードウェアエンジン0
121 ハードウェアエンジン1
122 ハードウェアエンジン2
130 起動信号0
131 起動信号1
132 起動信号2
134 命令
135 カウンタ出力
136 比較出力
137 タスク切り替え信号
140 終了信号0
141 終了信号1
142 終了信号2
203 カウンタ
204 比較器
234 初期値設定命令
235 カウンタ出力
236 比較出力
322 ハードウェアエンジン3
334 起動信号3
343 終了信号3[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a task scheduling device having a multitasking function and a task switching method.
[0002]
[Prior art]
In a microcontroller having a multitasking function, when a single processor is used, one task is selected from a plurality of tasks, and the selected task is executed by the processor.
[0003]
When trying to control multiple hardware engines with different number of processing cycles by multitasking, associate multiple tasks with each of the multiple hardware engines, and switch the task when the hardware engine execution process is completed. It is.
[0004]
[Problems to be solved by the invention]
However, in the above-described conventional microcontroller, task switching is performed upon completion of execution of the hardware engine, so it is very difficult to control the timing at which task switching occurs from the microcontroller program.
[0005]
For this reason, a controller using multitasking has a problem that it takes time to develop a hardware function test and program depending on task switching timing.
[0006]
An object of the present invention is to solve the above-described conventional problems, and to provide a task scheduling apparatus and a task switching method that can easily perform task switching timing control.
[0007]
[Means for Solving the Problems]
In order to achieve this object, the task scheduling apparatus of the present invention has a configuration in which a mechanism for switching tasks occurs after the number of cycles set by an instruction.
[0008]
That is, the task scheduling apparatus of the present invention has a microcontroller that selects one task from a plurality of tasks and executes it sequentially, and performs task switching after a predetermined cycle when an instruction is issued in the task being executed. Features.
[0009]
The task switching method of the present invention includes a first step of designating a set value by an instruction in a task being executed, a second step of counting a value, the counted value, and the set value. And a fourth step of selecting a task to be executed next. In the third step, the task switching is performed when the counted value is equal to the set value. It is generated.
[0010]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
[0011]
(Embodiment 1)
FIG. 1 shows the configuration of a task scheduling apparatus according to Embodiment 1 of the present invention.
[0012]
In FIG. 1,
[0013]
[0014]
A
[0015]
[0016]
A
[0017]
[0018]
With respect to the present embodiment configured as described above, the operation at the time of task switching will be described below.
[0019]
It is assumed that task 0 is executed in
[0020]
In the
[0021]
In the
[0022]
When the counter output 135 is not “10”, “0” is output as the comparison output 136. When the counter output 135 is “10”, “1” is output as the comparison output 136. The comparison output 136 is a
[0023]
In the
[0024]
For example, if task 1 is selected, the execution position of task 1 saved in task 1 (111) is sent to the processor, and program execution of task 1 is started.
[0025]
As described above, according to the present embodiment, task switching can occur after a predetermined value “10” cycles from the issue of the instruction described in task 0.
[0026]
(Embodiment 2)
FIG. 2 shows a configuration of a task scheduling apparatus according to the second embodiment of the present invention.
[0027]
In FIG. 2,
[0028]
A
[0029]
With respect to the present embodiment configured as described above, the operation at the time of task switching will be described below.
[0030]
It is assumed that task 0 is executed in
[0031]
When the initial value setting command 234 is issued, the
[0032]
For example, when the initial value is “10”, decrementing is performed every cycle as 10, 9, 8, 7,..., And it is output as the counter output 235.
[0033]
When the counter output 235 is input to the
[0034]
When the counter output 235 is not “0”, “0” is output as the comparison output 236. When the counter output 235 is “0”, “1” is output as the comparison output 236. Thereafter, similarly, a task switching signal 137 is generated and task switching is performed.
[0035]
As described above, task switching can be generated after a set cycle by an instruction described in task 0.
[0036]
(Embodiment 3)
FIG. 3 shows a configuration of a task scheduling apparatus according to the third embodiment of the present invention.
[0037]
In FIG. 3,
[0038]
In the
[0039]
With respect to the present embodiment configured as described above, the operation at the time of task switching will be described below.
[0040]
It is assumed that task 0 is executed in the
[0041]
When an activation command for the
[0042]
The hardware engine 3 (322) decrements every cycle from the sent counter initial value, and when the count value is “0”, an end signal 3 (343) is generated. Thereafter, similarly, a task switching signal 107 is generated and task switching is performed.
[0043]
As described above, task switching can occur after the cycle set by the instruction described in task 0.
[0044]
(Embodiment 4)
FIG. 4 is a flowchart of the task switching method according to the fourth embodiment of the present invention.
[0045]
In FIG. 4, in the first step S1, a set value is designated by an instruction in the program of the task being executed. This set value specifies the number of cycles from when an instruction is issued until task switching is performed.
[0046]
In the second step S2, counting is started. The initial value of the count is “0”, and the count value is incremented every cycle.
[0047]
In the third step S3, the set value designated in the first step S1 is compared with the count value counted in the second step.
[0048]
If the set value is not equal to the count value, the process returns to the second step S2. If the set value is equal to the count value, the process proceeds to the fourth step S4.
[0049]
In the fourth step S4, a task to be executed next is selected.
[0050]
As described above, according to this embodiment, task switching can occur after a cycle set by an instruction described in a task being executed.
[0051]
【The invention's effect】
According to the present invention, task switching timing control can be easily performed by providing a mechanism for generating task switching after the number of cycles set by an instruction.
[Brief description of the drawings]
FIG. 1 is a block diagram illustrating a task scheduling apparatus according to a first embodiment of the present invention. FIG. 2 is a block diagram illustrating a task scheduling apparatus according to a second embodiment of the present invention. FIG. 4 is a block diagram showing a task scheduling apparatus. FIG. 4 is a flowchart of a task switching method according to the fourth embodiment of the present invention.
100
111 Task 1
112 Task 2
120 Hardware engine 0
121 Hardware engine 1
122 Hardware Engine 2
130 Start signal 0
131 Start signal 1
132 Start signal 2
134 Command 135 Counter output 136 Comparison output 137 Task switching signal 140 End signal 0
141 End signal 1
142 End signal 2
203
334
343
Claims (2)
実行中のタスクにおいて特定の命令を発行すると、タスクの実行処理が終了していなくても、前記特定の命令の発行から所定サイクル後にタスク切り替えを行い、前記所定サイクル数は前記特定の命令によって設定されることを特徴とするタスクスケジューリング装置。Select one task from a plurality of tasks, comprising a microcontroller for executing sequentially, a execution process of the task is completed the task scheduling apparatus for performing e replacement task cutting,
When a specific instruction is issued in a task being executed , task switching is performed after a predetermined cycle from the issuance of the specific instruction, even if task execution processing has not ended , and the predetermined number of cycles is set by the specific instruction A task scheduling apparatus.
前記第3のステップにおいて、前記カウント値と前記設定値とが等しい場合には、前記タスクの実行処理が終了していなくてもタスク切り替えを発生することを特徴とするタスクの切り替え方法。Select one task from a plurality of tasks, the execution of the task is completed, a switching method of the task to be performed by switching a task, the particular instruction by the task, the particular instruction issued The first step of designating the number of cycles from the start to task switching as a set value, the second step of counting the value as a count value every cycle, and the second step A third step of comparing the count value with the set value specified in the first step, and a fourth step of selecting a task to be executed next,
In the third step, when the count value is equal to the set value, task switching is generated even if the task execution processing is not completed .
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP30213599A JP4156148B2 (en) | 1999-10-25 | 1999-10-25 | Task scheduling device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP30213599A JP4156148B2 (en) | 1999-10-25 | 1999-10-25 | Task scheduling device |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2001125795A JP2001125795A (en) | 2001-05-11 |
JP4156148B2 true JP4156148B2 (en) | 2008-09-24 |
Family
ID=17905339
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP30213599A Expired - Fee Related JP4156148B2 (en) | 1999-10-25 | 1999-10-25 | Task scheduling device |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP4156148B2 (en) |
-
1999
- 1999-10-25 JP JP30213599A patent/JP4156148B2/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
JP2001125795A (en) | 2001-05-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JPH06139107A (en) | Brake address detecting circuit | |
JPH0454255B2 (en) | ||
KR20110080073A (en) | Coverage apparatus and method for testing multi-thread environment | |
JP4156148B2 (en) | Task scheduling device | |
JP4132802B2 (en) | Method, apparatus and program for simulating general multitask software | |
JPS6019028B2 (en) | information processing equipment | |
US20030225812A1 (en) | Controller for machine | |
JPH064318A (en) | Error detecting system | |
JPH06259115A (en) | Programmable controller | |
WO2019244472A1 (en) | Simulation device | |
JPH08202548A (en) | Processing cycle controller of programmable controller | |
JP2631541B2 (en) | Programmable controller | |
JP2726126B2 (en) | Periodic task management method | |
JPH07175406A (en) | Scan start control system of programmable controller | |
JPS6269352A (en) | Microprocessor | |
JPH02113363A (en) | Time slice controlling system for multiprocessor system | |
JP2002007145A (en) | Task manager | |
JPH02254544A (en) | Multitask sequence processor and its starting method | |
JPH06230988A (en) | Computer | |
JPH04251331A (en) | Information processor | |
CN115509884A (en) | Method and device for testing thread scheduling performance and electronic equipment | |
JPH04275635A (en) | Constant cycle processing system | |
JPH03209530A (en) | Time division multi-task executing device | |
JPH04192037A (en) | Semiconductor integrated circuit | |
JPH01102653A (en) | Microprogram control system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20041025 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20041207 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20050202 |
|
RD01 | Notification of change of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7421 Effective date: 20050629 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20050816 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20051014 |
|
A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20060124 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20060327 |
|
A911 | Transfer of reconsideration by examiner before appeal (zenchi) |
Free format text: JAPANESE INTERMEDIATE CODE: A911 Effective date: 20060406 |
|
A912 | Removal of reconsideration by examiner before appeal (zenchi) |
Free format text: JAPANESE INTERMEDIATE CODE: A912 Effective date: 20060908 |
|
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: 20080709 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110718 Year of fee payment: 3 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110718 Year of fee payment: 3 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110718 Year of fee payment: 3 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120718 Year of fee payment: 4 |
|
LAPS | Cancellation because of no payment of annual fees |