JPH0778091A - Multitask managing method - Google Patents

Multitask managing method

Info

Publication number
JPH0778091A
JPH0778091A JP24750993A JP24750993A JPH0778091A JP H0778091 A JPH0778091 A JP H0778091A JP 24750993 A JP24750993 A JP 24750993A JP 24750993 A JP24750993 A JP 24750993A JP H0778091 A JPH0778091 A JP H0778091A
Authority
JP
Japan
Prior art keywords
event
task
control block
code
queued
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP24750993A
Other languages
Japanese (ja)
Inventor
Toru Kobayashi
徹 小林
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.)
NEC Corp
Original Assignee
NEC 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 NEC Corp filed Critical NEC Corp
Priority to JP24750993A priority Critical patent/JPH0778091A/en
Publication of JPH0778091A publication Critical patent/JPH0778091A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To preferentially process an event which is high in emergency by enabling the same task to be actuated repeatedly for processes of different events. CONSTITUTION:A task 4 processes events of event codes 0, 1, and 2. When the event of the code 1 is generated and a task 4 is executed so as to process the event, only the event control block 8 of the code 1 is queued in a task control block 3. If an event of a code 0 having higher priority is generated in this state, an interruption process part 15 interrupts the task 4 and saves various register information in a block 8 and a scheduler 2 queues the event control block 7 of the code 0 in the task control block 3 and nearly starts the task 4 so as to process the event of the code 0. After the task 4 finishes processing the event of the code 0 and ends, the scheduler 2 reloads the register information saved in the block 8 to a CPU 11 and actuates the task 4 to restart the process of the event of the code at the interruption point.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は、情報処理装置における
マルチタスク管理方法に関し、特に複数のタスクから構
成され各タスクに幾つかの事象の処理を分担させるよう
にしたマルチタスク構造の制御プログラムに好適なマル
チタスク管理方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a multitask management method in an information processing apparatus, and more particularly to a control program having a multitask structure which is composed of a plurality of tasks and which allows each task to share processing of some events. A preferred multitask management method.

【0002】[0002]

【従来の技術】伝送制御プログラム等の機器組み込み用
制御プログラムにおいては、複数のタスクによりプログ
ラムが構成されており、各タスクに幾つかの事象の処理
を分担させている。このため、或るタスクで処理すべき
複数の事象が連続して発生した場合、どのような順序で
それらの事象をそのタスクで処理するかが問題となる。
若し、事象の発生順に処理を行うとすると、処理の緊急
度の高い事象がそれより緊急度の低い事象のために後回
しにされ、問題である。
2. Description of the Related Art In a device-embedded control program such as a transmission control program, the program is composed of a plurality of tasks, and each task is made to share processing of some events. Therefore, when a plurality of events to be processed by a certain task occur consecutively, there is a problem in what order the events are processed by the task.
If processing is performed in the order of occurrence of events, an event with a high urgency of processing is postponed due to an event with a lower urgency, which is a problem.

【0003】そこで、例えば特開平2−12433号公
報に見られるように、各タスクで処理すべき事象にそれ
ぞれユニークな事象コードを定めると共に、そのうちの
何れかを特定の事象コードに定め、タスクの停止中に発
生した事象を特定の事象コードの事象以外は事象コード
の昇順にタスク制御ブロックにキューイングするに止め
てタスクのスケジューリングは実行せず、特定の事象コ
ードの事象が発生した時点でそれをキューイングすると
共にタスクをスケジュールして特定事象を処理させ、こ
の特定事象の処理を終えた時点で、タスク制御ブロック
にキューイングされている他の事象を順次に処理させる
マルチタスク管理方法が提案されている。
Therefore, for example, as disclosed in Japanese Patent Laid-Open No. 12433/1990, a unique event code is defined for each event to be processed in each task, and any one of them is defined as a specific event code. Except for events with a specific event code, the events that occurred during suspension are queued in the task control block in ascending order of the event code, and the task scheduling is not executed. Proposal of a multi-task management method that queues tasks and schedules a task to process a specific event, and when the processing of this specific event is finished, sequentially processes other events queued in the task control block Has been done.

【0004】[0004]

【発明が解決しようとする課題】このような従来方法に
よれば、事象がその事象コードの順番で処理されるの
で、事象コードの値で処理の緊急度を表現すれば、緊急
度の高い事象から優先的に処理することが可能となる。
According to such a conventional method, since the events are processed in the order of the event code, if the processing urgency is expressed by the value of the event code, the event with high urgency is expressed. Therefore, it is possible to preferentially process.

【0005】しかしながら、特定の事象という概念を導
入して、この特定の事象の発生を契機にタスクのスケジ
ューリングを開始するため、タスクの停止中に発生した
特定事象以外の通常の事象は、特定事象が発生するまで
処理されないことになり、通常の事象の処理が遅延する
ことになる。また、各タスクは処理が終わるまでCPU
の実行権を放棄しないような管理形式が採用されている
ため、タスクが通常の事象を処理している最中に、緊急
度の高い特定の事象が発生しても、それを優先的に処理
することはできない。
However, since the concept of a specific event is introduced and task scheduling is started upon the occurrence of this specific event, normal events other than the specific event that occur while the task is stopped are specific events. Will not be processed until the event occurs, and the processing of normal events will be delayed. In addition, each task is processed by the CPU
Since a management format that does not abandon the execution right of is adopted, even if a specific event with a high degree of urgency occurs while the task is processing a normal event, it will be processed with priority. You cannot do it.

【0006】そこで本発明の第1の目的は、同一タスク
を異なる事象の為に多重に起動し得るようにして、タス
ク動作中に、より緊急度の高い事象が発生した場合に
は、タスクの実行を中断して、その緊急度の高い事象の
ためにそのタスクを速やかに動作させ、然もその事象の
処理後には、先に処理していた事象をその中断箇所から
再開できるようにしたマルチタスク管理方法を提供する
ことにある。
Therefore, a first object of the present invention is to make it possible to activate the same task multiple times for different events so that when a more urgent event occurs during task operation, the task Multi-tasking that suspends execution and causes the task to operate promptly for an event with a high degree of urgency, and after the event has been processed, the previously processed event can be resumed from the interrupted point. It is to provide a task management method.

【0007】また本発明の第2の目的は、或るタスクで
処理すべき複数の事象が連続して発生した場合に、緊急
度の高い順番で事象を処理し得るようにすることにあ
る。
A second object of the present invention is to be able to process events in a descending order of urgency when a plurality of events to be processed by a certain task occur consecutively.

【0008】[0008]

【課題を解決するための手段】本発明は上記の第1の目
的を達成するために、複数のタスクから構成され各タス
クに処理すべき幾つかの事象を分担させるようにしたマ
ルチタスク構造の制御プログラムにおける前記各タスク
を管理するマルチタスク管理方法であって、(a)前記
制御プログラムで処理すべき事象の発生時、CPUで実
行中のタスクを中断して、各種レジスタの値を、前記中
断したタスクのタスク制御ブロックにキューイングされ
ている現処理中の事象に対応する事象制御ブロックに退
避する工程と、(b)前記発生した事象の事象コードお
よび各種レジスタの初期値を含む事象制御ブロックをそ
の事象を処理するタスクのタスク制御ブロックにキュー
イングする工程と、(c)各タスク制御ブロックにキュ
ーイングされている事象制御ブロックのうち、最も優先
度の高い事象に対応する事象制御ブロックを選択する工
程と、(d)該選択した事象制御ブロックに格納されて
いる各種レジスタの値を前記CPUの各種レジスタにセ
ットして、その事象制御ブロックがキューイングされて
いるタスク制御ブロックに対応するタスクを動作させる
工程とを含んでいる。
In order to achieve the above-mentioned first object, the present invention has a multi-task structure composed of a plurality of tasks, each task sharing some events to be processed. A multitask management method for managing each of the tasks in a control program, comprising: (a) interrupting a task being executed by a CPU when an event to be processed by the control program occurs, A step of saving to an event control block corresponding to an event in process currently queued in the task control block of the suspended task, and (b) an event control including an event code of the generated event and initial values of various registers Queuing the block into the task control block of the task that handles the event, and (c) queuing into each task control block A step of selecting an event control block corresponding to the event with the highest priority among the event control blocks; and (d) setting the values of various registers stored in the selected event control block in various registers of the CPU. And operating the task corresponding to the task control block whose event control block is queued.

【0009】なお、前記(c)の工程においては、各事
象制御ブロックに格納された事象コードにより事象の優
先度を判定している。
In the step (c), the priority of the event is determined by the event code stored in each event control block.

【0010】また、上記第2の目的をも達成するため
に、前記(b)の工程においては、発生した事象の事象
制御ブロックを、その事象コードの順にソートして、タ
スク制御ブロックにキューイングするようにしている。
In order to achieve the above-mentioned second object, in the step (b), the event control blocks of the occurred events are sorted in the order of the event codes and queued in the task control block. I am trying to do it.

【0011】[0011]

【作用】今、或るタスクAが処理すべき事象として、事
象コード「0」,「1」,「2」の3つの事象があり、
別のタスクBが処理すべき事象として、事象コード
「3」,「4」,「5」の3つの事象があり、事象コー
ドの値が小さな事象ほど優先度が高いものとする。ま
た、現在タスクAが事象コード「1」の事象を処理する
ために起動されており、タスクAのタスク制御ブロック
には事象コード「1」の事象制御ブロックのみキューイ
ングされており、タスクBのタスク制御ブロックには事
象コード「3」の事象制御ブロックのみがキューイング
されているものとする。
Now, there are three events with event codes "0", "1", and "2" as the events to be processed by a certain task A.
There are three events with event codes “3”, “4”, and “5” as events to be processed by another task B, and an event with a smaller event code value has a higher priority. Further, the task A is currently activated to process the event with the event code “1”, and only the event control block with the event code “1” is queued in the task control block of the task A. Only the event control block with the event code "3" is queued in the task control block.

【0012】この状態で、事象コード「2」の事象が発
生すると、CPUで実行中のタスクAが中断されて、各
種レジスタの値が、タスクAのタスク制御ブロックにキ
ューイングされている事象コード「1」の事象制御ブロ
ックに退避され、発生した事象の事象コード「2」およ
び各種レジスタの初期値を含む事象制御ブロックがタス
クAのタスク制御ブロックに事象コードの順(例えば昇
順)にキューイングされ、次に、各タスク制御ブロック
にキューイングされている事象制御ブロックのうち、最
も優先度の高い事象に対応する事象制御ブロックが選択
される。従って、今の場合はタスクAのタスク制御ブロ
ックにキューイングされている事象コード「1」の事象
制御ブロックが選択され、そこに格納されている各種レ
ジスタの値がCPUの各種レジスタに復帰されて、タス
クAが動作する。
In this state, when the event of the event code "2" occurs, the task A being executed by the CPU is interrupted, and the values of various registers are queued in the task control block of the task A. The event control block saved in the event control block of "1" and including the event code "2" of the event that occurred and the initial values of various registers is queued in the task control block of task A in the order of the event code (for example, ascending order). Then, among the event control blocks queued in each task control block, the event control block corresponding to the event with the highest priority is selected. Therefore, in this case, the event control block with the event code "1" queued in the task control block of task A is selected, and the values of the various registers stored therein are restored to the various registers of the CPU. , Task A operates.

【0013】このように、現在実行中の事象より優先度
の低い事象が発生しても、元の事象の処理が継続して実
行される。
As described above, even if an event having a lower priority than the currently executed event occurs, the processing of the original event is continuously executed.

【0014】他方、その後、事象コード「0」の事象が
発生すると、CPUで実行中のタスクAが中断されて、
各種レジスタの値が、タスクAのタスク制御ブロックに
キューイングされている事象コード「1」の事象制御ブ
ロックに退避され、発生した事象の事象コード「0」お
よび各種レジスタの初期値を含む事象制御ブロックがタ
スクAのタスク制御ブロックに事象コードの順(例えば
昇順)にキューイングされ、次に、各タスク制御ブロッ
クにキューイングされている事象制御ブロックのうち、
最も優先度の高い事象に対応する事象制御ブロックが選
択される。従って、今の場合はタスクAのタスク制御ブ
ロックにキューイングされている事象コード「0」の事
象制御ブロックが選択され、そこに格納されている各種
レジスタの値がCPUの各種レジスタに復帰されて、タ
スクAが動作する。
On the other hand, when an event of event code "0" occurs thereafter, the task A being executed by the CPU is interrupted,
The value of each register is saved in the event control block of the event code "1" that is queued in the task control block of task A, and the event control including the event code "0" of the generated event and the initial value of each register The blocks are queued in the task control block of task A in the order of event codes (for example, in ascending order), and then, among the event control blocks queued in each task control block,
The event control block corresponding to the event with the highest priority is selected. Therefore, in this case, the event control block with the event code “0” queued in the task control block of task A is selected, and the values of the various registers stored therein are restored to the various registers of the CPU. , Task A operates.

【0015】このように、現在実行中の事象より優先度
の高い事象が発生すると、現在実行中の事象の処理が中
断され、優先度の高い事象が処理される。
As described above, when an event having a higher priority than the currently executed event occurs, the processing of the currently executed event is interrupted and the high priority event is processed.

【0016】その後、タスクAにより事象コード「0」
の事象の処理が終了すると、次に優先度の高い事象コー
ド「1」の事象の処理がその中断箇所からタスクAによ
り再開され、それが終了すると、次に事象コード「2」
の処理がタスクAにより実行され、次に、タスクBによ
り事象コード「3」の事象が処理される。
Thereafter, the task A causes event code "0".
When the processing of the event of No. 2 is completed, the processing of the event of the next highest priority event code “1” is restarted by the task A from the interrupted point, and when it is completed, the next event code “2” is generated.
Is executed by the task A, and then the event of the event code “3” is processed by the task B.

【0017】[0017]

【実施例】次に本発明の実施例について図面を参照して
詳細に説明する。
Embodiments of the present invention will now be described in detail with reference to the drawings.

【0018】図1を参照すると、本発明のマルチタスク
管理方法の一実施例を適用した情報処理装置の一例は、
CPU11とメモリ12と入出力装置等13とこれらを
接続するバス14とで構成されている。
Referring to FIG. 1, an example of an information processing apparatus to which an embodiment of the multitask management method of the present invention is applied,
It is composed of a CPU 11, a memory 12, an input / output device 13 and a bus 14 connecting them.

【0019】メモリ12上には、タスク4およびタスク
6で構成されるプログラム10と、スケジューラ2,タ
スク4に対応するタスク制御ブロック3およびタスク6
に対応するタスク制御ブロック5とを含むオペレーティ
ング・システム(OS)9とから構成される機器組み込
み用制御プログラム(以下、単に制御プログラムと言
う)1が設けられている。
On the memory 12, a program 10 composed of tasks 4 and 6 and task control blocks 3 and 6 corresponding to the scheduler 2 and the task 4 are provided.
A device-embedded control program (hereinafter, simply referred to as a control program) 1 including an operating system (OS) 9 including a task control block 5 corresponding to the.

【0020】タスク制御ブロック3は、図中に示すよう
に、キューイングポインタ3−1を有し、このキューイ
ングポインタ3−1を先頭に、タスク4で処理すべき事
象に対応する事象制御ブロックが、事象コードの昇順に
キューイングされる。
As shown in the figure, the task control block 3 has a queuing pointer 3-1 and an event control block corresponding to an event to be processed by the task 4 with the queuing pointer 3-1 at the head. Are queued in ascending order of event codes.

【0021】各事象制御ブロックは、事象制御ブロック
7,8に例示するように、事象コード7−1,8−1
と、プログラムカウンタやその他の各種レジスタの退避
場所となるレジスタ退避域7−2,8−2とを有してい
る。
Each event control block has event codes 7-1 and 8-1 as illustrated in the event control blocks 7 and 8.
And register save areas 7-2 and 8-2 which are save areas for the program counter and other various registers.

【0022】本発明では、各タスク4,6の中断時のレ
ジスタ情報を、そのタスクが動作する原因となった事象
に対応する事象制御ブロック中のレジスタ退避域に退避
する構成を採用しているため、タスク制御ブロック3,
5自体にはレジスタ退避域は設けられていない。なお、
本実施例では、事象制御ブロック自体にレジスタ退避域
を設けたが、メモリ12上に各事象毎のスタックを用意
し、各種レジスタ情報はその事象に対応するスタックに
退避し、スタックのポインタを事象制御ブロックに退避
するようにしても良く、要するに、各事象毎にレジスタ
退避域が存在すれば良い。
The present invention employs a configuration in which the register information at the time of suspending each task 4 and 6 is saved in the register save area in the event control block corresponding to the event causing the task to operate. Therefore, the task control block 3,
5 itself does not have a register save area. In addition,
In the present embodiment, the register save area is provided in the event control block itself, but a stack for each event is prepared in the memory 12, various register information is saved in the stack corresponding to the event, and the pointer of the stack is saved as an event. It may be saved in the control block. In short, it suffices that a register save area exists for each event.

【0023】図示していないが、タスク制御ブロック5
もタスク制御ブロック3と同様にキューイングポインタ
を有し、タスク6で処理すべき事象が発生した場合、そ
の事象の事象制御ブロックがタスク制御ブロック5にキ
ューイングされる。
Although not shown, the task control block 5
Also has a queuing pointer like the task control block 3, and when an event to be processed occurs in the task 6, the event control block of the event is queued in the task control block 5.

【0024】また、CPU11には、割り込み処理部1
5があり、この割り込み処理部15で、図2および図3
に示すようなスケジューラ起動等の処理がハードウェア
またはファームウェアにより実行される。
The CPU 11 also includes an interrupt processing unit 1
2 and FIG. 3 in the interrupt processing unit 15.
Processing such as scheduler activation as shown in is executed by hardware or firmware.

【0025】更に、スケジューラ2は、図4および図5
に示すような処理を行うように構成されている。
Further, the scheduler 2 has a configuration shown in FIG. 4 and FIG.
It is configured to perform the processing shown in.

【0026】以下、本実施例の動作を説明する。The operation of this embodiment will be described below.

【0027】プログラム10が処理すべき事象にはユニ
ークな事象コードが付与されている。また各事象コード
にはその優先度が与えられている。本実施例の場合、事
象コードの値がその事象の優先度を示し、事象コードの
値が小さいほど、優先度が高くなっている。説明の便宜
上、プログラム10が処理すべき事象が全部で6つあ
り、それぞれの事象コードを「0」,「1」,「2」,
「3」,「4」,「5」とし、タスク4は事象コード
「0」,「1」,「2」の事象を分担し、タスク6は事
象コード「3」,「4」,「5」の事象を分担するもの
とする。
A unique event code is assigned to the event to be processed by the program 10. The priority is given to each event code. In the case of the present embodiment, the value of the event code indicates the priority of the event, and the smaller the value of the event code, the higher the priority. For convenience of explanation, there are a total of six events to be processed by the program 10, and the respective event codes are “0”, “1”, “2”,
“3”, “4” and “5” are set, task 4 shares events of event codes “0”, “1” and “2”, and task 6 assigns event codes “3”, “4” and “5”. The event of “” will be shared.

【0028】処理すべき事象が全く発生していない場
合、タスク制御ブロック3,5には1つも事象制御ブロ
ックはキューイングされておらず、タスク4,6は停止
状態になっている。
When no event to be processed has occurred, no task control block is queued in the task control blocks 3 and 5, and the tasks 4 and 6 are in a stopped state.

【0029】この状態で、例えば事象コード「1」,
「3」,「0」,「2」の事象がその順に例えば入出力
装置等13からの割り込みにより発生した場合、各々の
時点で以下のような動作が行われる。
In this state, for example, event code "1",
When the events "3", "0", and "2" occur in that order due to an interrupt from the input / output device 13 or the like, the following operation is performed at each time point.

【0030】(1)事象コード「1」の発生時 事象コード「1」の事象が発生すると、CPU11の割
り込み処理部15は図2に示す処理を開始し、先ず、動
作中のタスクが存在するか否かを判別する(S1)。今
の場合、動作中のタスクは存在しないので、速やかにス
ケジューラ2を起動する(S4)。
(1) When an event code "1" occurs When an event with an event code "1" occurs, the interrupt processing unit 15 of the CPU 11 starts the processing shown in FIG. 2, and first there is a task in operation. It is determined whether or not (S1). In this case, there is no task in operation, so the scheduler 2 is activated immediately (S4).

【0031】スケジューラ2は起動されると、図4に示
す処理を開始する。先ず、処理S21にて事象の発生に
よる起動であることを判別し、発生した事象の事象制御
ブロックを、事象コードの優先度の昇順に、その事象を
処理すべきタスク4に対応するタスク制御ブロック3に
キューイングする(S22)。これにより、図6(a)
に示すように、タスク制御ブロック3に事象コード
「1」の事象制御ブロック71がキューイングされる。
なお、事象制御ブロック71には、事象コードとして
「1」が設定され、また、そのレジスタ退避域には各種
レジスタの初期値(例えばプログラムカウンタについて
はタスク4の先頭番地)が設定される。
When the scheduler 2 is activated, it starts the processing shown in FIG. First, in step S21, it is determined that the event is activated due to the occurrence of an event, and the event control blocks of the occurred event are assigned to the task control blocks corresponding to the task 4 that should process the event in ascending order of priority of the event code. Queuing to 3 (S22). As a result, FIG.
As shown in FIG. 6, the event control block 71 with the event code “1” is queued in the task control block 3.
In the event control block 71, "1" is set as the event code, and initial values of various registers (for example, the head address of task 4 for the program counter) are set in the register save area.

【0032】そして、スケジューラ2はタスク起動処理
S24を実行する。
Then, the scheduler 2 executes the task starting process S24.

【0033】タスク起動処理S24の詳細は図5に示す
通りであり、先ず、全てのタスク制御ブロック3,5に
キューイングされている先頭の事象制御ブロック中から
事象コードを取り出す(S31)。今の場合、タスク制
御ブロック5には事象制御ブロックは1つもキューイン
グされていないので、タスク制御ブロック3にキューイ
ングされているタスク制御ブロック71だけから事象コ
ード「1」が取り出される。
The details of the task activation process S24 are as shown in FIG. 5. First, the event code is extracted from the first event control block queued in all the task control blocks 3 and 5 (S31). In this case, since no event control block is queued in the task control block 5, the event code "1" is extracted only from the task control block 71 queued in the task control block 3.

【0034】次にスケジューラ2は、図5のS32,S
33を経てS36へ進み、タスク制御ブロック3にキュ
ーイングされている先頭の事象制御ブロック71におけ
るレジスタ退避域の内容をCPU11の各種レジスタに
セットして、タスク4を起動する。なお、起動に際して
は、処理すべき事象をタスク4に対して指示する。
Next, the scheduler 2 executes S32 and S in FIG.
After 33, the process proceeds to S36, in which the contents of the register save area in the first event control block 71 queued in the task control block 3 are set in various registers of the CPU 11, and the task 4 is started. At the time of activation, the task 4 is instructed of an event to be processed.

【0035】これにより、タスク4がCPU11で実行
される。タスク4は事象コード「1」の事象の処理を開
始する。
As a result, the task 4 is executed by the CPU 11. Task 4 starts processing the event with event code “1”.

【0036】(2)事象コード「3」の事象の発生時 CPU11でタスク4が実行されているときに、事象コ
ード「3」の事象が発生すると、割り込み処理部15は
図2の処理を開始し、動作中のタスク4が存在するの
で、S1からS2へ進み、動作中のタスク4を中断す
る。そして、中断時点のCPU11のプログラムカウン
タやその他各種のレジスタの内容を、中断したタスク4
のタスク制御ブロック3の先頭にキューイングされてい
る事象制御ブロック71におけるレジスタ退避域へセー
ブし(S3)、スケジューラ2を起動する(S4)。
(2) When an event with an event code "3" occurs When the event with an event code "3" occurs while the task 4 is being executed by the CPU 11, the interrupt processing unit 15 starts the processing shown in FIG. Since there is a task 4 in operation, the process proceeds from S1 to S2, and the task 4 in operation is interrupted. Then, the contents of the program counter and other various registers of the CPU 11 at the time of the interruption are changed to the task 4
The task control block 3 is saved in the register save area in the event control block 71 queued at the head (S3), and the scheduler 2 is activated (S4).

【0037】スケジューラ2は、図4の処理S21から
S22へ進み、発生した事象の事象制御ブロックを、事
象コードの優先度の昇順に、その事象を処理すべきタス
ク6に対応するタスク制御ブロック5にキューイングす
る。これにより、図6(a)に示すように、タスク制御
ブロック5に事象コード「3」の事象制御ブロック73
がキューイングされる。なお、事象制御ブロック73に
は、事象コードとして「3」が設定され、また、そのレ
ジスタ退避域には各種レジスタの初期値(例えばプログ
ラムカウンタについてはタスク6の先頭番地)が設定さ
れる。
The scheduler 2 advances from the processing S21 of FIG. 4 to S22, and the event control blocks of the occurred event are assigned in the ascending order of the priority of the event code to the task control block 5 corresponding to the task 6 which should process the event. Queue to. As a result, as shown in FIG. 6A, the event control block 73 with the event code "3" is added to the task control block 5.
Is queued. In the event control block 73, "3" is set as the event code, and initial values of various registers (for example, the head address of task 6 for the program counter) are set in the register save area.

【0038】そして、スケジューラ2はタスク起動処理
S24を実行し、先ず、全てのタスク制御ブロック3,
5にキューイングされている先頭の事象制御ブロック中
から事象コードを取り出す(S31)。今の場合、図6
(a)に示すようにタスク制御ブロック3には事象制御
ブロック71が、タスク制御ブロック5には事象制御ブ
ロック73がキューイングされているので、それらから
事象コード「1」,「3」が取り出される。
Then, the scheduler 2 executes the task starting process S24, and first, all the task control blocks 3,
The event code is extracted from the first event control block queued in step 5 (S31). In the present case, Fig. 6
As shown in (a), since the event control block 71 is queued in the task control block 3 and the event control block 73 is queued in the task control block 5, the event codes "1" and "3" are extracted from them. Be done.

【0039】次にスケジューラ2は、S32,S33を
経てS34へ進み、これら複数の事象コードの優先度を
比較する。そして、その比較結果に基づき、最高の優先
度の事象コード「1」を含むタスク制御ブロック3を選
択し(S35)、このタスク制御ブロック3にキューイ
ングされている先頭の事象制御ブロック71におけるレ
ジスタ退避域の内容をCPU11の各種レジスタにセッ
トして、タスク4の動作を再開させる(S36)。
Next, the scheduler 2 advances to S34 through S32 and S33, and compares the priorities of these plural event codes. Then, based on the comparison result, the task control block 3 including the highest priority event code "1" is selected (S35), and the register in the first event control block 71 queued in this task control block 3 is selected. The contents of the save area are set in various registers of the CPU 11 to restart the operation of task 4 (S36).

【0040】これにより、タスク4がCPU11で実行
され、事象コード「1」の事象にかかる処理が中断箇所
から再開される。
As a result, the task 4 is executed by the CPU 11, and the process related to the event of the event code "1" is restarted from the interrupted position.

【0041】(3)事象コード「0」の事象の発生時 CPU11でタスク4が実行されているときに、事象コ
ード「0」の事象が発生すると、割り込み処理部15
は、動作中のタスク4が存在するので、図2のS1から
S2へ進み、動作中のタスク4を中断し、中断時点のC
PU11の各種レジスタの内容を、タスク制御ブロック
3の先頭にキューイングされている事象制御ブロック7
1におけるレジスタ退避域へセーブし(S3)、スケジ
ューラ2を起動する(S4)。
(3) Occurrence of event with event code "0" When task 4 is being executed by the CPU 11 and event with event code "0" occurs, interrupt processing unit 15
Has a task 4 in operation, the process advances from S1 to S2 in FIG.
Event control block 7 in which contents of various registers of PU 11 are queued at the head of task control block 3
The data is saved in the register save area in 1 (S3), and the scheduler 2 is activated (S4).

【0042】スケジューラ2は、図4の処理S21から
S22へ進み、発生した事象コード「0」の事象制御ブ
ロックを、事象コードの優先度の昇順に、その事象を処
理すべきタスク4に対応するタスク制御ブロック3にキ
ューイングする。これにより、図6(b)に示すよう
に、タスク制御ブロック3に事象コード「0」の事象制
御ブロック70,事象コード「1」の事象制御ブロック
71がその順にキューイングされる。なお、事象制御ブ
ロック70には、事象コードとして「0」が設定され、
また、そのレジスタ退避域には各種レジスタの初期値
(例えばプログラムカウンタについてはタスク4の先頭
番地)が設定される。
The scheduler 2 advances from the processing S21 of FIG. 4 to S22, and the event control blocks of the generated event code "0" correspond to the task 4 which should process the event in ascending order of the priority of the event code. Queue to task control block 3. As a result, as shown in FIG. 6B, the event control block 70 with the event code “0” and the event control block 71 with the event code “1” are queued in the task control block 3 in that order. In the event control block 70, “0” is set as the event code,
Further, initial values of various registers (for example, the head address of task 4 for the program counter) are set in the register save area.

【0043】次にスケジューラ2はタスク起動処理S2
4を実行し、全てのタスク制御ブロック3,5にキュー
イングされている先頭の事象制御ブロック中から事象コ
ードを取り出す(S31)。今の場合、図6(b)に示
すようにタスク制御ブロック3には事象制御ブロック7
0が、タスク制御ブロック5には事象制御ブロック73
がキューイングされているので、それらから事象コード
「0」,「3」が取り出される。
Next, the scheduler 2 executes task start processing S2.
4 is executed, and the event code is extracted from the first event control block queued in all the task control blocks 3 and 5 (S31). In this case, as shown in FIG. 6B, the event control block 7 is included in the task control block 3.
0 is the event control block 73 in the task control block 5.
Are queued, the event codes “0” and “3” are extracted from them.

【0044】次にスケジューラ2は、図5のS32,S
33を経てS34へ進み、これら複数の事象コード
「0」,「3」の優先度を比較する。そして、その比較
結果に基づき、最高の優先度の事象コード「0」を含む
タスク制御ブロック3を選択し(S35)、このタスク
制御ブロック3にキューイングされている先頭の事象制
御ブロック70におけるレジスタ退避域の内容をCPU
11の各種レジスタにセットして、タスク4を動作させ
る(S36)。
Next, the scheduler 2 executes S32 and S of FIG.
After S33, the process proceeds to S34, and the priorities of the plurality of event codes "0" and "3" are compared. Then, based on the comparison result, the task control block 3 including the event code "0" having the highest priority is selected (S35), and the register in the first event control block 70 queued in this task control block 3 is selected. Save the contents of the save area to the CPU
11 are set in various registers to operate task 4 (S36).

【0045】これにより、事象コード「1」の事象の処
理のために起動されていたタスク4が、事象コード
「0」の事象の処理のために再起動されてCPU11で
実行されることになる。
As a result, the task 4 started for processing the event with the event code "1" is restarted for processing the event with the event code "0" and executed by the CPU 11. .

【0046】(4)事象コード「2」の事象の発生時 CPU11でタスク4が実行されているときに、事象コ
ード「2」の事象が発生すると、割り込み処理部15
は、動作中のタスク4が存在するので、図2のS1から
S2へ進み、動作中のタスク4を中断し、中断時点のC
PU11の各種レジスタの内容を、タスク制御ブロック
3の先頭にキューイングされている事象制御ブロック7
0におけるレジスタ退避域へセーブし(S3)、スケジ
ューラ2を起動する(S4)。
(4) Occurrence of Event with Event Code “2” When task 4 is being executed by the CPU 11, if an event with event code “2” occurs, the interrupt processing unit 15
Has a task 4 in operation, the process advances from S1 to S2 in FIG.
Event control block 7 in which contents of various registers of PU 11 are queued at the head of task control block 3
The data is saved in the register save area at 0 (S3), and the scheduler 2 is activated (S4).

【0047】スケジューラ2は、図4の処理S21から
S22へ進み、発生した事象コード「2」の事象制御ブ
ロックを、事象コードの優先度の昇順に、その事象を処
理すべきタスク4に対応するタスク制御ブロック3にキ
ューイングする。これにより、図6(c)に示すよう
に、タスク制御ブロック3に事象コード「0」の事象制
御ブロック70,事象コード「1」の事象制御ブロック
71,事象コード「2」の事象制御ブロック72がその
順にキューイングされる。なお、事象制御ブロック72
には、事象コードとして「2」が設定され、また、その
レジスタ退避域には各種レジスタの初期値(例えばプロ
グラムカウンタについてはタスク4の先頭番地)が設定
される。
The scheduler 2 advances from the processing S21 of FIG. 4 to S22, and the event control blocks of the generated event code "2" correspond to the task 4 which should process the event in ascending order of the priority of the event code. Queue to task control block 3. As a result, as shown in FIG. 6C, the task control block 3 includes an event control block 70 with an event code “0”, an event control block 71 with an event code “1”, and an event control block 72 with an event code “2”. Are queued in that order. The event control block 72
"2" is set as the event code, and initial values of various registers (for example, the head address of task 4 for the program counter) are set in the register save area.

【0048】次にスケジューラ2はタスク起動処理S2
4を実行し、全てのタスク制御ブロック3,5にキュー
イングされている先頭の事象制御ブロック中から事象コ
ードを取り出す(S31)。今の場合、図6(c)に示
すようにタスク制御ブロック3には事象制御ブロック7
0が、タスク制御ブロック5には事象制御ブロック73
がキューイングされているので、それらから事象コード
「0」,「3」が取り出される。この結果、スケジュー
ラ2の図5のS35において、最高の優先度の事象コー
ド「0」を含むタスク制御ブロック3が選択され、この
タスク制御ブロック3にキューイングされている先頭の
事象制御ブロック70におけるレジスタ退避域の内容が
CPU11の各種レジスタにセットされて、タスク4が
起動される。
Next, the scheduler 2 executes the task starting process S2.
4 is executed, and the event code is extracted from the first event control block queued in all the task control blocks 3 and 5 (S31). In this case, as shown in FIG. 6C, the event control block 7 is included in the task control block 3.
0 is the event control block 73 in the task control block 5.
Are queued, the event codes “0” and “3” are extracted from them. As a result, in S35 of FIG. 5 of the scheduler 2, the task control block 3 including the event code "0" having the highest priority is selected, and the event control block 70 in the head queued in this task control block 3 is selected. The contents of the register save area are set in various registers of the CPU 11, and the task 4 is activated.

【0049】これにより、事象コード「0」の事象のた
めに起動されていたタスク4が再びその事象のためにC
PU11で実行され、中断箇所から事象コード「0」の
事象の処理が再開される。
As a result, the task 4 started for the event with the event code "0" is again C for the event.
It is executed by the PU 11 and the processing of the event with the event code “0” is restarted from the interrupted point.

【0050】 (5)事象コード「0」の事象の処理終了時 タスク4が事象コード「0」の事象にかかる処理を終了
すると、終了割り込みがCPU11の割り込み処理部1
5に出され、割り込み処理部15は、図3に示すよう
に、速やかにスケジューラ2を起動する。
(5) When the processing of the event with the event code “0” is completed When the task 4 finishes the processing related to the event with the event code “0”, the end interrupt is issued by the interrupt processing unit 1 of the CPU 11.
5, the interrupt processing unit 15 promptly activates the scheduler 2 as shown in FIG.

【0051】起動されたスケジューラ2は、図4のS2
1において、タスクの終了を判別し、終了したタスク4
が処理した事象制御ブロック(即ち、タスク制御ブロッ
ク3の先頭にキューイングされている事象制御ブロック
70)を、図6(d)に示すようにキューから取り去る
(S23)。そして、図5に示すタスク起動処理を行
う。
The activated scheduler 2 is S2 in FIG.
In 1, the end of the task is determined, and the finished task 4
The event control block processed by (i.e., the event control block 70 queued at the head of the task control block 3) is removed from the queue as shown in FIG. 6D (S23). Then, the task activation process shown in FIG. 5 is performed.

【0052】このタスク起動処理では、タスク制御ブロ
ック3,5にキューイングされている先頭の事象制御ブ
ロック中から事象コード「1」,「3」が取り出され
(S31)、次にこれらの優先度が比較され(S3
4)、最高の優先度の事象コード「1」を含むタスク制
御ブロック3が選択され(S35)、このタスク制御ブ
ロック3にキューイングされている先頭の事象制御ブロ
ック71におけるレジスタ退避域の内容がCPU11の
各種レジスタにセットされて、タスク4が起動される
(S36)。
In this task activation process, the event codes "1" and "3" are extracted from the first event control block queued in the task control blocks 3 and 5 (S31), and then these priority levels are set. Are compared (S3
4) The task control block 3 including the highest priority event code "1" is selected (S35), and the contents of the register save area in the first event control block 71 queued in this task control block 3 are The task 4 is activated by being set in various registers of the CPU 11 (S36).

【0053】これにより、タスク4が事象コード「1」
の処理のために再びCPU11で実行され、事象コード
「1」の処理がその中断箇所から再開される。
As a result, the task 4 has the event code "1".
The processing of event code "1" is restarted by the CPU 11 for the processing of 1.

【0054】以下、事象コード「1」の処理を終えてタ
スク4が終了すると、次に事象コード「2」の事象の処
理を行うべくタスク4が起動され、それが終了すると、
事象コード「3」の事象の処理を中断箇所から再開する
ためにタスク6が起動される。勿論、その間に、現処理
中の事象より優先度の高い事象が発生した場合には、現
処理中の事象の処理が中断され、優先度の高い事象が処
理されることになる。
Thereafter, when the task 4 is completed after the processing of the event code "1" is completed, the task 4 is activated to process the event of the event code "2", and when it is completed,
Task 6 is activated to restart the processing of the event of event code “3” from the interrupted point. Of course, in the meantime, when an event having a higher priority than the event currently being processed occurs, the processing of the event currently being processed is interrupted and the high priority event is processed.

【0055】[0055]

【発明の効果】以上説明したように本発明によれば以下
のような効果を得ることができる。
As described above, according to the present invention, the following effects can be obtained.

【0056】同一のタスクを異なる事象の処理のために
多重に起動することを可能にし、事象が発生する毎に、
発生した事象の優先度と現在処理中の事象の優先度とを
比較し、発生した事象の優先度の方が高ければ、現在処
理中の事象の処理を中断して優先的に処理するため、緊
急度の高い事象の処理がそれより緊急度の低い事象のた
めに遅延することがなくなり、また、中断した事象の処
理は中断箇所から再開できるので、処理の無駄が無くな
る。
It is possible to activate the same task multiple times for the processing of different events, each time an event occurs,
Compare the priority of the event that occurred with the priority of the event that is currently being processed, and if the priority of the event that occurred is higher, to interrupt the processing of the event that is currently being processed and process it preferentially, Processing of high-urgency events will not be delayed due to lower-urgency events, and since the processing of interrupted events can be resumed from the point of interruption, waste of processing is eliminated.

【0057】優先度の高い事象が優先的に処理されるよ
うにタスクが起動される為、各タスクは事象の優先度を
意識する必要がなくなり、発生事象対処理という図式で
各タスクをプログラミングでき、事象処理の手順が簡単
になる。
Since the task is activated so that the event with the high priority is preferentially processed, each task does not need to be aware of the priority of the event, and each task can be programmed by the diagram of occurrence event pair processing. , The procedure of event processing becomes simple.

【図面の簡単な説明】[Brief description of drawings]

【図1】本発明のマルチタスク管理方法の一実施例を適
用した情報処理装置の一例を示すブロック図である。
FIG. 1 is a block diagram showing an example of an information processing apparatus to which an embodiment of a multitask management method of the present invention is applied.

【図2】事象発生時に割り込み処理部で行われる処理例
を示すフローチャートである。
FIG. 2 is a flowchart showing an example of processing performed by an interrupt processing unit when an event occurs.

【図3】タスク終了時に割り込み処理部で行われる処理
例を示すフローチャートである。
FIG. 3 is a flowchart showing an example of processing performed by an interrupt processing unit when a task ends.

【図4】スケジューラの処理例を示すフローチャートで
ある。
FIG. 4 is a flowchart showing a processing example of a scheduler.

【図5】スケジューラのタスク起動処理の詳細を示すフ
ローチャートである。
FIG. 5 is a flowchart showing details of task activation processing of a scheduler.

【図6】タスク制御ブロックにキューイングされる事象
制御ブロックの状態を示す図である。
FIG. 6 is a diagram showing states of event control blocks queued in a task control block.

【符号の説明】[Explanation of symbols]

1…機器組み込み用制御プログラム 2…スケジューラ 3,5…タスク制御ブロック 4,6…タスク 7,8,70〜73…事象制御ブロック 7−1,8−1…事象コード 7−2,8−2…レジスタ退避域 9…オペレーティング・システム(OS) 10…プログラム 11…CPU 12…メモリ 13…入出力装置等 14…バス 15…割り込み処理部 1 ... Device incorporation control program 2 ... Scheduler 3, 5 ... Task control block 4, 6 ... Task 7, 8, 70-73 ... Event control block 7-1, 8-1 ... Event code 7-2, 8-2 Register save area 9 Operating system (OS) 10 Program 11 CPU 12 Memory 13 I / O device 14 Bus 15 Interrupt processing unit

Claims (3)

【特許請求の範囲】[Claims] 【請求項1】 複数のタスクから構成され各タスクに幾
つかの処理すべき事象を分担させるようにしたマルチタ
スク構造の制御プログラムにおける前記各タスクを管理
するマルチタスク管理方法において、(a)前記制御プ
ログラムで処理すべき事象の発生時、CPUで実行中の
タスクを中断して、各種レジスタの値を、前記中断した
タスクのタスク制御ブロックにキューイングされている
現処理中の事象に対応する事象制御ブロックに退避する
工程と、(b)前記発生した事象の事象コードおよび各
種レジスタの初期値を含む事象制御ブロックをその事象
を処理するタスクのタスク制御ブロックにキューイング
する工程と、(c)各タスク制御ブロックにキューイン
グされている事象制御ブロックのうち、最も優先度の高
い事象に対応する事象制御ブロックを選択する工程と、
(d)該選択した事象制御ブロックに格納されている各
種レジスタの値を前記CPUの各種レジスタにセットし
て、その事象制御ブロックがキューイングされているタ
スク制御ブロックに対応するタスクを動作させる工程
と、を含むことを特徴とするマルチタスク管理方法。
1. A multitask management method for managing each task in a control program having a multitask structure, comprising a plurality of tasks, each task sharing some events to be processed, wherein: When an event to be processed by the control program occurs, the task being executed by the CPU is interrupted, and the values of various registers correspond to the event currently being processed which is queued in the task control block of the interrupted task. Saving to an event control block, (b) queuing an event control block containing the event code of the generated event and initial values of various registers to a task control block of a task that processes the event, (c) ) Respond to the event with the highest priority among the event control blocks queued in each task control block. Selecting an elephant control block,
(D) A step of setting values of various registers stored in the selected event control block in various registers of the CPU and operating a task corresponding to a task control block in which the event control block is queued And a multitask management method including:
【請求項2】 前記(c)の工程において、各事象制御
ブロックに格納された事象コードにより事象の優先度を
判定することを特徴とする請求項1記載のマルチタスク
管理方法。
2. The multitask management method according to claim 1, wherein in the step (c), the priority of the event is determined by the event code stored in each event control block.
【請求項3】 前記(b)の工程において、発生した事
象の事象制御ブロックを、その事象コードの順に、タス
ク制御ブロックにキューイングすることを特徴とする請
求項2記載のマルチタスク管理方法。
3. The multitask management method according to claim 2, wherein in the step (b), the event control blocks of the generated event are queued in the task control block in the order of the event code.
JP24750993A 1993-09-08 1993-09-08 Multitask managing method Pending JPH0778091A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP24750993A JPH0778091A (en) 1993-09-08 1993-09-08 Multitask managing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP24750993A JPH0778091A (en) 1993-09-08 1993-09-08 Multitask managing method

Publications (1)

Publication Number Publication Date
JPH0778091A true JPH0778091A (en) 1995-03-20

Family

ID=17164543

Family Applications (1)

Application Number Title Priority Date Filing Date
JP24750993A Pending JPH0778091A (en) 1993-09-08 1993-09-08 Multitask managing method

Country Status (1)

Country Link
JP (1) JPH0778091A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE19608204C2 (en) * 1996-03-04 1998-04-16 Siemens Ag Method and arrangement for the transmission of information via the radio interface between a subscriber device and a network device of a cellular mobile radio network
JP2015090548A (en) * 2013-11-05 2015-05-11 オムロン株式会社 Control device

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01220040A (en) * 1988-02-29 1989-09-01 Nippon Telegr & Teleph Corp <Ntt> Task scheduling system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01220040A (en) * 1988-02-29 1989-09-01 Nippon Telegr & Teleph Corp <Ntt> Task scheduling system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE19608204C2 (en) * 1996-03-04 1998-04-16 Siemens Ag Method and arrangement for the transmission of information via the radio interface between a subscriber device and a network device of a cellular mobile radio network
JP2015090548A (en) * 2013-11-05 2015-05-11 オムロン株式会社 Control device

Similar Documents

Publication Publication Date Title
JP3037182B2 (en) Task management method
US6006247A (en) Method and system for scheduling threads and handling exceptions within a multiprocessor data processing system
KR970016979A (en) Queuing system and method of tasks in a multiprocessing system
JP2636722B2 (en) Multitask execution management method
JP3644042B2 (en) Multitask processing device
JPH0778091A (en) Multitask managing method
JP2693916B2 (en) Task scheduling method
JPH0588917A (en) Job scheduling system
JPH1063515A (en) Scheduling method for multitask control
JP2667575B2 (en) Task scheduling method
JP2597283B2 (en) Scheduling method for interrupt
JP3524961B2 (en) Multiprocessor system and task scheduling method in the system
JP3169316B2 (en) Task scheduling method
JPS63636A (en) Task control system
JPH01258135A (en) Transaction execution control system
JPH0240723A (en) Message transmission/reception control system
JP2000047881A (en) Real-time system
JPH01216432A (en) Multitask system
JP2000194573A (en) System and method for thread control
JPS5822454A (en) Job scheduling mechanism
JPS63136233A (en) Schedule system for timer service utilization process
JP2000066903A (en) Interrupt processing system and interrupt processing method
JPS63163640A (en) Scheduling system
JPH03188531A (en) Time-division multitask executing device
JPH07129480A (en) File transfer device