JP5155336B2 - Task processing device - Google Patents

Task processing device Download PDF

Info

Publication number
JP5155336B2
JP5155336B2 JP2009549892A JP2009549892A JP5155336B2 JP 5155336 B2 JP5155336 B2 JP 5155336B2 JP 2009549892 A JP2009549892 A JP 2009549892A JP 2009549892 A JP2009549892 A JP 2009549892A JP 5155336 B2 JP5155336 B2 JP 5155336B2
Authority
JP
Japan
Prior art keywords
task
circuit
processing
register
auxiliary
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2009549892A
Other languages
Japanese (ja)
Other versions
JPWO2009090684A1 (en
Inventor
修孝 丸山
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kernelon Silicon Inc
Original Assignee
Kernelon Silicon Inc
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 Kernelon Silicon Inc filed Critical Kernelon Silicon Inc
Publication of JPWO2009090684A1 publication Critical patent/JPWO2009090684A1/en
Application granted granted Critical
Publication of JP5155336B2 publication Critical patent/JP5155336B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline, look ahead
    • G06F9/3836Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution
    • G06F9/3851Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution from multiple instruction streams, e.g. multistreaming

Description

この発明は、OS(Operating System)の機能に関し、特に、補助プロセッサ(co-processor)の制御に関する。   The present invention relates to an OS (Operating System) function, and more particularly to control of an auxiliary processor (co-processor).

パーソナルコンピュータのような汎用機器用のOSに限らず、携帯電話のような専用機器用のOSにも高度な機能が求められつつある。特に、1つのCPU(Central Processing Unit)で複数のタスクを実行可能なOS(以下、このようなタイプのOSのことを「マルチタスクOS」ともよぶ)が多くの電子機器に搭載されるようになってきている。   Advanced functions are being demanded not only for OSs for general-purpose devices such as personal computers but also for OSs for dedicated devices such as mobile phones. In particular, an OS capable of executing a plurality of tasks with a single CPU (Central Processing Unit) (hereinafter, this type of OS is also referred to as a “multitask OS”) is installed in many electronic devices. It has become to.

マルチタスクOSは、CPUの処理時間を単位時間(タイムスライス)に分割し、複数のタスクにタイムスライスを順番に割り当てる。各タスクは、OSからタイムスライスを与えられたときだけCPUを使用できる。各タイムスライスにおいては一つのタスクが実行される。タイムスライスはユーザからみて非常に短い時間なので、複数のタスクはあたかも同時実行されているかのようにみえる。このような処理方法によれば、タスクAが入力待機状態に至りCPUの処理能力を当面必要としなくなったとき、別のタスクBに実行権を与えることでCPUの処理能力を有効活用できる。ここでいう実行権とは、CPUの使用権と同義である。   The multitask OS divides the processing time of the CPU into unit times (time slices) and assigns time slices to a plurality of tasks in order. Each task can use the CPU only when a time slice is given from the OS. One task is executed in each time slice. Since time slices are very short from the user's point of view, it looks as if multiple tasks are being executed simultaneously. According to such a processing method, when the task A reaches an input standby state and does not require the CPU processing capability for the time being, the processing capability of the CPU can be effectively utilized by giving another task B the execution right. The execution right here is synonymous with the right to use the CPU.

マルチタスクOSがタスクの実行権の切り換えることを「タスクスイッチ」とよぶ。タスクスイッチは、タイムスライスが経過したときや、タスクが所定命令を実行したときに発生する。マルチタスクOSは、タスクスイッチの実行タイミングに至ると、実行中のタスクのコンテキスト情報をTCB(Task Control Block)に退避させる。コンテキスト情報とは、タスク実行時においてCPUのレジスタに格納されていたデータやタスクの実行状態に関するデータである。TCBとは、タスク固有の情報を保持するためにメモリに確保される領域である。マルチタスクOSは、実行中のタスクのコンテキスト情報をTCBに退避させたあと、次に実行権を割り当てるタスクを選択し、そのタスクのTCBからコンテキスト情報を読み出して、CPUレジスタにロードする。このようにして、各タスクはタイムスライスを単位として少しずつ自己の処理を進めていく。   Switching the task execution right by the multitasking OS is called “task switch”. A task switch occurs when a time slice elapses or when a task executes a predetermined instruction. When the task switch execution timing is reached, the multitask OS saves the context information of the task being executed in a TCB (Task Control Block). The context information is data related to the execution state of a task or data stored in a CPU register at the time of task execution. The TCB is an area secured in the memory for holding task-specific information. After saving the context information of the task being executed to the TCB, the multitask OS selects the next task to which the execution right is assigned, reads the context information from the TCB of the task, and loads it into the CPU register. In this way, each task advances its own processing little by little in units of time slices.

マルチタスクOSは、複数のタスクを効率的に実行できるというメリットがあるが、コンテキスト情報の退避・ロードというオーバーヘッドが新たに発生するというデメリットもある。通常、マルチタスクOSのメリットはタスクスイッチにともなうオーバーヘッドを補って余りある。
特開平11−272480号公報 特開2001−75820号公報 特開平11−234302号公報 特開2000−10803号公報 特開2000−276362号公報 森久直、坂巻佳壽美、重松宏志、「組込み制御システム向けリアルタイムOSのハードウェア化(Hardware implementation of a read-time operating system for embedded control system)」、東京都立産業技術研究所研究報告、日本、2005年8月4日(原稿受付)、8、p.55−58
The multitask OS has an advantage that a plurality of tasks can be efficiently executed, but has a disadvantage that an overhead of saving / loading context information is newly generated. Usually, the merit of the multitasking OS more than compensates for the overhead associated with task switching.
JP 11-272480 A JP 2001-75820 A JP 11-234302 A JP 2000-10803 A JP 2000-276362 A Naohisa Mori, Yoshimi Sakamaki, Hiroshi Shigematsu, "Hardware implementation of a read-time operating system for embedded control system", Tokyo Metropolitan Industrial Technology Research Institute research report, Japan, 2005 August 4, 2014 (manuscript acceptance), 8, p. 55-58

近年においては、決められた時間内に処理が完了することを厳密に要求するリアルタイムOS(以下、「RTOS(Real-Time Operating System)」)が組込システム(Embedded System)を中心として普及しつつある。このような時間的要件の厳しいRTOSにおいては、タスクスイッチ時のオーバーヘッドがシステム全体のパフォーマンスに大きく影響することがある。   In recent years, a real-time OS (hereinafter referred to as “RTOS (Real-Time Operating System)”) that strictly requires completion of processing within a predetermined time has become widespread mainly in an embedded system. is there. In such an RTOS with strict time requirements, the overhead at the time of task switching may greatly affect the performance of the entire system.

また、タスクの一部をCPU以外の補助プロセッサに委譲することも多い。補助プロセッサとしては、たとえば、DMAC(Direct Memory Access Controller)、浮動小数点演算ユニット(FPU:Floating-point Processing Unit)、暗号処理ユニットなどがある。以下、補助プロセッサが実行する処理のことを「補助処理」とよぶ。補助プロセッサは特定の補助処理の専用回路である。このため、一般的には、同じの補助処理をCPUで実行するよりも補助プロセッサで実行する方が高速である。しかし、CPUと補助プロセッサという複数のハードウェア資源を利用する上では特有のオーバーヘッドが発生する。RTOSのパフォーマンスをいっそう向上させるためには、補助処理にともなうオーバーヘッドを抑制することが重要である。   Also, a part of the task is often delegated to an auxiliary processor other than the CPU. Examples of the auxiliary processor include a direct memory access controller (DMAC), a floating-point processing unit (FPU), and a cryptographic processing unit. Hereinafter, processing executed by the auxiliary processor is referred to as “auxiliary processing”. The auxiliary processor is a dedicated circuit for specific auxiliary processing. For this reason, in general, it is faster to execute the same auxiliary processing with the auxiliary processor than with the CPU. However, when using a plurality of hardware resources such as a CPU and an auxiliary processor, a specific overhead occurs. In order to further improve the performance of the RTOS, it is important to suppress overhead associated with auxiliary processing.

本発明は、本発明者による上記課題認識に基づいて完成されたものであり、その目的は、マルチタスク処理においてより効率的にタスクを実行制御するための技術を提供することであり、特に、補助処理を高速化するための技術、を提供することにある。   The present invention has been completed on the basis of the above-mentioned problem recognition by the present inventor, and its object is to provide a technique for performing and controlling tasks more efficiently in multitask processing, and in particular, It is to provide a technique for speeding up auxiliary processing.

本発明のある態様は、タスク処理装置である。
この装置は、処理レジスタと、メモリから処理レジスタにデータをロードし、処理レジスタのデータにしたがってタスクを実行する実行制御回路と、タスクごとの状態データを保持する状態レジスタと、タスクの実行状態を制御するタスク切換回路と、所定の選択条件によりタスクを選択するタスク選択回路と、補助処理を実行する補助処理回路、を備える。
実行制御回路は、システムコール命令を実行するとき、その旨をタスク切換回路に通知する。タスク選択回路は、実行可能に待機している状態を示すREADY(レディ)状態のタスクの中から実行対象となるタスクを選択する。
タスク切換回路は、システムコール命令実行時におけるタスク選択回路からの出力により次の実行対象となるのタスクを選択し、処理レジスタのデータを所定の記憶領域に退避させるとともに、実行中のタスクの状態データを設定変更し、選択したタスクについて記憶領域に退避されていたデータを処理レジスタにロードするとともにその状態データをREADY状態からRUN(ラン)状態に変更することにより、実行対象となるタスクを切り換える。
タスクが補助処理の実行を要求すると、タスク切換回路が補助処理回路に補助処理の実行を指示する。
One embodiment of the present invention is a task processing device.
This device includes a processing register, an execution control circuit that loads data from the memory to the processing register and executes a task according to the data in the processing register, a state register that holds state data for each task, and a task execution state. A task switching circuit for controlling, a task selection circuit for selecting a task according to a predetermined selection condition, and an auxiliary processing circuit for executing auxiliary processing are provided.
When executing the system call instruction, the execution control circuit notifies the task switching circuit to that effect. The task selection circuit selects a task to be executed from among the tasks in the READY state indicating the state waiting for execution.
The task switching circuit selects the next task to be executed by the output from the task selection circuit when the system call instruction is executed, saves the data in the processing register to a predetermined storage area, and indicates the status of the task being executed Change the data setting, load the data saved in the storage area for the selected task into the processing register, and change the status data from the READY state to the RUN state to switch the task to be executed .
When a task requests execution of auxiliary processing, the task switching circuit instructs the auxiliary processing circuit to execute auxiliary processing.

処理レジスタにロードされるデータは、命令(instruction)とオペランド、オペランドを持たない命令、あるいは、プログラムカウンタやスタックポインタのような単純なデータであってもよい。このような処理方法によれば、状態レジスタによりタスクの状態を管理するので、タスク切換回路はタスク選択回路からの出力に基づいてタスクスイッチを実行できる。タスクが補助処理の実行を要求するとき、タスク切換回路がこの実行要求を一元的に受け付け、補助処理回路に補助処理の実行を指示してもよい。この場合、タスク切換回路により補助処理制御を一元的に管理できる。   The data loaded into the processing register may be an instruction and an operand, an instruction having no operand, or simple data such as a program counter or a stack pointer. According to such a processing method, since the state of the task is managed by the state register, the task switching circuit can execute the task switch based on the output from the task selection circuit. When a task requests execution of auxiliary processing, the task switching circuit may centrally accept the execution request and instruct the auxiliary processing circuit to execute auxiliary processing. In this case, the auxiliary process control can be managed centrally by the task switching circuit.

なお、以上の構成要素の任意の組合せ、本発明を方法、システム、記録媒体、コンピュータプログラムにより表現したものもまた、本発明の態様として有効である。   It should be noted that any combination of the above-described components, and the present invention expressed by a method, system, recording medium, and computer program are also effective as an aspect of the present invention.

本発明によれば、マルチタスク処理において、より効率的なタスクの実行制御が実現される。   According to the present invention, more efficient task execution control is realized in multitask processing.

タスクの状態遷移図である。It is a state transition diagram of a task. 一般的なRTOSの概念図である。It is a conceptual diagram of general RTOS. ソフトウェアRTOSが実行される一般的なCPUの回路図である。It is a circuit diagram of a general CPU on which software RTOS is executed. 本実施例におけるRTOSの概念図である。It is a conceptual diagram of RTOS in a present Example. 基本例におけるタスク処理装置の回路図である。It is a circuit diagram of a task processing device in a basic example. 図5のCPUの回路図である。FIG. 6 is a circuit diagram of the CPU in FIG. 5. 実行制御回路152がCPUクロックを停止させる仕組みを示す回路図である。It is a circuit diagram which shows the mechanism in which the execution control circuit 152 stops a CPU clock. 割り込み要求信号発生時における各種信号の関係を示すタイムチャートである。It is a time chart which shows the relationship of the various signals at the time of interruption request signal generation. システムコール実行時における各種信号の関係を示すタイムチャートである。It is a time chart which shows the relationship of the various signals at the time of system call execution. パイプライン処理におけるCPUクロックの停止タイミングを説明するための模式図である。It is a schematic diagram for demonstrating the stop timing of the CPU clock in a pipeline process. 状態記憶部とタスク切換回路の関係を示す回路図である。It is a circuit diagram which shows the relationship between a state memory | storage part and a task switching circuit. 一般的なRTOSによるRUN−タスク選択に際して利用されるタスクレディリストを示す図である。It is a figure which shows the task ready list utilized at the time of RUN-task selection by general RTOS. 実行選択回路の回路図である。It is a circuit diagram of an execution selection circuit. 一般的なRTOSによるセマフォ処理において利用されるウェイトセマフォリストを示す図である。It is a figure which shows the wait semaphore list utilized in the semaphore process by general RTOS. セマフォ選択回路の回路図である。It is a circuit diagram of a semaphore selection circuit. タスク切換回路の状態遷移図である。It is a state transition diagram of a task switching circuit. 図5のタスク処理装置のうち、タスク制御回路を搭載しないタスク処理装置の回路図である。FIG. 6 is a circuit diagram of a task processing device that does not include a task control circuit in the task processing device of FIG. 5. 図5のタスク処理装置のうち、退避回路を搭載しないタスク処理装置の回路図である。FIG. 6 is a circuit diagram of a task processing device that does not include a save circuit among the task processing devices of FIG. 5. 改良例1におけるタスク処理装置の回路図である。FIG. 10 is a circuit diagram of a task processing device in an improved example 1; 改良例1におけるタスク制御回路の部分的な回路図である。FIG. 6 is a partial circuit diagram of a task control circuit in Modification Example 1. キュー制御回路の回路図である。It is a circuit diagram of a queue control circuit. 仮想キューとタスクの関係を示す概念図である。It is a conceptual diagram which shows the relationship between a virtual queue and a task. 図21に対応した状態レジスタのデータ構造図である。FIG. 22 is a data structure diagram of a status register corresponding to FIG. 21. 図21の仮想キューにタスク(E4)を順投入するときの概念図である。FIG. 22 is a conceptual diagram when tasks (E4) are sequentially placed in the virtual queue of FIG. 図23に対応した状態レジスタのデータ構造図である。FIG. 24 is a data structure diagram of a status register corresponding to FIG. 23. 図23の仮想キューにタスク(E5)を順投入するときの概念図である。FIG. 24 is a conceptual diagram when tasks (E5) are sequentially placed in the virtual queue of FIG. 図25に対応した状態レジスタのデータ構造図である。FIG. 26 is a data structure diagram of a status register corresponding to FIG. 25. 順投入の処理過程を示すフローチャートである。It is a flowchart which shows the process process of order insertion. 最大値選択回路の部分的な回路図である。It is a partial circuit diagram of a maximum value selection circuit. 図25の仮想キューにタスク(E6)を逆投入するときの概念図である。FIG. 26 is a conceptual diagram when a task (E6) is put back into the virtual queue of FIG. 図29に対応した状態レジスタのデータ構造図である。FIG. 30 is a data structure diagram of a status register corresponding to FIG. 29. 逆投入の処理過程を示すフローチャートである。It is a flowchart which shows the process of reverse insertion. タスク選択回路の部分的な回路図である。It is a partial circuit diagram of a task selection circuit. 図29の仮想キューからタスク(E3)を抽出するときの概念図である。It is a conceptual diagram when extracting a task (E3) from the virtual queue of FIG. 図33に対応した状態レジスタのデータ構造図である。FIG. 34 is a data structure diagram of a status register corresponding to FIG. 33. 抽出の処理過程を示すフローチャートである。It is a flowchart which shows the process process of extraction. 再実行優先型タスクスケジューリングにおける仮想キューとタスクの関係を示す第1の概念図である。It is a 1st conceptual diagram which shows the relationship between the virtual queue and a task in re-execution priority type task scheduling. 再実行優先型タスクスケジューリングにおける仮想キューとタスクの関係を示す第2の概念図である。It is a 2nd conceptual diagram which shows the relationship between the virtual queue and a task in re-execution priority type task scheduling. ソフトウェアOSにより補助処理を実行する場合の一般的な回路構成を示す図である。It is a figure which shows the general circuit structure in the case of performing an auxiliary process by software OS. 一般的な直列型補助処理の制御方法を示すタイムチャートである。It is a time chart which shows the control method of a general serial type auxiliary process. 一般的な並列型補助処理の制御方法を示すタイムチャートである。It is a time chart which shows the control method of a general parallel type auxiliary process. 基本例のタスク処理装置により図38から図40までに示した補助処理制御を実現する場合の回路構成を示す図である。It is a figure which shows the circuit structure in the case of implement | achieving auxiliary | assistant process control shown to FIGS. 38-40 by the task processing apparatus of a basic example. 改良例2においてタスク処理装置とHWFの関係を示す回路構成図である。FIG. 10 is a circuit configuration diagram showing a relationship between a task processing device and an HWF in an improved example 2; 改良例2における状態記憶部とタスク切換回路の関係を示す回路図である。It is a circuit diagram which shows the relationship between the state memory | storage part and task switching circuit in the modification 2. 改良例2における直列型補助処理の制御方法を示すタイムチャートである。It is a time chart which shows the control method of the serial type auxiliary process in the modification 2. 改良例2における並列型補助処理の制御方法を示すタイムチャートである。It is a time chart which shows the control method of the parallel type auxiliary process in the modification 2.

まず、マルチタスクOSのタスクスケジューリングを電子回路により実現するタスク処理装置100について「基本例」として説明する。次に、改良例2におけるタスク処理装置100にとって好適な「両投入型キューアルゴリズム(後述)」のハードウェア実装について「改良例1」として説明する。最後に、補助処理を高速化したタスク処理装置100について「改良例2」として説明する。
以下、「本実施例」というときには、原則として、「基本例」および「改良例1」、「改良例2」のすべてを示すものとする。
{基本例}
First, a task processing apparatus 100 that realizes task scheduling of a multitask OS by an electronic circuit will be described as a “basic example”. Next, a hardware implementation of a “double-input queue algorithm (described later)” suitable for the task processing apparatus 100 in the improved example 2 will be described as “improved example 1”. Finally, the task processing apparatus 100 that speeds up the auxiliary processing will be described as “Improvement 2”.
Hereinafter, when referring to "this embodiment", in principle, all of "basic example", "improved example 1", and "improved example 2" are shown.
{Basic example}

本実施例に示すタスク処理装置100は、マルチタスクOSのタスクスケジューリング機能を電子回路により実現している。タスク処理装置100の詳細を説明する前に、まず図1に関連してタスクの状態遷移について説明する。ここでは一般的なマルチタスクOSにおけるタスクの状態遷移として説明するが、タスク処理装置100によるタスクの状態遷移についても同じである。また、タスク処理装置100において実行されるシステムコールについても概説する。図2および図3に関連して一般的なマルチタスクOSの設計思想について述べた上で、図4から図10に関連して、基本例におけるタスク処理装置100の処理方法について詳述する。更に、セマフォ(Semaphore)やミューテックス(Mutex)、イベントなどに関する処理についても、適宜、一般的な技術と比較しながらタスク処理装置100の特徴を説明していく。
[タスクの状態遷移]
The task processing apparatus 100 shown in the present embodiment realizes a task scheduling function of a multitask OS by an electronic circuit. Before explaining the details of the task processing apparatus 100, first, the task state transition will be explained with reference to FIG. Here, description will be made on task state transition in a general multitask OS, but the same applies to task state transition by the task processing apparatus 100. The system call executed in the task processing apparatus 100 will also be outlined. A general multitask OS design concept will be described with reference to FIGS. 2 and 3, and a processing method of the task processing apparatus 100 in the basic example will be described in detail with reference to FIGS. Further, the characteristics of the task processing apparatus 100 will be described as appropriate for processing related to semaphores, mutexes, events, and the like, as compared with general techniques.
[Task state transition]

図1は、タスクの状態遷移図である。
マルチタスク処理において、各タスクは「状態(ステート)」を持つ。各タスクは、後述する複数の状態間を遷移し、常に、いずれかの状態となっている。状態遷移の契機となるのは、「システムコールの実行」と「割り込み要求信号の検出」である。システムコールとは各タスクが実行する命令のうちの特別な命令である。割り込み要求信号とは、キーボードの押下やマウスのクリック、通信データの受信など、周辺機器から所定データを受け取ったときに発生する信号である。もちろん、各タスクに割り当てられるタイムスライスが消費されたときにも状態遷移が発生する。
FIG. 1 is a task state transition diagram.
In multitask processing, each task has a “state”. Each task transits between a plurality of states described later, and is always in one of the states. The trigger for the state transition is “execution of system call” and “detection of interrupt request signal”. A system call is a special instruction among instructions executed by each task. The interrupt request signal is a signal generated when predetermined data is received from a peripheral device, such as a keyboard press, a mouse click, or communication data reception. Of course, the state transition also occurs when the time slice allocated to each task is consumed.

タスクは「一般タスク」と「特殊タスク」の2種類に大別される。一般タスクとは、システムコールを契機として実行される通常のタスクである。特殊タスクは、割り込み要求信号の検出を契機として実行されるタスクである。いわゆる割り込みハンドラである。まず、各タスク状態について述べた後、各種システムコール命令について説明する。   Tasks are roughly classified into two types: “general tasks” and “special tasks”. A general task is a normal task that is executed in response to a system call. The special task is a task that is executed when an interrupt request signal is detected. This is a so-called interrupt handler. First, after describing each task state, various system call instructions will be described.

(1)STOP状態(休止状態)
タスクが休止状態にあることを示す。一般タスクも特殊タスクもSTOP状態となり得る。以下、STOP状態にあるタスクのことを「STOP−タスク」とよぶ。
1−1.一般タスク
他のタスクが別のタスクの起動を指示するシステムコール(以下、「起動システムコール」とよぶ)を実行すると、STOP状態にある一般タスクは後述のREADY状態に遷移する。
1−2.特殊タスク
特殊タスクは、通常、STOP状態にある。後述のタスク切換回路210により割り込み要求信号が検出されると、特殊タスクはSTOP状態から後述のRUN状態に遷移する。このときRUN状態にあったタスクは入れ替わりにREADY状態に遷移する。
(1) STOP state (resting state)
Indicates that the task is in a dormant state. Both general tasks and special tasks can be in the STOP state. Hereinafter, a task in the STOP state is referred to as “STOP-task”.
1-1. General Task When another system executes a system call instructing activation of another task (hereinafter referred to as “activation system call”), the general task in the STOP state transitions to the READY state described later.
1-2. Special tasks Special tasks are usually in the STOP state. When an interrupt request signal is detected by a task switching circuit 210 described later, the special task transits from a STOP state to a RUN state described later. At this time, the task in the RUN state is switched to the READY state instead.

(2)RUN状態(実行状態)
タスクが実行中であることを示す。すなわち、タスクがタイムスライスを割り当てられ、CPUの使用権を取得している状態である。一般タスクも特殊タスクもRUN状態となり得る。以下、RUN状態にあるタスクのことを「RUN−タスク」とよぶ。複数のタスクのうち、RUN状態になることができるタスクは常に1つだけであり、同時に2つのタスクがRUN状態となることはできない。
2−1.一般タスク
RUN状態にある一般タスクは、所定のシステムコールを実行するとRUN状態からREADY状態または後述するWAIT状態に遷移する。RUN状態にある一般タスクは、タイムスライスを消費したときにも、READY状態に遷移する。いずれの場合においても、RUN状態にあった一般タスクの代わりに、READY状態にある一般タスクがRUN状態に遷移する。割り込み要求信号が検出されると、RUN−タスクはREADY状態に遷移する。このときには、STOP状態にある特殊タスクがRUN状態に遷移する。
RUN−タスクが自らを終了させるシステムコール(以下、「終了システムコール」とよぶ)を実行すると、RUN−タスクはSTOP状態に遷移する。
2−2.特殊タスク
割り込み要求信号によりSTOP状態からRUN状態に遷移した特殊タスクは、自処理が完了するとSTOP状態に戻る。特殊タスクが取り得る状態はSTOP状態とRUN状態のみである。
(2) RUN state (execution state)
Indicates that the task is running. That is, the task is assigned a time slice and has acquired the right to use the CPU. Both general and special tasks can be in the RUN state. Hereinafter, a task in the RUN state is referred to as “RUN-task”. Of the plurality of tasks, only one task can be in the RUN state at any one time, and two tasks cannot be in the RUN state at the same time.
2-1. General Task A general task in the RUN state transitions from the RUN state to the READY state or a WAIT state described later when a predetermined system call is executed. A general task in the RUN state also transitions to the READY state when the time slice is consumed. In any case, instead of the general task that was in the RUN state, the general task that is in the READY state transitions to the RUN state. When an interrupt request signal is detected, the RUN-task transitions to the READY state. At this time, the special task in the STOP state transitions to the RUN state.
When the RUN-task executes a system call that terminates itself (hereinafter referred to as “end system call”), the RUN-task transitions to the STOP state.
2-2. Special task The special task that has transitioned from the STOP state to the RUN state by the interrupt request signal returns to the STOP state when its own processing is completed. The states that the special task can take are only the STOP state and the RUN state.

(3)READY状態(実行可能状態)
タスクが実行可能な状態にあることを示す。READY状態にあるタスクは、OSから実行権を与えられればいつでもRUN状態に遷移できる。一般タスクのみREADY状態となり得る。以下、READY状態にあるタスクのことを「READY−タスク」とよぶ。
RUN状態にある一般タスクがシステムコールの実行によりRUN状態以外の状態に遷移するとき、または、RUN状態にある特殊タスクが自らの処理を終了してSTOP状態に遷移するとき、READY−タスクが入れ替わりにRUN状態に遷移する。一般タスクは、READY状態からのみRUN状態に遷移する。READY状態にあるタスクが複数存在するときには、コンテキスト情報の一部であるタスク優先順位に基づいて、いずれか一つのREADY−タスクがRUN状態に遷移する。タスク優先順位が同じとなるREADY−タスクが複数存在するときには、READY状態に移行したのが最も古いタスクがRUN状態に遷移する。
(3) READY state (executable state)
Indicates that the task is ready to run. A task in the READY state can transition to the RUN state at any time if an execution right is given from the OS. Only general tasks can be in the READY state. Hereinafter, a task in the READY state is referred to as “READY-task”.
When a general task in the RUN state transitions to a state other than the RUN state by executing a system call, or when a special task in the RUN state ends its processing and transitions to the STOP state, the READY-task is switched. Transition to the RUN state. The general task changes from the READY state only to the RUN state. When there are a plurality of tasks in the READY state, one of the READY-tasks transitions to the RUN state based on the task priority that is part of the context information. When there are a plurality of READY-tasks having the same task priority, the task having the oldest transition to the READY state transitions to the RUN state.

(4)WAIT状態(待機状態)
タスクが所定のWAIT解除条件の成立を待っている状態を示す。WAIT解除条件が成立すると、WAIT状態にあるタスクはREADY状態に遷移する。一般タスクのみWAIT状態となり得る。以下、WAIT状態にあるタスクのことを「WAIT−タスク」とよぶ。WAIT解除条件に関しては後に詳述する。
(4) WAIT state (standby state)
The task is waiting for a predetermined WAIT cancellation condition to be satisfied. When the WAIT cancellation condition is satisfied, the task in the WAIT state transitions to the READY state. Only general tasks can be in the WAIT state. Hereinafter, a task in the WAIT state is referred to as “WAIT-task”. The WAIT cancellation condition will be described in detail later.

以上をまとめると、各タスクはRUN状態にあるときだけCPUを使って自らの処理を進めることができる。RTOSは、複数のタスクの状態を管理しながら、適宜、RUN−タスクを切り換える。これにより、CPUが常時いずれかのタスクを実行する処理形態が実現される。
[システムコール]
In summary, each task can proceed with its own processing using the CPU only when it is in the RUN state. The RTOS switches RUN-tasks as appropriate while managing the states of a plurality of tasks. As a result, a processing mode in which the CPU always executes one of the tasks is realized.
[System Call]

次に、システムコールについて付言しておく。システムコールは、「起動系」、「WAIT系」、「SET系」の3種類に大別される。
(1)起動系システムコール
STOP状態とREADY状態の間の遷移に関連するシステムコールである。
1−1.起動システムコール
RUN−タスクであるタスクAが別の一般タスクBを起動させるシステムコールである。このとき、STOP状態にある一般タスクBはREADY状態に遷移する。
1−2.終了システムコール
このシステムコールを実行したタスクは、自己の処理を終了させ、RUN状態からSTOP状態に遷移する。終了システムコールは、あるタスクが別のタスクを終了させる命令であってもよい。
(2)WAIT系システムコール
RUN状態とWAIT状態の間の遷移に関連するシステムコールである。
2−1.ウェイトセマフォシステムコール
セマフォ(後述)の獲得を要求するシステムコールである。
2−2.ウェイトミューテックスシステムコール
ミューテックス(後述)の獲得を要求するシステムコールである。
2−3.ウェイトイベントシステムコール
イベント(後述)の成立を待つシステムコールである。イベントIDのほか、待機フラグパターン(後述)やフラグ条件(後述)を変数として実行される。
いずれの場合においても、WAIT系システムコールにより、さまざまなWAIT解除条件が設定される。WAIT系システムコールの実行時において、既にWAIT解除条件が成立する状況にあるときには、システムコールを実行したRUN−タスクはREADY状態に遷移する。一方、WAIT解除条件が成立していないときには、RUN−タスクは、WAIT解除条件の成立を待機するWAIT状態に遷移する。
(3)SET系システムコール
WAIT状態とREADY状態の間の遷移に関連するシステムコールである。SET系システムコールの実行は、WAIT解除条件の成立契機となる。
3−1.リリースセマフォシステムコール
セマフォを解放するシステムコールである。
3−2.リリースミューテックスシステムコール
ミューテックスを解放するシステムコールである。
3−3.セットイベントシステムコール
イベントのカレントフラグパターン(後述)を設定するシステムコールである。
3−4.クリアフラグシステムコール
カレントフラグパターンをゼロクリアするためのシステムコールである。
本実施例においては、以上の計9種類のシステムコールを対象として説明するが、これ以外にもさまざまなシステムコールを実装可能であることはいうまでもない。
[一般的なRTOSの設計思想]
Next, I will add a note about system calls. System calls are roughly classified into three types: “activation system”, “WAIT system”, and “SET system”.
(1) Activation system call A system call related to a transition between the STOP state and the READY state.
1-1. Activation system call This is a system call in which task A, which is a RUN-task, activates another general task B. At this time, the general task B in the STOP state transitions to the READY state.
1-2. End system call The task that executed this system call ends its own processing and transitions from the RUN state to the STOP state. The end system call may be an instruction for one task to end another task.
(2) WAIT system call A system call related to a transition between the RUN state and the WAIT state.
2-1. Wait semaphore system call This system call requests acquisition of a semaphore (described later).
2-2. Wait mutex system call This system call requests acquisition of a mutex (described later).
2-3. Wait event system call A system call that waits for the establishment of an event (described later). In addition to the event ID, a standby flag pattern (described later) and a flag condition (described later) are executed as variables.
In any case, various WAIT cancellation conditions are set by the WAIT system call. If a WAIT cancellation condition is already satisfied when a WAIT system call is executed, the RUN-task that executed the system call transitions to the READY state. On the other hand, when the WAIT cancellation condition is not satisfied, the RUN-task transits to a WAIT state that waits for the WAIT cancellation condition to be satisfied.
(3) SET system call A system call related to a transition between the WAIT state and the READY state. Execution of a SET system call triggers the establishment of a WAIT cancellation condition.
3-1. Release semaphore system call This system call releases a semaphore.
3-2. Release mutex system call This system call releases a mutex.
3-3. Set event system call This system call sets the current flag pattern (described later) of an event.
3-4. Clear flag system call This system call clears the current flag pattern to zero.
In the present embodiment, the above nine types of system calls will be described, but it goes without saying that various system calls can be implemented.
[General RTOS design concept]

図2は、一般的なRTOSの概念図である。
このRTOSはマルチタスクOSである。一般的なRTOSはソフトウェアとして実現される。タスクAからタスクBへRUN−タスクを切り換える場合を例として説明する。タスクAがCPUを占有しているので、RTOSはCPUに割り込みをかけて、CPUの使用権をタスクAから取り上げる。その上で、タスクAのコンテキスト情報をTCBに退避させる。RTOSは、次のRUN−タスクとしてタスクBを選択し、タスクBのTCBからコンテキスト情報をCPUのレジスタにロードする。ロードが完了すると、RTOSはCPUの使用権をタスクBに渡す。このように、RTOSは、一時的にCPUの使用権を取得することにより、タスクAからタスクBへのタスクスイッチを実行する。特殊タスクの実行に関しても同様である。この場合にも、RUN−タスクのコンテキスト情報をTCBに退避させた後、特殊タスクにCPUの使用権を渡すことによりタスクスイッチを実現している。
RTOSは、ソフトウェアとして実現されるため、自らの処理を実行するためにはCPUの使用権を必要とする。いいかえれば、RTOSとタスクは、CPUの使用に関して競合関係にある。以下、このようにソフトウェアによって実現されるRTOSのことを「ソフトウェアRTOS」とよぶ。
FIG. 2 is a conceptual diagram of a general RTOS.
This RTOS is a multitasking OS. A general RTOS is realized as software. A case where the RUN-task is switched from task A to task B will be described as an example. Since task A occupies the CPU, the RTOS interrupts the CPU and picks up the right to use the CPU from task A. After that, the context information of task A is saved in the TCB. The RTOS selects task B as the next RUN-task and loads context information from the task B TCB into the CPU registers. When the loading is completed, the RTOS passes the right to use the CPU to task B. In this way, the RTOS executes task switching from task A to task B by temporarily acquiring the right to use the CPU. The same applies to the execution of special tasks. Also in this case, the task switch is realized by saving the context information of the RUN-task to the TCB and then passing the right to use the CPU to the special task.
Since the RTOS is realized as software, it requires the right to use the CPU in order to execute its own processing. In other words, RTOS and tasks are competing for CPU usage. Hereinafter, the RTOS realized by software in this way is referred to as “software RTOS”.

図3は、ソフトウェアRTOSが実行される一般的なCPUの回路図である。
CPU84は、メモリアクセスや命令の実行等を統括的に制御する実行制御回路90と、タスクのコンテキスト情報など各種データを格納する処理レジスタ92、演算を実行する演算回路94を含む。処理レジスタ92は複数種類のレジスタの集合であり、特殊レジスタ88と汎用レジスタ86に大別される。特殊レジスタ88は、プログラムカウンタ、スタックポインタ、フラグ等を保持するレジスタである。汎用レジスタ86は、作業用のデータを保持するレジスタであり、R0〜R15までの計16レジスタを含む。特殊レジスタ88は、ユーザ用とシステム用の2面が存在するが、汎用レジスタ86は一面のみである。以下、処理レジスタ92に格納されるデータのことを「処理データ」とよぶ。
FIG. 3 is a circuit diagram of a general CPU on which software RTOS is executed.
The CPU 84 includes an execution control circuit 90 that comprehensively controls memory access, instruction execution, and the like, a processing register 92 that stores various data such as task context information, and an arithmetic circuit 94 that executes arithmetic operations. The processing register 92 is a set of a plurality of types of registers, and is roughly divided into a special register 88 and a general-purpose register 86. The special register 88 is a register that holds a program counter, a stack pointer, a flag, and the like. The general-purpose register 86 is a register that holds work data, and includes a total of 16 registers R0 to R15. The special register 88 has two sides for the user and the system, but the general-purpose register 86 has only one side. Hereinafter, the data stored in the processing register 92 is referred to as “processing data”.

実行制御回路90は、出力セレクタ98に対する制御信号(CTRL)により、処理レジスタ92のうちの所望のレジスタの処理データを演算回路94に出力させる。演算回路94は、処理データ、すなわち、命令や変数にしたがって演算を実行する。演算結果は入力セレクタ96へ出力される。実行制御回路90は、入力セレクタ96に対する制御信号(CTRL)により、処理レジスタ92のうちの所望のレジスタに演算結果を入力する。   The execution control circuit 90 causes the arithmetic circuit 94 to output processing data of a desired register among the processing registers 92 in response to a control signal (CTRL) for the output selector 98. The arithmetic circuit 94 performs an operation according to processing data, that is, an instruction or a variable. The calculation result is output to the input selector 96. The execution control circuit 90 inputs an operation result to a desired register among the processing registers 92 by a control signal (CTRL) for the input selector 96.

また、実行制御回路90は、CPUデータバスを介してメモリからデータを読み出し、入力セレクタ96を介して処理レジスタ92に適宜ロードする。実行制御回路90は、同じくCPUデータバスを介して処理データをメモリに適宜記録する。実行制御回路90は、特殊レジスタ88のプログラムカウンタを更新しながら、タスクを実行する。   Further, the execution control circuit 90 reads data from the memory via the CPU data bus, and loads it appropriately into the processing register 92 via the input selector 96. The execution control circuit 90 also records processing data in the memory as appropriate via the CPU data bus. The execution control circuit 90 executes the task while updating the program counter of the special register 88.

タスクスイッチが発生するときには、実行制御回路90は処理データをメモリ上の領域であるTCBに退避させる。仮にタスクAがシステムコールを実行し、タスクAからタスクBへのタスクスイッチが発生したとする。RTOSはシステムコール実行を契機としてCPUの使用権を取得するので、CPU84は一時的にRTOS用のプログラムにしたがって動作することになる。その処理過程は以下の通りである。
<タスクAのコンテキスト情報の退避>
When a task switch occurs, the execution control circuit 90 saves the processing data in the TCB, which is an area on the memory. Assume that task A executes a system call and a task switch from task A to task B occurs. Since the RTOS acquires the right to use the CPU when the system call is executed, the CPU 84 temporarily operates according to the RTOS program. The processing process is as follows.
<Save context information of task A>

1.実行制御回路90は、特殊レジスタ88をユーザ用からシステム用に切り換える。システム用の特殊レジスタ88にはRTOS処理用の処理データがロードされている。
2.実行制御回路90は、汎用レジスタ86のデータを図示しないスタックに退避させる。
3.実行制御回路90は、図示しない記憶媒体、たとえば、別のレジスタから、RTOSのための処理データを汎用レジスタ86にロードする。この段階で、処理レジスタ92の処理データは、完全にRTOS用の処理データに入れ替わる。
4.RTOSは、メモリからタスクAのTCBを検出し、スタックに退避されている処理データをTCBに書き込む。また、ユーザ用の特殊レジスタ88の処理データもコンテキスト情報の一部としてTCBに書き込む。こうして、タスクAの処理データがTCBに退避される。RTOSは、タスクAが「RUN」から「READY(またはWAIT)」に状態遷移したことをタスクAのTCBに記録する。
<タスクBのコンテキスト情報のロード>
1. The execution control circuit 90 switches the special register 88 from the user to the system. The system special register 88 is loaded with processing data for RTOS processing.
2. The execution control circuit 90 saves the data in the general-purpose register 86 in a stack (not shown).
3. The execution control circuit 90 loads processing data for RTOS into the general-purpose register 86 from a storage medium (not shown), for example, another register. At this stage, the processing data in the processing register 92 is completely replaced with processing data for RTOS.
4). The RTOS detects the TCB of task A from the memory and writes the processing data saved in the stack to the TCB. Also, the processing data of the user special register 88 is written to the TCB as part of the context information. In this way, the processing data of task A is saved in the TCB. The RTOS records in the TCB of the task A that the state transition of the task A from “RUN” to “READY (or WAIT)”.
<Load context information of task B>

1.RTOSは、メモリからタスクBのTCBを検出し、TCBのコンテキスト情報をスタックと特殊レジスタ88に書き込む。RTOSは、タスクBが「READY」から「RUN」に状態遷移したことをタスクBのTCBに記録する。
2.RTOSは、RTOS処理用のデータを汎用レジスタ86から図示しない記録媒体に退避させる。
3.実行制御回路90は、スタックのコンテキスト情報を汎用レジスタ86にロードする。実行制御回路90は、特殊レジスタ88をシステム用からユーザ用に切り換える。こうして、タスクBの処理データが処理レジスタ92にロードされる。
1. The RTOS detects the task B TCB from the memory and writes the TCB context information to the stack and special register 88. The RTOS records in the TCB of the task B that the state transition of the task B from “READY” to “RUN”.
2. The RTOS saves RTOS processing data from the general-purpose register 86 to a recording medium (not shown).
3. The execution control circuit 90 loads the stack context information into the general-purpose register 86. The execution control circuit 90 switches the special register 88 from the system to the user. In this way, the processing data of task B is loaded into the processing register 92.

以上のような処理過程を経て、タスクスイッチが実現される。通常、汎用レジスタ86は一面構成のため、タスク用の処理データとRTOS用の処理データを切り換えるためにスタックを使っている。汎用レジスタ86も2面化すれば、スタックを介して退避・ロードする必要がなくなるため、より高速なタスクスイッチが可能である。   The task switch is realized through the above processing steps. Normally, the general-purpose register 86 has a one-sided structure, and therefore a stack is used to switch between task processing data and RTOS processing data. If the general-purpose register 86 is also made two-sided, it is not necessary to save and load through the stack, so that higher-speed task switching is possible.

本実施例においては、更に、タスクごとに退避レジスタ110を設けることにより、いっそう高速なタスクスイッチを実現している。退避レジスタ110を使ったタスクスイッチについては図5に関連して詳述する。図3に関連して説明したCPU84と一般的なソフトウェアRTOSの場合、タスクスイッチに際して、頻繁にTCBへのアクセスが発生していることがわかる。上記設例では、タスクAからタスクBにタスクスイッチするという前提で説明したが、実際には、RTOSが次に実行すべきタスクBを選択するためにも多くの命令を実行する必要がある。このときにも、RTOSは頻繁にメモリにアクセスすることになる。本実施例におけるタスク処理装置100は、後述のタスク制御回路200がタスク選択処理を専用に実行するため、更に高速なタスクスイッチを実現している。
[タスク処理装置100によるRTOSのハードウェア化]
In this embodiment, a save register 110 is further provided for each task, thereby realizing a faster task switch. The task switch using the save register 110 will be described in detail with reference to FIG. In the case of the CPU 84 and the general software RTOS described in relation to FIG. 3, it can be seen that frequent access to the TCB occurs during task switching. In the above example, description has been made on the premise that the task is switched from the task A to the task B, but actually, it is necessary for the RTOS to execute many instructions in order to select the task B to be executed next. Also at this time, the RTOS frequently accesses the memory. The task processing apparatus 100 according to the present embodiment realizes a faster task switch because a task control circuit 200 described later executes task selection processing exclusively.
[RTOS hardware implementation by the task processing device 100]

図4は、本実施例におけるRTOSの概念図である。
一般的なソフトウェアRTOSと異なり、本実施例におけるRTOSは、主として、CPUとは別個のハードウェアとして実現される。以下、ハードウェアによって実現されるRTOSのことを、「ハードウェアRTOS」とよぶ。本実施例のRTOSは、主として、CPUとは別個のハードウェアであるため、自らの処理を実行するためにはCPUの使用権を実質的にほとんど必要としない。いいかえれば、RTOSとタスクは、CPUの使用に関してほとんど競合関係にない。図2に示した一般的なソフトウェアRTOSの場合、CPUはタスク実行用回路であるとともに、RTOS実行用回路でもあった。これに対し、本実施例におけるハードウェアRTOSの場合、CPUはタスク実行回路として明確化され、タスクスケジューリング機能は後述の退避回路120とタスク制御回路200を中心として実現することができる。
FIG. 4 is a conceptual diagram of the RTOS in this embodiment.
Unlike a general software RTOS, the RTOS in the present embodiment is mainly realized as hardware separate from the CPU. Hereinafter, RTOS realized by hardware is referred to as “hardware RTOS”. The RTOS of this embodiment is mainly hardware that is separate from the CPU, and therefore requires substantially no right to use the CPU to execute its own processing. In other words, RTOS and tasks have little competition for CPU usage. In the case of the general software RTOS shown in FIG. 2, the CPU is not only a task execution circuit but also an RTOS execution circuit. On the other hand, in the case of the hardware RTOS in this embodiment, the CPU is clarified as a task execution circuit, and the task scheduling function can be realized centering on a save circuit 120 and a task control circuit 200 described later.

図5は、基本例におけるタスク処理装置100の回路図である。
タスク処理装置100は、CPU150に加えて退避回路120とタスク制御回路200を含む。CPU150はタスクの実行主体であり、退避回路120とタスク制御回路200が図4に示したRTOSの役割を担う回路である。タスクススケジューリング処理は、タスク制御回路200により主導される。
FIG. 5 is a circuit diagram of the task processing apparatus 100 in the basic example.
The task processing device 100 includes a save circuit 120 and a task control circuit 200 in addition to the CPU 150. The CPU 150 is a task execution subject, and the save circuit 120 and the task control circuit 200 are circuits that play the role of the RTOS shown in FIG. The task scheduling process is led by the task control circuit 200.

CPU150は、実行制御回路152、処理レジスタ154および演算回路160を含む。CPU150は、図3に関連して説明した一般的なCPUであってもよい。ただし、本実施例におけるCPU150は、図3に示したCPU84とは信号線の接続方法等が若干変更されている。具体的な回路構成については次の図6に関連して詳述する。   The CPU 150 includes an execution control circuit 152, a processing register 154, and an arithmetic circuit 160. The CPU 150 may be a general CPU described with reference to FIG. However, the CPU 150 in the present embodiment is slightly different from the CPU 84 shown in FIG. A specific circuit configuration will be described in detail with reference to FIG.

タスク制御回路200は、タスク切換回路210、セマフォテーブル212、イベントテーブル214、タスク選択回路230および状態記憶部220を含む。セマフォテーブル212とイベントテーブル214については、図13以降に関連して詳述する。状態記憶部220は、タスクごとに対応づけられたユニットである。以下、タスクAに対応する状態記憶部220のことを「状態記憶部220_A」のように表記する。各状態記憶部220は、タスクの状態データを保持する。状態データとは、コンテキスト情報のうち、特に、タスク優先順位や状態など、タスクの属性を示す情報である。具体的なデータの内容については、図10に関連して後述する。各状態記憶部220からは、全タスクの全状態データがタスク選択回路230に常時出力している。タスク選択回路230は、各タスクの状態データに基づいて、RUN−タスクの選択等、各種タスク選択を行う回路である。タスク選択回路230についても図10以降に関連して詳述する。タスク切換回路210は、実行制御回路152から受信するシステムコール信号(SC)や外部装置からの割り込み要求信号(INTR)を検出すると、タスクスイッチを実行する。   The task control circuit 200 includes a task switching circuit 210, a semaphore table 212, an event table 214, a task selection circuit 230, and a state storage unit 220. The semaphore table 212 and the event table 214 will be described in detail with reference to FIG. The state storage unit 220 is a unit associated with each task. Hereinafter, the state storage unit 220 corresponding to the task A is expressed as “state storage unit 220_A”. Each state storage unit 220 holds task state data. The state data is information indicating task attributes such as task priority and state among context information. Specific data contents will be described later with reference to FIG. From each state storage unit 220, all state data of all tasks is constantly output to the task selection circuit 230. The task selection circuit 230 is a circuit that performs various task selection such as selection of a RUN-task based on the state data of each task. The task selection circuit 230 will also be described in detail with reference to FIG. When task switching circuit 210 detects a system call signal (SC) received from execution control circuit 152 or an interrupt request signal (INTR) from an external device, task switching circuit 210 executes a task switch.

実行制御回路152はシステムコール実行時には、システムコール信号(SC)をタスク切換回路210に送信する。また、タスク切換回路210が割り込み要求信号(INTR)を検出したときには、タスク切換回路210は実行制御回路152に対して停止要求信号(HR)をアサートする。実行制御回路152は、CPU150の動作が停止しているときには停止完了信号(HC)をタスク切換回路210にアサートする。これら3種類の信号によって、CPU150とタスク制御回路200が連係動作することになる。   The execution control circuit 152 transmits a system call signal (SC) to the task switching circuit 210 when the system call is executed. When the task switching circuit 210 detects an interrupt request signal (INTR), the task switching circuit 210 asserts a stop request signal (HR) to the execution control circuit 152. The execution control circuit 152 asserts a stop completion signal (HC) to the task switching circuit 210 when the operation of the CPU 150 is stopped. With these three types of signals, the CPU 150 and the task control circuit 200 are linked to each other.

退避回路120は、ロード選択回路112および複数の退避レジスタ110を含む。退避レジスタ110も、タスクごとに対応づけられたユニットであり、処理レジスタ154の処理データを退避させるためのレジスタである。したがって、退避レジスタ110は、処理レジスタ154と同等以上のデータ容量を持つ。以下、タスクAに対応する退避レジスタ110のことを「退避レジスタ110_A」のように表記する。ロード選択回路112は、タスク切換回路210から指示されると、いずれかの退避レジスタ110のデータ(以下、退避レジスタ110が保持するデータのことを「退避データ」とよぶ)を処理レジスタ154にロードする。   The save circuit 120 includes a load selection circuit 112 and a plurality of save registers 110. The save register 110 is also a unit associated with each task, and is a register for saving the processing data of the processing register 154. Therefore, the save register 110 has a data capacity equal to or greater than that of the processing register 154. Hereinafter, the save register 110 corresponding to the task A is expressed as “save register 110_A”. When instructed by the task switching circuit 210, the load selection circuit 112 loads data in any of the save registers 110 (hereinafter, data held by the save register 110 is referred to as “saved data”) into the processing register 154. To do.

各退避レジスタ110はそれぞれの退避データをロード選択回路112に常時出力する。タスク切換回路210がロード選択回路112にタスクIDを指定したタスク選択信号(TS)を入力すると、ロード選択回路112は指定されたタスクに対応する退避レジスタ110の退避データを処理レジスタ154に出力する。更に、タスク切換回路210が処理レジスタ154に対して書き込み信号(WT)を入力すると、その退避データは処理レジスタ154に実際にロードされる。   Each save register 110 always outputs each save data to the load selection circuit 112. When the task switching circuit 210 inputs a task selection signal (TS) designating a task ID to the load selection circuit 112, the load selection circuit 112 outputs the saved data of the save register 110 corresponding to the designated task to the processing register 154. . Further, when the task switching circuit 210 inputs a write signal (WT) to the processing register 154, the saved data is actually loaded into the processing register 154.

一方、処理レジスタ154の全処理データも全退避レジスタ110に常時出力されている。タスク切換回路210が所望の退避レジスタ110に対して書き込み信号(WT)をアサートすると、その退避レジスタ110に処理データが退避される。ここで、処理レジスタ154と各退避レジスタ110を接続するバスが一度に伝送可能なビット数は、処理データをパラレル転送できるように設定されている。そのため、タスク切換回路210は、退避レジスタ110に書き込み信号を一度送信するだけで、処理データを退避レジスタ110に一気に書き込むことができる。また、退避レジスタ110とロード選択回路112、ロード選択回路112とCPU150を接続するバスのビット数も同様に設定されている。
以下、システムコールと割り込み要求信号のそれぞれについてタスクスイッチの実行方法を説明する。
[1]システムコール実行
On the other hand, all the processing data in the processing register 154 is always output to the all save register 110. When the task switching circuit 210 asserts a write signal (WT) to a desired save register 110, the processing data is saved in the save register 110. Here, the number of bits that can be transmitted at one time by the bus connecting the processing register 154 and each save register 110 is set so that the processing data can be transferred in parallel. Therefore, the task switching circuit 210 can write the processing data to the save register 110 at a stretch by only transmitting the write signal to the save register 110 once. The number of bits of the bus connecting the save register 110 and the load selection circuit 112, and the load selection circuit 112 and the CPU 150 are set in the same manner.
Hereinafter, a task switch execution method for each of the system call and the interrupt request signal will be described.
[1] System call execution

CPU150の実行制御回路152がシステムコールを実行するとき、実行制御回路152はCPU150のクロック(以下、「CPUクロック(CLK)」とよぶ)を停止させる。具体的な停止方法については、図7等に関連して後に詳述する。実行制御回路152は、システムコールの実行を示すシステムコール信号(SC)をタスク制御回路200のタスク切換回路210に送信する。また、CLKが停止完了すると、実行制御回路152は停止完了信号(HC)をタスク切換回路210にアサートする。   When the execution control circuit 152 of the CPU 150 executes the system call, the execution control circuit 152 stops the clock of the CPU 150 (hereinafter referred to as “CPU clock (CLK)”). A specific stopping method will be described later in detail with reference to FIG. The execution control circuit 152 transmits a system call signal (SC) indicating the execution of the system call to the task switching circuit 210 of the task control circuit 200. When CLK is completely stopped, the execution control circuit 152 asserts a stop completion signal (HC) to the task switching circuit 210.

CPU150とタスク切換回路210の間には、システムコール信号伝送用に9本の信号線が接続されている。9本の信号線は先述した9種類のシステムコールに対応する。実行制御回路152は、実行されたシステムコールの種類に応じて、いずれかのシステムコール信号線にてデジタルパルスを伝送する。タスク切換回路210は、9本のシステムコール信号線のうち、どの信号線からデジタルパルスが検出されたかに応じて、即座に実行されたシステムコールの種類を検出できる。タスク切換回路210は、システムコールの種類に応じて、タスク選択回路230の出力データから必要なデータを選択し、システムコールにより指示された処理を実行する。この処理は、HCがアサートされたことを条件として実行される。タスク切換回路210とタスク選択回路230の関係については、図10に関連して詳述する。なお、システムコールのパラメータや戻り値は、処理レジスタ154のうち、所定の汎用レジスタ158に書き込まれる。タスク切換回路210は汎用レジスタ158に対してパラメータの読み出しや戻り値の書き込みを実行可能である。ここでは、RUN−タスクであるタスクAがウェイトセマフォシステムコールを実行したとする。したがって、まず、タスクAの処理データを退避させる必要がある。
<タスクAのコンテキスト情報の退避>
Nine signal lines are connected between the CPU 150 and the task switching circuit 210 for system call signal transmission. Nine signal lines correspond to the nine types of system calls described above. The execution control circuit 152 transmits a digital pulse through one of the system call signal lines according to the type of the system call that has been executed. The task switching circuit 210 can immediately detect the type of the system call that has been executed according to which of the nine system call signal lines the digital pulse is detected from. The task switching circuit 210 selects necessary data from the output data of the task selection circuit 230 according to the type of the system call, and executes the process instructed by the system call. This process is executed on condition that HC is asserted. The relationship between the task switching circuit 210 and the task selection circuit 230 will be described in detail with reference to FIG. The system call parameters and return values are written to a predetermined general-purpose register 158 in the processing register 154. The task switching circuit 210 can read parameters and write return values to the general-purpose register 158. Here, it is assumed that task A, which is a RUN-task, executes a wait semaphore system call. Therefore, first, it is necessary to save the processing data of task A.
<Save context information of task A>

実行制御回路152は、ウェイトセマフォシステムコールを示すSC信号をタスク切換回路210に入力する。実行制御回路152はCLKを停止させ、停止が完了するとHCをアサートする。タスク切換回路210はタスク選択回路230に内蔵される各種選択回路のうち、後述のセマフォ選択回路234に対して待機対象となるセマフォのセマフォIDを出力した上で、次に実行すべきタスクBを選択する。タスク切換回路210は、状態記憶部220_Aに対して所定データを書き込む。たとえば、タスクAの状態として「RUN」から「READY」や「WAIT」に設定変更する。より具体的には、タスク切換回路210は、状態データのうちタスク状態を示すデータとして「WAIT」を全状態記憶部220に出力した上で、状態記憶部220_Aだけに書き込み信号(WT_A)を入力する。こうして、タスクAの状態が設定変更される。   The execution control circuit 152 inputs an SC signal indicating a wait semaphore system call to the task switching circuit 210. The execution control circuit 152 stops CLK and asserts HC when the stop is completed. The task switching circuit 210 outputs a semaphore ID of a semaphore to be waited for to a semaphore selection circuit 234, which will be described later, among various selection circuits built in the task selection circuit 230, and then selects a task B to be executed next. select. The task switching circuit 210 writes predetermined data to the state storage unit 220_A. For example, the state of task A is changed from “RUN” to “READY” or “WAIT”. More specifically, the task switching circuit 210 outputs “WAIT” as data indicating the task state among the state data to the entire state storage unit 220 and then inputs a write signal (WT_A) only to the state storage unit 220_A. To do. In this way, the state of task A is changed.

次に、タスク切換回路210は、退避レジスタ110_Aに対して書き込み信号(WT)を出力する。処理レジスタ154の処理データは、常時、各退避レジスタ110に出力されているので、この書き込み信号(WT)によりタスクAの退避レジスタ110_Aに退避される。
<タスクBのコンテキスト情報のロード>
Next, the task switching circuit 210 outputs a write signal (WT) to the save register 110_A. Since the processing data of the processing register 154 is always output to each save register 110, it is saved in the save register 110_A of the task A by this write signal (WT).
<Load context information of task B>

タスク切換回路210は、タスクAの状態データの変更、処理データの退避が完了すると、タスクBを指定したタスク選択信号(TS_B)をロード選択回路112に出力する。これにより、退避レジスタ110_Bの退避データが処理レジスタ154に出力される。タスク切換回路210は、処理レジスタ154に書き込み信号(WT)を出力すると、タスクBの退避データが処理レジスタ154にロードされる。また、タスク切換回路210は、タスクBの状態記憶部220に対して所定データを書き込む。たとえば、タスクBの状態を「READY」から「RUN」に設定変更する。以上の処理が完了すると、実行制御回路152はCPUクロックを再開させる。CPU150は、再開されたCPUクロックによりタスクBの実行を開始する。処理方法の更なる詳細については、図8(b)に関連して後述する。
[2]割り込み要求信号の発生
The task switching circuit 210 outputs a task selection signal (TS_B) designating the task B to the load selection circuit 112 when the change of the state data of the task A and the saving of the processing data are completed. As a result, the save data of the save register 110_B is output to the processing register 154. When the task switching circuit 210 outputs a write signal (WT) to the processing register 154, the saved data of task B is loaded into the processing register 154. Further, the task switching circuit 210 writes predetermined data in the state storage unit 220 of task B. For example, the state of task B is changed from “READY” to “RUN”. When the above processing is completed, the execution control circuit 152 restarts the CPU clock. The CPU 150 starts executing the task B by the resumed CPU clock. Further details of the processing method will be described later with reference to FIG.
[2] Generation of interrupt request signal

タスク切換回路210は周辺機器からの割り込み要求信号(INTR)を検出する。より具体的には、割り込み要求信号(INTR)は、図示しない割込コントローラからタスク切換回路210に送信される。割り込み要求信号(INTR)のレベルを示すパラメータは、割込コントローラが内蔵するレジスタに記録される。タスク切換回路210は実行制御回路152に停止要求信号(HR)をアサートし、実行制御回路152はCPUクロックを停止させる。システムコール実行時と同様、タスク切換回路210はRUN−タスクの処理データを退避レジスタ110に退避させる。次に、タスク切換回路210は特殊タスクを起動する。割り込み要求信号のパラメータに関わらず起動される特殊タスクは1種類である。特殊タスクは、割込コントローラの内蔵レジスタからINTRのパラメータを読み出し、パラメータに応じた処理を実行する。特殊タスクが実行する処理は、セットイベントシステムコールやセットセマフォシステムコールの実行かもしれないし、一般タスクの起動かもしれない。パラメータによっては、特殊タスクは特段の処理を実行せずに終了するかもしれない。INTRのパラメータによってどのような処理を実行するかは特殊タスクの実装による。特殊タスクが実行終了すると、READY−タスクの中から次のRUN−タスクが選択される。   The task switching circuit 210 detects an interrupt request signal (INTR) from a peripheral device. More specifically, the interrupt request signal (INTR) is transmitted to the task switching circuit 210 from an interrupt controller (not shown). A parameter indicating the level of the interrupt request signal (INTR) is recorded in a register built in the interrupt controller. The task switching circuit 210 asserts a stop request signal (HR) to the execution control circuit 152, and the execution control circuit 152 stops the CPU clock. As in the case of system call execution, the task switching circuit 210 saves the processing data of the RUN-task in the save register 110. Next, the task switching circuit 210 starts a special task. There is one type of special task that is activated regardless of the parameters of the interrupt request signal. The special task reads the INTR parameter from the built-in register of the interrupt controller and executes a process according to the parameter. The processing executed by the special task may be execution of a set event system call or a set semaphore system call, or activation of a general task. Depending on the parameters, the special task may end without executing any special processing. What processing is executed according to the parameters of INTR depends on the implementation of the special task. When the execution of the special task is completed, the next RUN-task is selected from the READY-tasks.

タスク切換回路210は、特殊タスクに対応した退避レジスタ110の処理データをCPU150にロードさせる。このような一般タスクから特殊タスクへの切り換えのために要する時間は、タスク制御回路200の動作クロックによってあらかじめ見積もることができる。HRを実行制御回路152にアサートしてからタスク切換回路210の動作クロックが所定クロック分経過すると、タスク切換回路210はCPUクロックの停止を解除するためにHRをネゲートする。実行制御回路152はHRをネゲートされるとCPUクロックを再開させる。このときには、タスク切換回路210によって一般タスクから特殊タスクへのタスクスイッチが完了している。処理方法の詳細については、図8(a)に関連して後述する。   The task switching circuit 210 causes the CPU 150 to load the processing data of the save register 110 corresponding to the special task. The time required for switching from the general task to the special task can be estimated in advance by the operation clock of the task control circuit 200. When the operation clock of the task switching circuit 210 elapses after the HR is asserted to the execution control circuit 152, the task switching circuit 210 negates HR to cancel the stop of the CPU clock. The execution control circuit 152 restarts the CPU clock when HR is negated. At this time, the task switching circuit 210 completes the task switch from the general task to the special task. Details of the processing method will be described later with reference to FIG.

いずれの場合においても、
(A)処理データの退避・ロード
(B)タスクの状態遷移およびRUN−タスクの選択
というタスクスイッチの中核となる処理をハードウェアにより実現している。(A)および(B)に関し、メモリ上のTCBにアクセスする必要がなくなることもタスクスイッチの高速化に寄与している。また、タスク処理装置100を実現するにあたり、CPU150については、CPUクロックを停止および再開する機能を追加するだけでよい。なお、これらの機能がすべてハードウェアによって実現されることは、本発明の範囲を限定するものではない。たとえば、(A)または(B)の主たる機能をハードウェアにより実現し、ハードウェアの機能を補助するためにRTOSの一部の機能をソフトウェアで実現してもよいことは当業者には理解されるところである。
In either case,
(A) Saving / loading of processing data (B) The core processing of task switching such as task state transition and RUN-task selection is realized by hardware. Regarding (A) and (B), the need to access the TCB on the memory is eliminated, which contributes to the speedup of the task switch. In realizing the task processing apparatus 100, the CPU 150 need only have a function of stopping and restarting the CPU clock. Note that the realization of all of these functions by hardware does not limit the scope of the present invention. For example, those skilled in the art will understand that the main functions of (A) or (B) may be realized by hardware, and some functions of RTOS may be realized by software in order to assist the hardware functions. It is a place.

図6は、図5のCPU150の回路図である。
図3のCPU84と異なり、処理レジスタ154は特殊レジスタ156と汎用レジスタ158共に一面だけの構成となっている。処理レジスタ154にはそれぞれロード選択回路112からの入力バス、退避レジスタ110への出力バス、タスク切換回路210からの書き込み信号(WT)用の信号線が追加されている。実行制御回路152は、出力セレクタ164に対する制御信号(CTRL)により、処理レジスタ92のうちの所望のレジスタのデータを演算回路160に入力する。演算結果は入力セレクタ162への入力となる。実行制御回路152は、入力セレクタ162に対する制御信号(CTRL)により、処理レジスタ154のうちの所望のレジスタに演算結果を入力する。実行制御回路152は、特殊レジスタ156のプログラムカウンタを更新しながら、タスクを実行する。
FIG. 6 is a circuit diagram of the CPU 150 of FIG.
Unlike the CPU 84 in FIG. 3, the processing register 154 includes only one surface for both the special register 156 and the general-purpose register 158. In the processing register 154, an input bus from the load selection circuit 112, an output bus to the save register 110, and a signal line for a write signal (WT) from the task switching circuit 210 are added. The execution control circuit 152 inputs data of a desired register in the processing register 92 to the arithmetic circuit 160 by a control signal (CTRL) for the output selector 164. The calculation result is input to the input selector 162. The execution control circuit 152 inputs a calculation result to a desired register among the processing registers 154 by a control signal (CTRL) to the input selector 162. The execution control circuit 152 executes the task while updating the program counter of the special register 156.

処理データは、メモリ上のTCBではなく退避レジスタ110に退避される。処理レジスタ154からは常時、各退避レジスタ110に処理データが出力されている。実際にどの退避レジスタ110にどのタイミングで処理データを退避させるかは、先述のようにタスク切換回路210によって制御される。   The processing data is saved in the save register 110 instead of the TCB on the memory. The processing data is always output from the processing register 154 to each save register 110. The task switching circuit 210 controls which save data is actually saved in which save register 110 as described above.

処理レジスタ154には、メモリ上のTCBではなく退避レジスタ110から退避データがロードされる。実際にどの退避レジスタ110の処理データをどのタイミングでロードするかは、先述のようにタスク切換回路210によって制御される。   The save data is loaded into the processing register 154 from the save register 110 instead of the TCB on the memory. The task switching circuit 210 controls which save register 110 processing data is actually loaded at which timing as described above.

処理レジスタ154とロード選択回路112、処理レジスタ154と退避レジスタ110を接続するバスは、一度に処理データをパラレル転送可能なビット数のバスである。そのため、タスク切換回路210による書き込み信号(WT)により、一度に読み出しや書き込みが可能となっている。一般的なソフトウェアRTOSは、タスクスイッチに際しては処理レジスタ154を一時的に占有する必要がある。これに対して、本実施例におけるハードウェアRTOSは、タスクスイッチ処理のための特別な処理データを処理レジスタ154にロードする必要がない。タスクAからタスクBの切り換えに際しては、タスクAの処理データを退避したあとにタスクBの処理データをロードするだけなので、処理レジスタ154をシステム用とユーザ用の2面分用意したり、スタックを介したデータの入れ替え処理を実行する必要がない。   The bus connecting the processing register 154 and the load selection circuit 112, and the processing register 154 and the save register 110 is a bus having the number of bits that can transfer the processing data in parallel at one time. Therefore, reading and writing can be performed at once by the write signal (WT) from the task switching circuit 210. The general software RTOS needs to temporarily occupy the processing register 154 at the time of task switching. On the other hand, the hardware RTOS in this embodiment does not need to load special processing data for task switch processing into the processing register 154. When switching from task A to task B, the task B processing data is simply loaded after saving the task A processing data, so two processing registers 154 are prepared for the system and the user, or stacks are prepared. There is no need to perform data exchange processing via

図7は、実行制御回路152がCPUクロックを停止させる仕組みを示す回路図である。
第2ANDゲート174の入力は原クロック(CLK0)と第1ANDゲート172の出力で、後者は負論理である。第1ANDゲート172の出力は停止完了信号(HC)である。停止完了信号(HC)は通常は0なので、第2ANDゲート174は、入力された原クロック(CLK0)をCPUクロック(CLK)としてそのまま出力する。CPU150は、第2ANDゲート174の出力するCPUクロックを受けて動作する。第1ANDゲート172の出力が「1」のとき、いいかえれば、停止完了信号(HC)=1のときには、第2ANDゲート174の出力はゼロに固定され、CPUクロック(CLK)が停止する。
FIG. 7 is a circuit diagram showing a mechanism by which the execution control circuit 152 stops the CPU clock.
The inputs of the second AND gate 174 are the original clock (CLK0) and the output of the first AND gate 172, and the latter is negative logic. The output of the first AND gate 172 is a stop completion signal (HC). Since the stop completion signal (HC) is normally 0, the second AND gate 174 outputs the input original clock (CLK0) as it is as the CPU clock (CLK). The CPU 150 operates in response to the CPU clock output from the second AND gate 174. When the output of the first AND gate 172 is “1”, in other words, when the stop completion signal (HC) = 1, the output of the second AND gate 174 is fixed to zero and the CPU clock (CLK) stops.

第1ANDゲート172の入力は、ORゲート176の出力とCPUビジー信号(CBUSY)で、後者は負論理である。CBUSYは、CPU150の内部サイクルを発生させる既知のステートマシンから出力される信号であり、CPU150が停止可能な状態にあるときに「1」となる信号である。たとえば、演算回路94が実行中の単一の命令またはロックされている複数の命令の最後の命令を完了させ、CPUが停止可能な状態になったとき、または、既にCPUクロックの供給が停止されているときに「0」となる。   The inputs of the first AND gate 172 are the output of the OR gate 176 and the CPU busy signal (CBUSY), the latter being negative logic. CBUSY is a signal output from a known state machine that generates an internal cycle of the CPU 150, and is a signal that is “1” when the CPU 150 is in a stoppable state. For example, when the arithmetic circuit 94 completes the last instruction of a single instruction being executed or a plurality of locked instructions, the CPU can be stopped, or the supply of the CPU clock has already been stopped. "0" when

ORゲート176の入力は、命令復号器170の出力(SC_DETECT)とタスク切換回路210からの停止要求信号(HR)である。命令復号器170は、SC_DETECTを保持するラッチ回路を内蔵する。命令復号器170は、CPU150からフェッチされたデータ(FD)を入力とし、FDがシステムコール命令のときにSC_DETECT=1を出力する。内蔵ラッチ回路により、その後にFDが変化しても、命令復号器170はSC_DETECT=1を継続して出力する。命令復号器170にはタスク切換回路210の処理レジスタ154に対する書き込み信号(WT)も入力される。WTが0から1に変化するとき、先述したように退避データの処理レジスタ154へのロードが実行される。このWTは所定時間後に1から0に戻るパルス信号である。WTが1から0に変化するとき、命令復号器170のラッチ回路はリセットされ、命令復号器170はSC_DETECTをネゲートする。SC_DETECTと書き込み信号(WT)の関係については、図8(b)に関連して詳述する。本実施例における命令復号器170は、実行対象命令がシステムコールか否かを判定するために実行制御回路152に専用に設けられる装置である。変形例として、命令復号器170はCPU150のデコードステージを担当するCPUデコーダと共通化されてもよい。この場合、命令復号器170は、CPUデコーダに、復号したデータがシステムコール命令であったときにSC_DETECT=1を出力する機能を追加することにより実現できる。
割り込み要求信号(INTR)が発生したとき、タスク切換回路210は実行制御回路152に停止要求信号(HR)をアサートする。すなわち、ORゲート176の出力は、システムコールが実行されるか、停止要求信号(HR)がアサートされたときに「1」となる。
The inputs of the OR gate 176 are an output (SC_DETECT) of the instruction decoder 170 and a stop request signal (HR) from the task switching circuit 210. The instruction decoder 170 includes a latch circuit that holds SC_DETECT. The instruction decoder 170 receives the data (FD) fetched from the CPU 150, and outputs SC_DETECT = 1 when the FD is a system call instruction. Even if the FD subsequently changes due to the built-in latch circuit, the instruction decoder 170 continues to output SC_DETECT = 1. The instruction decoder 170 also receives a write signal (WT) for the processing register 154 of the task switching circuit 210. When WT changes from 0 to 1, loading of the saved data into the processing register 154 is executed as described above. This WT is a pulse signal that returns from 1 to 0 after a predetermined time. When WT changes from 1 to 0, the latch circuit of instruction decoder 170 is reset and instruction decoder 170 negates SC_DETECT. The relationship between SC_DETECT and the write signal (WT) will be described in detail with reference to FIG. The instruction decoder 170 in this embodiment is a device provided exclusively for the execution control circuit 152 in order to determine whether or not the execution target instruction is a system call. As a modification, the instruction decoder 170 may be shared with a CPU decoder in charge of the decoding stage of the CPU 150. In this case, the instruction decoder 170 can be realized by adding a function of outputting SC_DETECT = 1 to the CPU decoder when the decoded data is a system call instruction.
When the interrupt request signal (INTR) is generated, the task switching circuit 210 asserts a stop request signal (HR) to the execution control circuit 152. That is, the output of the OR gate 176 becomes “1” when a system call is executed or a stop request signal (HR) is asserted.

まとめると、システムコールが実行されるか割り込み要求信号が発生し、かつ、CPUビジー信号が「0」となったとき、第1ANDゲート172の出力は「1」となり、第2AND174からはCPUクロックが出力されなくなる。   In summary, when a system call is executed or an interrupt request signal is generated and the CPU busy signal becomes “0”, the output of the first AND gate 172 becomes “1”, and the second AND 174 outputs the CPU clock. No output.

図8(a)は、割り込み要求信号発生時における各種信号の関係を示すタイムチャートである。
同図においては、まず、時刻tにおいて、タスク切換回路210は外部からの割り込み要求信号(INTR)を検出している。タスク切換回路210は、特殊タスクを実行させるため、実行制御回路152に停止要求信号(HR)をアサートする。入力タイミングtは、検出タイミングtとほとんど同時である。時刻tでは、CPU150のステートマシンは「タスク実行中」であり、CBUSY=1である。HR=1より、ORゲート176は「1」を出力するが、CBUSY=1ゆえにCPU150は停止しない。そのため、HR=1が入力されても、しばらくはCPUクロック(CLK)は原クロック(CLK0)に同期して出力される。
FIG. 8A is a time chart showing the relationship between various signals when an interrupt request signal is generated.
In the figure, first, at time t 0 , the task switching circuit 210 detects an external interrupt request signal (INTR). The task switching circuit 210 asserts a stop request signal (HR) to the execution control circuit 152 in order to execute a special task. Input timing t 1 is almost simultaneous with the detection timing t 0. At time t 1, the state machine of the CPU150 is "in the task execution" is a CBUSY = 1. Since HR = 1, the OR gate 176 outputs “1”, but since CBUSY = 1, the CPU 150 does not stop. Therefore, even if HR = 1 is input, the CPU clock (CLK) is output in synchronization with the original clock (CLK0) for a while.

時間が経過し、時刻tにおいてCBUSY=0に変化している。既にHR=1のため、第1ANDゲート172はHC=1を出力し、第2ANDゲート174から出力されるCPUクロックは0に固定される。一方、タスク切換回路210は、HCがアサートされたことを契機として、一般タスクから特殊タスクへタスクスイッチを開始する。詳しくは後述するが、このタスクスイッチのために要する時間はタスク制御回路200の動作クロックにして数回分である。HCがアサートされてから、タスク制御回路200の動作クロックが所定回数変化したことを条件として(時刻t)、タスク制御回路200は停止要求信号(HR)をネゲートする。HR=0なので、実行制御回路152はCPUクロック(CLK)を再開させる。CPU150が処理を再開すると、CPU150はCBUSYを0から1に変化させる(時刻t)。このように、CPUクロックが停止する時刻tから時刻tの間に、一般タスクから特殊タスクへのタスクスイッチが実行されることになる。
なお、別の処理方法として、タスク制御回路200の動作クロックが所定回数変化したことを条件とする代わりに、タスク制御回路200がタスクスイッチを完了させたことを条件として、HRをネゲートしてもよい。そして、実行制御回路152が、HRがネゲートされたことを条件として、HCをネゲートさせてもよい。HC=0となると、実行制御回路152はCPUクロック(CLK)を再開させる。こうして、タスクの実行を再開させてもよい。
As time elapses, it changes CBUSY = 0 at time t 2. Since HR = 1 already, the first AND gate 172 outputs HC = 1, and the CPU clock output from the second AND gate 174 is fixed to 0. On the other hand, the task switching circuit 210 starts task switching from a general task to a special task when HC is asserted. As will be described in detail later, the time required for the task switch is several times as the operation clock of the task control circuit 200. The task control circuit 200 negates the stop request signal (HR) on condition that the operation clock of the task control circuit 200 has changed a predetermined number of times after HC is asserted (time t 3 ). Since HR = 0, the execution control circuit 152 restarts the CPU clock (CLK). When the CPU 150 resumes the processing, the CPU 150 changes CBUSY from 0 to 1 (time t 4 ). Thus, the period from time t 2 the CPU clock is stopped at time t 3, so that the task switch to a special task is performed from the general task.
As another processing method, HR may be negated on the condition that the task control circuit 200 has completed the task switch instead of being conditional on the operation clock of the task control circuit 200 changing a predetermined number of times. Good. Then, the execution control circuit 152 may negate HC on the condition that HR is negated. When HC = 0, the execution control circuit 152 restarts the CPU clock (CLK). In this way, the execution of the task may be resumed.

図8(b)は、システムコール実行時における各種信号の関係を示すタイムチャートである。
同図においては、まず、時刻tにおいて、命令復号器170がシステムコールを検出し、SC_DETECTを0から1に変化させている。時刻tでは、CPU150のステートマシンは「タスク実行中」であり、CBUSY=1である。SC_DETECT=1より、ORゲート176は「1」を出力するが、CBUSY=1ゆえにCPU150は停止しない。そのため、SC_DETECT=1が出力されても、しばらくはCPUクロック(CLK)は原クロック(CLK0)に同期して出力される。
FIG. 8B is a time chart showing the relationship between various signals when a system call is executed.
In the figure, first, at time t 0 , the instruction decoder 170 detects a system call and changes SC_DETECT from 0 to 1. At time t 0 , the state machine of the CPU 150 is “task executing” and CBUSY = 1. Since SC_DETECT = 1, the OR gate 176 outputs “1”, but the CPU 150 does not stop because CBUSY = 1. Therefore, even if SC_DETECT = 1 is output, the CPU clock (CLK) is output in synchronization with the original clock (CLK0) for a while.

時間が経過し、時刻tにおいてCBUSY=0に変化している。SC_DETECT=1、かつ、CBUSY=1となったので、HCはネゲートされ、CPUクロックは停止される。タスク切換回路210は、HC=0を入力されると、タスクスイッチ処理を開始し、書き込み信号(WT)をCPU150に出力する。WTが0から1に変化する時刻tに退避データが処理レジスタ154にロードされる。書き込み信号(WT)は、パルス信号のため、所定時間経過後の時刻tにWT=0となる。このWT:1→0の立ち下がり検出により命令復号器170にラッチされているSC_DETECTはリセットされる(時刻t)。このとき、CBUSYは0から1に変化する。CBUSY=1となったので、HC=0となり、CPUクロックが再開される。CPUクロックが停止する時刻tから時刻tの間に、タスクスイッチが実行されることになる。
なお、別の処理方法として、WT:1→0の立ち下がり検出を条件とする代わりに、タスク制御回路200がタスクスイッチを完了させ、HRをネゲートしたことを条件として、実行制御回路152が、HCをネゲートしてもよい。HC=0となったことを条件として、SC_DETECTをリセットする。実行制御回路152はCPUクロック(CLK)を再開させ、CBUSYは0から1に変化する。
As time elapses, it changes CBUSY = 0 at time t 1. Since SC_DETECT = 1 and CBUSY = 1, HC is negated and the CPU clock is stopped. When HC = 0 is input, task switching circuit 210 starts task switch processing and outputs a write signal (WT) to CPU 150. The saved data is loaded into the processing register 154 at time t 2 when WT changes from 0 to 1. Write signal (WT), since the pulse signal, the WT = 0 to time t 3 after a predetermined time. SC_DETECT latched in the instruction decoder 170 is reset by detecting the falling edge of WT: 1 → 0 (time t 4 ). At this time, CBUSY changes from 0 to 1. Since CBUSY = 1, HC = 0 and the CPU clock is restarted. Between time t 1 at which the CPU clock is stopped at time t 4, so that the task switch is performed.
As another processing method, the execution control circuit 152 is configured on the condition that the task control circuit 200 completes the task switch and negates the HR instead of being conditional on the detection of the falling edge of WT: 1 → 0. HC may be negated. SC_DETECT is reset on condition that HC = 0. The execution control circuit 152 restarts the CPU clock (CLK), and CBUSY changes from 0 to 1.

いずれの場合においても、CPU150は、CPUクロックが停止している期間にRUN−タスクの切り換えが行われたことを認識する必要はない。タスク切換回路210は、CPUクロックが停止し、CPU150がいわばフリーズしている間にタスクスイッチ処理を行うため、CPU150の処理とタスク制御回路200の処理はシーケンシャルに分離されている。   In any case, the CPU 150 does not need to recognize that the RUN-task switching has been performed while the CPU clock is stopped. Since the task switching circuit 210 performs task switching while the CPU clock is stopped and the CPU 150 is frozen, the processing of the CPU 150 and the processing of the task control circuit 200 are sequentially separated.

図9は、パイプライン処理におけるCPUクロックの停止タイミングを説明するための模式図である。
CPU150は、複数の命令をメモリから処理レジスタ154に順次読み出しながら実行することにより、タスクを実行する。このタスクの実行単位である命令は、以下の4つのフェーズに分解される。
1.F(フェッチ):メモリから命令を取り出す。
2.D(デコード):命令を解釈する。
3.E(エグゼキューション):命令を実行する。
4.WB(ライトバック):実行結果をメモリに書き込む。
FIG. 9 is a schematic diagram for explaining the stop timing of the CPU clock in the pipeline processing.
The CPU 150 executes a task by executing a plurality of instructions while sequentially reading them from the memory to the processing register 154. The instruction which is the execution unit of this task is decomposed into the following four phases.
1. F (fetch): fetch an instruction from the memory.
2. D (decode): interprets an instruction.
3. E (execution): execute an instruction.
4). WB (write back): The execution result is written in the memory.

あるタスクが命令1から命令5を順次実行する場合、命令1のFからWBまで実行した後、命令2のFを実行してもよい。しかし、より効率的な実行のために、命令1の実行中に命令2の実行を開始することが多い。このような処理方法は、パイプライン処理とよばれる。たとえば、命令1が、Dのフェーズに至ったとき、命令2のFのフェーズを開始する。命令1が、Eのフェーズに至ったときには、命令2のDフェーズ、命令3のFフェーズを実行する。このように、単位時間当たりに実行される命令の数を増やすことにより、タスクごとの実行時間を減少させることができる。   When a certain task sequentially executes instruction 1 to instruction 5, F from instruction 2 may be executed after execution from F of instruction 1 to WB. However, for more efficient execution, execution of instruction 2 is often initiated during execution of instruction 1. Such a processing method is called pipeline processing. For example, when the instruction 1 reaches the phase D, the F phase of the instruction 2 is started. When the instruction 1 reaches the phase E, the D phase of the instruction 2 and the F phase of the instruction 3 are executed. Thus, by increasing the number of instructions executed per unit time, the execution time for each task can be reduced.

更に、各フェーズを2つのフェーズに細分化してもよい。たとえば、FフェーズをF1:F2という2つのフェーズに分離される。命令1が、F2のフェーズに至ったとき、命令2のF1のフェーズを開始する。命令1が、D1のフェーズに至ったときには、命令2のF2フェーズ、命令3のF1フェーズを実行する。フェーズの細分化により、いっそうCPU150の計算資源を効率的に利用できる。図9においては、各フェーズを2つのフェーズに細分化して実行するパイプライン処理において、システムコールが発生したときのCPUクロック停止タイミングについて説明する。   Furthermore, each phase may be subdivided into two phases. For example, the F phase is separated into two phases F1: F2. When instruction 1 reaches the phase of F2, the phase of F1 of instruction 2 is started. When the instruction 1 reaches the phase D1, the F2 phase of the instruction 2 and the F1 phase of the instruction 3 are executed. By subdividing the phases, the calculation resources of the CPU 150 can be used more efficiently. In FIG. 9, the CPU clock stop timing when a system call occurs in the pipeline processing in which each phase is divided into two phases will be described.

同図において、命令1はCPUクロック「0」のタイミングで処理を開始されている。CPUクロック「4」のタイミングで、命令1のデコードが完了する。命令1はシステムコールであったとする。命令復号器170はSC_DETECTを0から1に変化させる。次にSC_DETECTが1から0に戻る条件は、タスク切換回路210から処理レジスタ154への書き込み信号(WT)が1から0に変化することである。SC_DETECT=1となっても、命令2〜5が既に実行中または実行開始済であるため、CBUSY=1のままである。そのため、第2ANDゲート174はCPUクロックを引き続き出力することになる。ただし、実行制御回路152は、SC_DETECT=1のときには、新たな命令がフェッチされないようにプログラムカウンタの更新を一時停止させる。したがって、命令6以降はメモリからフェッチされなくなる。   In the figure, instruction 1 starts processing at the timing of CPU clock “0”. Decoding of the instruction 1 is completed at the timing of the CPU clock “4”. Assume that instruction 1 is a system call. The instruction decoder 170 changes SC_DETECT from 0 to 1. Next, the condition for SC_DETECT to return from 1 to 0 is that the write signal (WT) from the task switching circuit 210 to the processing register 154 changes from 1 to 0. Even when SC_DETECT = 1, since instructions 2 to 5 are already being executed or have been started, CBUSY = 1 remains. Therefore, the second AND gate 174 continues to output the CPU clock. However, when SC_DETECT = 1, the execution control circuit 152 temporarily stops the update of the program counter so that a new instruction is not fetched. Therefore, the instruction 6 and later are not fetched from the memory.

CPUクロック「8」のタイミングで命令1は実行完了するが、命令2〜5は実行中であるため、CPUビジー信号は「1」のままである。CPUクロック「12」のタイミングに至ると命令5が実行完了する。このとき、CPUビジー信号は「0」となる。あとは、図8(b)に関連したプロセスにしたがって、CPUクロックの供給が停止される。タスク切換回路210は、命令5まで終了した段階の処理データを退避レジスタ110に退避させる。このような停止方法によれば、システムコールが実行されたあとの命令の実行結果を無駄にすることなくタスクスイッチできる。タスクスイッチが完了すると、CPUビジー信号は再び「1」にセットされ、命令復号器170の処理も再開される。こうして、CPUクロックが再び供給されるようになる。
なお、別の処理方法として、システムコール命令が実行完了するタイミングで、CPUビジー信号を「0」とし、CPUクロックの供給を停止してもよい。この場合、システムコール命令と同時に実行されていた別の命令は実行途中のまま停止する。中途停止された命令の中間的な処理結果は処理レジスタ154に記録されたあと、退避レジスタ110に退避される。次回、このタスクがRUN−タスクとなるときには、中途停止された命令の続きが実行される。たとえば、ある命令が、フェッチを終了した段階で中途停止された場合、メモリから読み出された命令やオペランドは退避レジスタ110に退避される。タスク再開時には、退避レジスタ110のデータが処理レジスタ154にロードされ、デコードステージから続きの処理が実行されることになる。
Although the instruction 1 is completely executed at the timing of the CPU clock “8”, since the instructions 2 to 5 are being executed, the CPU busy signal remains “1”. When the timing of the CPU clock “12” is reached, execution of the instruction 5 is completed. At this time, the CPU busy signal becomes “0”. After that, the supply of the CPU clock is stopped according to the process related to FIG. The task switching circuit 210 saves the processing data at the stage where the instructions up to the instruction 5 are completed in the save register 110. According to such a stopping method, the task can be switched without wasting the execution result of the instruction after the system call is executed. When the task switch is completed, the CPU busy signal is set to “1” again, and the processing of the instruction decoder 170 is resumed. Thus, the CPU clock is supplied again.
As another processing method, the CPU busy signal may be set to “0” and the supply of the CPU clock may be stopped when the execution of the system call instruction is completed. In this case, another instruction that has been executed simultaneously with the system call instruction is stopped during execution. The intermediate processing result of the interrupted instruction is recorded in the processing register 154 and then saved in the save register 110. The next time this task becomes a RUN-task, the continuation of the suspended instruction is executed. For example, when an instruction is interrupted at the stage where the fetch is completed, the instruction and operand read from the memory are saved in the save register 110. When the task is resumed, the data in the save register 110 is loaded into the processing register 154, and the subsequent processing is executed from the decode stage.

図10は、状態記憶部220とタスク切換回路210の関係を示す回路図である。
状態記憶部220は、状態レジスタ250とタイマ252を含む、状態記憶部220は、タスクの状態データを保持する。また、タイマ252は、タスクがREADY状態またはWAIT状態に遷移したときに開始するタイマである。タスクがREADY状態に遷移してから経過した時間のことを「READY経過時間」、タスクがWAIT状態に遷移してから経過した時間のことを「WAIT経過時間」とよぶ。タイマ252は、その値をTIM信号として常時出力する。タスク切換回路210は、タスクスイッチに際して、あるタスクがREADY状態またはWAIT状態に変化したときには、そのタスクのタイマ252を駆動して時間計測を開始させる。
FIG. 10 is a circuit diagram showing the relationship between the state storage unit 220 and the task switching circuit 210.
The state storage unit 220 includes a state register 250 and a timer 252. The state storage unit 220 holds task state data. The timer 252 is a timer that starts when the task transitions to the READY state or the WAIT state. The time that has elapsed since the task transitioned to the READY state is referred to as “READY elapsed time”, and the time that has elapsed since the task transitioned to the WAIT state is referred to as “WAIT elapsed time”. The timer 252 always outputs the value as a TIM signal. When a task is switched to a READY state or a WAIT state at the time of task switching, the task switching circuit 210 drives the timer 252 of the task to start time measurement.

状態記憶部220は、以下に示すレジスタの集合である。
(A)タスクIDレジスタ254:タスクIDを保持する。タスクIDレジスタ254からはタスクIDを示すID信号がタスク選択回路230に常時出力される。以下、タスクAのタスクIDレジスタ254からタスク選択回路230に出力されるID信号のことを「ID_A信号」と表記する。状態記憶部220から出力される他の信号についても同様である。
(B)タスク優先順位レジスタ256:タスク優先順位を保持する。タスク優先順位レジスタ256からはタスク優先順位を示すPR信号が常時出力される。「0」が最高優先順位であり、値が大きいほどタスク優先順位が低いことを示す。
(C)タスク状態レジスタ258:タスク状態を示す。STOP、READY、RUN、WAIT、IDLEのいずれかがST信号として常時出力される。なお、IDLEとは、タスクが初期化される前の状態である。
(D)タスク起動アドレスレジスタ260:メモリにおけるタスクのTCBアドレスを示す。出力はAD信号である。
(E)待機理由レジスタ262:タスクがWAIT状態にあるとき、WAIT解除条件の一部として待機の理由を示す。待機理由は、「セマフォ待ち」、「イベント待ち」、「ミューテックス待ち」のいずれかである。出力はWR信号である。
(F)セマフォIDレジスタ264:タスクがセマフォ待ちを理由として、WAIT状態にあるとき、待ち対象のセマフォ(以下、単に「待機セマフォ」)のセマフォIDを保持する。出力はSID信号である。
(G)ミューテックスIDレジスタ265:タスクがミューテックス待ちを理由として、WAIT状態にあるとき、待ち対象のミューテックス(以下、単に「待機ミューテックス」)のミューテックスIDを保持する。出力はMID信号である。
(H)イベントIDレジスタ266:タスクがイベント待ちを理由として、WAIT状態にあるとき、待ち対象のイベント(以下、単に「待機イベント」)のイベントIDを保持する。出力はEID信号である。
(I)待機フラグレジスタ268:タスクがイベント待ちを理由として、WAIT状態にあるとき、待機フラグパターンを保持する。出力はFL信号である。
(J)フラグ条件レジスタ270:タスクがイベント待ちを理由として、WAIT状態にあるとき、フラグ条件を保持する。出力はFLC信号である。待機フラグパターンやフラグ条件については後述する。
(K)フラグ初期化レジスタ272:待機フラグパターンの有無を示すデータを保持する。出力はFLI信号である。
(L)タイムアウトカウンタ274:WAIT系システムコールにおいてはタイムアウト値が変数として指定される。タイムアウトカウンタ274は、タイムアウト値を保持する。タスク切換回路210は、各タイムアウトカウンタ274のタイムアウト値を定期的にデクリメントする。出力はTO信号である。タスク切換回路210がタイムアウト値をデクリメントする代わりに、タイムアウトカウンタ274自体が自律的に自らのタイムアウト値を定期的にデクリメントしてもよい。
The state storage unit 220 is a set of registers shown below.
(A) Task ID register 254: Holds a task ID. An ID signal indicating a task ID is constantly output from the task ID register 254 to the task selection circuit 230. Hereinafter, the ID signal output from the task ID register 254 of the task A to the task selection circuit 230 is referred to as “ID_A signal”. The same applies to other signals output from the state storage unit 220.
(B) Task priority order register 256: Holds task priority order. The task priority order register 256 always outputs a PR signal indicating the task priority order. “0” is the highest priority, and a larger value indicates a lower task priority.
(C) Task status register 258: indicates a task status. Any one of STOP, READY, RUN, WAIT, and IDLE is always output as the ST signal. Note that IDLE is a state before the task is initialized.
(D) Task activation address register 260: indicates the TCB address of the task in the memory. The output is an AD signal.
(E) Wait reason register 262: When the task is in the WAIT state, it indicates the reason for waiting as part of the WAIT cancellation condition. The reason for waiting is one of “waiting for semaphore”, “waiting for event”, and “waiting for mutex”. The output is a WR signal.
(F) Semaphore ID register 264: Holds the semaphore ID of the semaphore to be waited (hereinafter simply referred to as “waiting semaphore”) when the task is in the WAIT state because of waiting for the semaphore. The output is a SID signal.
(G) Mutex ID register 265: Holds the mutex ID of the mutex to be waited (hereinafter simply referred to as “waiting mutex”) when the task is in the WAIT state because of waiting for the mutex. The output is a MID signal.
(H) Event ID register 266: Holds an event ID of an event to be waited (hereinafter simply referred to as “waiting event”) when the task is in the WAIT state because of waiting for an event. The output is an EID signal.
(I) Wait flag register 268: Holds a wait flag pattern when the task is in the WAIT state because of waiting for an event. The output is the FL signal.
(J) Flag condition register 270: Holds a flag condition when the task is in the WAIT state because of waiting for an event. The output is an FLC signal. The standby flag pattern and flag conditions will be described later.
(K) Flag initialization register 272: Holds data indicating the presence or absence of a standby flag pattern. The output is the FLI signal.
(L) Timeout counter 274: In a WAIT system call, a timeout value is specified as a variable. The timeout counter 274 holds a timeout value. The task switching circuit 210 periodically decrements the timeout value of each timeout counter 274. The output is a TO signal. Instead of the task switching circuit 210 decrementing the timeout value, the timeout counter 274 itself may autonomously decrement its own timeout value periodically.

タスク選択回路230は、各状態記憶部220から出力される各種信号をもとに、タスクの選択を行う。タスク選択回路230は、以下に示す回路を含む。
(A)実行選択回路232:タスクスイッチに際して、次のRUN−タスクを選択する。実行選択回路232は、状態記憶部220から常時出力される状態データにより常にいずれかのタスクをRUN−タスクとして選択している。実行選択回路232の入力信号は、ID、ST、PR、TIMの4種類である。出力は、次のRUN−タスクのタスクIDである。詳細な回路構成については図12に関連して詳述する。
(B)セマフォ選択回路234:リリースセマフォシステムコールの実行により、WAIT状態からREADY状態に遷移すべきタスクを選択する。リリースセマフォシステムコールにより解放されるセマフォ(以下、単に「解放セマフォ」)のセマフォIDをタスク切換回路210から入力される。状態記憶部220からの入力信号は、ID、ST、WR、PR、SID、TIMの6種類である。出力信号は、WAIT状態からREADY状態に遷移するタスクのタスクIDである。該当するタスクが存在しなければ、−1などの所定値を出力する。より具体的な回路構成については図13に関連して詳述する。
(C)イベント選択回路236:セットイベントシステムコールの実行により、WAIT状態からREADY状態に遷移するタスクを選択する。セットイベントシステムコールによりセットされるイベント(以下、単に「設定イベント」)のイベントIDをタスク切換回路210から入力される。状態記憶部220からの入力信号は、ID、ST、WR、EID、FL、FLCの6種類である。出力信号は、WAIT状態からREADY状態に遷移するタスクのタスクIDと、そのタスクのFL、FLCを出力する。
(D)タイムアウト検出回路238:WAIT状態のタスクのうち、タイムアウトカウンタ274のタイムアウト値がゼロとなったタスクを検出する。タイムアウト検出回路238は、タイムアウト値が更新されるごとに駆動される。タイムアウト検出回路238の入力信号は、ID、ST、TOの3種類である。出力信号は、該当するタスクのタスクIDである。該当するタスクが存在しなければ、−1などの所定値を出力する。
(E)ミューテックス回路240:リリースミューテックスシステムコールの実行により、WAIT状態からREADY状態に遷移するタスクを選択する。リリースミューテックスシステムコールにより解放されるミューテックス(以下、単に「解放ミューテックス」)のミューテックスIDをタスク切換回路210から入力される。状態記憶部220からの入力信号は、ID、ST、WR、PR、SID、TIMの6種類である。出力信号は、WAIT状態からREADY状態に遷移するタスクのタスクIDである。該当するタスクが存在しなければ、−1などの所定値を出力する。
(F)検索回路242:タスク切換回路210からタスクIDを入力されると、そのタスクの全状態データを出力する。
The task selection circuit 230 selects a task based on various signals output from each state storage unit 220. The task selection circuit 230 includes the following circuits.
(A) Execution selection circuit 232: When the task is switched, the next RUN-task is selected. The execution selection circuit 232 always selects one of the tasks as a RUN-task based on the state data constantly output from the state storage unit 220. There are four types of input signals of the execution selection circuit 232: ID, ST, PR, and TIM. The output is the task ID of the next RUN-task. A detailed circuit configuration will be described in detail with reference to FIG.
(B) Semaphore selection circuit 234: Selects a task to transition from the WAIT state to the READY state by executing a release semaphore system call. A semaphore ID of a semaphore released by a release semaphore system call (hereinafter simply “release semaphore”) is input from the task switching circuit 210. There are six types of input signals from the state storage unit 220: ID, ST, WR, PR, SID, and TIM. The output signal is a task ID of a task that makes a transition from the WAIT state to the READY state. If there is no corresponding task, a predetermined value such as -1 is output. A more specific circuit configuration will be described in detail with reference to FIG.
(C) Event selection circuit 236: Selects a task that transitions from the WAIT state to the READY state by executing the set event system call. An event ID of an event (hereinafter simply referred to as “setting event”) set by the set event system call is input from the task switching circuit 210. There are six types of input signals from the state storage unit 220: ID, ST, WR, EID, FL, and FLC. The output signal outputs the task ID of the task that transitions from the WAIT state to the READY state, and the FL and FLC of the task.
(D) Timeout detection circuit 238: Among the tasks in the WAIT state, a task for which the timeout value of the timeout counter 274 has become zero is detected. The timeout detection circuit 238 is driven every time the timeout value is updated. There are three types of input signals to the timeout detection circuit 238: ID, ST, and TO. The output signal is the task ID of the corresponding task. If there is no corresponding task, a predetermined value such as -1 is output.
(E) Mutex circuit 240: Selects a task that transitions from the WAIT state to the READY state by executing the release mutex system call. The mutex ID of the mutex released by the release mutex system call (hereinafter simply referred to as “release mutex”) is input from the task switching circuit 210. There are six types of input signals from the state storage unit 220: ID, ST, WR, PR, SID, and TIM. The output signal is a task ID of a task that makes a transition from the WAIT state to the READY state. If there is no corresponding task, a predetermined value such as -1 is output.
(F) Search circuit 242: When a task ID is input from the task switching circuit 210, all state data of the task is output.

以下においては、タスクスイッチに関連し、RUN−タスクの選択、セマフォ、イベント、ミューテックス、タイムアウトについて、特に、タスク選択回路230の処理を中心として一般的な技術と比較しながら説明する。
[RUN−タスク選択]
[1]一般的なソフトウェアRTOSによるRUN−タスクの選択
In the following, regarding the task switch, RUN-task selection, semaphore, event, mutex, and timeout will be described in comparison with a general technique, particularly focusing on the processing of the task selection circuit 230.
[RUN-task selection]
[1] Selection of RUN-task by general software RTOS

図11は、一般的なRTOSによるRUN−タスク選択に際して利用されるタスクレディリストを示す図である。
タスクレディリストは、メモリ上に形成され、各READY−タスクのTCBをポインタによって連結したリストである。優先順位ポインタ280は、タスク優先順位ごとに設けられ、該当タスク優先順位のタスクのTCBの先頭アドレスを指す。同図のタスクレディリストの場合、タスク優先順位「0」の優先順位ポインタ280は、タスクAのTCBをアドレスし、タスク優先順位「1」の優先順位ポインタ280は、タスクBのTCBをアドレスしている。タスクAのTCBは、更に、タスクDのTCBをアドレスしている。 一般的なソフトウェアRTOSは、このタスクレディリストを走査しながら、次のRUN−タスクを選択する。このとき、RTOSは、
A.RUN−タスクをRUNからREADYに状態遷移させる。
B.次のRUN−タスクを選択し、そのタスクのタスク状態をREADYからRUNに状態遷移させる。
という2段階の処理を行う。ソフトウェアRTOSによる各処理を分解すると以下の通りである。
<RUN−タスクの状態遷移>
FIG. 11 is a diagram showing a task ready list used when selecting a RUN-task by a general RTOS.
The task ready list is formed on a memory and is a list in which TCBs of each READY-task are linked by pointers. The priority level pointer 280 is provided for each task priority level and points to the head address of the TCB of the task having the corresponding task priority level. In the case of the task ready list shown in the figure, the task priority “0” priority pointer 280 addresses the task A TCB, and the task priority “1” priority pointer 280 addresses the task B TCB. ing. The TCB of task A further addresses the TCB of task D. The general software RTOS selects the next RUN-task while scanning the task ready list. At this time, RTOS
A. RUN--Transitions the task from RUN to READY.
B. The next RUN-task is selected, and the task state of the task is changed from READY to RUN.
A two-stage process is performed. Each processing by the software RTOS is disassembled as follows.
<RUN-task state transition>

ここでは、RUN−タスクをタスクJとして説明する。
A1.RTOSは、RUN−タスクのタスクIDをメモリに保持している。このタスクIDをもとに、タスクJのTCBのアドレスを取得する。
A2.TCBにアクセスし、タスクJのタスク優先順位を取得する。タスク優先順位は「0」であったとする。
A3.図11に示すタスクレディリストのうち、タスクJのタスク優先順位に対応する優先順位ポインタ280を取得する。
A4.取得した優先順位ポインタ280が示すTCBを検出する。ここではタスクAのTCBが検出される。
A5.タスクAのTCBが持つポインタをたどっていき、最後尾のTCBを検出する。同図においては、タスクFが最後尾である。
A6:タスクFのTCBのポインタがタスクJのTCBをアドレスするように設定する。こうして、タスクJのTCBがタスクレディリストに追加される。
A7.タスクJのTCBに「READY」を設定する。また、処理データは、TCBのレジスタ格納エリアにコピーされる。
<READY−タスクの状態遷移>
Here, RUN-task is described as task J.
A1. The RTOS holds the task ID of the RUN-task in the memory. Based on this task ID, the TCB address of task J is acquired.
A2. Access TCB and obtain task priority of task J. It is assumed that the task priority is “0”.
A3. A priority order pointer 280 corresponding to the task priority order of task J is acquired from the task ready list shown in FIG.
A4. The TCB indicated by the acquired priority order pointer 280 is detected. Here, the TCB of task A is detected.
A5. Traces the pointer of the task A TCB and detects the last TCB. In the figure, task F is the last.
A6: The task F TCB pointer is set to address the task J TCB. In this way, the TCB of task J is added to the task ready list.
A7. “READY” is set in the TCB of task J. Further, the processing data is copied to the register storage area of the TCB.
<READY-task state transition>

B1.RTOSは、タスク優先順位「0」の優先順位ポインタ280がいずれかのTCBを示しているか検出する。TCBがなければ、タスク優先順位「1」の優先順位ポインタ280がいずれかのTCBを示しているか検出する。TCBが見つかるまで、タスク優先順位を下げながらいずれかのタスクを特定する。同図の場合、タスクAが特定されることになる。
B2.タスクAをタスクレディリストからはずす。具体的には、タスク順位「0」の優先順位ポインタ280がタスクAではなくタスクDのTCBをアドレスするように書き換える。また、タスクAのポインタがタスクDをアドレスしないようにNULL設定する。こうして、タスクAのTCBがタスクレディリストから外される。
B3.タスクAのTCBに「RUN」を設定する。また、タスクAのTCBのレジスタ格納エリアに退避されていた処理データが処理レジスタにロードされる。
B1. The RTOS detects which TCB the priority level pointer 280 of the task priority level “0” indicates. If there is no TCB, it is detected whether the priority order pointer 280 of the task priority “1” indicates any TCB. One task is specified while lowering the task priority until a TCB is found. In the case of the figure, task A is specified.
B2. Remove task A from the task ready list. Specifically, the priority order pointer 280 of the task order “0” is rewritten so as to address the TCB of the task D instead of the task A. Also, NULL is set so that the pointer of task A does not address task D. Thus, the TCB for task A is removed from the task ready list.
B3. “RUN” is set in the TCB of task A. Further, the processing data saved in the TCB register storage area of task A is loaded into the processing register.

一般的なソフトウェアRTOSは、このようなタスクレディリストによりタスクスイッチを行う。すなわち、RTOSが複数のREADY−タスクの中からRUN−タスクを選択するポリシは以下の通りである。
1.READY−タスクであること(第1条件)。
2.READY−タスクのうち、最もタスク優先順位の高いタスクであること(第2条件)。
3.最もタスク優先順位の高いタスクが複数存在するときには、READY状態になった時期が最も古いタスクであること(第3条件)。
このような3つの条件のことを、まとめて「RUNタスク選択条件」とよぶことにする。タスク処理装置100の実行選択回路232は、このようなRTOSのタスクスケジューリング機能をハードウェアにより実現している。
[2]基本例のハードウェアRTOSによるRUN−タスクの選択
A general software RTOS performs task switching by such a task ready list. That is, the policy for RTOS to select a RUN-task from a plurality of READY-tasks is as follows.
1. READY-task (first condition).
2. READY-task having the highest task priority (second condition).
3. When there are a plurality of tasks having the highest task priority, the task in the READY state is the oldest task (third condition).
These three conditions are collectively referred to as “RUN task selection conditions”. The execution selection circuit 232 of the task processing apparatus 100 implements such a task scheduling function of RTOS by hardware.
[2] RUN-task selection by hardware RTOS in basic example

図12は、実行選択回路232の回路図である。
ここでは、タスク0〜タスク7の8つのタスクから、RUN−タスクを選択するとして説明する。実行選択回路232は、4つの第1比較回路290(290a〜290d)、2つの第2比較回路292(292a、292b)、1つの第3比較回路294を含む。また、8つの判定回路296(296a〜296h)も含む。
判定回路296は、タスクの状態を示すST信号を入力とし、READYであれば「1」、READY以外であれば「0」を示すCID信号を出力する。判定回路296は、上記RUNタスク選択条件のうちの第1条件に基づく判定を行っている。第1比較回路290は、2つのタスクのID、PR、TIM、および、判定回路296からのCID信号を入力とする。
FIG. 12 is a circuit diagram of the execution selection circuit 232.
Here, a description will be given assuming that a RUN-task is selected from eight tasks of task 0 to task 7. The execution selection circuit 232 includes four first comparison circuits 290 (290a to 290d), two second comparison circuits 292 (292a and 292b), and one third comparison circuit 294. Further, eight determination circuits 296 (296a to 296h) are also included.
The determination circuit 296 receives the ST signal indicating the task state, and outputs a CID signal indicating “1” if READY and “0” if not READY. The determination circuit 296 performs determination based on the first condition among the RUN task selection conditions. The first comparison circuit 290 receives the IDs of the two tasks, PR, TIM, and the CID signal from the determination circuit 296 as inputs.

第1比較回路290aに着目して説明する。第1比較回路290aは、タスク0とタスク1を比較し、上記したRUNタスク選択条件に基づいて、より好適なタスクを選択する。
第1の判定:まず、判定回路296aと判定回路296bのそれぞれから出力されるCID信号を比較する。いずれか一方が「1」であれば、いいかえれば、いずれか一方のタスクだけがREADY状態であれば、第1比較回路290aは、そのタスクのID、PR、TIMを出力する。いずれも「0」であれば、すなわち、いずれのタスクもREADY状態でなければ、第1比較回路290aは、ID=PR=TIM=NULLを出力する。これは、いずれのタスクも選択されなかったことを示す。いすれも「1」であれば、すなわち、いずれのタスクもREADY状態であれば、次の第2の判定が実行される。
第2の判定:タスク0のPR信号とタスク1のPR信号を比較し、タスク優先順位が上位となるタスクを選択する。たとえば、タスク0のタスク優先順位が「1」、タスク1のタスク優先順位が「2」であれば、タスク0のID、PR、TIMを出力する。第2の判定により、タスク優先順位が上位のタスクがRUN−タスクの候補として選択されることになる。タスク0とタスク1のタスク優先順位が同じであれば、次の第3の判定が実行される。
第3の判定:タスク0のTIM信号とタスク1のTIM信号を比較し、READY経過時間が長い方のタスクを選択する。READY経過時間が同じであれば、タスク0を選択するものとする。経過時間の大小を比較するだけで判定できるため、タスクレディリストのようなTCBの順序管理が不要となる。
Description will be made by paying attention to the first comparison circuit 290a. The first comparison circuit 290a compares the task 0 and the task 1, and selects a more suitable task based on the RUN task selection condition described above.
First determination: First, the CID signals output from the determination circuit 296a and the determination circuit 296b are compared. If either one is “1”, in other words, if only one of the tasks is in the READY state, the first comparison circuit 290a outputs the ID, PR, and TIM of the task. If both are “0”, that is, if no task is in the READY state, the first comparison circuit 290a outputs ID = PR = TIM = NULL. This indicates that no task has been selected. If both are “1”, that is, if any task is in the READY state, the next second determination is executed.
Second determination: The PR signal of task 0 and the PR signal of task 1 are compared, and a task having a higher task priority is selected. For example, if the task priority of task 0 is “1” and the task priority of task 1 is “2”, the ID, PR, and TIM of task 0 are output. According to the second determination, a task having a higher task priority is selected as a RUN-task candidate. If the task priorities of task 0 and task 1 are the same, the next third determination is executed.
Third determination: The task 0 TIM signal is compared with the task 1 TIM signal, and the task having the longer READY elapsed time is selected. If the READY elapsed time is the same, task 0 is selected. Since the determination can be made simply by comparing the magnitudes of the elapsed times, TCB order management like a task ready list becomes unnecessary.

このようにして、タスク0とタスク1、タスク2とタスク3、タスク4とタスク5、タスク6とタスク7がそれぞれRUNタスク選択条件により比較される。第2比較回路292は、2つの第1比較回路290からの出力により、更にRUN−タスクの候補を絞り込む。第2比較回路292aは、第1比較回路290aと第1比較回路290bの出力によりタスク選択を実行する。このため、第2比較回路292aは、タスク0〜タスク3のうち、最もRUNタスク選択条件に適合するタスクのID、PR、TIMを出力する。第3比較回路294も同様であり、第3比較回路294はタスク0〜タスク7のいずれかのタスクのタスクIDを出力する。   In this way, task 0 and task 1, task 2 and task 3, task 4 and task 5, task 6 and task 7 are respectively compared according to the RUN task selection condition. The second comparison circuit 292 further narrows down RUN-task candidates based on the outputs from the two first comparison circuits 290. The second comparison circuit 292a executes task selection based on the outputs of the first comparison circuit 290a and the first comparison circuit 290b. For this reason, the second comparison circuit 292a outputs the ID, PR, and TIM of the task that best meets the RUN task selection condition among the tasks 0 to 3. The same applies to the third comparison circuit 294, and the third comparison circuit 294 outputs the task ID of one of the tasks 0 to 7.

このような処理方法によれば、RUNタスク選択条件をハードウェアにより実現できる。一般的なソフトウェアRTOSは、タスクレディリストにアクセスしながらRUN−タスクを選択していたが、本実施例における実行選択回路232は、状態記憶部220から常時出力される状態データによりRUN−タスクを選択している。実行選択回路232の処理をまとめると以下の通りである。
<RUN−タスクの状態遷移>
According to such a processing method, the RUN task selection condition can be realized by hardware. The general software RTOS selects the RUN-task while accessing the task ready list. However, the execution selection circuit 232 in this embodiment selects the RUN-task based on the state data constantly output from the state storage unit 220. Selected. The processing of the execution selection circuit 232 is summarized as follows.
<RUN-task state transition>

ここでは、RUN−タスクをタスクJとして説明する。
A1.タスク切換回路210は、タスクJのタスク状態レジスタ258に「READY」を設定する。
A2.タスク切換回路210は、タスクJのタイマ252をセットしてREADY経過時間の計測を開始させる。
こうして、タスクJはRUN→READYに状態遷移する。処理データは、先述したようにタスクJの退避レジスタ110に退避される。処理レジスタ154と退避レジスタ110をつなぐバスは、処理データをパラレルに伝送可能であるため、A1とA2の処理は1クロック時間で実行可能である。
<READY−タスクの状態遷移>
Here, RUN-task is described as task J.
A1. The task switching circuit 210 sets “READY” in the task status register 258 of task J.
A2. The task switching circuit 210 sets the timer 252 of the task J and starts measuring the READY elapsed time.
Thus, task J makes a state transition from RUN to READY. The processing data is saved in the save register 110 of the task J as described above. Since the bus connecting the processing register 154 and the save register 110 can transmit processing data in parallel, the processing of A1 and A2 can be executed in one clock time.
<READY-task state transition>

B1.タスク切換回路210は、タスクJの状態遷移が完了したときに実行選択回路232が出力するタスクIDから、RUN−タスクを特定する。このタスクのタスク状態レジスタ258に「RUN」を設定する。
こうして、特定されたタスクはREADY→RUNに状態遷移する。特定されたタスクの処理データは退避レジスタ110から処理レジスタ154にロードされる。退避レジスタ110と処理レジスタ154をつなぐバスも、処理データをパラレルに伝送可能なビット数であるため、B1の処理は1クロック時間で実行可能である。
B1. The task switching circuit 210 specifies a RUN-task from the task ID output by the execution selection circuit 232 when the state transition of the task J is completed. “RUN” is set in the task status register 258 of this task.
Thus, the specified task makes a state transition from READY to RUN. The processing data of the identified task is loaded from the save register 110 to the processing register 154. Since the bus connecting the save register 110 and the processing register 154 is also the number of bits that can transmit the processing data in parallel, the processing of B1 can be executed in one clock time.

ソフトウェアRTOSは、タスクスイッチに際して、タスクレディリストへのアクセス等によりCPUのCPUクロック時間を多く消費する。これに対し、本実施例におけるタスク制御回路200は、僅かな時間でタスクスイッチを完了させることができる。状態記憶部220は常時状態データを実行選択回路232に出力しているため、実行選択回路232は常時いずれかのタスクのタスクIDを出力している。タスクスイッチが発生してからRUN−タスクの選択処理を開始するのではなく、タスクスイッチが発生したときの実行選択回路232の出力によりRUN−タスクの選択を行う点もタスクスイッチの高速化に寄与している。ここでは、タスクが8つであるとして説明したが、比較回路の段数を増やすことにより、より多くのタスクにも対応可能である。
[セマフォ処理]
The software RTOS consumes a large amount of CPU clock time due to access to a task ready list or the like at the time of task switching. On the other hand, the task control circuit 200 in this embodiment can complete the task switch in a short time. Since the state storage unit 220 always outputs the state data to the execution selection circuit 232, the execution selection circuit 232 always outputs the task ID of any task. RUN-task selection processing is not started after the task switch occurs, but the selection of the RUN-task by the output of the execution selection circuit 232 when the task switch occurs also contributes to the speedup of the task switch. doing. Here, although it has been described that there are eight tasks, it is possible to deal with more tasks by increasing the number of stages of the comparison circuit.
[Semaphore processing]

図13は、一般的なRTOSによるセマフォ処理において利用されるウェイトセマフォリストを示す図である。
ウェイトセマフォリストを説明する前に、セマフォについて簡単に説明する。セマフォテーブル212には、セマフォIDとセマフォカウンタが対応づけて記録される。セマフォカウンタは、初期値として有限数に設定される。たとえば、セマフォID=4、セマフォカウンタ=3として設定されているとする。いずれかのタスクがセマフォID=4のセマフォを待機セマフォとしてウェイトセマフォシステムコールを実行すると、タスク切換回路210は待機セマフォのセマフォカウンタをデクリメントする。セマフォカウンタはウェイトセマフォイベントコールにより獲得要求されるごとにデクリメントされ、0になると獲得できなくなる。セマフォカウンタが0となっているセマフォを待機セマフォとしてウェイトセマフォシステムコールを実行したタスクは、WAIT状態に状態遷移する。
FIG. 13 is a diagram showing a wait semaphore list used in semaphore processing by a general RTOS.
Before describing the wait semaphore list, a brief description of semaphores will be given. In the semaphore table 212, a semaphore ID and a semaphore counter are recorded in association with each other. The semaphore counter is set to a finite number as an initial value. For example, it is assumed that semaphore ID = 4 and semaphore counter = 3 are set. When any task executes a wait semaphore system call with the semaphore with semaphore ID = 4 as a waiting semaphore, the task switching circuit 210 decrements the semaphore counter of the waiting semaphore. The semaphore counter is decremented each time an acquisition request is made by a wait semaphore event call. A task that has executed a wait semaphore system call with a semaphore whose semaphore counter is 0 as a standby semaphore makes a transition to the WAIT state.

一方、いずれかのタスクがセマフォID=4のセマフォを解放セマフォとしてリリースセマフォシステムコールを実行すると、タスク切換回路210はセマフォテーブル212のセマフォカウンタをインクリメントする。まとめると、
セマフォカウンタ>0のとき:ウェイトセマフォシステムコールを実行したタスクは、RUN→READYに遷移する。このときセマフォカウンタはデクリメントされる。
セマフォカウンタ=0のとき:ウェイトセマフォシステムコールを実行したタスクは、RUN→WAITに遷移する。セマフォカウンタはデクリメントされない。
ウェイトセマフォシステムコールを実行したタスクがWAIT状態からREADY状態に遷移するためには、別のタスクがリリースセマフォシステムコールを実行する必要がある。
[1]一般的なソフトウェアRTOSによるセマフォ処理
On the other hand, when any task executes a release semaphore system call with the semaphore with semaphore ID = 4 as a release semaphore, the task switching circuit 210 increments the semaphore counter in the semaphore table 212. Summary,
When semaphore counter> 0: The task that executed the wait semaphore system call transits from RUN to READY. At this time, the semaphore counter is decremented.
When semaphore counter = 0: The task that executed the wait semaphore system call transits from RUN to WAIT. The semaphore counter is not decremented.
In order for the task that executed the wait semaphore system call to transition from the WAIT state to the READY state, another task needs to execute the release semaphore system call.
[1] Semaphore processing by general software RTOS

一般的なソフトウェアRTOSはウェイトセマフォリストにより、セマフォ待ちを理由としてWAIT状態にあるタスク(以下、特に、「セマフォ待ちタスク」とよぶ)のTCBを管理する。ウェイトセマフォリストは、図11のタスクレディリストと同等の形状のリストであり、メモリ上に形成される。各セマフォ待ちタスクのTCBは、ポインタによって連結される。優先順位ポインタ280は、該当タスク優先順位のセマフォ待ちタスクのTCBの先頭アドレスを指す。
一般的なソフトウェアRTOSは、リリースセマフォシステムコールが実行されたとき、このウェイトセマフォリストを走査しながら、WAIT状態からREADY状態に遷移させるべきセマフォ待ちタスクを選択する。ウェイトセマフォシステムコールおよびリリースセマフォシステムコール実行時におけるRTOSの処理は以下の通りである。
<ウェイトセマフォシステムコールの実行>
A general software RTOS manages a TCB of a task in a WAIT state because of waiting for a semaphore (hereinafter, particularly referred to as “semaphore waiting task”) using a wait semaphore list. The wait semaphore list is a list having the same shape as the task ready list of FIG. 11, and is formed on the memory. The TCB of each semaphore waiting task is linked by a pointer. The priority order pointer 280 indicates the head address of the TCB of the semaphore waiting task having the corresponding task priority order.
When a general software RTOS executes a release semaphore system call, it scans this wait semaphore list and selects a semaphore waiting task to be changed from the WAIT state to the READY state. The RTOS processing at the time of executing the wait semaphore system call and the release semaphore system call is as follows.
<Execution of wait semaphore system call>

ここでは、RUN−タスクをタスクJとして説明する。
A1.RTOSは、RUN−タスクのタスクIDをメモリに保持している。このタスクIDをもとに、タスクJのTCBのアドレスを取得する。
A2.ウェイトセマフォシステムコールにおいて指定された待機セマフォのセマフォカウンタを検出する。以下、セマフォカウンタの値に応じて処理は分岐する。
(セマフォカウンタ>0のとき)
A3.RTOSは、待機セマフォのセマフォカウンタをデクリメントする。
A4.タスクJのTCBに「READY」を設定する。この場合、タスクJのTCBはタスクレディリストに追加される。
(セマフォカウンタ=0のとき)
A3.TCBにアクセスし、タスクJのタスク優先順位を取得する。タスク優先順位は「0」であったとする。
A4.ウェイトセマフォリストのうち、タスクJのタスク優先順位に対応する優先順位ポインタを取得する。
A5.取得した優先順位ポインタが示すTCBを検出する。ここではタスクAのTCBが検出される。
A6.タスクAのTCBが持つポインタをたどっていき、最後尾のTCBを検出する。同図においては、タスクFが最後尾である。
A7:タスクFのTCBのポインタがタスクJのTCBをアドレスするように設定する。こうして、タスクJのTCBがウェイトセマフォリストに追加される。
A8.タスクJのTCBに「WAIT」を設定する。また、待機セマフォのセマフォIDも設定する。
<リリースセマフォシステムコールの実行>
Here, RUN-task is described as task J.
A1. The RTOS holds the task ID of the RUN-task in the memory. Based on this task ID, the TCB address of task J is acquired.
A2. The semaphore counter of the waiting semaphore specified in the wait semaphore system call is detected. Hereinafter, the process branches according to the value of the semaphore counter.
(When semaphore counter> 0)
A3. The RTOS decrements the semaphore counter of the standby semaphore.
A4. “READY” is set in the TCB of task J. In this case, the TCB of task J is added to the task ready list.
(When semaphore counter = 0)
A3. Access TCB and obtain task priority of task J. It is assumed that the task priority is “0”.
A4. A priority pointer corresponding to the task priority of task J is acquired from the wait semaphore list.
A5. The TCB indicated by the acquired priority order pointer is detected. Here, the TCB of task A is detected.
A6. Traces the pointer of the task A TCB and detects the last TCB. In the figure, task F is the last.
A7: The task F TCB pointer is set to address the task J TCB. Thus, the TCB of task J is added to the wait semaphore list.
A8. “WAIT” is set in the TCB of task J. A semaphore ID of the standby semaphore is also set.
<Execution of release semaphore system call>

B1.RTOSは、タスク優先順位「0」のタスクを順番にたどりながら、解放セマフォを待機セマフォとするセマフォ待ちタスクを検索する。存在しなければ、タスク優先順位「1」のタスクを検索対象とする。解放セマフォを待機セマフォとするセマフォ待ちタスクが検出されるか否かに応じて処理は分岐する。
(検出されたとき)
B2.検出されたタスクがタスクEであるとして説明する。タスクEのTCBに「READY」を設定する。また、待機セマフォのセマフォIDをクリアする。
B3.タスクEのTCBをウェイトセマフォリストから外す。
B4.セマフォを解放したタスクの状態をRUN→READYに状態遷移させる。このタスクのTCBは、タスクレディリストに追加される。
(検出されなかったとき)
B2.セマフォカウンタをインクリメントする。
B3.セマフォを解放したタスクの状態をRUN→READYに状態遷移させる。このタスクのTCBは、タスクレディリストに追加される。
B1. The RTOS searches for a semaphore waiting task with the release semaphore as a waiting semaphore while following the tasks with the task priority “0” in order. If not, the task with the task priority “1” is set as a search target. Processing branches depending on whether or not a semaphore waiting task whose release semaphore is a waiting semaphore is detected.
(When detected)
B2. A description will be given assuming that the detected task is task E. “READY” is set in the TCB of task E. Also, the semaphore ID of the standby semaphore is cleared.
B3. The task E TCB is removed from the wait semaphore list.
B4. The state of the task that has released the semaphore is changed from RUN to READY. The TCB for this task is added to the task ready list.
(When not detected)
B2. Increment the semaphore counter.
B3. The state of the task that has released the semaphore is changed from RUN to READY. The TCB for this task is added to the task ready list.

一般的なソフトウェアRTOSは、このようなウェイトセマフォリストを管理することによって、セマフォ関連処理を行う。セマフォの解放に際し、RTOSが複数のWAIT−タスクの中からREADY−タスクを選択するポリシは以下の通りである。
1.WAIT−タスクであること(第1条件)。
2.WAIT−タスクのうち、解放セマフォを待機セマフォとするタスクであること(第2条件)
3.そのようなタスクが複数存在するときには、最もタスク優先順位の高いタスクであること(第3条件)。
4.最もタスク優先順位の高いタスクが複数存在するときには、WAIT状態になった時期が最も古いタスクであること(第4条件)。
このような4つの条件のことを、まとめて「セマフォ待機解除条件」とよぶことにする。タスク処理装置100のセマフォ選択回路234は、このようなRTOSのタスクスケジューリング機能をハードウェアにより実現している。
[2]基本例のハードウェアRTOSによるセマフォ処理
A general software RTOS performs semaphore-related processing by managing such a wait semaphore list. When releasing a semaphore, the policy for RTOS to select a READY-task from a plurality of WAIT-tasks is as follows.
1. WAIT-task (first condition).
2. Of the WAIT-tasks, the task must be a release semaphore as a standby semaphore (second condition)
3. When there are a plurality of such tasks, the task has the highest task priority (third condition).
4). When there are a plurality of tasks having the highest task priority, the task that has entered the WAIT state is the oldest task (fourth condition).
These four conditions are collectively referred to as “semaphore standby release conditions”. The semaphore selection circuit 234 of the task processing device 100 realizes such a task scheduling function of RTOS by hardware.
[2] Semaphore processing by hardware RTOS in basic example

図14は、セマフォ選択回路234の回路図である。
ここでも、タスク0〜タスク7の8つのタスクを前提として説明する。セマフォ選択回路234は、4つの第1比較回路300(300a〜300d)、2つの第2比較回路302(302a、302b)、1つの第3比較回路304を含む。また、8つの判定回路306(306a〜306h)も含む。
判定回路306は、状態記憶部220からのST、WR、SID信号とタスク切換回路210からのセマフォIDを示す信号を入力とする回路である。ここで入力されるセマフォIDは、解放セマフォのセマフォIDである。判定回路306は、解放セマフォを待機セマフォとするセマフォ待ちタスクであれば「1」、そうでなければ「0」を示すCID信号を出力する。判定回路306は、上記セマフォ待機解除条件のうちの第1条件と第2条件に関する判定結果を出力する回路である。第1比較回路300は、2つのタスクのID、PR、TIM、および、判定回路306からのCID信号を入力とする。
FIG. 14 is a circuit diagram of the semaphore selection circuit 234.
Here, description will be made on the premise of eight tasks of task 0 to task 7. The semaphore selection circuit 234 includes four first comparison circuits 300 (300a to 300d), two second comparison circuits 302 (302a and 302b), and one third comparison circuit 304. Also, eight determination circuits 306 (306a to 306h) are included.
The determination circuit 306 is a circuit that receives the ST, WR, and SID signals from the state storage unit 220 and the signal indicating the semaphore ID from the task switching circuit 210 as inputs. The semaphore ID input here is the semaphore ID of the released semaphore. The determination circuit 306 outputs a CID signal indicating “1” if the task is a semaphore waiting task having the released semaphore as a standby semaphore, and “0” otherwise. The determination circuit 306 is a circuit that outputs a determination result regarding the first condition and the second condition among the semaphore standby cancellation conditions. The first comparison circuit 300 receives the IDs of the two tasks, PR, TIM, and the CID signal from the determination circuit 306 as inputs.

第1比較回路300は、セマフォ待機解除条件のうち第3条件と第4条件についての判定を行う回路である。第2比較回路302や第3比較回路304も同様である。既に明らかなように、RUNタスク選択条件の第2条件および第3条件は、セマフォ待機解除条件の第3条件および第4条件と同じである。実行選択回路232の各比較回路は、タスクの状態データ(PR、TIM)を比較する回路である。一方、セマフォ選択回路234の各比較回路も、タスクの状態データ(PR、TIM)を比較する回路である。したがって、実行選択回路232の第1比較回路290とセマフォ選択回路234の第1比較回路300は、同等のロジックを内蔵する回路であり、共通化することができる。各タスクは判定回路306により第1条件と第2条件を判定された上で、第1比較回路300の判定処理に供される。あとは、実行選択回路232と同等の判定処理により、いずれかのタスクIDが第3比較回路304から出力される。ウェイトセマフォシステムコールおよびリリースセマフォシステムコール実行時における処理は以下の通りである。
<ウェイトセマフォシステムコールの実行>
The first comparison circuit 300 is a circuit that performs determination on the third condition and the fourth condition among the semaphore standby cancellation conditions. The same applies to the second comparison circuit 302 and the third comparison circuit 304. As is apparent, the second condition and the third condition of the RUN task selection condition are the same as the third condition and the fourth condition of the semaphore standby cancellation condition. Each comparison circuit of the execution selection circuit 232 is a circuit that compares task state data (PR, TIM). On the other hand, each comparison circuit of the semaphore selection circuit 234 is also a circuit that compares task status data (PR, TIM). Therefore, the first comparison circuit 290 of the execution selection circuit 232 and the first comparison circuit 300 of the semaphore selection circuit 234 are circuits that incorporate the same logic and can be shared. Each task is subjected to the determination process of the first comparison circuit 300 after the determination circuit 306 determines the first condition and the second condition. After that, one of the task IDs is output from the third comparison circuit 304 by a determination process equivalent to the execution selection circuit 232. Processing when a wait semaphore system call and a release semaphore system call are executed is as follows.
<Execution of wait semaphore system call>

ここでは、RUN−タスクをタスクJとして説明する。
A1.タスク切換回路210は、ウェイトセマフォシステムコールにおいて指定されたセマフォのセマフォカウンタをセマフォテーブル212から検出する。以下、セマフォカウンタの値に応じて処理は分岐する。
(セマフォカウンタ>0のとき)
A2.タスク切換回路210は、セマフォテーブル212のセマフォカウンタをデクリメントする。
A3.タスクJのタスク状態レジスタ258に「READY」を設定する。このとき、タスク切換回路210は、RUN−タスクのタイマ252をセットしてREADY経過時間の計測を開始させる。
(セマフォカウンタ=0のとき)
A2.タスク切換回路210は、タスクJのタスク状態レジスタ258に「WAIT」、待機理由レジスタ262に「セマフォ待ち」、セマフォIDレジスタ264に待機セマフォのセマフォIDをセットし、タイマ252をセットしてWAIT経過時間の計測を開始させる。
こうして、ウェイトセマフォシステムコールを実行したタスクはRUN→READYまたはWAITに状態遷移する。
<リリースセマフォシステムコールの実行>
Here, RUN-task is described as task J.
A1. The task switching circuit 210 detects the semaphore counter of the semaphore specified in the wait semaphore system call from the semaphore table 212. Hereinafter, the process branches according to the value of the semaphore counter.
(When semaphore counter> 0)
A2. The task switching circuit 210 decrements the semaphore counter of the semaphore table 212.
A3. “READY” is set in the task status register 258 of the task J. At this time, the task switching circuit 210 sets the RUN-task timer 252 and starts measuring the READY elapsed time.
(When semaphore counter = 0)
A2. The task switching circuit 210 sets “WAIT” in the task status register 258 of the task J, “waits for semaphore” in the waiting reason register 262, sets the semaphore ID of the waiting semaphore in the semaphore ID register 264, sets the timer 252 and waits for WAIT Start measuring time.
In this way, the task that executed the wait semaphore system call makes a state transition from RUN to READY or WAIT.
<Execution of release semaphore system call>

B1.タスク切換回路210は、解放セマフォのセマフォIDを各判定回路306に入力する。各判定回路306は、このセマフォIDを対象としてセマフォ待機解除条件のうちの第1条件および第2条件の成否を判定する。したがって、各第1比較回路300は、第3条件および第4条件にもとづいてタスクを選択する。
(いずれかの判定回路306が「1」を出力し、第3比較回路304がいずれかのタスクIDを出力したとき)
B2.検出されたタスクのタスク状態レジスタ258に「READY」を設定し、待機理由レジスタ262とセマフォIDレジスタ264をクリアし、タイマ252にREADY経過時間を計測させる。
B3.システムコールを実行したタスクのタスク状態レジスタ258に「READY」に設定し、READY経過時間の計測を開始する。
(いずれの判定回路306も「1」を出力せず、第3比較回路304がいずれのタスクIDも出力しないとき)
B2.タスク切換回路210はセマフォテーブル212のセマフォカウンタをインクリメントする。
B3.システムコールを実行したタスクの状態をRUN→READYに状態遷移させる。
B1. The task switching circuit 210 inputs the semaphore ID of the released semaphore to each determination circuit 306. Each determination circuit 306 determines the success or failure of the first condition and the second condition of the semaphore standby cancellation conditions for this semaphore ID. Accordingly, each first comparison circuit 300 selects a task based on the third condition and the fourth condition.
(When any determination circuit 306 outputs “1” and the third comparison circuit 304 outputs any task ID)
B2. “READY” is set in the task status register 258 of the detected task, the waiting reason register 262 and the semaphore ID register 264 are cleared, and the timer 252 is made to measure the READY elapsed time.
B3. The task status register 258 of the task that executed the system call is set to “READY”, and measurement of the READY elapsed time is started.
(None of the determination circuits 306 outputs “1”, and the third comparison circuit 304 does not output any task ID)
B2. The task switching circuit 210 increments the semaphore counter of the semaphore table 212.
B3. The state of the task that executed the system call is changed from RUN to READY.

状態記憶部220は常時状態データをセマフォ選択回路234に出力しているため、タスク切換回路210がセマフォIDを判定回路306に入力すると、セマフォ選択回路234は直ちに選択処理を実行できる。
[ミューテックス処理]
Since the state storage unit 220 always outputs the state data to the semaphore selection circuit 234, when the task switching circuit 210 inputs the semaphore ID to the determination circuit 306, the semaphore selection circuit 234 can immediately execute the selection process.
[Mutex processing]

ミューテックスもセマフォと同じく、タスク間の同期処理に利用される。ミューテックスとセマフォは以下の点において相違する。
1.セマフォカウンタは1以上の整数を設定可能である。これに対し、ミューテックスはセマフォカウンタが1または0の特殊なセマフォである。セマフォカウンタが2以上のときには、同一セマフォを2以上のタスクが獲得できる。しかし、ミューテックスの場合、あるミューテックスを獲得できるタスクは常に1つだけである。
2.リリースセマフォシステムコールによりセマフォを解放できるタスクは、ウェイトセマフォシステムコールによりセマフォを獲得したタスクに限らない。これに対し、リリースミューテックスシステムコールによりミューテックスを解放できるタスクは、ウェイトミューテックスシステムコールによりミューテックスを獲得したタスクだけである。
Mutexes, like semaphores, are also used for synchronization between tasks. Mutexes and semaphores differ in the following respects.
1. The semaphore counter can set an integer of 1 or more. In contrast, a mutex is a special semaphore with a semaphore counter of 1 or 0. When the semaphore counter is 2 or more, two or more tasks can acquire the same semaphore. However, in the case of a mutex, there can always be only one task that can acquire a mutex.
2. A task that can release a semaphore by a release semaphore system call is not limited to a task that has acquired a semaphore by a wait semaphore system call. On the other hand, the task that can release the mutex by the release mutex system call is only the task that has acquired the mutex by the wait mutex system call.

ミューテックスの解放に際し、複数のWAIT−タスクの中からREADY−タスクを選択するポリシは以下の通りである。
1.WAIT−タスクであること(第1条件)。
2.WAIT−タスクのうち、解放ミューテックスを待機ミューテックスとするタスクであること(第2条件)
3.そのようなタスクが複数存在するときには、最もタスク優先順位の高いタスクであること(第3条件)。
4.最もタスク優先順位の高いタスクが複数存在するときには、WAIT状態になった時期が最も古いタスクであること(第4条件)。
このような4つの条件のことを、まとめて「ミューテックス待機解除条件」とよぶことにする。
The policy for selecting a READY-task from a plurality of WAIT-tasks when releasing a mutex is as follows.
1. WAIT-task (first condition).
2. Among WAIT-tasks, the task must have a release mutex as a waiting mutex (second condition)
3. When there are a plurality of such tasks, the task has the highest task priority (third condition).
4). When there are a plurality of tasks having the highest task priority, the task that has entered the WAIT state is the oldest task (fourth condition).
These four conditions are collectively referred to as “mutex standby release conditions”.

したがって、ウェイトミューテックスシステムコールおよびリリースミューテックスシステムコール実行時における基本例のハードウェアRTOSの処理は以下の通りである。セマフォテーブル212には、ミューテックスIDと、そのミューテックスがいずれかのタスクに占有されているか否かを示す占有状態データが対応づけて保持されている。占有状態データは、占有されていないときには「0」であり、占有されているときにはミューテックスを占有しているタスクのタスクIDとなる。
<ウェイトミューテックスシステムコールの実行>
Accordingly, the processing of the hardware RTOS of the basic example when executing the wait mutex system call and the release mutex system call is as follows. The semaphore table 212 holds a mutex ID and occupation state data indicating whether or not the mutex is occupied by any task. The occupation state data is “0” when not occupied, and becomes the task ID of the task occupying the mutex when occupied.
<Execution of wait mutex system call>

ここでは、RUN−タスクをタスクJとして説明する。
A1.タスク切換回路210は、ウェイトミューテックスシステムコールにおいて指定されたミューテックスが占有されているか検出する。以下、ミューテックスの占有状態に応じて処理は分岐する。
(ミューテックスが占有されていないとき)
A2.タスク切換回路210は、ミューテックスの占有データとして、システムコールを実行したタスクのタスクIDを記録する。
A3.タスクJのタスク状態レジスタ258に「READY」を設定する。このとき、タスク切換回路210は、RUN−タスクのタイマ252をセットしてREADY経過時間の計測を開始させる。
(ミューテックスが占有されているとき)
A2.タスク切換回路210は、タスクJのタスク状態レジスタ258に「WAIT」、待機理由レジスタ262に「ミューテックス待ち」、ミューテックスIDレジスタ265に待機ミューテックスのミューテックスIDをセットし、タイマ252をセットしてWAIT経過時間の計測を開始させる。
<リリースミューテックスシステムコールの実行>
Here, RUN-task is described as task J.
A1. The task switching circuit 210 detects whether the mutex designated in the wait mutex system call is occupied. Hereinafter, the process branches depending on the occupation state of the mutex.
(When the mutex is not occupied)
A2. The task switching circuit 210 records the task ID of the task that executed the system call as the mutex occupation data.
A3. “READY” is set in the task status register 258 of the task J. At this time, the task switching circuit 210 sets the RUN-task timer 252 and starts measuring the READY elapsed time.
(When mutex is occupied)
A2. The task switching circuit 210 sets “WAIT” in the task status register 258 of task J, “waiting for mutex” in the waiting reason register 262, sets the mutex ID of the waiting mutex in the mutex ID register 265, sets the timer 252, and waits for WAIT. Start measuring time.
<Execution of release mutex system call>

B1.タスク切換回路210は、システムコールを実行したタスクが、解放ミューテックスを占有していることを条件として、解放セマフォIDをミューテックス回路240に入力する。ミューテックス回路240も、図14と同じく多段接続された比較回路とミューテックス待機解除条件のうちの第1条件および第2条件の成否を判定する判定回路を含む。この判定回路は、このミューテックスを対象としてミューテックス待機条件のうちの第1条件および第2条件が共に成立したときだけ「1」を出力する。なお、解放ミューテックスを占有しないタスクがリリースミューテックスシステムコールを実行したときには、そのタスクの状態をRUN→READYに状態遷移させる。
(いずれかの判定回路が「1」を出力し、ミューテックス回路240からいずれかのタスクIDを出力したとき)
B2.検出されたタスクのタスク状態レジスタ258に「READY」を設定し、待機理由レジスタ262とミューテックスIDレジスタ265をクリアし、タイマ252をREADY経過時間を計測させる。
B3.システムコールを実行したタスクのタスク状態レジスタ258に「READY」に設定し、READY経過時間の計測を開始する。
(いずれの判定回路も「1」を出力せず、ミューテックス回路240がいずれのタスクIDも出力しないとき)
B2.タスク切換回路210はセマフォテーブル212において、ミューテックスを非占有状態に設定する。
B3.システムコールを実行したタスクの状態をRUN→READYに状態遷移させる。
[イベント処理]
B1. The task switching circuit 210 inputs the release semaphore ID to the mutex circuit 240 on the condition that the task that executed the system call occupies the release mutex. The mutex circuit 240 also includes a comparison circuit that is connected in multiple stages as in FIG. 14 and a determination circuit that determines whether the first condition and the second condition of the mutex standby cancellation conditions are successful. This determination circuit outputs “1” only when both the first condition and the second condition of the mutex standby conditions are satisfied for this mutex. When a task that does not occupy the release mutex executes a release mutex system call, the task state is changed from RUN to READY.
(When any judgment circuit outputs "1" and any task ID is output from the mutex circuit 240)
B2. “READY” is set in the task status register 258 of the detected task, the waiting reason register 262 and the mutex ID register 265 are cleared, and the timer 252 is made to measure the READY elapsed time.
B3. The task status register 258 of the task that executed the system call is set to “READY”, and measurement of the READY elapsed time is started.
(None of the determination circuits outputs “1” and the mutex circuit 240 does not output any task ID)
B2. In the semaphore table 212, the task switching circuit 210 sets the mutex to an unoccupied state.
B3. The state of the task that executed the system call is changed from RUN to READY.
[Event processing]

基本例におけるイベント管理について簡単に説明する。イベントテーブル214には、イベントIDにフラグパターン(以下、「カレントフラグパターン」とよぶ)が対応づけて記録される。フラグパターンは8ビットのビットパターンである。
セットイベントシステムコールは、カレントフラグパターンを設定変更するシステムコールであり、イベントIDとフラグパターン(以下、「セットフラグパターン」とよぶ)をパラメータとする。セットイベントシステムコールが実行されると、該当イベントについて、カレントフラグパターンは、セットフラグパターンとの論理和に変更される。たとえば、カレントフラグパターン「00001100」、セットフラグパターン「00000101」のときには、カレントフラグパターンは、「00001101」となる。以下、各フラグパターンについて左から第0ビット、第1ビット、・・・、第7ビットとよぶ。
The event management in the basic example will be briefly described. In the event table 214, an event ID is recorded in association with a flag pattern (hereinafter referred to as “current flag pattern”). The flag pattern is an 8-bit bit pattern.
The set event system call is a system call for setting and changing the current flag pattern, and uses an event ID and a flag pattern (hereinafter referred to as “set flag pattern”) as parameters. When the set event system call is executed, the current flag pattern is changed to a logical sum with the set flag pattern for the corresponding event. For example, when the current flag pattern is “00001100” and the set flag pattern is “00000101”, the current flag pattern is “00001011”. Hereinafter, each flag pattern is referred to as 0th bit, 1st bit,..., 7th bit from the left.

ウェイトイベントシステムコールは、待機イベントのカレントフラグパターンが所定条件を満たすのを待つためのシステムコールであり、イベントID、フラグパターン(以下、「待機フラグパターン」とよぶ)、フラグ条件をパラメータとする。ウェイトイベントシステムコールが実行されると、カレントフラグパターンと待機フラグパターンの間にフラグ条件が成立するか判定される。フラグ条件は論理和(OR)または論理積(AND)である。フラグ条件が論理積(AND)の場合、待機フラグパターンにおいて「1」となっているすべてのビットについて、カレントフラグパターンの該当ビットもすべて「1」であることがWAIT解除条件となる。フラグ条件が論理和(OR)の場合、待機フラグパターンにおいて「1」となっているいずれかのビットについて、カレントフラグパターンの該当ビットが「1」であることがWAIT解除条件となる。たとえば、カレントフラグパターン「00001101」、待機フラグパターン「00000011」、フラグ条件「論理和(OR)」の場合、待機フラグパターンの第6ビットおよび第7ビットのうち、カレントフラグパターンの第7ビットが1なので、この場合には、ウェイトイベントシステムコールによるWAIT解除条件は成立する。一方、フラグ条件が「論理積(AND)」の場合、カレントフラグパターンの第6ビットが「0」なのでWAIT解除条件は成立しない。
[1]一般的なソフトウェアRTOSによるイベント処理
The wait event system call is a system call for waiting for the current flag pattern of the standby event to satisfy a predetermined condition, and uses an event ID, a flag pattern (hereinafter referred to as “standby flag pattern”), and a flag condition as parameters. . When the wait event system call is executed, it is determined whether a flag condition is satisfied between the current flag pattern and the standby flag pattern. The flag condition is logical sum (OR) or logical product (AND). When the flag condition is AND (AND), the WAIT cancellation condition is that all the corresponding bits of the current flag pattern are “1” for all the bits that are “1” in the standby flag pattern. When the flag condition is logical sum (OR), the WAIT cancellation condition is that the corresponding bit of the current flag pattern is “1” for any bit that is “1” in the standby flag pattern. For example, in the case of the current flag pattern “00001011”, the standby flag pattern “00000011”, and the flag condition “logical sum (OR)”, the seventh bit of the current flag pattern among the sixth bit and the seventh bit of the standby flag pattern is In this case, the WAIT cancellation condition by the wait event system call is satisfied. On the other hand, when the flag condition is “logical product (AND)”, the sixth bit of the current flag pattern is “0”, so the WAIT cancellation condition is not satisfied.
[1] Event processing by general software RTOS

ウェイトイベントシステムコールおよびセットイベントシステムコール実行時における一般的なRTOSの処理は以下の通りである。一般的なRTOSにおいては、イベント管理のために、メモリ上にイベントテーブルを保持する。このイベントテーブルにおいては、イベントID、カレントフラグパターンだけではなく、通常、そのイベントを待機イベントとしてWAIT状態にあるタスク(以下、「イベント待ちタスク」とよぶ)のタスクID、待機フラグパターン、フラグ条件が対応づけられて保持される。
<ウェイトイベントシステムコールの実行>
A general RTOS process at the time of executing the wait event system call and the set event system call is as follows. In general RTOS, an event table is held in a memory for event management. In this event table, not only the event ID and current flag pattern, but also the task ID, standby flag pattern, and flag condition of a task that is normally in the WAIT state with the event as a standby event (hereinafter referred to as “event waiting task”). Are associated and held.
<Execution of wait event system call>

A1.RTOSは、システムコールで指定されたイベントのカレントフラグパターンをイベントテーブルから読み出す。
A2.カレントフラグパターンと待機フラグパターンをフラグ条件にしたがって比較し、WAIT解除条件の成否を判定する。
(WAIT解除条件が成立するとき)
A3.システムコールを実行したタスクのタスク状態をRUN→READYに状態遷移させる。
(WAIT解除条件が成立しないとき)
A3.イベントテーブルに、システムコールを実行したタスクのタスクIDを記録する。
A4.イベントテーブルに待機フラグパターンを記録する。
A5.イベントテーブルにフラグ条件を記録する。
A6.システムコールを実行したタスクのタスク状態をRUN→WAITに状態遷移させる。
<セットイベントシステムコールの実行>
A1. The RTOS reads the current flag pattern of the event specified by the system call from the event table.
A2. The current flag pattern and the standby flag pattern are compared according to the flag condition to determine whether the WAIT cancellation condition is successful.
(When WAIT cancellation condition is satisfied)
A3. The task state of the task that executed the system call is changed from RUN to READY.
(When WAIT cancellation condition is not satisfied)
A3. The task ID of the task that executed the system call is recorded in the event table.
A4. Record the wait flag pattern in the event table.
A5. Record the flag condition in the event table.
A6. The task state of the task that executed the system call is changed from RUN to WAIT.
<Execution of set event system call>

B1.RTOSは、システムコールで指定された設定イベントについて、イベントテーブルからカレントフラグパターン、タスクID、待機フラグパターン、フラグ条件を読み出す。
B2.カレントフラグパターンとセットフラグパターンの論理和を新たなカレントフラグパターンとして記録する。
(設定イベントについてイベント待ちタスクが存在しないとき、または、存在したとしても待機フラグパターンとフラグ条件からWAIT解除条件が成立しないとき)
B3.システムコールを実行したタスクのタスク状態をRUN→READYに状態遷移させる。
(設定イベントについてイベント待ちタスクが存在し、WAIT解除条件が成立するとき)
B3.イベントを待機していたタスクのタスク状態をWAIT→READYに状態遷移させる。
B4.イベントテーブルにおける待機タスクID、待機フラグパターン、フラグ条件をクリアする。
B5.システムコールを実行したタスクのタスク状態をRUN→READYに状態遷移させる。また、RUN−タスクの選択が行われる。
B1. The RTOS reads the current flag pattern, task ID, standby flag pattern, and flag condition from the event table for the set event specified by the system call.
B2. The logical sum of the current flag pattern and the set flag pattern is recorded as a new current flag pattern.
(When there is no event-waiting task for the set event, or even if it exists, the WAIT cancellation condition is not satisfied from the wait flag pattern and flag condition)
B3. The task state of the task that executed the system call is changed from RUN to READY.
(When there is an event waiting task for the set event and the WAIT cancellation condition is met)
B3. The task state of the task waiting for the event is changed from WAIT to READY.
B4. The standby task ID, standby flag pattern, and flag condition in the event table are cleared.
B5. The task state of the task that executed the system call is changed from RUN to READY. In addition, a RUN-task is selected.

セットイベントシステムコールが実行されるとき、複数のWAIT−タスクの中からREADY−タスクを選択するポリシは以下の通りである。
1.WAIT−タスクであること(第1条件)。
2.WAIT−タスクのうち、設定イベントを待機イベントとするタスクであること(第2条件)。
3.待機フラグパターンとカレントフラグパターン、フラグ条件を比較してWAIT解除条件が成立するタスクであること(第3条件)
このような3つの条件のことを、まとめて「イベント待機解除条件」とよぶことにする。
[2]基本例のハードウェアRTOSによるイベント処理
When a set event system call is executed, a policy for selecting a READY-task from a plurality of WAIT-tasks is as follows.
1. WAIT-task (first condition).
2. Of the WAIT-tasks, the task must be a set event as a standby event (second condition).
3. The task must satisfy the WAIT cancellation condition by comparing the standby flag pattern, current flag pattern, and flag conditions (third condition)
These three conditions are collectively referred to as “event standby release conditions”.
[2] Event processing by hardware RTOS of basic example

タスク処理装置100のウェイトイベントシステムコールおよびセットイベントシステムコール実行時における処理は以下の通りである。タスク処理装置100が内蔵するイベントテーブル214においては、イベントIDとカレントフラグパターンが対応づけられている。待機タスクIDや待機フラグパターンなどの情報は、状態記憶部220に格納される。
<ウェイトイベントシステムコールの実行>
Processing when the task processing apparatus 100 executes the wait event system call and the set event system call is as follows. In the event table 214 built in the task processing apparatus 100, an event ID and a current flag pattern are associated with each other. Information such as a standby task ID and a standby flag pattern is stored in the state storage unit 220.
<Execution of wait event system call>

A1.タスク切換回路210は、イベントテーブル214からカレントフラグパターンを読み出す。
A2.タスク切換回路210は、カレントフラグパターンと待機フラグパターンをフラグ条件にしたがって比較し、WAIT解除条件の成否を判定する。
(WAIT解除条件が成立するとき)
A3.システムコールを実行したタスクのタスク状態レジスタ258に「READY」を設定する。
(WAIT解除条件が成立しないとき)
A3.タスク切換回路210は、システムコールを実行したタスクのタスク状態レジスタ258に「WAIT」、待機理由レジスタ262に「イベント待ち」、イベントIDレジスタ266に待機イベントのイベントID、待機フラグレジスタ268に待機フラグパターン、フラグ条件レジスタ270にフラグ条件をそれぞれ設定する。
<セットイベントシステムコールの実行>
A1. The task switching circuit 210 reads the current flag pattern from the event table 214.
A2. The task switching circuit 210 compares the current flag pattern with the standby flag pattern according to the flag condition, and determines whether the WAIT cancellation condition is met.
(When WAIT cancellation condition is satisfied)
A3. “READY” is set in the task status register 258 of the task that executed the system call.
(When WAIT cancellation condition is not satisfied)
A3. The task switching circuit 210 “WAIT” in the task status register 258 of the task that executed the system call, “waiting for event” in the wait reason register 262, event ID of the standby event in the event ID register 266, and standby flag in the standby flag register 268. Flag conditions are set in the pattern and flag condition register 270, respectively.
<Execution of set event system call>

B1.タスク切換回路210は、イベントテーブル214からカレントフラグパターンを読み出すとともに、システムコールで指定された設定イベントのイベントIDをイベント選択回路236に入力する。
B2.タスク切換回路210は、イベントテーブル214のカレントフラグパターンにセットフラグパターンを論理加算する。
B3.イベント選択回路236は、入力されたイベントIDについて、イベント待機条件が成立するタスクを選択する。このとき、タスク優先順位やWAIT経過時間に関わらず複数のタスクが選択されてもよい。
(イベント待機解除条件を満たすタスクが存在するとき)
B4.イベント待ちタスクのタスク状態レジスタ258に「READY」を設定し、イベントIDレジスタ266、待機フラグレジスタ268、フラグ条件レジスタ270をクリアする。
B5.システムコールを実行したタスクのタスク状態をRUN→READYに状態遷移させる。
(イベント待機解除条件を満たすタスクが存在しないとき)
B4.システムコールを実行したタスクのタスク状態をRUN→READYに状態遷移させる。
[タイムアウト処理]
B1. The task switching circuit 210 reads the current flag pattern from the event table 214 and inputs the event ID of the set event designated by the system call to the event selection circuit 236.
B2. The task switching circuit 210 logically adds the set flag pattern to the current flag pattern of the event table 214.
B3. The event selection circuit 236 selects a task that satisfies the event standby condition for the input event ID. At this time, a plurality of tasks may be selected regardless of the task priority order and the WAIT elapsed time.
(When there is a task that satisfies the event waiting cancellation condition)
B4. “READY” is set in the task status register 258 of the event waiting task, and the event ID register 266, the standby flag register 268, and the flag condition register 270 are cleared.
B5. The task state of the task that executed the system call is changed from RUN to READY.
(When there is no task that satisfies the event wait cancellation condition)
B4. The task state of the task that executed the system call is changed from RUN to READY.
[Timeout processing]

WAIT状態に移行したタスクは、WAIT解除条件が成立したときにREADY状態に遷移する。しかし、何らかの外的要因やアプリケーションプログラムのバグにより、WAIT解除条件の成立が阻害されると、タスクはWAIT状態から抜け出せなくなってしまう。そこで、通常、タスクをWAIT状態に遷移させるときにはタイムアウト値を設定する。タイムアウト値は定期的にデクリメントされ、ゼロとなったときには、WAIT解除条件が成立していなくてもタスクはWAIT状態からREADY状態に遷移する。すなわち、タイムアウト値以上の時間、タスクがWAIT状態に止まるのを防止している。
[1]一般的なソフトウェアRTOSによるタイムアウト処理
A task that has transitioned to the WAIT state transitions to the READY state when the WAIT cancellation condition is satisfied. However, if the establishment of the WAIT cancellation condition is hindered due to some external factor or a bug in the application program, the task cannot escape from the WAIT state. Therefore, normally, a timeout value is set when the task is shifted to the WAIT state. The timeout value is decremented periodically, and when it becomes zero, the task transitions from the WAIT state to the READY state even if the WAIT cancellation condition is not satisfied. That is, the task is prevented from stopping in the WAIT state for a time longer than the timeout value.
[1] Time-out processing by general software RTOS

ソフトウェアによる一般的なRTOSの場合、WAIT状態のタスクのTCBにはタイムアウト値が設定され、このタイムアウト値は定期的にデクリメントされる。RTOSは周期的にCPUの処理に割り込みをかけ、全TCBをチェックし、タイムアウト値がゼロに至ったWAIT−タスクを検出する。このようなタスクが検出されたときには、RTOSはそのタスクのタスク状態をWAITからREADYに状態遷移させる。
[2]基本例のハードウェアRTOSによるタイムアウト処理
In the case of a general RTOS by software, a timeout value is set in the TCB of a task in a WAIT state, and this timeout value is periodically decremented. The RTOS periodically interrupts the processing of the CPU, checks all TCBs, and detects a WAIT-task whose timeout value has reached zero. When such a task is detected, the RTOS changes the task state of the task from WAIT to READY.
[2] Time-out process by hardware RTOS of basic example

一方、基本例の場合、タスク切換回路210は各タイムアウトカウンタ274のタイムアウト値を定期的にデクリメントする。タイムアウト値は、WAIT系システムコールを実行する時にパラメータとして設定され、タスク切換回路210はそのシステムコールを実行したタスクのタイムアウトカウンタ274にタイムアウト値を設定する。   On the other hand, in the basic example, the task switching circuit 210 periodically decrements the timeout value of each timeout counter 274. The timeout value is set as a parameter when the WAIT system call is executed, and the task switching circuit 210 sets the timeout value in the timeout counter 274 of the task that executed the system call.

タイムアウト値のデクリメント処理にCPU150が介在しないため、タスク切換回路210がタスク実行処理とは独立してタイムアウト値を更新できる。そのため、CPU150がタスクを実行している最中にも、タスク制御回路200において自律的にタイムアウト値の更新がなされる。タイムアウト検出回路238には状態データが常時入力されているので、タイムアウト検出回路238は、タイムアウトカウント値が更新されたタイミングとほぼ同じタイミングにて、タイムアウトカウント値がゼロとなったタスクを検出できる。タイムアウト検出回路238は、そのようなタスクのタスクIDを出力する。タスク切換回路210は、タイムアウト検出回路238からタスクIDを入力されると、タイムアウトが発生したと認識し、HCをアサートしてCPUクロックを供給停止させる。タスク制御回路200は、タイムアウトが発生したWAIT−タスクをREADY状態に遷移させるとともに、RUN−タスクをREADY状態に遷移させる。タスク切換回路210は、READY−タスクの中から次に実行すべきタスクを選択する。また、タスク切換回路210は、タイムアウトが発生したタスクのタイマ252をリスタートさせ、READY経過時間を計測させる。   Since the CPU 150 is not involved in the timeout value decrement process, the task switching circuit 210 can update the timeout value independently of the task execution process. For this reason, the task control circuit 200 autonomously updates the timeout value while the CPU 150 is executing a task. Since the status data is always input to the timeout detection circuit 238, the timeout detection circuit 238 can detect a task whose timeout count value has become zero at almost the same timing as when the timeout count value is updated. The timeout detection circuit 238 outputs the task ID of such a task. When the task switching circuit 210 receives the task ID from the timeout detection circuit 238, the task switching circuit 210 recognizes that a timeout has occurred, and asserts HC to stop supplying the CPU clock. The task control circuit 200 causes the WAIT-task in which a timeout has occurred to transition to the READY state, and causes the RUN-task to transition to the READY state. The task switching circuit 210 selects a task to be executed next from among the READY-tasks. In addition, the task switching circuit 210 restarts the timer 252 of the task that has timed out, and measures the READY elapsed time.

このような処理方法によれば、タスクの実行中、すなわち、CPUクロックの動作中にタイムアウトが発生したときに、即時的にCPU150に割り込みをかけて、タスクスイッチを実行できる。また、タスクの実行中において、タスク切換回路210はCPU150の処理能力を借りることなく独立してタイムアウト値の更新処理を実行できる。
[有限ステートマシンとしてのタスク切換回路210]
According to such a processing method, when a timeout occurs during the execution of a task, that is, during the operation of the CPU clock, it is possible to immediately interrupt the CPU 150 and execute the task switch. Further, during the execution of the task, the task switching circuit 210 can execute the timeout value update process independently without borrowing the processing capability of the CPU 150.
[Task switching circuit 210 as a finite state machine]

図15は、タスク切換回路210の状態遷移図である。
初期化処理(A1)においては、全タスクがIDLE状態にある。初期化処理が完了すると(S10)、いずれかのタスクがRUN−タスクとなりタスク実行状態(A2)となる。割り込み要求信号が検出されると(S12)、特殊タスクがRUN−タスクとなり、割り込み処理(A3)が実行される。割り込み処理が終了すると(S14)、タスク切換回路210は、一般タスクからRUN−タスクを選択し、A2に遷移する。
FIG. 15 is a state transition diagram of the task switching circuit 210.
In the initialization process (A1), all tasks are in the IDLE state. When the initialization process is completed (S10), one of the tasks becomes a RUN-task and enters the task execution state (A2). When an interrupt request signal is detected (S12), the special task becomes a RUN-task, and interrupt processing (A3) is executed. When the interrupt process ends (S14), the task switching circuit 210 selects a RUN-task from the general tasks, and transitions to A2.

また、タスク実行中(A2)において、システムコールが実行されると(S16)、システムコール処理が実行される(A4)。タスクスイッチ、すなわち、RUN−タスクの切り換えが発生しない場合には(S18)、A2に戻る。一方、システムコール処理(A4)により、タスクスイッチが発生する場合には(S20)、タスク切換回路210は実行選択回路232の出力に基づいてRUN−タスクの選択を行う(A5)。タスクスイッチが完了すると(S22)、処理状態はA2に移行する。
基本例に関連して、更に、タスク処理装置100の主要素である退避回路120とタスク制御回路200のうち一方のみを実装する場合について付言する。
[タスク制御回路200を搭載しないタイプのタスク処理装置100]
When a system call is executed during task execution (A2) (S16), system call processing is executed (A4). If task switching, that is, RUN-task switching does not occur (S18), the process returns to A2. On the other hand, when a task switch occurs due to the system call process (A4) (S20), the task switching circuit 210 selects a RUN-task based on the output of the execution selection circuit 232 (A5). When the task switch is completed (S22), the processing state shifts to A2.
In relation to the basic example, a case where only one of the save circuit 120 and the task control circuit 200 which are main elements of the task processing device 100 is mounted will be additionally described.
[A task processing apparatus 100 of a type that does not include the task control circuit 200]

図16は、図5のタスク処理装置100のうち、タスク制御回路200を搭載しないタスク処理装置100の回路図である。
タスク制御回路200を搭載しない代わりに、レジスタ切換制御回路322と処理データ保持部320を追加している。タスク制御回路200を搭載しないため、タスクスケジューリング機能はソフトウェアRTOSにより実現される。したがって、RTOSはタスクスイッチに際して、CPU150の使用権を一時的に取得する必要が生じる。処理データ保持部320は、通常、RTOSのための処理データを保持する。RTOSがCPU150の使用権を取得するときには、処理データ保持部320は処理データ保持部320にあるRTOS用の処理データと特殊レジスタ156のタスク用の処理データを入れ替える。以下、タスクAからタスクBへタスクスイッチするとして、その処理過程を説明する。
FIG. 16 is a circuit diagram of the task processing apparatus 100 that does not include the task control circuit 200 in the task processing apparatus 100 of FIG.
Instead of mounting the task control circuit 200, a register switching control circuit 322 and a processing data holding unit 320 are added. Since the task control circuit 200 is not installed, the task scheduling function is realized by software RTOS. Therefore, it becomes necessary for the RTOS to temporarily acquire the right to use the CPU 150 at the time of task switching. The processing data holding unit 320 normally holds processing data for RTOS. When the RTOS acquires the right to use the CPU 150, the processing data holding unit 320 replaces the processing data for RTOS in the processing data holding unit 320 with the processing data for tasks in the special register 156. In the following, the processing process will be described on the assumption that task switching is performed from task A to task B.

A1.タスクAがシステムコール実行するとき、システムコールの変数やシステムコールのIDを汎用レジスタ158の一部に記録する。
A2.レジスタ切換制御回路322は、タスクAの処理データを処理データ保持部320に移動させ、処理データ保持部320のRTOS用処理データを処理レジスタ154にロードする。この段階で、RTOSがCPU150の使用権を取得する。
A3.レジスタ切換制御回路322は、退避レジスタ110aに書き込み信号を入力し、処理データ保持部320のタスクA用処理データを退避レジスタ110に退避させる。
A4.RTOSは、汎用レジスタ158に記録されているシステムコールの変数やIDに基づき、システムコールに対応する処理を実行する。また、タスクAのTCBのタスク状態データを「READY」に設定し、タスクレディリストにタスクAのTCBを追加する。
A1. When the task A executes a system call, the system call variable and the system call ID are recorded in a part of the general-purpose register 158.
A2. The register switching control circuit 322 moves the processing data of task A to the processing data holding unit 320 and loads the RTOS processing data of the processing data holding unit 320 into the processing register 154. At this stage, the RTOS acquires the right to use the CPU 150.
A3. The register switching control circuit 322 inputs a write signal to the save register 110 a and saves the task A process data in the process data holding unit 320 to the save register 110.
A4. The RTOS executes processing corresponding to the system call based on the system call variable and ID recorded in the general-purpose register 158. Also, the task status data of the task A TCB is set to “READY”, and the task A TCB is added to the task ready list.

B1.次に、RTOSは先述したRUNタスク選択条件にしたがって、RUN−タスク、ここでは、タスクBを選択する。
B2.RTOSはレジスタ切換制御回路322に指示して、タスクBを指定したタスク選択信号をロード選択回路112に入力させる。退避レジスタ110bから処理データ保持部320に処理データが移動される。
B3.レジスタ切換制御回路322は、処理データ保持部320のタスクB用処理データと処理レジスタ154のRTOS用処理データを入れ替える。これにより、タスクBがCPU150の使用権を取得する。
B1. Next, the RTOS selects a RUN-task, in this case, task B, according to the RUN task selection condition described above.
B2. The RTOS instructs the register switching control circuit 322 to input a task selection signal designating task B to the load selection circuit 112. The processing data is moved from the save register 110b to the processing data holding unit 320.
B3. The register switching control circuit 322 switches the task B processing data in the processing data holding unit 320 and the RTOS processing data in the processing register 154. As a result, the task B acquires the right to use the CPU 150.

このような処理方法によれば、タスク制御回路200を搭載する図5のタスク処理装置100に比べて、タスク処理装置100全体としての回路サイズをコンパクトにできる。RTOSはソフトウェアとして実現されるが、処理データのロード・退避はレジスタ切換制御回路322からの信号によってハードウェア制御できる。処理レジスタ154、処理データ保持部320、ロード選択回路112、退避レジスタ110をそれぞれつなぐバスは処理データをパラレル転送可能なビット数に設定すれば、TCBへの処理データの退避やTCBからの処理データのロードに比べて高速なタスクスイッチが可能となる。
[退避回路120を搭載しないタイプのタスク処理装置100]
According to such a processing method, the circuit size of the task processing device 100 as a whole can be made compact compared to the task processing device 100 of FIG. Although the RTOS is realized as software, loading and saving of processing data can be controlled by hardware by a signal from the register switching control circuit 322. If the bus connecting the processing register 154, the processing data holding unit 320, the load selection circuit 112, and the save register 110 is set to the number of bits that can be transferred in parallel, the processing data can be saved to the TCB or processed from the TCB. Task switching can be performed faster than loading of
[A task processing device 100 of a type that does not include the save circuit 120]

図17は、図5のタスク処理装置100のうち、退避回路120を搭載しないタスク処理装置100の回路図である。
退避回路120を搭載しない代わりに、割込インタフェース回路324を追加している。退避回路120を搭載しないため、処理データはメモリのTCBに退避される。処理データの退避・ロードに関してはソフトウェアベースのRTOSにより実現される。したがって、RTOSはタスクスイッチに際して、CPU150の使用権を一時的に取得する必要が生じる。以下、タスクAからタスクBへタスクスイッチするとして、その処理過程を説明する。
FIG. 17 is a circuit diagram of the task processing apparatus 100 in which the save circuit 120 is not mounted in the task processing apparatus 100 of FIG.
Instead of mounting the save circuit 120, an interrupt interface circuit 324 is added. Since the save circuit 120 is not installed, the processing data is saved in the TCB of the memory. Processing data saving / loading is realized by a software-based RTOS. Therefore, it becomes necessary for the RTOS to temporarily acquire the right to use the CPU 150 at the time of task switching. In the following, the processing process will be described on the assumption that task switching is performed from task A to task B.

システムコールの実行によりタスクスイッチが発生すると、まず、ソフトウェアRTOSがタスクAの処理データをタスクAのTCBに退避させる。そして、RTOS用の処理データを処理レジスタ154にロードする。このときの処理方法は、図3に関連して説明した内容と同等となる。   When a task switch occurs due to the execution of a system call, first, the software RTOS saves the processing data of task A in the TCB of task A. Then, the processing data for RTOS is loaded into the processing register 154. The processing method at this time is equivalent to the content described in relation to FIG.

ソフトウェアRTOSは、割込インタフェース回路324にシステムコールのパラメータを書き込む。実行制御回路152は、CPU150のCPUクロックを停止させる。割込インタフェース回路324は、タスク制御回路200にタスクスイッチを実行させる。タスク切換回路210は、まず、タスクAのタスク状態レジスタ258をREADYに設定し、タスク選択回路230からの出力により次のRUN−タスクであるタスクBを選択する。タスク切換回路210は、割込インタフェース回路324に指示してタスクBの処理データのロードを指示する。ここで、割込インタフェース回路324は実行制御回路152にCPUクロックを再開させる。また、割込インタフェース回路324は、タスクBが選択された旨をソフトウェアRTOSに通知する。ソフトウェアRTOSは、タスクBのTCBにアクセスし、タスクBの処理データを処理レジスタ154にロードする。   The software RTOS writes the system call parameters in the interrupt interface circuit 324. The execution control circuit 152 stops the CPU clock of the CPU 150. The interrupt interface circuit 324 causes the task control circuit 200 to execute a task switch. The task switching circuit 210 first sets the task status register 258 of the task A to READY, and selects the task B that is the next RUN-task based on the output from the task selection circuit 230. The task switching circuit 210 instructs the interrupt interface circuit 324 to load task B processing data. Here, the interrupt interface circuit 324 causes the execution control circuit 152 to restart the CPU clock. The interrupt interface circuit 324 notifies the software RTOS that the task B has been selected. The software RTOS accesses the TCB of task B and loads the processing data of task B into the processing register 154.

このような処理方法によっても、退避回路120を搭載する図5のタスク処理装置100に比べて、タスク処理装置100全体としての回路サイズをコンパクトにできる。RTOSの機能の一部はソフトウェアとして実現されるが、タスク選択処理はタスク制御回路200により実現できる。   Even with such a processing method, the circuit size of the task processing device 100 as a whole can be made compact compared to the task processing device 100 of FIG. Some of the functions of the RTOS are realized as software, but the task selection process can be realized by the task control circuit 200.

図2および図3に関連して説明したソフトウェアRTOSに比べて、図16および図17のタスク処理装置100は、いずれもRTOSの機能の一部をハードウェア化することができる。図16に関連して説明したように、退避回路120が存在することによって、処理データの退避・ロードのためにTCBにアクセスする必要がなくなる。このため、レジスタ切換制御回路322により処理データの退避・ロード処理を実行可能となっている。また、図17に関連して説明したように、タスク制御回路200が存在することによって、ソフトウェアRTOSはタスク選択機能をタスク制御回路200に委譲できる。   Compared to the software RTOS described with reference to FIGS. 2 and 3, the task processing device 100 of FIGS. 16 and 17 can implement some of the functions of the RTOS as hardware. As described with reference to FIG. 16, the existence of the save circuit 120 eliminates the need to access the TCB for saving / loading the processing data. Therefore, the register switching control circuit 322 can execute processing data save / load processing. As described with reference to FIG. 17, the presence of the task control circuit 200 allows the software RTOS to delegate the task selection function to the task control circuit 200.

図5に関連して説明したように、退避回路120とタスク制御回路200を搭載するタスク処理装置100の場合、RTOSのタスクスケジューリング機能を完全にハードウェア化できる。タスクスイッチに際してメモリのTCBにアクセスする必要性がなくなるため、タスクスイッチ処理がいっそう高速化される。本発明者らの実験によると、図3等に関連して説明した一般的なソフトウェアRTOSに比べて、基本例におけるタスク処理装置100は約100倍の速度で動作することが確認されている。
{改良例1}
As described with reference to FIG. 5, in the case of the task processing device 100 including the save circuit 120 and the task control circuit 200, the RTOS task scheduling function can be completely implemented in hardware. Since there is no need to access the memory TCB at the time of task switching, the task switching process is further accelerated. According to the experiments by the present inventors, it has been confirmed that the task processing apparatus 100 in the basic example operates at a speed about 100 times that of the general software RTOS described with reference to FIG.
{Improved Example 1}

コンピュータプログラムを作成する上で、「キュー(Queue)」は定番かつ使用頻度の高いアルゴリズムである。このため、キュー処理の高速化は、コンピュータプログラムの処理速度向上に寄与しやすい。ただし、FIFO(First-In First Out)のキューであっても、場合によってはLIFO(Last-In Last-Out)的に動作させたい場合がある。あるいは、LIFOを基本としつつもFIFO的に動作させたい場合もある。改良例1では、LIFOにも対応できる特殊なキューのアルゴリズム(以下、「両投入型キューアルゴリズム」とよぶ)のハードウェア実装するタスク処理装置100について説明する。   In creating a computer program, “Queue” is a standard and frequently used algorithm. For this reason, speeding up the queue processing tends to contribute to an improvement in the processing speed of the computer program. However, even in the case of a FIFO (First-In First-Out) queue, there are cases where it is desired to operate in a LIFO (Last-In Last-Out) manner. Alternatively, there is a case where it is desired to operate in a FIFO manner based on the LIFO. In the improvement example 1, a task processing apparatus 100 that implements a hardware of a special queue algorithm (hereinafter referred to as “double-throw queue algorithm”) that can also handle LIFO will be described.

基本例のタスク処理装置100は、タイマ管理に基づくタスクスケジューリング機能を搭載している。基本例のタスクスケジューリングは、「タスク優先順位が同じである限り、待ち時間が長いタスクに優先的に実行権を割り当てる」アルゴリズムである。以下、このようなタスクスケジューリングを「公平型タスクスケジューリング」とよぶ。   The task processing apparatus 100 of the basic example has a task scheduling function based on timer management. The basic example task scheduling is an algorithm that “assigns an execution right preferentially to a task having a long waiting time as long as the task priorities are the same”. Hereinafter, such task scheduling is referred to as “fair type task scheduling”.

図11においても公平型タスクスケジューリングの考え方に基づいてタスクレディリストの管理方法を説明した。RUN−タスクであるタスクJがREADY状態に戻るときには、最後尾のタスクFの後ろに連結される。タスクJの次には、タスクAがRUN−タスクとなるので、タスク優先順位「0」の優先順位ポインタ280には、タスクD、・・・、タスクF、タスクJという順に各タスクのTCBが連結されることになる。タスクJは、少なくとも、タスクFの実行が終わるまで実行権を与えられない。公平型タスクスケジューリングにおける処理方法は、FIFO、すなわち、キューのアルゴリズムに似ている。時間管理に馴染みやすいアルゴリズムであるため、タイマ管理により公平型タスクスケジューリングをハードウェア実装できる。   In FIG. 11 as well, the task ready list management method has been described based on the concept of fair task scheduling. When task J, which is a RUN-task, returns to the READY state, it is linked after the last task F. Since task A becomes a RUN-task next to task J, the TCB of each task is displayed in the order of task D,..., Task F, task J in the priority pointer 280 with task priority “0”. Will be linked. The task J is not given the execution right until at least the execution of the task F is completed. The processing method in fair task scheduling is similar to the FIFO, ie, queue algorithm. Since the algorithm is familiar to time management, fair task scheduling can be implemented in hardware by timer management.

一方、ソフトウェアOSにおいては、「タスク優先順位が同じである限り、いったんRUN−タスクとなったタスクには優先的に実行権を割り当てる」というタスクスケジューリングが採用されることも多い。以下、このようなタスクスケジューリングを「再実行優先型タスクスケジューリング」とよぶ。再実行優先型タスクスケジューリングでは、RUN−タスクであるタスクJがREADY状態に戻るときには、最後尾ではなく先頭に挿入される。タスクJの次には、タスクAがRUN−タスクとなるので、タスク優先順位「0」の優先順位ポインタ280には、タスクJ、タスクD、・・・、タスクFという順に各タスクのTCBが連結されることになる。タスクJは、タスクAが終了すると、タスクDやタスクFよりも先に実行権を再付与される。いったん実行権を与えられたら、なるべくまとめて実行させたいタイプのタスクが存在するときには、再実行優先型タスクスケジューリングは有効である。再実行優先型タスクスケジューリングは、LIFO、すなわち、スタック的なアルゴリズムを含んでいるといえる。改良例1では、FIFOを基本としつつもLIFOにも対応できる両投入型キューアルゴリズムのハードウェア実装により、再実行優先型タスクスケジューリングを実現する。
なお、再実行優先型タスクスケジューリングに限らず、両投入型キューアルゴリズムは一般的なアプリケーションプログラムにおいても有用である。このため、両投入型キューアルゴリズムのハードウェア実装は、さまざまなコンピュータプログラムの処理速度を向上させる上で有効である。
On the other hand, in the software OS, task scheduling of “assigning an execution right preferentially to a task once a RUN-task as long as the task priority is the same” is often adopted. Hereinafter, such task scheduling is referred to as “re-execution priority type task scheduling”. In the re-execution priority type task scheduling, when the task J, which is a RUN-task, returns to the READY state, it is inserted at the head instead of the tail. Since task A becomes a RUN-task next to task J, the TCB of each task is displayed in the order of task J, task D,... Will be linked. When the task A is completed, the task J is reassigned the execution right before the task D and the task F. Once the execution right is given, the re-execution priority type task scheduling is effective when there are types of tasks that should be executed together as much as possible. It can be said that the re-execution priority type task scheduling includes a LIFO, that is, a stack-like algorithm. In the improved example 1, the re-execution priority type task scheduling is realized by the hardware implementation of the double-throw type queue algorithm that can support the LIFO while being based on the FIFO.
Note that not only the re-execution priority type task scheduling but also the double-input type queue algorithm is useful in general application programs. For this reason, the hardware implementation of the double-throw queue algorithm is effective in improving the processing speed of various computer programs.

図18は、改良例1におけるタスク処理装置100の回路図である。
改良例1におけるタスク処理装置100も、CPU150に加えて退避回路120とタスク制御回路200を含む。ただし、改良例1におけるタスク切換回路210は、メイン回路400、書込回路402、キュー制御回路404および最大値選択回路406を含む。メイン回路400は、基本例におけるタスク切換回路210とほぼ同等の機能を備える回路である。このため、改良例1におけるタスク切換回路210は、基本例におけるタスク切換回路210としてのメイン回路400に書込回路402、キュー制御回路404および最大値選択回路406を追加した構成となっている。各状態記憶部220からは全タスクの全状態データが、タスク選択回路230だけではなく、最大値選択回路406やキュー制御回路404にも常時出力されている。
FIG. 18 is a circuit diagram of the task processing device 100 in the first modification.
The task processing device 100 according to the improved example 1 also includes a save circuit 120 and a task control circuit 200 in addition to the CPU 150. However, the task switching circuit 210 in the first modification includes a main circuit 400, a writing circuit 402, a queue control circuit 404, and a maximum value selection circuit 406. The main circuit 400 is a circuit having substantially the same function as the task switching circuit 210 in the basic example. For this reason, the task switching circuit 210 in the improved example 1 has a configuration in which a writing circuit 402, a queue control circuit 404, and a maximum value selection circuit 406 are added to the main circuit 400 as the task switching circuit 210 in the basic example. All state data of all tasks is constantly output from each state storage unit 220 not only to the task selection circuit 230 but also to the maximum value selection circuit 406 and the queue control circuit 404.

図19は、改良例1におけるタスク制御回路200の部分的な回路図である。
タスク制御回路200の基本構成は、図10に示した回路構成とほぼ同等である。各タスクに対応づけられる状態レジスタ250は、タスクIDレジスタ410、タスク優先順位レジスタ412、キュー順序レジスタ414、キュー識別レジスタ416を含む。状態レジスタ250は、そのほかのレジスタを含んでもよいが、ここでは両投入型キューアルゴリズムに関わるレジスタ群を中心として説明する。
(A)タスクIDレジスタ410:タスクIDを保持する。基本例に示したタスクIDレジスタ254と同等である。タスクIDレジスタ410からはタスクIDを示すEID_S信号が常時出力される。
(B)タスク優先順位レジスタ412:タスク優先順位(PR)を保持する。基本例に示したタスク優先順位レジスタ256と同様である。PR_S信号として常時出力される。
(C)キュー順序レジスタ414:後述する仮想キューへの投入順位を示す「順序値(ODR)」を保持する。順序値が大きいほど、仮想キューの深くに投入されていることを示すが、詳しくは後述する。順序値は、ODR_S信号として常時出力される。
(D)キュー識別レジスタ416:仮想キューを識別する「キューID(QID)」を保持する。QID_S信号として常時出力される。
タスク優先順位レジスタ412と、キュー順序レジスタ414、キュー識別レジスタ416は、特に、仮想キューを管理するためのキューレジスタとして機能する。
FIG. 19 is a partial circuit diagram of the task control circuit 200 in the first modification.
The basic configuration of the task control circuit 200 is almost the same as the circuit configuration shown in FIG. The status register 250 associated with each task includes a task ID register 410, a task priority register 412, a queue order register 414, and a queue identification register 416. The status register 250 may include other registers, but here, a description will be given focusing on a register group related to the double-throw queue algorithm.
(A) Task ID register 410: Holds a task ID. This is equivalent to the task ID register 254 shown in the basic example. The task ID register 410 constantly outputs an EID_S signal indicating the task ID.
(B) Task priority order register 412: Holds task priority order (PR). This is the same as the task priority order register 256 shown in the basic example. Always output as a PR_S signal.
(C) Queue order register 414: Holds an “order value (ODR)” indicating the order of entry into a virtual queue to be described later. The larger the order value, the deeper the virtual queue is, which will be described later in detail. The order value is always output as an ODR_S signal.
(D) Queue identification register 416: Holds a “queue ID (QID)” for identifying a virtual queue. Always output as the QID_S signal.
The task priority order register 412, the queue order register 414, and the queue identification register 416 function as queue registers for managing virtual queues in particular.

仮想キューは、タスク状態に対応づけられるキューである。たとえば、QID=0の仮想キュー(以下、「仮想キュー(0)」のように表記する)をREADY状態、仮想キュー(1)をセマフォ待ち状態、仮想キュー(2)をミューテックス待ち状態に対応づけてもよい。あるいは、仮想キュー(1)をセマフォID=0についてのセマフォ待ち状態、仮想キュー(2)をセマフォID=1についてのセマフォ待ち状態に対応づけてもよい。QIDとタスク状態の対応づけは、ソフトウェアにて任意に設定すればよい。   A virtual queue is a queue associated with a task state. For example, the virtual queue with QID = 0 (hereinafter referred to as “virtual queue (0)”) is associated with the READY state, the virtual queue (1) is associated with the semaphore wait state, and the virtual queue (2) is associated with the mutex wait state. May be. Alternatively, the virtual queue (1) may be associated with the semaphore waiting state for semaphore ID = 0, and the virtual queue (2) may be associated with the semaphore waiting state for semaphore ID = 1. The association between the QID and the task state may be arbitrarily set by software.

タスクAがREADY状態であるとき、キュー識別レジスタ416_Aには、READY状態に対応づけられる仮想キューのQIDが設定される。タスク選択回路230やキュー制御回路404は、各キュー識別レジスタ416を参照することにより、各タスクのタスク状態を判別できる。このため、キュー識別レジスタ416は、基本例におけるタスク状態レジスタ258、待機理由レジスタ262、セマフォIDレジスタ264、ミューテックスIDレジスタ265、イベントIDレジスタ266等と同等に機能できる。   When the task A is in the READY state, the QID of the virtual queue associated with the READY state is set in the queue identification register 416_A. The task selection circuit 230 and the queue control circuit 404 can determine the task state of each task by referring to each queue identification register 416. Therefore, the queue identification register 416 can function in the same way as the task status register 258, the waiting reason register 262, the semaphore ID register 264, the mutex ID register 265, the event ID register 266, etc. in the basic example.

仮想キューは、物理的に存在するものではなく、キュー順序レジスタ414やキュー識別レジスタ416の設定内容によって想定される概念的なキューである点は重要である。たとえば、各キュー識別レジスタ416とキュー順序レジスタ414において、
タスクA:QID=0、ODR=0
タスクB:QID=0、ODR=1
タスクC:QID=0、ODR=2
タスクD:QID=1、ODR=0
として設定されているときには、仮想キュー(0)には、タスクC、B、Aの順に投入されており、仮想キュー(1)には、タスクDだけが投入されていることを示す。QIDとODRの数値範囲によって仮想キューの数やサイズを柔軟に変更できる。
It is important that the virtual queue does not physically exist but is a conceptual queue assumed by the setting contents of the queue order register 414 and the queue identification register 416. For example, in each queue identification register 416 and queue order register 414,
Task A: QID = 0, ODR = 0
Task B: QID = 0, ODR = 1
Task C: QID = 0, ODR = 2
Task D: QID = 1, ODR = 0
Is set in the virtual queue (0) in the order of tasks C, B, and A, and only the task D is input in the virtual queue (1). The number and size of virtual queues can be flexibly changed according to the numerical range of QID and ODR.

タスク選択回路230は、状態レジスタ250から出力される状態データに基づいて、状態遷移させるべきタスクを選択する。メイン回路400は、CND信号をタスク選択回路230に入力する。CNDはタスク選択条件を示す信号であり、キューIDを示すQID_Cとタスク優先順位を示すPR_Cを含む。たとえば、仮想キュー(0)からタスクを抽出したい場合、メイン回路400は、CNDにQID_C=0を設定する。タスク選択回路230は、指定された仮想キュー(0)において抽出対象となるタスク(以下、単に「抽出タスク」とよぶ)のタスクIDをEID_A1に出力し、EID_A1_ENをアサートする。また、PR_A1、ODR_A1には、抽出タスクのタスク優先順位と順序値が出力される。このように、メイン回路400は、QID_C=Qnを指定してタスク選択回路230に問い合わせることにより、仮想キュー(Qn)の抽出タスクを知ることができる。タスク選択回路230は抽出タスクを選択する抽出候補回路として機能する。より詳細については図32に関連して後述する。   The task selection circuit 230 selects a task whose state is to be changed based on the state data output from the state register 250. The main circuit 400 inputs the CND signal to the task selection circuit 230. CND is a signal indicating a task selection condition, and includes QID_C indicating a queue ID and PR_C indicating a task priority. For example, when it is desired to extract a task from the virtual queue (0), the main circuit 400 sets QID_C = 0 in CND. The task selection circuit 230 outputs a task ID of a task to be extracted in the designated virtual queue (0) (hereinafter simply referred to as “extraction task”) to EID_A1, and asserts EID_A1_EN. In addition, the task priority order and the order value of the extracted task are output to PR_A1 and ODR_A1. As described above, the main circuit 400 can know the extraction task of the virtual queue (Qn) by inquiring of the task selection circuit 230 by designating QID_C = Qn. The task selection circuit 230 functions as an extraction candidate circuit that selects an extraction task. More details will be described later with reference to FIG.

最大値選択回路406には、メイン回路400からCND信号が入力される。最大値選択回路406は、CNDによりQID_C=Qnが指定されると、仮想キュー(Qn)における最大順序値をODR_A2に出力し、EID_A2_ENをアサートする。より詳細については図28に関連して後述する。   The maximum value selection circuit 406 receives a CND signal from the main circuit 400. When QID_C = Qn is specified by CND, the maximum value selection circuit 406 outputs the maximum order value in the virtual queue (Qn) to ODR_A2, and asserts EID_A2_EN. More details will be described later with reference to FIG.

キュー制御回路404は、各状態レジスタ250の状態データを設定することにより、各タスクの状態遷移を制御する。キュー制御回路404には、メイン回路400からCMDとEID_Cを入力される、そのほかにも、CND(QID_C、PR_C)、ODR_A1、ODR_A2、ODR_A2_ENと各状態レジスタ250の状態データが入力される。   The queue control circuit 404 controls the state transition of each task by setting the state data in each state register 250. The CMD and EID_C are input from the main circuit 400 to the queue control circuit 404. In addition, CND (QID_C, PR_C), ODR_A1, ODR_A2, ODR_A2_EN, and status data of each status register 250 are input.

CMDは、仮想キューを操作するためのコマンドを示す。CMDの対象となる仮想キューのキューID、タスクのタスクID、タスク優先順位は、それぞれ、QID_C、EID_C、PR_Cにより指定される。コマンドは、ENQ_TL、ENQ_TP、DEQの3種類のうちのいずれかである。   CMD indicates a command for operating the virtual queue. The queue ID of the virtual queue subject to CMD, the task ID of the task, and the task priority are designated by QID_C, EID_C, and PR_C, respectively. The command is one of three types of ENQ_TL, ENQ_TP, and DEQ.

順投入コマンドENQ_TLが入力されると、仮想キューの最後尾からEID_C信号により指定されたタスクが投入される。以下、キューの最後尾からの投入を「順投入」とよぶ。抽出コマンドDEQが入力されると、仮想キューの先頭からタスクが取り出される。ENQ_TLとDEQにより、FIFOとしてのキュー制御が実行される。逆投入コマンドENQ_TPが入力されると、仮想キューの先頭からEID_C信号により指定されたタスクが投入される。以下、このようなキューの先頭からの投入を「逆投入」とよぶ。逆投入は、FIFOとしての投入ではない点で特殊な投入方法である。   When the sequential input command ENQ_TL is input, the task specified by the EID_C signal is input from the tail of the virtual queue. Hereinafter, input from the tail of the queue is referred to as “ordered input”. When the extraction command DEQ is input, a task is taken out from the head of the virtual queue. The queue control as a FIFO is executed by ENQ_TL and DEQ. When the reverse input command ENQ_TP is input, the task specified by the EID_C signal is input from the head of the virtual queue. Hereinafter, the input from the head of such a queue is referred to as “reverse input”. Reverse injection is a special input method in that it is not input as a FIFO.

メイン回路400からCMDが入力されると、書込回路402はWTをアサートし、キュー制御回路404から出力される各データの状態レジスタ250への書き込みが実行される。キュー制御回路404や書込回路402、タスク選択回路230、最大値選択回路406等が、仮想キューを制御するための仮想キュー処理回路として機能する。
キュー制御回路404の回路構成については、次の図20に関連して詳述する。
When CMD is input from the main circuit 400, the write circuit 402 asserts WT, and writing of each data output from the queue control circuit 404 to the status register 250 is executed. The queue control circuit 404, the write circuit 402, the task selection circuit 230, the maximum value selection circuit 406, and the like function as a virtual queue processing circuit for controlling the virtual queue.
The circuit configuration of the queue control circuit 404 will be described in detail with reference to FIG.

図20は、キュー制御回路404の回路図である。
キュー制御回路404は、複数のレジスタ値生成回路420の集合体である。各レジスタ値生成回路420は同じ回路である。レジスタ値生成回路420は、タスクごとに対応づけられている。状態レジスタ250ごとに対応づけられているともいえる。レジスタ値生成回路420_Enは、タスクID=Enのタスク(以下、「タスク(En)」のように表記する)に対応づけられる。レジスタ値生成回路420には、該当タスクのタスクIDがELM_ID信号として固定的に入力される。
FIG. 20 is a circuit diagram of the queue control circuit 404.
The queue control circuit 404 is an aggregate of a plurality of register value generation circuits 420. Each register value generation circuit 420 is the same circuit. The register value generation circuit 420 is associated with each task. It can be said that each status register 250 is associated with each other. The register value generation circuit 420_En is associated with a task with task ID = En (hereinafter referred to as “task (En)”). The task ID of the corresponding task is fixedly input to the register value generation circuit 420 as an ELM_ID signal.

ODR_S、QID_S、PR_Sは、状態レジスタ250から出力される状態データであり、それぞれ、順序値、キューID、タスク優先順位を示す。タスク(En)に対応づけられるレジスタ値生成回路420_Enには、タスク(En)の順序値、キューID、タスク優先順位がそれぞれODR_S_En、QID_S_En、PR_S_Enとして入力される。CMD、EID_Cは、メイン回路400から入力される。ODR_A2_ENとODR_A2は、最大値選択回路406から入力される。最大順序値を示すODR_A2は、ODR_A2_ENがアサートされるときに有効な入力となる。ODR_A1は、タスク選択回路230から入力される。ODR_A1は、抽出タスクのタスクIDを示す。QID_CとPR_Cは、メイン回路400から入力されるCND信号であり、それぞれ、タスク選択条件としてのQIDとPRを示す。
レジスタ値生成回路420_Enは、タスク(En)の順序値、キューID、タスク優先順位をそれぞれQID_N_En、ODR_N_En、PR_N_Enとして出力し、書込回路402によりWTがアサートされたときに状態レジスタ250_Enに書き込まれる。
書込回路402がWTをアサートすると、全てのレジスタ値生成回路420のQID_N_En、ODR_N_En、PR_N_Enが全ての状態レジスタ250に書き込まれる。CMDにより影響を受けるタスクについてのレジスタ値生成回路420は、後述するアルゴリズムにて指定される新たなデータを状態レジスタ250に書き込む。一方、CMDにより影響を受けないタスクについてのレジスタ値生成回路420も、状態レジスタ250に書き込まれているデータと同じデータを再出力して書き込みを実行する。
なお、レジスタ値生成回路420のWTは、各状態レジスタ250ではなくキュー制御回路404に直接入力されてもよい。この場合、キュー制御回路404に内蔵されるレジスタ値生成回路420のうち、CMDにより状態変更すべきタスクについてのレジスタ値生成回路420だけが、新たなデータを状態レジスタ250に書き込むとしてもよい。
レジスタ値生成回路420の具体的な処理内容については後述する。
ODR_S, QID_S, and PR_S are status data output from the status register 250, and indicate an order value, a queue ID, and a task priority, respectively. The register value generation circuit 420_En associated with the task (En) receives the order value, queue ID, and task priority of the task (En) as ODR_S_En, QID_S_En, and PR_S_En, respectively. CMD and EID_C are input from the main circuit 400. ODR_A2_EN and ODR_A2 are input from the maximum value selection circuit 406. ODR_A2 indicating the maximum order value becomes a valid input when ODR_A2_EN is asserted. ODR_A1 is input from the task selection circuit 230. ODR_A1 indicates the task ID of the extraction task. QID_C and PR_C are CND signals input from the main circuit 400, and indicate QID and PR as task selection conditions, respectively.
The register value generation circuit 420_En outputs the task (En) order value, queue ID, and task priority as QID_N_En, ODR_N_En, and PR_N_En, respectively, and is written in the state register 250_En when the write circuit 402 asserts WT. .
When the write circuit 402 asserts WT, QID_N_En, ODR_N_En, and PR_N_En of all the register value generation circuits 420 are written to all the status registers 250. The register value generation circuit 420 for the task affected by the CMD writes new data designated by an algorithm described later to the status register 250. On the other hand, the register value generation circuit 420 for the task not affected by the CMD also re-outputs the same data as the data written in the status register 250 and executes the writing.
Note that the WT of the register value generation circuit 420 may be directly input to the queue control circuit 404 instead of each status register 250. In this case, only the register value generation circuit 420 for a task whose state should be changed by CMD among the register value generation circuits 420 built in the queue control circuit 404 may write new data into the state register 250.
Specific processing contents of the register value generation circuit 420 will be described later.

図21は、仮想キューとタスクの関係を示す概念図である。
ここでは、仮想キュー(Q0)と仮想キュー(Q1)の2つの仮想キューを想定している。仮想キュー(Q0)は、タスク優先順位PR=0のタスクが投入される優先キュー(以下、「優先キュー(Q0:0)」と表記する)とタスク優先順位PR=1のタスクが投入される優先キュー(Q0:1)の2つの優先キューの集合である。仮想キュー(Q1)についても同様であり、実質的には4つの優先キューが想定される。たとえば、仮想キュー(Q0)はREADY状態、仮想キュー(Q1)はWAIT状態に対応づけられてもよい。
FIG. 21 is a conceptual diagram showing the relationship between virtual queues and tasks.
Here, two virtual queues of a virtual queue (Q0) and a virtual queue (Q1) are assumed. In the virtual queue (Q0), a priority queue (hereinafter referred to as “priority queue (Q0: 0)”) into which tasks with task priority PR = 0 are input and a task with task priority PR = 1 are input. This is a set of two priority queues of priority queues (Q0: 1). The same applies to the virtual queue (Q1), and substantially four priority queues are assumed. For example, the virtual queue (Q0) may be associated with the READY state, and the virtual queue (Q1) may be associated with the WAIT state.

各仮想キューは、同図向かって左を投入口、右を抽出口とするキューである。順投入においては左側からタスクが投入され、逆投入においては右側からタスクが投入される。タスクが抽出されるのは常に右側からである。   Each virtual cue is a cue having an input port on the left and an extraction port on the right as viewed in FIG. Tasks are entered from the left side in the forward entry, and tasks are entered from the right side in the reverse entry. Tasks are always extracted from the right side.

同図では、タスクID=E0、E1、E2、E3の4つのタスクが仮想キューに投入されている。タスク(E0)とタスク(E2)、タスク(E3)は仮想キュー(Q0)に投入されている。このうち、タスク(E0)とタスク(E3)は、タスク優先順位PR=0のタスクであるため、優先キュー(Q0:0)に投入される。タスク(E2)はPR=1のタスクであるため、優先キュー(Q0:1)に投入される。仮想キュー(Q0)に投入されるタスク(E3)、タスク(E2)、タスク(E0)の順序値ODRは、2、1、0となっている。タスク優先順位PR=0のタスク(E1)は、仮想キュー(Q1)に投入されている。ODRは「0」である。   In the figure, four tasks with task ID = E0, E1, E2, E3 are put in the virtual queue. The task (E0), the task (E2), and the task (E3) are put in the virtual queue (Q0). Among these, the task (E0) and the task (E3) are tasks with the task priority order PR = 0, and are therefore placed in the priority queue (Q0: 0). Since the task (E2) is a task with PR = 1, it is put into the priority queue (Q0: 1). The order values ODR of the task (E3), the task (E2), and the task (E0) input to the virtual queue (Q0) are 2, 1, 0. The task (E1) having the task priority order PR = 0 is put in the virtual queue (Q1). The ODR is “0”.

図22は、図21に対応した状態レジスタ250のデータ構造図である。
図21に示した仮想キューへの各タスクの投入状態は、状態レジスタ250の設定により表現される。図21に示した状態においては、タスク(E0)〜タスク(E7)のうち、仮想キューに投入されているのはタスク(E0)〜タスク(E3)である。このため、それ以外のタスクのキュー識別レジスタ416には未投入を示す「Non」が設定される。仮想キュー(Q0)に投入されるタスク(E0)、タスク(E3)、タスク(E2)のキュー識別レジスタ416には「Q0」が設定される。また、仮想キュー(Q1)に投入されるタスク(E1)のキュー識別レジスタ416には「Q1」が設定される。キュー識別レジスタ416の設定内容により、どのタスクがどの仮想キューに投入されているかを表現する。
FIG. 22 is a data structure diagram of the status register 250 corresponding to FIG.
The input status of each task to the virtual queue shown in FIG. 21 is expressed by the setting of the status register 250. In the state shown in FIG. 21, among tasks (E0) to (E7), tasks (E0) to (E3) are put in the virtual queue. Therefore, “Non” indicating non-input is set in the queue identification register 416 of other tasks. “Q0” is set in the queue identification register 416 of the task (E0), the task (E3), and the task (E2) input to the virtual queue (Q0). Further, “Q1” is set in the queue identification register 416 of the task (E1) to be put into the virtual queue (Q1). According to the setting contents of the queue identification register 416, which task is put in which virtual queue is expressed.

仮想キュー(Q0)に投入されている3つのタスク(E0)、タスク(E3)、タスク(E2)のキュー順序レジスタ414には、それぞれODRとして0、2、1が設定される。仮想キュー(Q1)に投入されているタスクは、タスク(E1)だけなので、順序値は最小の「0」が設定される。キュー順序レジスタ414の設定内容により、各タスクの仮想キューにおける位置を表現する。   In the queue order registers 414 of the three tasks (E0), task (E3), and task (E2) put in the virtual queue (Q0), 0, 2, and 1 are set as ODR, respectively. Since only the task (E1) is put in the virtual queue (Q1), the minimum order value is set to “0”. The position of each task in the virtual queue is expressed by the setting contents of the queue order register 414.

タスク(E0)、タスク(E1)、タスク(E3)のタスク優先順位PRは「0」である。そこで、これらのタスクのタスク優先順位レジスタ412には「0」が設定される。タスク(E2)のタスク優先順位PRは「1」であるため、タスク優先順位レジスタ412_E2には「1」が設定される。タスク優先順位レジスタ412の設定により、各タスクがどの優先キューに投入されているかを表現する。
以上の設定に基づいて、順投入、逆投入、抽出における処理内容について詳述する。
[順投入]
The task priority order PR of task (E0), task (E1), and task (E3) is “0”. Therefore, “0” is set in the task priority order register 412 of these tasks. Since the task priority order PR of the task (E2) is “1”, “1” is set in the task priority order register 412_E2. According to the setting of the task priority order register 412, which priority queue is assigned to each task is expressed.
Based on the above settings, the processing contents in the forward input, reverse input, and extraction will be described in detail.
[Sequential input]

図23は、図21の仮想キューにタスク(E4)を順投入するときの概念図である。
ここでは、仮想キュー(Q1)にタスク優先順位PR=0のタスク(E4)を順投入するとして説明する。メイン回路400は、CMD=ENQ_TL(順投入コマンド)として、EID_C=E4、QID_C=Q1、PR_C=0を設定する。キュー制御回路404に内蔵されるレジスタ値生成回路420_E4は、EID_C=ELM_ID=E4を検出すると、QID_N_E4=QID_C=Q1、ODR_N_E4=0、PR_N_E4=PR_C=0を出力する。QID_N_E4はタスク(E4)の投入先となる仮想キューのQID、ODR_N_E4は投入時における順序値、PR_N_E4はタスク(E4)のタスク優先順位である。順投入されるタスクについてのODR_Nは、常に「0」に設定される。これは、キューに対する最新の投入を示す順序値である。
FIG. 23 is a conceptual diagram when tasks (E4) are sequentially entered into the virtual queue of FIG.
Here, description will be made assuming that the task (E4) with the task priority order PR = 0 is sequentially placed in the virtual queue (Q1). The main circuit 400 sets EID_C = E4, QID_C = Q1, and PR_C = 0 as CMD = ENQ_TL (sequential input command). When register value generation circuit 420_E4 built in queue control circuit 404 detects EID_C = ELM_ID = E4, it outputs QID_N_E4 = QID_C = Q1, ODR_N_E4 = 0, and PR_N_E4 = PR_C = 0. QID_N_E4 is the QID of the virtual queue to which the task (E4) is input, ODR_N_E4 is the order value at the time of input, and PR_N_E4 is the task priority of the task (E4). ODR_N for tasks that are sequentially entered is always set to “0”. This is an order value indicating the latest input to the queue.

レジスタ値生成回路420_E4だけでなく、QID_S_En=QID_C=Q1となるレジスタ値生成回路420_Enも反応する。レジスタ値生成回路420_Enは、ODR_N_En=ODR_S_En+1を出力する。ここでは、レジスタ値生成回路420_E1がQID_S_E1=QID_C=Q1を検出し、ODR_N_E1=0+1=1を出力する。ODR_N_E1はタスク(E1)投入後の順序値である。タスク(E4)の順投入先となる仮想キュー(Q1)に既に投入されているタスクは、順序値が影響を受けることになる。このような処理過程を経て、仮想キュー(Q1)の要素であるタスク(E4)とタスク(E1)の状態データが調整される。   Not only the register value generation circuit 420_E4 but also the register value generation circuit 420_En in which QID_S_En = QID_C = Q1 reacts. The register value generation circuit 420_En outputs ODR_N_En = ODR_S_En + 1. Here, the register value generation circuit 420_E1 detects QID_S_E1 = QID_C = Q1, and outputs ODR_N_E1 = 0 + 1 = 1. ODR_N_E1 is an order value after the task (E1) is input. The order value of the task that has already been submitted to the virtual queue (Q1) that is the destination of the task (E4) is affected. Through such a process, the state data of the task (E4) and the task (E1) which are elements of the virtual queue (Q1) are adjusted.

図24は、図23に対応した状態レジスタ250のデータ構造図である。
同図において下線を付与している部分が、図22に示した状態レジスタ250の設定内容から変化した箇所である。タスク(E4)の仮想キュー(Q1)への順投入により、キュー識別レジスタ416_E4にはQID_N_E4により「Q1」が設定される。タスク(E4)のODRは「0」、PRは「0」である。タスク(E4)の順投入により、仮想キュー(Q1)に既に投入されていたタスク(E1)のODRは、「0」から「1」にインクリメントされる。変更後の状態レジスタ250の設定内容により、図23に示した仮想キュー(Q1)の状態が表現される。
FIG. 24 is a data structure diagram of the status register 250 corresponding to FIG.
In FIG. 22, the underlined portion is a portion changed from the setting contents of the status register 250 shown in FIG. As the task (E4) enters the virtual queue (Q1) in order, “Q1” is set in the queue identification register 416_E4 by QID_N_E4. The ODR of task (E4) is “0”, and PR is “0”. As the tasks (E4) are sequentially input, the ODR of the task (E1) that has already been input to the virtual queue (Q1) is incremented from “0” to “1”. The state of the virtual queue (Q1) shown in FIG. 23 is expressed by the setting contents of the state register 250 after the change.

図25は、図23の仮想キューにタスク(E5)を順投入するときの概念図である。
ここでは、仮想キュー(Q0)にタスク優先順位PR=1のタスク(E5)を順投入するとして説明する。メイン回路400は、CMD=ENQ_TL(順投入コマンド)として、EID_C=E5、QID_C=Q0、PR_C=1を設定する。レジスタ値生成回路420_E5は、QID_N_E5=QID_C=Q0、ODR_N_E5=0、PR_N_E5=PR_C=1を出力する。
FIG. 25 is a conceptual diagram when the tasks (E5) are sequentially entered into the virtual queue of FIG.
Here, a description will be given assuming that the task (E5) with the task priority order PR = 1 is sequentially entered into the virtual queue (Q0). The main circuit 400 sets EID_C = E5, QID_C = Q0, and PR_C = 1 as CMD = ENQ_TL (order input command). The register value generation circuit 420_E5 outputs QID_N_E5 = QID_C = Q0, ODR_N_E5 = 0, and PR_N_E5 = PR_C = 1.

レジスタ値生成回路420_E5だけでなく、QID_C=QID_S_En=Q0となるレジスタ値生成回路420_Enは、QID_C=QID_S_Enを検出すると、ODR_N_En=ODR_S_En+1を出力する。この例では、タスク(E0)、タスク(E2)、タスク(E3)に対応するレジスタ値生成回路420が該当する。こうして、仮想キュー(Q0)の要素であるタスク(E5)とタスク(E0)、タスク(E2)、タスク(E3)の状態データが調整される。   Not only the register value generating circuit 420_E5 but also the register value generating circuit 420_En that satisfies QID_C = QID_S_En = Q0 outputs ODR_N_En = ODR_S_En + 1 when detecting QID_C = QID_S_En. In this example, the register value generation circuit 420 corresponding to the task (E0), the task (E2), and the task (E3) corresponds. Thus, the state data of the task (E5), the task (E0), the task (E2), and the task (E3) that are elements of the virtual queue (Q0) are adjusted.

図26は、図25に対応した状態レジスタ250のデータ構造図である。
同図において下線を付与している部分が、図24に示した状態レジスタ250の設定内容から変化した箇所である。まず、タスク(E5)の仮想キュー(Q0)への順投入により、キュー識別レジスタ416_E5には新たに「Q0」が設定される。タスク(E5)のODRは「0」、PRは「1」である。タスク(E5)の順投入により、仮想キュー(Q0)に元々投入されていたタスク(E0)、タスク(E1)、タスク(E3)のODRは、それぞれインクリメントされる。
FIG. 26 is a data structure diagram of the status register 250 corresponding to FIG.
In FIG. 24, the underlined portion is a portion changed from the setting contents of the status register 250 shown in FIG. First, “Q0” is newly set in the queue identification register 416_E5 by the sequential entry of the task (E5) into the virtual queue (Q0). The ODR of task (E5) is “0”, and PR is “1”. ODRs of the task (E0), task (E1), and task (E3) that were originally submitted to the virtual queue (Q0) are incremented by the sequential entry of the task (E5).

図27は、順投入の処理過程を示すフローチャートである。
メイン回路400は、順投入させるタスク(以下、「順投入タスク」とよぶ)についての投入条件を設定する(S10)。具体的には、CMD=ENQ_TLとして、EID_C、QID_C、PR_Cを設定する。キュー制御回路404のうち、順投入タスクに対応するレジスタ値生成回路420は、順投入タスクのタスク優先順位レジスタ412、キュー順序レジスタ414、キュー識別レジスタ416にそれぞれ、PR_C、0、QID_Cを設定する(S12)。
FIG. 27 is a flowchart showing the ordering process.
The main circuit 400 sets the input conditions for the tasks to be sequentially input (hereinafter referred to as “sequential input task”) (S10). Specifically, EID_C, QID_C, and PR_C are set as CMD = ENQ_TL. Of the queue control circuit 404, the register value generation circuit 420 corresponding to the sequential entry task sets PR_C, 0, and QID_C in the task priority order register 412, the queue order register 414, and the queue identification register 416 of the sequential entry task, respectively. (S12).

仮想キュー(QID_C)に既に別のタスクが投入されている場合には(S14のY)、既投入の各タスクについてODRをインクリメントする(S16)。図25に示した例の場合、タスク(E0)、タスク(E2)、タスク(E3)について、ODRがインクリメントされる。S12、S14、S16の処理は時間的にほぼ並行して実行される。
[逆投入]
If another task has already been submitted to the virtual queue (QID_C) (Y in S14), the ODR is incremented for each task that has already been submitted (S16). In the case of the example shown in FIG. 25, the ODR is incremented for the task (E0), the task (E2), and the task (E3). The processes of S12, S14, and S16 are executed substantially in parallel in time.
[Reverse input]

図28は、最大値選択回路406の部分的な回路図である。
最大値選択回路406は、逆投入処理のためにメイン回路400により駆動される回路である。最大値選択回路406は、CND信号としてQID_C=Qnを入力されたとき、仮想キュー(Qn)における最大順序値をODR_A2に出力し、ODR_A2_ENをアサートする。最大値選択回路406は、基本例に示した実行選択回路232やセマフォ選択回路234と同じく、複数段の比較回路から構成される。最大値選択回路406は、4つの第1比較回路422(422a、422b等)、2つの第2比較回路424(424a等)、1つの第3比較回路(図示せず)を含む。また、8つの判定回路426(426a、426b、426c、426d等)を含む。
FIG. 28 is a partial circuit diagram of the maximum value selection circuit 406.
The maximum value selection circuit 406 is a circuit driven by the main circuit 400 for reverse input processing. When QID_C = Qn is input as the CND signal, the maximum value selection circuit 406 outputs the maximum order value in the virtual queue (Qn) to ODR_A2, and asserts ODR_A2_EN. Similar to the execution selection circuit 232 and the semaphore selection circuit 234 shown in the basic example, the maximum value selection circuit 406 includes a plurality of comparison circuits. The maximum value selection circuit 406 includes four first comparison circuits 422 (422a, 422b, etc.), two second comparison circuits 424 (424a, etc.), and one third comparison circuit (not shown). In addition, eight determination circuits 426 (426a, 426b, 426c, 426d, etc.) are included.

第1比較回路422aに着目して説明する。第1比較回路422aは、タスク0とタスク1を比較し、どちらも仮想キュー(Qn)に投入されていれば、順序値が大きい方のタスクを選択する。第1比較回路422aには、タスク0とタスク1のタスクIDと順序値がEID_S、ODR_Sとして入力される。
第1の判定:判定回路426aは、タスク0が仮想キュー(Qn)に投入済みであればEID_11A_ENをアサートする。判定回路426bは、タスク1が仮想キュー(Qn)に投入済みであればEID_11B_ENをアサートする。第1比較回路422aは、まず、判定回路426aと判定回路426bのそれぞれから出力されるEID_11_EN信号を参照する。いずれか一方が「1」であれば、いずれか一方のタスクだけが仮想キュー(Qn)に投入されていることになる。このとき、第1比較回路422aは、仮想キュー(Qn)に投入されている方のタスクのタスクID(EID_S)と順序値(ODR_S)をそれぞれEID_21A、ODR_21Aとして出力し、EID_21A_ENをアサートする。
判定回路426aと判定回路426bが共に「0」を出力するときには、どちらのタスクも仮想キュー(Qn)に投入されていない。このとき、EID_21A_ENはネゲートされ、以後、タスク0とタスク1のいずれも第2比較回路424aにおいて考慮の対象とはならない。
判定回路426aと判定回路426bが共に「1」を出力するときには、どちらのタスクも仮想キュー(Qn)に投入済である、このとき、次の第2の判定が実行される。
Description will be made by paying attention to the first comparison circuit 422a. The first comparison circuit 422a compares the task 0 and the task 1, and if both are put in the virtual queue (Qn), the task having the larger order value is selected. The task IDs and order values of task 0 and task 1 are input to the first comparison circuit 422a as EID_S and ODR_S.
First determination: The determination circuit 426a asserts EID_11A_EN if the task 0 has been put into the virtual queue (Qn). The determination circuit 426b asserts EID_11B_EN if the task 1 has been put into the virtual queue (Qn). The first comparison circuit 422a first refers to the EID_11_EN signal output from each of the determination circuit 426a and the determination circuit 426b. If either one is “1”, only one of the tasks is put in the virtual queue (Qn). At this time, the first comparison circuit 422a outputs the task ID (EID_S) and the order value (ODR_S) of the task that is put in the virtual queue (Qn) as EID_21A and ODR_21A, respectively, and asserts EID_21A_EN.
When both the determination circuit 426a and the determination circuit 426b output “0”, neither task is put in the virtual queue (Qn). At this time, EID_21A_EN is negated, and thereafter neither task 0 nor task 1 is taken into consideration in the second comparison circuit 424a.
When both the determination circuit 426a and the determination circuit 426b output “1”, both tasks have been put into the virtual queue (Qn). At this time, the next second determination is executed.

第2の判定:タスク0のODR_S_0とタスク1のODR_S_1を比較し、順序値が大きい方のタスクを選択する。第1比較回路422aは、順序値が大きい方のタスクのタスクID(EID_S)と順序値(ODR_S)をそれぞれEID_21A、ODR_21Aとして出力し、EID_21A_ENをアサートする。   Second determination: ODR_S_0 of task 0 and ODR_S_1 of task 1 are compared, and the task with the larger order value is selected. The first comparison circuit 422a outputs the task ID (EID_S) and the order value (ODR_S) of the task having the larger order value as EID_21A and ODR_21A, respectively, and asserts EID_21A_EN.

他の第1比較回路422の処理内容も同様であり、タスク0とタスク1、タスク2とタスク3、タスク4とタスク5、タスク6とタスク7がそれぞれ比較される。第2比較回路424は、2つの第1比較回路422からの出力により、更に順序値が大きい方のタスクを選択する。第2比較回路424aに着目して説明する。第2比較回路424aは、第1比較回路422aの出力信号と第1比較回路422bの出力信号を比較し、順序値が大きい方のタスクを選択する。第2比較回路424aには、第1比較回路422aと第1比較回路422bからそれぞれ、EID_21、ODR_21、EID_ENが入力される。第2比較回路424は、タスク0〜タスク3のうち、仮想キュー(Qn)の中で最も順序値の大きいタスクを選択する。他の第2比較回路424も同様であり、最終的に、仮想キュー(Qn)における最大順序値がODR_A2信号として出力される。いずれかのタスクが選択されたときにはODR_A2_ENはアサートされ、いずれのタスクも仮想キュー(Qn)に存在しないときにはODR_A2_ENはネゲートされる。
なお、第1比較回路422、第2比較回路424、第3比較回路には、優先順位判定を無効化するためのPR無効信号が入力されてもよい。PR無効信号がアサートされているときには、各比較回路は、優先順位を判定条件から除外してタスクを選択する。図32に示す各比較回路についても同様である。
The processing contents of the other first comparison circuits 422 are the same, and task 0 and task 1, task 2 and task 3, task 4 and task 5, and task 6 and task 7 are compared. The second comparison circuit 424 selects a task having a larger order value based on outputs from the two first comparison circuits 422. Description will be made by paying attention to the second comparison circuit 424a. The second comparison circuit 424a compares the output signal of the first comparison circuit 422a and the output signal of the first comparison circuit 422b, and selects the task having the larger order value. EID_21, ODR_21, and EID_EN are input to the second comparison circuit 424a from the first comparison circuit 422a and the first comparison circuit 422b, respectively. The second comparison circuit 424 selects a task having the largest order value in the virtual queue (Qn) among the tasks 0 to 3. The same applies to the other second comparison circuit 424. Finally, the maximum order value in the virtual queue (Qn) is output as the ODR_A2 signal. ODR_A2_EN is asserted when any task is selected, and ODR_A2_EN is negated when no task exists in the virtual queue (Qn).
Note that a PR invalid signal for invalidating the priority determination may be input to the first comparison circuit 422, the second comparison circuit 424, and the third comparison circuit. When the PR invalid signal is asserted, each comparison circuit selects a task by excluding priority from the determination conditions. The same applies to each comparison circuit shown in FIG.

図29は、図25の仮想キューにタスク(E6)を逆投入するときの概念図である。
ここでは、仮想キュー(Q0)にタスク優先順位PR=1のタスク(E6)を逆投入するとして説明する。まず、メイン回路400は、投入先のQID=Q0をQID_C信号により最大値選択回路406に入力する。最大値選択回路406は、仮想キュー(Q0)の最大順序値をキュー制御回路404にODR_A2として出力し、ODR_A2_ENをアサートする。図25によると、仮想キュー(Q0)の最大順序値はタスク(E3)の「3」であるため、ODR_A2=3となる。
FIG. 29 is a conceptual diagram when the task (E6) is put back into the virtual queue of FIG.
Here, description will be made assuming that the task (E6) with the task priority order PR = 1 is reversely input to the virtual queue (Q0). First, the main circuit 400 inputs the input destination QID = Q0 to the maximum value selection circuit 406 by the QID_C signal. The maximum value selection circuit 406 outputs the maximum order value of the virtual queue (Q0) to the queue control circuit 404 as ODR_A2, and asserts ODR_A2_EN. According to FIG. 25, since the maximum order value of the virtual queue (Q0) is “3” of the task (E3), ODR_A2 = 3.

次に、メイン回路400は、CMD=ENQ_TP(逆投入コマンド)として、EID_C=E6、QID_C=Q0、PR_C=1を設定する。このとき、キュー制御回路404に内蔵されるレジスタ値生成回路420_E6は、EID_C=ELM_ID=E6を検出すると、QID_N_E6=QID_C=Q0、ODR_N_E6=ODR_A2+1=3+1=4、PR_N_E6=PR_C=1を出力する。   Next, the main circuit 400 sets EID_C = E6, QID_C = Q0, and PR_C = 1 as CMD = ENQ_TP (reverse input command). At this time, when the register value generation circuit 420_E6 built in the queue control circuit 404 detects EID_C = ELM_ID = E6, it outputs QID_N_E6 = QID_C = Q0, ODR_N_E6 = ODR_A2 + 1 = 3 + 1 = 4, and PR_N_E6 = PR_C = 1.

CMD=ENQ_TP(逆投入コマンド)のときには、EID_Cにて指定されたタスクに対応づけられているレジスタ値生成回路420しか動作しない。このため、逆投入されるタスク(E6)の状態データだけが設定変更される。   When CMD = ENQ_TP (reverse input command), only the register value generation circuit 420 associated with the task specified by EID_C operates. For this reason, only the status data of the task (E6) to be reversely input is changed.

図30は、図29に対応した状態レジスタ250のデータ構造図である。
同図において下線を付与している部分が、図26に示した状態レジスタ250の設定内容から変化した箇所である。まず、タスク(E6)の仮想キュー(Q0)への逆投入により、キュー識別レジスタ416_E6には新たに「Q0」が設定される。タスク(E6)のODRは「4」、PRは「1」である。タスク(E6)の逆投入により、他のタスクの状態データは影響を受けない。
FIG. 30 is a data structure diagram of the status register 250 corresponding to FIG.
In FIG. 26, an underlined portion is a portion changed from the setting contents of the status register 250 shown in FIG. First, “Q0” is newly set in the queue identification register 416_E6 due to reverse input of the task (E6) to the virtual queue (Q0). The ODR of the task (E6) is “4”, and PR is “1”. The state data of other tasks are not affected by the reverse input of the task (E6).

図31は、逆投入の処理過程を示すフローチャートである。
メイン回路400は、まず、逆投入先となる仮想キューのQID=Qnを最大値選択回路406に入力する(S20)。メイン回路400は、仮想キュー(Qn)の最大順序値をキュー制御回路404に出力する(S22)。メイン回路400は、逆投入させるタスク(以下、「逆投入タスク」とよぶ)についての投入条件を設定する(S24)。具体的には、CMD=ENQ_TP(逆投入コマンド)として、EID_C、QID_C、PR_Cを設定する。キュー制御回路404のうち、逆投入タスクに対応するレジスタ値生成回路420は、逆投入タスクのタスク優先順位レジスタ412、キュー順序レジスタ414、キュー識別レジスタ416にそれぞれ、PR_C、最大順序値+1、QID_Cを設定する(S26)。ただし、最大順序値=0であってODR_A2_ENがネゲートされているとき、すなわち、仮想キュー(Qn)にタスクが未投入であるときには、キュー順序レジスタ414には初投入を示す順序値「0」を設定する。
FIG. 31 is a flowchart showing the reverse charging process.
First, the main circuit 400 inputs QID = Qn of the virtual queue to be reversely input into the maximum value selection circuit 406 (S20). The main circuit 400 outputs the maximum order value of the virtual queue (Qn) to the queue control circuit 404 (S22). The main circuit 400 sets the input condition for the task to be reverse input (hereinafter referred to as “reverse input task”) (S24). Specifically, EID_C, QID_C, and PR_C are set as CMD = ENQ_TP (reverse input command). Among the queue control circuits 404, the register value generation circuit 420 corresponding to the reverse input task includes the PR_C, the maximum order value + 1, and the QID_C in the task priority register 412, the queue order register 414, and the queue identification register 416 of the reverse input task, respectively. Is set (S26). However, when the maximum order value = 0 and ODR_A2_EN is negated, that is, when a task has not been submitted to the virtual queue (Qn), the queue order register 414 is given an order value “0” indicating the first submission. Set.

以上に示したように、順投入時においては他のタスクについて順序値の調整が発生する可能性があるが、逆投入時においてはこのような調整は不要である。FIFOを前提として仮想キューを見たとき、過去に投入されたタスクほど大きな順序値が設定される。いいかえれば、仮想キュー深くに投入されているタスクほど、順序値が大きい。反対に、仮想キュー深くに投入されているタスクほど順序値が小さくなるように設定してもよい。この場合には、順投入時においては他のタスクについて順序値の調整は不要となるが、逆投入時においては他のタスクについて順序値の調整が発生する可能性がある。
[抽出]
As described above, there is a possibility that the order value may be adjusted for other tasks at the time of sequential input, but such adjustment is not necessary at the time of reverse input. When a virtual queue is viewed on the premise of FIFO, a larger order value is set for a task input in the past. In other words, tasks placed deeper in the virtual queue have a higher order value. On the contrary, it may be set so that the order value becomes smaller as the task is inserted deeper in the virtual queue. In this case, it is not necessary to adjust the order value for other tasks at the time of sequential input, but there is a possibility that the adjustment of the order value for other tasks may occur at the time of reverse input.
[Extract]

図32は、タスク選択回路230の部分的な回路図である。
タスク選択回路230の基本構成は、基本例として図12に関連して説明した通りである。改良例1におけるタスク選択回路230は、メイン回路400からの問い合わせを受けたときに、抽出タスクを特定する。ここでは、この抽出タスクを特定するための仕組みに関わる回路構成について説明する。タスク選択回路230は、CND信号としてQID_C=Qnを入力されたとき、仮想キュー(Qn)において最もタスク優先順位の高い優先キューから抽出タスクを選択し、抽出タスクのタスクID、タスク優先順位、順序値をそれぞれEID_A1、PR_A1、ODR_A1に出力し、EID_A1_ENをアサートする。タスク選択回路230は、基本例に示した実行選択回路232やセマフォ選択回路234と同じく、複数段の比較回路から構成される。タスク選択回路230は、4つの第1比較回路430(430a、430b等)、2つの第2比較回路432(432等)、1つの第3比較回路(図示せず)を含む。また、8つの判定回路434(434a、434b、434c、434d等)を含む。
FIG. 32 is a partial circuit diagram of the task selection circuit 230.
The basic configuration of the task selection circuit 230 is as described with reference to FIG. 12 as a basic example. When receiving a query from the main circuit 400, the task selection circuit 230 in the first improvement example specifies an extraction task. Here, a circuit configuration related to a mechanism for specifying this extraction task will be described. When QID_C = Qn is input as the CND signal, the task selection circuit 230 selects an extraction task from the priority queue having the highest task priority in the virtual queue (Qn), and extracts the task ID, task priority, and order of the extraction task The values are output to EID_A1, PR_A1, and ODR_A1, respectively, and EID_A1_EN is asserted. Similar to the execution selection circuit 232 and the semaphore selection circuit 234 shown in the basic example, the task selection circuit 230 includes a plurality of stages of comparison circuits. The task selection circuit 230 includes four first comparison circuits 430 (430a, 430b, etc.), two second comparison circuits 432 (432, etc.), and one third comparison circuit (not shown). Also, eight determination circuits 434 (434a, 434b, 434c, 434d, etc.) are included.

第1比較回路430aに着目して説明する。第1比較回路422aは、タスク0とタスク1を比較し、どちらも仮想キュー(Qn)に投入されていれば、タスク優先順位が高い方のタスクを選択する。タスク優先順位が同じであれば、順序値が大きい方のタスクを選択する。第1比較回路430aには、タスク0とタスク1のタスクID、タスク優先順位、順序値がEID_S、PR_S、ODR_Sとして入力される。
第1の判定:判定回路434aは、タスク0が仮想キュー(Qn)に投入済みであればEID_11A_ENをアサートする。判定回路434bは、タスク1が仮想キュー(Qn)に投入済みであればEID_11B_ENをアサートする。第1比較回路430aは、まず、判定回路434aと判定回路434bのそれぞれから出力されるEID_11_EN信号を参照する。いずれか一方が「1」であれば、いずれか一方のタスクだけが仮想キュー(Qn)に投入されていることになる。このとき、第1比較回路430aは、仮想キュー(Qn)に投入されている方のタスクのタスクID(EID_S)、タスク優先順位(PR_S)および順序値(ODR_S)をそれぞれEID_21A、PR_11A、ODR_21Aとして出力し、EID_21A_ENをアサートする。
判定回路434aと判定回路434bが共に「0」を出力するときには、どちらのタスクも仮想キュー(Qn)に投入されていない。このとき、EID_21A_ENはネゲートされ、以後、タスク0とタスク1のいずれも第2比較回路432aにおいて考慮の対象とはならない。
判定回路434aと判定回路434bが共に「1」を出力するときには、どちらのタスクも仮想キュー(Qn)に投入済である、このとき、次の第2の判定が実行される。
Description will be made by paying attention to the first comparison circuit 430a. The first comparison circuit 422a compares the task 0 and the task 1, and if both are put in the virtual queue (Qn), the task having the higher task priority is selected. If the task priorities are the same, the task with the larger order value is selected. The task IDs, task priorities, and order values of task 0 and task 1 are input to the first comparison circuit 430a as EID_S, PR_S, and ODR_S.
First determination: The determination circuit 434a asserts EID_11A_EN if the task 0 has been put into the virtual queue (Qn). The determination circuit 434b asserts EID_11B_EN if the task 1 has been put into the virtual queue (Qn). The first comparison circuit 430a first refers to the EID_11_EN signal output from each of the determination circuit 434a and the determination circuit 434b. If either one is “1”, only one of the tasks is put in the virtual queue (Qn). At this time, the first comparison circuit 430a sets the task ID (EID_S), task priority (PR_S), and order value (ODR_S) of the task put in the virtual queue (Qn) as EID_21A, PR_11A, and ODR_21A, respectively. Output and assert EID_21A_EN.
When both the determination circuit 434a and the determination circuit 434b output “0”, neither task is put in the virtual queue (Qn). At this time, EID_21A_EN is negated, and thereafter neither task 0 nor task 1 is taken into consideration in the second comparison circuit 432a.
When both the determination circuit 434a and the determination circuit 434b output “1”, both tasks have been put into the virtual queue (Qn). At this time, the next second determination is executed.

第2の判定:タスク0のPR_S_0とタスク1のPR_S_1を比較し、タスク優先順位が高い方、いいかえれば、PR_Sが小さい方のタスクを選択する。第1比較回路430aは、タスク優先順位が高い方のタスクのタスクID(EID_S)、タスク優先順位(PR_S)および順序値(ODR_S)をそれぞれEID_21A、PR_21A、ODR_21Aとして出力し、EID_21A_ENをアサートする。2つのタスクのタスク優先順位が同じであれば、次の第3の判定が実行される。   Second determination: PR_S_0 of task 0 and PR_S_1 of task 1 are compared, and the task with the higher task priority, in other words, the task with the smaller PR_S is selected. The first comparison circuit 430a outputs the task ID (EID_S), task priority (PR_S), and order value (ODR_S) of the task with the higher task priority as EID_21A, PR_21A, and ODR_21A, and asserts EID_21A_EN. If the task priorities of the two tasks are the same, the next third determination is executed.

第3の判定:タスク0のODR_S_0とタスク1のODR_S_1を比較し、順序値が大きい方のタスクを選択する。第1比較回路430aは、順序値が大きい方のタスクのタスクID(EID_S)、タスク優先順位(PR_S)と順序値(ODR_S)をそれぞれEID_21A、PR_21A、ODR_21Aとして出力し、EID_21A_ENをアサートする。   Third determination: ODR_S_0 of task 0 and ODR_S_1 of task 1 are compared, and the task with the larger order value is selected. The first comparison circuit 430a outputs the task ID (EID_S), task priority (PR_S), and order value (ODR_S) of the task with the larger order value as EID_21A, PR_21A, and ODR_21A, respectively, and asserts EID_21A_EN.

他の第1比較回路430の処理内容も同様であり、タスク0とタスク1、タスク2とタスク3、タスク4とタスク5、タスク6とタスク7がそれぞれ比較される。第2比較回路432は、2つの第1比較回路430からの出力により、更に抽出タスクの候補を絞り込む。最終的に、仮想キュー(Qn)において最もタスク優先順位の高い優先キューから、抽出タスクが選択される。いずれかのタスクが選択されたときにはEID_A1_ENはアサートされ、いずれのタスクも仮想キュー(Qn)に存在しないときにはEID_A1_ENはネゲートされる。   The processing contents of the other first comparison circuits 430 are the same, and task 0 and task 1, task 2 and task 3, task 4 and task 5, and task 6 and task 7 are compared. The second comparison circuit 432 further narrows down extraction task candidates based on the outputs from the two first comparison circuits 430. Finally, an extraction task is selected from the priority queue having the highest task priority in the virtual queue (Qn). EID_A1_EN is asserted when any task is selected, and EID_A1_EN is negated when no task exists in the virtual queue (Qn).

図33は、図29の仮想キューからタスク(E3)を抽出するときの概念図である。
ここでは、仮想キュー(Q0)からタスクを1つ抽出するとして説明する。メイン回路400は、QID_C=Q0をタスク選択回路230に入力する。図29によると、仮想キュー(Q0)のうち最も高いタスク優先順位に対応する優先キュー(Q0:0)には、順序値「1」のタスク(E0)と順序値「3」のタスク(E3)が投入されている。タスク選択回路230は、順序値が大きい方のタスク(E3)を抽出タスクとして選択する。タスク選択回路230は、EID_A1=E3、PR_A1=0、ODR_A1=3として、EID_A1_ENをアサートする。
FIG. 33 is a conceptual diagram when the task (E3) is extracted from the virtual queue of FIG.
Here, it is assumed that one task is extracted from the virtual queue (Q0). The main circuit 400 inputs QID_C = Q0 to the task selection circuit 230. According to FIG. 29, in the priority queue (Q0: 0) corresponding to the highest task priority among the virtual queues (Q0), the task (E0) having the order value “1” and the task (E3) having the order value “3” are included. ) Has been entered. The task selection circuit 230 selects a task (E3) having a larger order value as an extraction task. The task selection circuit 230 asserts EID_A1_EN as EID_A1 = E3, PR_A1 = 0, and ODR_A1 = 3.

次に、メイン回路400は、CMD=DEQ(抽出コマンド)として、EID_C=EID_A1=E3、QID_C=Q0を設定する。レジスタ値生成回路420_E3は、QID_N_E3=Non、ODR_N_E3=0(リセット)、PR_N_E3=0(リセット)を出力する。こうして、タスク(E3)と仮想キュー(Q0)との関係が状態レジスタ250において解消される。   Next, the main circuit 400 sets EID_C = EID_A1 = E3 and QID_C = Q0 as CMD = DEQ (extraction command). The register value generation circuit 420_E3 outputs QID_N_E3 = Non, ODR_N_E3 = 0 (reset), and PR_N_E3 = 0 (reset). Thus, the relationship between the task (E3) and the virtual queue (Q0) is canceled in the status register 250.

レジスタ値生成回路420_E3だけでなく、QID_S_En=QID_C=Q0となるレジスタ値生成回路420_Enは、QID_C=QID_S_Enを検出すると、ODR_S_En>ODR_A1となるか判定する。ここでは、ODR_A1は、抽出タスク(E3)の抽出前の順序値である。ODR_S_En>ODR_A1であれば、すなわち、抽出タスクの順序値よりも順序値が大きいタスク(En)のレジスタ値生成回路420_Enは、ODR_N_En=ODR_S_En−1を出力する。図29に示す例では、タスク(E6)についてのレジスタ値生成回路420_E6が該当する。レジスタ値生成回路420_E6は、ODR_N_E6=ODR_S_E6−1=4−1=3を出力する。こうして、仮想キュー(Q0)の要素であるタスク(E6)の状態データが調整される。   Not only the register value generating circuit 420_E3 but also the register value generating circuit 420_En that satisfies QID_S_En = QID_C = Q0 determines whether or not ODR_S_En> ODR_A1 when detecting QID_C = QID_S_En. Here, ODR_A1 is an order value before extraction of the extraction task (E3). If ODR_S_En> ODR_A1, that is, the register value generation circuit 420_En of the task (En) whose order value is larger than the order value of the extracted task outputs ODR_N_En = ODR_S_En-1. In the example shown in FIG. 29, the register value generation circuit 420_E6 for the task (E6) corresponds. The register value generation circuit 420_E6 outputs ODR_N_E6 = ODR_S_E6-1 = 4-1 = 3. Thus, the state data of the task (E6) that is an element of the virtual queue (Q0) is adjusted.

図34は、図33に対応した状態レジスタ250のデータ構造図である。
同図において下線を付与している部分が、図30に示した状態レジスタ250の設定内容から変化した箇所である。まず、タスク(E3)の仮想キュー(Q0)からの抽出により、キュー識別レジスタ416_E3には新たに「Non」が設定される。また、キュー順序レジスタ414とタスク優先順位レジスタ412にはそれぞれリセット値として「0」が設定される。タスク(E3)の抽出により、仮想キュー(Q0)に元々投入されていたタスク(E0)、タスク(E2)、タスク(E5)、タスク(E6)のうち、抽出タスク(E3)よりも順序値が大きかったタスク(E6)のODRはデクリメントされる。
FIG. 34 is a data structure diagram of the status register 250 corresponding to FIG.
In the figure, the underlined portion is a portion changed from the setting contents of the status register 250 shown in FIG. First, by extracting the task (E3) from the virtual queue (Q0), “Non” is newly set in the queue identification register 416_E3. In addition, “0” is set as a reset value in each of the queue order register 414 and the task priority register 412. Of the task (E0), task (E2), task (E5), and task (E6) originally placed in the virtual queue (Q0) by the extraction of the task (E3), the order value is higher than that of the extraction task (E3). The ODR of the task (E6) having a large value is decremented.

図35は、抽出の処理過程を示すフローチャートである。
メイン回路400は、まず、抽出先となる仮想キューのQID=Qnをタスク選択回路230に入力する(S30)。タスク選択回路230は、仮想キュー(Qn)から抽出タスクを選択する(S32)。メイン回路400は、抽出タスクのタスクID=Enをキュー制御回路404に入力すると、キュー制御回路404は、抽出タスク(En)の状態データからQID=Qnをクリアする(S34)。このとき、PRやODRを「0」にリセットするが、必ずしもリセットはしなくてもよい。
FIG. 35 is a flowchart showing the extraction process.
First, the main circuit 400 inputs QID = Qn of the virtual queue to be extracted into the task selection circuit 230 (S30). The task selection circuit 230 selects an extraction task from the virtual queue (Qn) (S32). When the main circuit 400 inputs the task ID = En of the extraction task to the queue control circuit 404, the queue control circuit 404 clears QID = Qn from the status data of the extraction task (En) (S34). At this time, PR and ODR are reset to “0”, but they are not necessarily reset.

仮想キュー(Qn)に他のタスクも投入されており(S36のY)、ODR_S_En>ODR_A1となるタスクが存在するときには(S38のY)、該当タスクの順序値をデクリメントする(S40)。なお、S30からS40に示した処理はシリアル実行される必要はなく、時間的に並行して実行してもよい。
実装上、仮想キューの途中からでもタスクを取り出すことができる。たとえば、図33において、仮想キュー(Q0)の真ん中からタスク(E2)を取り出す必要が発生したとする。タスク(E2)は、あるフラグAがオンに設定されていることを条件として動作可能なタスクであるとする。このフラグAがオフにされたとき、タスク(E2)を仮想キュー(Q0)の途中から取り出す必要が発生する。あるいは、タスク(E2)についてあらかじめ設定されていた待ち時間がタイムアウトしたときにも、タスク(E2)を仮想キュー(Q0)の途中から取り出す必要が発生する。この場合には、タスク(E2)のQIDをクリアし、タスク(E2)の順序値「2」よりも順序値が大きいタスクのODRをデクリメントすることにより、タスク(E2)を仮想キュー(Q0)の途中からでも取り出すことができる。図33の場合、タスク(E6)のODRが「2」となる。仮想キューがハードウェアによって物理的な制約を受けないかたちで形成されるため、キューの途中からでも投入・抽出処理が可能となる。
When other tasks are also put in the virtual queue (Qn) (Y in S36) and there is a task satisfying ODR_S_En> ODR_A1 (Y in S38), the order value of the corresponding task is decremented (S40). Note that the processing shown in S30 to S40 need not be executed serially, and may be executed in parallel in time.
In terms of implementation, tasks can be taken out from the middle of the virtual queue. For example, in FIG. 33, it is assumed that the task (E2) needs to be taken out from the middle of the virtual queue (Q0). The task (E2) is assumed to be an operable task on condition that a certain flag A is set to ON. When the flag A is turned off, the task (E2) needs to be taken out from the middle of the virtual queue (Q0). Alternatively, it is necessary to take out the task (E2) from the middle of the virtual queue (Q0) even when the waiting time set in advance for the task (E2) times out. In this case, the QID of the task (E2) is cleared, and the task (E2) is decremented by the ODR of the task having an order value larger than the order value “2” of the task (E2), thereby making the task (E2) a virtual queue (Q0). It can be taken out even from the middle. In the case of FIG. 33, the ODR of the task (E6) is “2”. Since the virtual queue is formed in such a way that it is not physically restricted by hardware, it is possible to perform input / extraction processing even from the middle of the queue.

以上に示す仮想キュー制御によれば、FIFOを基本としつつも、LIFO的な動作を実現する特殊なキューをハードウェア・ロジックにより実現できる。両投入型キューアルゴリズムをソフトウェアで実装するとすれば、通常、連結リストによる実装となる。しかし、ソフトウェアによる処理である限り、メモリへのアクセスやアドレスの管理にともなうオーバーヘッドが発生せざるを得ない。これに対して、改良例1に示す仮想キュー制御は、ハードウェア・ロジックにより実現されるため、格段にシンプルで高速な制御が可能となる。特に、時間的要件が厳しいRTOSにおいては、両投入型キューアルゴリズムをハードウェア実装する意義は大きい。次に、再実行優先型タスクスケジューリングを上述した仮想キュー制御方法により実現する態様について説明する。   According to the virtual queue control described above, a special queue that realizes LIFO-like operation can be realized by hardware logic while being based on FIFO. If the double-throw queue algorithm is implemented by software, it is usually implemented by a linked list. However, as long as the processing is performed by software, overhead associated with memory access and address management must be generated. On the other hand, since the virtual queue control shown in the improvement example 1 is realized by hardware logic, it is possible to perform remarkably simple and high-speed control. In particular, in RTOS where time requirements are strict, it is significant to implement the double-throw queue algorithm in hardware. Next, an aspect in which the re-execution priority type task scheduling is realized by the above-described virtual queue control method will be described.

図36は、再実行優先型タスクスケジューリングにおける仮想キューとタスクの関係を示す第1の概念図である。
ここでは、READY状態に対応する仮想キュー(Q0)とWAITセマフォ状態に対応する仮想キュー(Q1)の2つの仮想キューを想定している。仮想キュー(Q0)は、タスク優先順位PR=0のタスクを投入するための優先キュー(以下、「優先キュー(Q0:0)」と表記する)とタスク優先順位PR=1のタスクを投入するための優先キュー(Q0:1)の2つの優先キューの集合体である。仮想キュー(Q1)についても同様であり、実質的には4つの優先キューが想定される。
FIG. 36 is a first conceptual diagram showing the relationship between virtual queues and tasks in re-execution priority task scheduling.
Here, two virtual queues are assumed, a virtual queue (Q0) corresponding to the READY state and a virtual queue (Q1) corresponding to the WAIT semaphore state. The virtual queue (Q0) inputs a priority queue (hereinafter referred to as “priority queue (Q0: 0)”) for inputting a task having a task priority order PR = 0 and a task having a task priority order PR = 1. It is an aggregate of two priority queues for priority queues (Q0: 1) for The same applies to the virtual queue (Q1), and substantially four priority queues are assumed.

同図においては、PR=1のタスク(E1)がRUN状態にあり、同じくPR=1のタスク(E0)、タスク(E2)は、優先キュー(Q0:1)にてREADY状態として待機している。また、PR=0のタスク(E3)は、優先キュー(Q1:0)にてWAITセマフォ状態にて待機している。ここで、タスク(E1)は、いったん実行されたら集中的・優先的に実行させたいタスクであるとする。   In this figure, the task (E1) with PR = 1 is in the RUN state, and the task (E0) and task (E2) with PR = 1 are also waiting in the READY state in the priority queue (Q0: 1). Yes. Further, the task (E3) with PR = 0 is waiting in the WAIT semaphore state in the priority queue (Q1: 0). Here, it is assumed that the task (E1) is a task to be executed intensively and preferentially once it is executed.

まず、RUN状態のタスク(E1)がリリースセマフォシステムコールを実行して、READY状態に戻るとする(S1)。タスク(E1)はなるべく早い段階で再実行させたいタスクであるため、優先キュー(Q0:1)に「逆投入」される。一方、リリースセマフォシステムコールにより、タスク(E3)のWAIT解除条件が成立したとする。タスク(E3)は優先キュー(Q1:0)から抽出され、優先キュー(Q0:0)に順投入される(S2)。次に、タスク選択回路230は、新たなRUN−タスクを選択する。タスク選択回路230は、READY状態にあるタスクのうち、タスク優先順位が最も高いタスク(E3)を抽出タスクとして選択する。こうして、WAIT状態からREADY状態に移行したばかりのタスク(E3)は、優先キュー(Q0:0)から抽出されて新たなRUN−タスクとなる。このようなタスクスケジューリングによれば、タスク優先順位が高いタスクは、WAIT解除条件が成立すれば比較的早い段階で実行権を取得できる。   First, it is assumed that the task (E1) in the RUN state executes a release semaphore system call and returns to the READY state (S1). Since the task (E1) is a task that is to be re-executed at the earliest possible stage, it is “reversely input” to the priority queue (Q0: 1). On the other hand, it is assumed that the WAIT cancellation condition for the task (E3) is satisfied by the release semaphore system call. The task (E3) is extracted from the priority queue (Q1: 0) and sequentially entered into the priority queue (Q0: 0) (S2). Next, the task selection circuit 230 selects a new RUN-task. The task selection circuit 230 selects the task (E3) having the highest task priority among the tasks in the READY state as the extraction task. Thus, the task (E3) just shifted from the WAIT state to the READY state is extracted from the priority queue (Q0: 0) and becomes a new RUN-task. According to such task scheduling, a task having a high task priority can acquire an execution right at a relatively early stage if the WAIT cancellation condition is satisfied.

図37は、再実行優先型タスクスケジューリングにおける仮想キューとタスクの関係を示す第2の概念図である。
タスク(E3)がウェイトセマフォシステムコールを実行すると、タスク(E3)は優先キュー(Q1:0)に順投入される(S4)。次に、タスク選択回路230は新たなRUN−タスクを選択する。タスク選択回路230は、READY状態にあるタスクのうち、タスク優先順位が最も高いタスクを選択するが、ここではタスク(E0)、タスク(E2)、タスク(E1)のタスク優先順位は同じである。この場合、優先キュー(Q0:1)からタスク(E1)が抽出される(S5)。タスク(E1)は、新たなRUN−タスクとなる。このような処理方法によれば、タスク優先順位PR=0を設定するほどではないが、いったん実行されたらなるべく連続的に実行させたいというタスク(E1)の仕様に対応できる。
FIG. 37 is a second conceptual diagram showing the relationship between virtual queues and tasks in re-execution priority task scheduling.
When the task (E3) executes the wait semaphore system call, the task (E3) is sequentially placed in the priority queue (Q1: 0) (S4). Next, the task selection circuit 230 selects a new RUN-task. The task selection circuit 230 selects the task having the highest task priority among the tasks in the READY state. Here, the task priority of the task (E0), the task (E2), and the task (E1) is the same. . In this case, the task (E1) is extracted from the priority queue (Q0: 1) (S5). Task (E1) becomes a new RUN-task. According to such a processing method, it is possible not only to set the task priority order PR = 0, but to cope with the specification of the task (E1) that is to be executed continuously as much as possible once it is executed.

再実行優先型タスクスケジューリングでは、実行状況やタスクの種類に応じて、順投入と逆投入を使い分けることにより、タスクの実行順位を制御できる。このため、基本例に示したタスク処理装置100の高速処理性能という特徴を維持しつつも、より精緻なタスクスケジューリングを実現できる。
{改良例2}
In the re-execution priority type task scheduling, the task execution order can be controlled by properly using the forward input and reverse input according to the execution status and the type of task. For this reason, more precise task scheduling can be realized while maintaining the feature of high-speed processing performance of the task processing apparatus 100 shown in the basic example.
{Improved Example 2}

次に、改良例2として、タスク処理装置100における補助処理の高速化について説明する。改良例2のタスク処理装置100においては、HWF(Hardware Function Module)が補助処理を実行する。ここでいうHWFは、いわゆる補助プロセッサであり、補助処理回路として機能する。補助処理は、タスクの一部として実行され、浮動小数点演算、DMA転送、暗号化・復号処理、3D画像の座標計算等、その処理内容はさまざまである。
まず、ソフトウェアOSによる一般的な補助処理の制御方法について説明する。そのあと、改良例2のタスク処理装置100による補助処理の制御方法について説明する。
Next, as an improved example 2, the speeding up of the auxiliary process in the task processing apparatus 100 will be described. In the task processing apparatus 100 according to the improved example 2, an HWF (Hardware Function Module) executes auxiliary processing. The HWF here is a so-called auxiliary processor and functions as an auxiliary processing circuit. The auxiliary processing is executed as a part of the task, and there are various contents of processing such as floating point calculation, DMA transfer, encryption / decryption processing, and 3D image coordinate calculation.
First, a general auxiliary processing control method by the software OS will be described. Then, the control method of the auxiliary process by the task processing apparatus 100 of the improvement example 2 is demonstrated.

図38は、ソフトウェアOSにより補助処理を実行する場合の一般的な回路構成を示す図である。
CPU84は、CPUバス512を介して図示しないメモリやHWF500と接続される。また、CPU84には、割り込みコントローラ502が接続される。割込コントローラ502は、HWF500等からさまざまな割り込み信号を受信し、割り込み信号(INTR)をCPU84に送信する。CPU84は、割り込み信号(INTR)を受信すると、適宜、特殊タスクにより割り込み信号(INTR)に対応した処理を実行する。
図2に示したように、CPU84によりソフトウェアOSが実行され、その上位階層において、一般タスクや特殊タスクが実行される。
FIG. 38 is a diagram showing a general circuit configuration when the auxiliary process is executed by the software OS.
The CPU 84 is connected to a memory (not shown) and the HWF 500 via the CPU bus 512. Further, an interrupt controller 502 is connected to the CPU 84. The interrupt controller 502 receives various interrupt signals from the HWF 500 or the like, and transmits an interrupt signal (INTR) to the CPU 84. When the CPU 84 receives the interrupt signal (INTR), the CPU 84 appropriately executes a process corresponding to the interrupt signal (INTR) by a special task.
As shown in FIG. 2, the software OS is executed by the CPU 84, and general tasks and special tasks are executed in the upper hierarchy.

補助処理は「直列型補助処理」と「並列型補助処理」の2種類に大別される。直列型補助処理の場合、その実行中に他のタスクを実行することはできない。並列型補助処理の場合には、その実行中においても他のタスクを並列実行できる。   Auxiliary processing is roughly divided into two types: “serial auxiliary processing” and “parallel auxiliary processing”. In the case of serial auxiliary processing, no other task can be executed during the execution. In the case of parallel auxiliary processing, other tasks can be executed in parallel even during the execution.

図39は、一般的な直列型補助処理の制御方法を示すタイムチャートである。
まず、タスクAは、HWF500を占有するためのシステムコールとして「割込禁止命令」を発行する(S100)。ここで対象となるHWF500は、FPU(浮動小数点演算ユニット)であるとする。「割込禁止命令」が発行されると、後述の「割込解除命令」が発行されるまで、タスクスイッチは抑止される。以下、割込禁止命令により割込禁止が設定されてから、割込解除命令により割込禁止が解除されるまでの期間のことを「割込禁止期間」とよぶ。割込禁止期間中に割り込み信号(INTR)が入力されても、特殊タスクは起動されない。割込禁止期間中は、タスクAがCPU84の使用権を独占することになる。したがって、タスクA以外のタスクがHWF500、すなわち、FPUへアクセスすることもない。
ソフトウェアOSが割込禁止を設定した後、タスクAに処理が戻る(S102)。タスクAは、HWF500に補助処理の実行を指示する(S104)。補助処理制御にともなうオーバーヘッドを抑制するため、タスクAはソフトウェアOSを介さずに、HWF500の内蔵レジスタにパラメータを直接書き込んで、補助処理の実行を指示する。HWF500は、タスクAに指示された補助処理を実行する。
FIG. 39 is a time chart showing a control method of a general serial type auxiliary process.
First, the task A issues an “interrupt prohibition instruction” as a system call for occupying the HWF 500 (S100). Here, it is assumed that the target HWF 500 is an FPU (floating point arithmetic unit). When the “interrupt disable instruction” is issued, the task switch is suppressed until an “interrupt cancel instruction” described later is issued. Hereinafter, the period from when the interrupt prohibition is set by the interrupt prohibition instruction until the interrupt prohibition is canceled by the interrupt cancel instruction is referred to as an “interrupt prohibition period”. Even if an interrupt signal (INTR) is input during the interrupt inhibition period, the special task is not activated. During the interrupt prohibition period, the task A monopolizes the right to use the CPU 84. Therefore, tasks other than the task A do not access the HWF 500, that is, the FPU.
After the software OS sets the interrupt prohibition, the process returns to task A (S102). The task A instructs the HWF 500 to execute auxiliary processing (S104). In order to suppress the overhead associated with the auxiliary process control, the task A directly writes the parameter to the built-in register of the HWF 500 and instructs the execution of the auxiliary process without using the software OS. The HWF 500 executes auxiliary processing instructed by the task A.

タスクAは、HWF500の内蔵レジスタを定期的にチェックしながら、補助処理の完了を待つ。補助処理の完了を検出すると(S106)、タスクAは割込解除命令を発行する(S108)。ソフトウェアOSは、割込解除命令を受け取ると、割込禁止を解除する(S110)。こうして割込禁止期間は終了する。ソフトウェアOSはタスクスイッチを実行し、次に実行すべきタスク、たとえば、タスクBを選択する(S112)。以後、タスクBに実行権が割り当てられる。タスクBも同様の方法によりHWF500を利用可能である。   Task A waits for the completion of auxiliary processing while periodically checking the internal register of HWF 500. When the completion of the auxiliary process is detected (S106), task A issues an interrupt release command (S108). When the software OS receives the interrupt release command, the software OS cancels the interrupt inhibition (S110). Thus, the interrupt prohibition period ends. The software OS executes a task switch and selects a task to be executed next, for example, task B (S112). Thereafter, an execution right is assigned to task B. The task B can also use the HWF 500 by the same method.

仮に、タスクAの依頼によりHWF500が補助処理を実行している最中に、別のタスク、たとえば、特殊タスクがHWF500の内蔵レジスタを書き換えてしまうと、タスクAは正しい処理結果を受け取れなくなってしまう。このため、HWF500の占有権を厳密に排他制御する必要がある。しかし、各タスクは、ソフトウェアOSを介さずともHWF500にアクセスできる。たとえば、S104において、タスクAはソフトウェアOSを介さずにHWF500に直接アクセスしている。そこで、ソフトウェアOSがHWF500の占有権を正しく管理できるように、タスクに「割込禁止命令」と「割込解除命令」を発行させている。ソフトウェアOSは、割込禁止命令により、補助処理中にタスクスイッチが発生するのを事前に抑止しておく。こうして、タスクAがHWF500を使用している最中に他のタスクがCPU84の使用権を獲得し、HWF500に干渉することがないように処置している。図39の場合、S102のタイミングから、S110のタイミングに至るまでが割込禁止期間となる。   If the HWF 500 is executing an auxiliary process at the request of the task A and another task, for example, a special task rewrites the internal register of the HWF 500, the task A cannot receive the correct processing result. . For this reason, it is necessary to strictly control the exclusive right of the HWF 500. However, each task can access the HWF 500 without going through the software OS. For example, in S104, the task A directly accesses the HWF 500 without going through the software OS. Therefore, the task is issued with an “interrupt disable instruction” and an “interrupt cancel instruction” so that the software OS can correctly manage the occupation right of the HWF 500. The software OS prevents the task switch from occurring during the auxiliary process in advance by an interrupt prohibition instruction. In this way, while the task A is using the HWF 500, another task acquires the right to use the CPU 84 and takes measures so as not to interfere with the HWF 500. In the case of FIG. 39, the interrupt prohibition period is from the timing of S102 to the timing of S110.

直列型補助処理の場合、割込禁止期間中においては、実質的に他のタスクを実行することができない。いいかえれば、直列型補助処理では、補助処理中に他のタスクがCPU84の使用権を取得できない。このため、浮動小数点演算のような比較的短時間で完了できる補助処理が直列型補助処理として好適である。   In the case of the serial type auxiliary processing, other tasks cannot be substantially executed during the interrupt prohibition period. In other words, in the serial type auxiliary process, another task cannot acquire the right to use the CPU 84 during the auxiliary process. For this reason, auxiliary processing that can be completed in a relatively short time, such as floating point arithmetic, is suitable as serial auxiliary processing.

図40は、一般的な並列型補助処理の制御方法を示すタイムチャートである。
まず、タスクAは、HWF500の使用権を待ち条件として、ウェイトセマフォシステムコールやウェイトミューテックスシステムコールなどのWAIT系システムコールを発行する(S120)。ここでは、ウェイトミューテックスシステムコールを対象として説明する。このウェイトミューテックスシステムコールは、HWF500の占有を要求するための命令として発行される。また、ここで対象となるHWF500は、DMAC(DMAコントローラ)であるとする。ソフトウェアOSは、ウェイトミューテックスシステムコールを受け取ると、ミューテックスにより、タスクA以外のタスクのHWF500へのアクセス、すなわち、DMACへのアクセスを禁止設定する(S122)。こうして、HWF500は一時的にタスクAにより占有される。ソフトウェアOSは次に実行すべきタスクを選択する。ここでは、タスクAが再選択されたとして説明を続ける。タスクAは、HWF500に補助処理の実行を指示する(S124)。ここでも、タスクAはソフトウェアOSを介さずに、HWF500に補助処理の実行を直接指示するとする。HWF500は、指示された補助処理を実行する。
FIG. 40 is a time chart showing a control method of a general parallel type auxiliary process.
First, the task A issues a WAIT system call such as a wait semaphore system call or a wait mutex system call using the right to use the HWF 500 as a waiting condition (S120). Here, a description will be given of the wait mutex system call. This wait mutex system call is issued as an instruction for requesting occupation of the HWF 500. Further, it is assumed that the target HWF 500 is a DMAC (DMA controller). When the software OS receives the wait mutex system call, the mutex prohibits the access to the HWF 500 by the task other than the task A, that is, the access to the DMAC (S122). Thus, the HWF 500 is temporarily occupied by the task A. The software OS selects a task to be executed next. Here, the description is continued on the assumption that the task A is selected again. The task A instructs the HWF 500 to execute auxiliary processing (S124). Here again, it is assumed that the task A directly instructs the HWF 500 to execute the auxiliary process without using the software OS. The HWF 500 executes the instructed auxiliary process.

タスクAは、補助処理の完了を待機条件として、ウェイトイベントシステムコールなどのWAIT系システムコールを発行する(S126)。タスクAは、WAIT状態に遷移する。ソフトウェアOSはタスクスイッチを実行し、次のRUN−タスク、たとえば、タスクBを選択する(S128)。タスクBは、補助処理と並行して実行される。ただし、HWF500はタスクAによって占有されているため、タスクBはHWF500を使用することはできない。   Task A issues a WAIT system call such as a wait event system call with the completion of auxiliary processing as a standby condition (S126). Task A transitions to the WAIT state. The software OS executes a task switch and selects the next RUN-task, for example, task B (S128). Task B is executed in parallel with the auxiliary process. However, since the HWF 500 is occupied by the task A, the task B cannot use the HWF 500.

HWF500は、補助処理が完了すると割り込み信号(INTR)を送信する(S130)。ソフトウェアOSは割り込み信号(INTR)を検出すると、割込ハンドラとしての特殊タスクを起動する(S132)。特殊タスクは、まず、セットイベントシステムコールなどのSET系システムコールにより、補助処理の完了をイベント通知する(S134)。こうして、タスクAが発行したウェイトイベントシステムコールの待機条件が成立する。再び、ソフトウェアOSから特殊タスクに実行権が移る(S136)。特殊タスクは残りの処理を実行後、STOP状態に遷移する(S138)。ソフトウェアOSは、再び実行権を取得し、特殊タスクを終了させたあと、タスクスイッチを実行する(S140)。ここでは、タスクAが再選択されたとする。   When the auxiliary process is completed, the HWF 500 transmits an interrupt signal (INTR) (S130). When detecting the interrupt signal (INTR), the software OS activates a special task as an interrupt handler (S132). The special task first notifies the event of completion of the auxiliary process by a SET system call such as a set event system call (S134). Thus, the wait condition for the wait event system call issued by task A is satisfied. Again, the execution right is transferred from the software OS to the special task (S136). After executing the remaining processing, the special task transitions to the STOP state (S138). The software OS acquires the execution right again, terminates the special task, and then executes a task switch (S140). Here, it is assumed that task A is selected again.

既に、タスクAが依頼した補助処理は完了しているので、タスクAはHWF500の内蔵レジスタから処理結果を読み取る(S142)。あるいは、タスクAは、HWF500がメモリの所定領域に書き込んだ処理結果を読み出すとしてもよい。タスクAは、リリースミューテックスシステムコールを発行する(S144)。ソフトウェアOSは、リリースミューテックスシステムコールを受け取ると、HWF500のタスクAによる占有権を解除する(S146)。ソフトウェアOSはタスクスイッチを実行し、次に実行すべきタスク、たとえば、タスクCを選択する(S148)。以後、タスクCに実行権が割り当てられる。HWF500の占有権は解除されているため、タスクCも同様の方法によりHWF500を利用可能である。   Since the auxiliary processing requested by task A has already been completed, task A reads the processing result from the built-in register of HWF 500 (S142). Alternatively, the task A may read the processing result written by the HWF 500 in a predetermined area of the memory. Task A issues a release mutex system call (S144). When the software OS receives the release mutex system call, the software OS releases the exclusive right by the task A of the HWF 500 (S146). The software OS executes a task switch and selects a task to be executed next, for example, task C (S148). Thereafter, an execution right is assigned to task C. Since the occupation right of the HWF 500 is released, the task C can use the HWF 500 in the same manner.

並列型においても、一般タスクがHWF500に直接アクセスしている点は直列型と同じである。並列型補助処理では、補助処理中に他のタスクがHWF500を使用できないようにしておくが、他のタスクはCPU84の使用権を取得すること自体は可能である。こうして、タスクAがHWF500を使用している最中に他のタスクがHWF500に干渉しないように処置している。   The parallel type is the same as the serial type in that general tasks directly access the HWF 500. In the parallel type auxiliary processing, other tasks are prevented from using the HWF 500 during the auxiliary processing, but other tasks can acquire the right to use the CPU 84 itself. In this way, while the task A is using the HWF 500, other tasks are prevented from interfering with the HWF 500.

並列型補助処理の実行中には、S128に示したように他のタスクを並列実行できる。ただし、S126やS134のシステムコール、特殊タスクの起動等により、直列型補助処理よりもオーバーヘッドが大きい。このため、DMA転送のような比較的時間がかかる補助処理が並列型補助処理として好適である。   During the execution of the parallel auxiliary processing, other tasks can be executed in parallel as shown in S128. However, the overhead is larger than the serial auxiliary processing due to the system call of S126 and S134, the activation of the special task, and the like. For this reason, auxiliary processing that takes a relatively long time such as DMA transfer is suitable as parallel auxiliary processing.

図39に示した直列型補助処理の場合、タスクはシステムコールを合計2回発行する必要がある。また、補助処理開始後も、HWF500を定期的にチェックし、補助処理が完了しているか否かを検知しなければならない。実際に補助処理が完了するタイミングと、タスクが補助処理の完了を検知するタイミングには「ずれ」が発生しやすく、結果として、処理効率が低下してしまう。   In the case of the serial auxiliary process shown in FIG. 39, the task needs to issue system calls twice in total. Further, even after the auxiliary process is started, it is necessary to periodically check the HWF 500 to detect whether or not the auxiliary process is completed. A “deviation” is likely to occur between the timing at which the auxiliary process is actually completed and the timing at which the task detects the completion of the auxiliary process, resulting in a reduction in processing efficiency.

図40に示した並列型補助処理の場合、タスクAはシステムコールを合計4回発行する必要がある。更に、補助処理が終了したとき、タスクAに補助処理完了を通知するために特殊タスクを起動しなければならない。   In the case of the parallel auxiliary process shown in FIG. 40, task A needs to issue system calls four times in total. Furthermore, when the auxiliary process is completed, a special task must be activated to notify task A of the completion of the auxiliary process.

一般的には、システムコール1回分につき500〜1000回程度のCPUクロックが消費される。補助処理は実行頻度が高い処理であり、時間的要件の厳しいRTOSにとってこういったオーバーヘッドをいかに抑制できるかは重要な設計ポイントである。   Generally, about 500 to 1000 CPU clocks are consumed per system call. The auxiliary process is a process with high execution frequency, and it is an important design point how to suppress such overhead for an RTOS with severe time requirements.

図41は、基本例のタスク処理装置100により図38から図40までに示した補助処理制御を実現する場合の回路構成を示す図である。
基本例に関連して説明したように、タスク処理装置100は、主として、CPU150、退避回路120およびタスク制御回路200を含む。図38に示した一般的な回路構成の場合、CPU84はソフトウェアOSとタスクの両方を実行する。これに対して、タスク処理装置100においては、CPU150がタスクを実行し、OSとしての機能は退避回路120とタスク制御回路200により実現されている。OSの機能をCPU150から外在化させることにより、全体としての処理効率が格段に向上することは基本例に関連して説明した通りである。図41においても、CPU150はCPUバス512を介してHWF500と接続されている。
FIG. 41 is a diagram showing a circuit configuration when the auxiliary processing control shown in FIGS. 38 to 40 is realized by the task processing apparatus 100 of the basic example.
As described in connection with the basic example, the task processing device 100 mainly includes the CPU 150, the save circuit 120, and the task control circuit 200. In the case of the general circuit configuration shown in FIG. 38, the CPU 84 executes both the software OS and the task. On the other hand, in the task processing apparatus 100, the CPU 150 executes the task, and the function as the OS is realized by the save circuit 120 and the task control circuit 200. As described in relation to the basic example, the processing efficiency as a whole is remarkably improved by externalizing the function of the OS from the CPU 150. Also in FIG. 41, the CPU 150 is connected to the HWF 500 via the CPU bus 512.

タスク処理装置100によるハードウェアOSの場合、システムコール実行、特に、タスクスイッチがソフトウェアOSに比べると格段に高速化される。タスク処理装置100は、システムコールを1回実行するために、CPUクロックを12クロック程度しか必要としない。このため、図41の回路構成にて、タスク処理装置100により図39および図40に示した補助処理制御を実行したとしても、補助処理にともなうオーバーヘッドを大きく抑制できる。
改良例2においては、タスク処理装置100とHWF500、特に、CPU150とHWF500の関係を見直すことにより、補助処理を更に高速化する。
In the case of the hardware OS by the task processing apparatus 100, the system call execution, in particular, the task switch is significantly faster than the software OS. The task processing apparatus 100 requires only about 12 CPU clocks in order to execute a system call once. For this reason, even if the auxiliary processing control shown in FIGS. 39 and 40 is executed by the task processing device 100 with the circuit configuration of FIG.
In the improved example 2, the auxiliary processing is further speeded up by reviewing the relationship between the task processing apparatus 100 and the HWF 500, in particular, the CPU 150 and the HWF 500.

図42は、改良例2においてタスク処理装置100とHWF500の関係を示す回路構成図である。
同図においては、複数のHWF500(HWF500_0、・・・、HWF500_k:kは任意の自然数)が、CPU150ではなくタスク制御回路200と接続される。各HWF500は、それぞれ異なる補助処理に対応して設計された専用回路である。たとえば、HWF500_0はFPU、HWF500_1はDMACであってもよい。各HWF500は、0〜kの範囲のHWFIDにより一意に識別される。
FIG. 42 is a circuit configuration diagram showing the relationship between the task processing device 100 and the HWF 500 in the second improved example.
In the figure, a plurality of HWFs 500 (HWF500_0,..., HWF500_k: k is an arbitrary natural number) are connected to the task control circuit 200 instead of the CPU 150. Each HWF 500 is a dedicated circuit designed for different auxiliary processing. For example, the HWF 500_0 may be an FPU and the HWF 500_1 may be a DMAC. Each HWF 500 is uniquely identified by an HWFID ranging from 0 to k.

CPU150で実行されるタスクは、タスク制御回路200を介して、各HWF500に補助処理を実行させる。タスクは、HWF500の内蔵レジスタに直接アクセスできない。改良例2においては、タスク制御回路200が各HWF500を一元管理することになる。   The task executed by the CPU 150 causes each HWF 500 to execute auxiliary processing via the task control circuit 200. The task cannot directly access the internal register of the HWF 500. In the improved example 2, the task control circuit 200 manages each HWF 500 in an integrated manner.

図43は、改良例2における状態記憶部220とタスク切換回路210の関係を示す回路図である。
改良例2のタスク選択回路230には、HWF待機選択回路510が追加される。また、タスク切換回路210には、複数のHWF500が新たに接続される。
FIG. 43 is a circuit diagram showing the relationship between the state storage unit 220 and the task switching circuit 210 in the second modification.
An HWF standby selection circuit 510 is added to the task selection circuit 230 of the improved example 2. A plurality of HWFs 500 are newly connected to the task switching circuit 210.

タスク制御回路200の基本構成は、図10に示した基本例の回路構成とほぼ同等である。各タスクに対応づけられる状態レジスタ250は、タスクIDレジスタ254、タスク優先順位レジスタ256等に加えて、HWFIDレジスタ504、キュー順序レジスタ506およびキュー識別レジスタ508が追加される。
(A)HWFIDレジスタ504:あるタスクが補助処理の実行を指示するとき、その補助処理の実行主体となるHWF500のHWFIDが設定される。HWFIDは、HID_S信号として常時出力される。改良例2においては、HWFIDレジスタ504には、並列型補助処理のときだけHWFIDが書き込まれる。
(B)キュー順序レジスタ506:仮想キューへのタスクの投入順位を示す「順序値(ODR)」を保持する。順序値が大きいほど、仮想キューの深くに投入されていることを示す。順序値は、ODR_S信号として常時出力される。改良例2の順序値ODRは、改良例1で説明した「順序値ODR」と同一概念である。
(C)キュー識別レジスタ508:仮想キューを識別する「キューID(QID)」を保持する。QID_S信号として常時出力される。キューIDは、改良例1で説明した「キューID(QID)」と同一概念である。
The basic configuration of the task control circuit 200 is almost the same as the circuit configuration of the basic example shown in FIG. The status register 250 associated with each task includes a HWFID register 504, a queue order register 506, and a queue identification register 508 in addition to the task ID register 254, the task priority order register 256, and the like.
(A) HWFID register 504: When a certain task instructs execution of auxiliary processing, the HWFID of the HWF 500 that is the execution subject of the auxiliary processing is set. HWFID is always output as an HID_S signal. In the improved example 2, the HWFID is written in the HWFID register 504 only during the parallel type auxiliary processing.
(B) Queue order register 506: Holds an “order value (ODR)” indicating the order in which tasks are submitted to the virtual queue. The larger the order value, the deeper the virtual queue is inserted. The order value is always output as an ODR_S signal. The order value ODR of the improvement example 2 has the same concept as the “order value ODR” described in the improvement example 1.
(C) Queue identification register 508: Holds a “queue ID (QID)” for identifying a virtual queue. Always output as the QID_S signal. The queue ID has the same concept as the “queue ID (QID)” described in the first modification.

仮想キューは、改良例1で示した仮想キューと同じく、タスク状態に対応づけられる仮想的なキューである。このように、キューIDとタスク状態の対応づけはハードウェア実装として固定化される必要はない。タスク選択回路230は、各キュー識別レジスタ508を参照することにより、各タスクのタスク状態を判別できる。   The virtual queue is a virtual queue that is associated with the task state, similar to the virtual queue shown in the first improvement example. As described above, the correspondence between the queue ID and the task state need not be fixed as hardware implementation. The task selection circuit 230 can determine the task state of each task by referring to each queue identification register 508.

タスク選択回路230は、状態レジスタ250から出力される状態データに基づいて、状態遷移させるべきタスクを選択する。タスク切換回路210がHWF待機選択回路510にHWFIDを入力すると、HWF待機選択回路510はそのHWFIDをHWFIDレジスタ504に設定されているタスクのタスクIDを出力する。いいかえれば、「指定されたHWF500による処理の完了を待っているタスク」をタスク切換回路210に通知する。指定されたHWF500が処理中でなければ、すなわち、どのタスクにも処理を依頼されていなければ、HWF待機選択回路510は「−1」などの所定値を出力する。   The task selection circuit 230 selects a task whose state is to be changed based on the state data output from the state register 250. When task switching circuit 210 inputs HWFID to HWF standby selection circuit 510, HWF standby selection circuit 510 outputs the task ID of the task whose HWFID is set in HWFID register 504. In other words, “task waiting for completion of processing by designated HWF 500” is notified to the task switching circuit 210. If the designated HWF 500 is not being processed, that is, if no task is requested to be processed, the HWF standby selection circuit 510 outputs a predetermined value such as “−1”.

各HWF500は、タスク切換回路210と直接接続される。各HWF500は、タスク切換回路210と以下に示す6種類の信号線により接続される。以下において、iは0〜kの任意の数であるとする。
a.HFi_REQ:タスク切換回路210は、HWF500_iに補助処理の実行を指示するとき、HFi_REQをアサートする。
b.HFi_ARG[m-1:0]:補助処理のパラメータを伝送する。補助処理の内容によってHFi_ARG[m-1:0]のサイズはさまざまであり、パラメータの個数もさまざまである。HFi_REQがアサートされるときに、HFi_ARG[m-1:0]がHWF500_iの内蔵レジスタに書き込まれる。
c.HFi_RQACK:HFi_REQがアサートされ、HFi_ARG[m-1:0]が書き込まれると、HWF500_iは補助処理を開始する。補助処理の開始に際し、HWF500_iはHFi_RQACKをアサートする。HFi_RQACKにより、タスク切換回路210は補助処理が開始されたことを認識する。
d.HFi_CMPLT:補助処理が完了すると、HWF500_iは補助処理の結果を内蔵レジスタに書き込んだ上で、HFi_CMPLTをアサートする。HFi_CMPLTにより、タスク切換回路210は補助処理の完了を認識する。
e.HFi_RSLT[m-1:0]:補助処理の結果を示す戻り値である。補助処理の内容によってHFi_RSLT[m-1:0]のサイズはさまざまであり、戻り値の個数もさまざまである。HWF500_iの内蔵レジスタに書き込まれている戻り値を伝送する。タスク切換回路210は、HFi_CMPLTがアサートされると、HFi_RSLT[m-1:0]の戻り値を取得する。
f.HFi_CMPACK:タスク切換回路210は、戻り値を取得するとHFi_CMPACKをアサートする。HFi_CMPACKにより、HWF500_iは戻り値が正常に取得されたことを認識する。
Each HWF 500 is directly connected to the task switching circuit 210. Each HWF 500 is connected to the task switching circuit 210 by the following six types of signal lines. In the following, it is assumed that i is an arbitrary number from 0 to k.
a. HFi_REQ: The task switching circuit 210 asserts HFi_REQ when instructing the HWF 500_i to execute auxiliary processing.
b. HFi_ARG [m-1: 0]: Transmit auxiliary processing parameters. The size of HFi_ARG [m-1: 0] varies depending on the contents of the auxiliary processing, and the number of parameters also varies. When HFi_REQ is asserted, HFi_ARG [m-1: 0] is written to the internal register of the HWF 500_i.
c. HFi_RQACK: When HFi_REQ is asserted and HFi_ARG [m-1: 0] is written, the HWF 500_i starts auxiliary processing. At the start of the auxiliary process, the HWF 500 — i asserts HFi_RQACK. From HFi_RQACK, the task switching circuit 210 recognizes that the auxiliary processing has started.
d. HFi_CMPLT: When the auxiliary process is completed, the HWF 500_i writes the result of the auxiliary process to the built-in register and then asserts HFi_CMPLT. By HFi_CMPLT, the task switching circuit 210 recognizes the completion of the auxiliary processing.
e. HFi_RSLT [m-1: 0]: A return value indicating the result of the auxiliary process. The size of HFi_RSLT [m-1: 0] varies depending on the contents of the auxiliary processing, and the number of return values also varies. The return value written in the internal register of the HWF 500 — i is transmitted. When HFi_CMPLT is asserted, the task switching circuit 210 acquires the return value of HFi_RSLT [m-1: 0].
f. HFi_CMPACK: When the task switching circuit 210 acquires the return value, it asserts HFi_CMPACK. From HFi_CMPACK, the HWF 500 — i recognizes that the return value has been acquired normally.

図44は、改良例2における直列型補助処理の制御方法を示すタイムチャートである。
改良例2のタスク処理装置100には、基本例で説明した9つのシステムコールに加えて、「HWFコール」が追加される。「HWFコール」は、タスクが補助処理を実行指示するためのシステムコールである。
FIG. 44 is a time chart showing a control method of serial auxiliary processing in the improved example 2.
In addition to the nine system calls described in the basic example, a “HWF call” is added to the task processing apparatus 100 of the improved example 2. The “HWF call” is a system call for a task to instruct execution of auxiliary processing.

まず、タスクAは、対象となる補助処理の種類をパラメータとしてHWFコールを発行する(S100)。たとえば、浮動小数点演算命令やDMA転送命令、暗号化処理命令などにより補助処理の種類が指定される。タスク切換回路210は、パラメータとして指定された補助処理に応じて、対象となるHWF500を選択し、該当HWFIDを特定する。なお、HWFID自体をパラメータとしてHWFコールが発行されてもよい。ここでは、HWFID=iが特定されたとして説明する。HWFコールのパラメータとして、補助処理の引数を指定してもよい。このようなパラメータは、CPU150における所定の汎用レジスタ158に書き込まれる。タスク切換回路210は、HWFコールを受け付けたとき、汎用レジスタ158からこれらのパラメータを読み出す。   First, the task A issues an HWF call with the type of target auxiliary processing as a parameter (S100). For example, the type of auxiliary processing is specified by a floating point arithmetic instruction, a DMA transfer instruction, an encryption processing instruction, or the like. The task switching circuit 210 selects the target HWF 500 according to the auxiliary process specified as the parameter, and identifies the corresponding HWFID. Note that an HWF call may be issued with the HWFID itself as a parameter. Here, a description will be given assuming that HWFID = i is specified. An argument of auxiliary processing may be specified as a parameter of the HWF call. Such parameters are written into a predetermined general-purpose register 158 in the CPU 150. The task switching circuit 210 reads these parameters from the general-purpose register 158 when receiving the HWF call.

タスク切換回路210は、HWF500_iに補助処理の実行を指示する(S102)。タスク切換回路210は、HC信号によりCPU150を停止させる。このため、タスクAはRUN状態のまま停止させられる。   The task switching circuit 210 instructs the HWF 500_i to execute auxiliary processing (S102). The task switching circuit 210 stops the CPU 150 by the HC signal. Therefore, task A is stopped in the RUN state.

S102においては、図39のようにタスクAがHWF500にアクセスするのではなく、タスク切換回路210がHWF500に補助処理の実行を指示する。具体的には、HFi_ARG[m-1:0]に引数を設定した上でHFi_REQをアサートする。HWF500_iは、補助処理を開始し、HFi_RQACKをアサートする。CPU150は既に停止されているので、補助処理中はタスクAは実行されない。もちろん、特殊タスクを含めた他のタスクも実行されない。   In S102, the task A does not access the HWF 500 as shown in FIG. 39, but the task switching circuit 210 instructs the HWF 500 to execute auxiliary processing. Specifically, HFi_REQ is asserted after setting an argument in HFi_ARG [m-1: 0]. The HWF 500 — i starts auxiliary processing and asserts HFi_RQACK. Since the CPU 150 is already stopped, the task A is not executed during the auxiliary process. Of course, other tasks including special tasks are not executed.

補助処理が完了すると、HWF500_iはHFi_RSLT[m-1:0]に戻り値を出力して、HFi_CMPLTをアサートする。タスク切換回路210は、戻り値を受け取って、HFi_CMPACKをアサートする(S104)。タスク切換回路210は、処理レジスタ92に戻り値を記録する。タスク切換回路210は、停止要求信号(HR)をネゲートして、タスクAの実行を再開させる(S106)。   When the auxiliary processing is completed, the HWF 500 — i outputs a return value to HFi_RSLT [m−1: 0] and asserts HFi_CMPLT. The task switching circuit 210 receives the return value and asserts HFi_CMPACK (S104). The task switching circuit 210 records the return value in the processing register 92. The task switching circuit 210 negates the stop request signal (HR) and resumes the execution of the task A (S106).

改良例2の直列型補助処理の場合、システムコールは1回しか必要ない。また、補助処理の実行中にCPU150を停止させるため、消費電力も抑制される。更に、補助処理を依頼したタスクAは、HWF500に補助処理の完了タイミングを問い合わせる必要がないため、補助処理が完了するタイミングとタスク処理装置100が補助処理の完了を検知するタイミングのずれがほとんど発生しない。   In the case of the serial type auxiliary process of the improved example 2, only one system call is required. Moreover, since the CPU 150 is stopped during the execution of the auxiliary process, power consumption is also suppressed. Further, since the task A that requested the auxiliary process does not need to inquire the completion timing of the auxiliary process to the HWF 500, there is almost no difference between the timing at which the auxiliary process is completed and the timing at which the task processing apparatus 100 detects the completion of the auxiliary process. do not do.

改良例2においては、タスクはHWF500に直接アクセスすることはできず、あくまでも、タスク切換回路210がHWF500へアクセスする。このため、割込禁止命令や割込解除命令により、タスクがOSに割込禁止期間を制御させるための処理は不要である。タスク処理装置100は、HFWコールを受けた後、停止要求信号(HR)によりCPUクロックの停止・再開を制御するだけである。タスク処理装置100は、処理レジスタ92に補助処理の結果を戻り値として書き込むので、補助処理を依頼していたタスクAは、実行再開時にはすでに補助処理の結果を取得した状態となっている。タスクAはHWF500やタスク制御回路200に補助処理の結果を問い合わせる必要がないため、処理効率が向上するだけでなく、タスクAのプログラムコードも簡素化できる。   In the improved example 2, the task cannot directly access the HWF 500, and the task switching circuit 210 accesses the HWF 500 to the last. For this reason, processing for causing the OS to control the interrupt prohibition period by the interrupt prohibition instruction or the interrupt release instruction is unnecessary. After receiving the HFW call, the task processing device 100 only controls the stop / restart of the CPU clock by the stop request signal (HR). Since the task processing apparatus 100 writes the result of the auxiliary process as a return value in the processing register 92, the task A that has requested the auxiliary process has already acquired the result of the auxiliary process when the execution is resumed. Since task A does not need to inquire the result of auxiliary processing to HWF 500 or task control circuit 200, not only the processing efficiency is improved, but also the program code of task A can be simplified.

図45は、改良例2における並列型補助処理の制御方法を示すタイムチャートである。
ここでも、対象となるHWF500は、FPU(浮動小数点演算ユニット)であるとする。また、FPUに該当するHWF500のHWFIDは「i」であるとする。まず、タスクAは、FPUの使用権を待ち条件として、ウェイトミューテックスシステムコールを発行する(S120)。ミューテックスやセマフォにより各HWFの占有権が管理される。ミューテックス等によるHWFの排他制御は必須ではない。たとえば、特定のタスクにしか使用されないHWFであれば、排他制御は不要である。
HWF500_iがミューテックスにより占有中として設定されていなければ、タスク処理装置100は、ミューテックスにより、タスクA以外のタスクがHWF500_iへアクセスするのを禁止設定する(S122)。
FIG. 45 is a time chart showing a control method of parallel auxiliary processing in the improved example 2.
Here again, it is assumed that the target HWF 500 is an FPU (floating point arithmetic unit). Further, the HWFID of the HWF 500 corresponding to the FPU is “i”. First, the task A issues a wait mutex system call using the FPU usage right as a waiting condition (S120). The exclusive right of each HWF is managed by the mutex and semaphore. Exclusive control of HWF by mutex or the like is not essential. For example, if the HWF is used only for a specific task, exclusive control is unnecessary.
If the HWF 500 — i is not set as occupied by the mutex, the task processing apparatus 100 prohibits the task other than the task A from accessing the HWF 500 — i by the mutex (S 122).

こうして、HWF500_iは一時的にタスクAに占有される。次に、タスクAはHWFコールを発行する(S124)。タスクAはRUNからWAITに状態遷移する。WAIT解除の条件は、HWF500_iの補助処理が完了することである。タスク切換回路210は、HWFコールを受けると、タスクAのHWFIDレジスタ504に、HWFID=iを設定する。   Thus, the HWF 500 — i is temporarily occupied by the task A. Next, task A issues an HWF call (S124). Task A makes a state transition from RUN to WAIT. The condition for releasing the WAIT is that the auxiliary process of the HWF 500 — i is completed. When task switching circuit 210 receives the HWF call, task switching circuit 210 sets HWFID = i in HWFID register 504 of task A.

改良例2では、図40のようにタスクAに実行権を戻すことなく、タスク切換回路210自体がHWF500に補助処理の開始を指示する(S126)。HWF500_iは、補助処理を開始する。タスク切換回路210は、次のRUN−タスク、たとえば、タスクBを選択する(S128)。タスクBは補助処理と並列実行される。ただし、タスクBはHWF500_iを使用することはできない。タスクAがミューテックスによりHWF500_iの占有権を確保しているためである。   In the improved example 2, the task switching circuit 210 itself instructs the HWF 500 to start the auxiliary process without returning the execution right to the task A as shown in FIG. 40 (S126). The HWF 500 — i starts auxiliary processing. The task switching circuit 210 selects the next RUN-task, for example, task B (S128). Task B is executed in parallel with auxiliary processing. However, the task B cannot use the HWF 500 — i. This is because the task A secures the occupation right of the HWF 500 — i by the mutex.

補助処理が完了すると、HWF500_iはHFi_RSLT[m-1:0]に戻り値を出力して、HFi_CMPLTをアサートする。タスク切換回路210は、戻り値を受け取って、HFi_CMPACKをアサートする(S130)。タスクBは、RUNからREADYに状態遷移する。具体的には、タスク処理装置100は、停止要求信号(HR)をアサートしてCPUクロックの停止を要求し、停止完了信号(HC)がアサートされるのを待って、タスクBの処理データを退避レジスタに退避させる。タスクBは、READY状態に対応づけられる仮想キューに逆投入される。タスク切換回路210は、HWFID=iをHWF待機選択回路510に入力し、HWF500_iに補助処理を依頼していたタスクAのタスクIDを取得する。そして、タスクAに対応する退避レジスタに補助処理の結果を示す戻り値を記録し、タスクAをREADY状態に設定する。ここでも、改良例1に示したようにREADYに対応する仮想キューにタスクAを逆投入してもよい。タスク切換回路210は、次に実行すべきタスク、たとえば、タスクAを選択する(S132)。以後、タスクAに実行権が割り当てられる。補助処理が完了したときには、その補助処理を依頼していたタスクAを必ず選択するとしてもよい。このようなタスクスイッチ・ルールによれば、補助処理を依頼したタスクのスループットを向上させることができる。タスクAは、リリースミューテックスシステムコールにより、HWF500_iの占有権を解除する(S134)。タスク処理装置100は、再びタスクスイッチを実行し、次に実行すべきタスク、たとえば、S128〜S130まで実行されていたタスクBを選択する(S136)。以後、タスクBに実行権が割り当てられる。HWF500の占有権は解除されているため、タスクBも同様の方法によりHWF500_iを利用可能である。   When the auxiliary processing is completed, the HWF 500 — i outputs a return value to HFi_RSLT [m−1: 0] and asserts HFi_CMPLT. The task switching circuit 210 receives the return value and asserts HFi_CMPACK (S130). Task B makes a state transition from RUN to READY. Specifically, the task processing device 100 asserts the stop request signal (HR) to request the stop of the CPU clock, waits for the stop completion signal (HC) to be asserted, and receives the processing data of the task B. Save to the save register. Task B is put back into the virtual queue associated with the READY state. The task switching circuit 210 inputs HWFID = i to the HWF standby selection circuit 510, and acquires the task ID of the task A that has requested the HWF 500_i to perform auxiliary processing. Then, a return value indicating the result of the auxiliary process is recorded in the save register corresponding to the task A, and the task A is set to the READY state. Here again, as shown in the first improvement, the task A may be put back into the virtual queue corresponding to READY. The task switching circuit 210 selects a task to be executed next, for example, task A (S132). Thereafter, an execution right is assigned to task A. When the auxiliary process is completed, the task A that has requested the auxiliary process may be selected. According to such a task switch rule, it is possible to improve the throughput of a task for which auxiliary processing is requested. The task A releases the exclusive right of the HWF 500 — i by the release mutex system call (S134). The task processing device 100 executes the task switch again, and selects the task to be executed next, for example, the task B that has been executed from S128 to S130 (S136). Thereafter, an execution right is assigned to task B. Since the occupation right of the HWF 500 is released, the task B can use the HWF 500 — i in the same manner.

図40に関連して示した並列型補助処理においては、計4回のシステムコールが発行されていた。これに対して、改良例2における並列型補助処理のシステムコール回数は「ウェイトミューテックスシステムコール」、「リリースミューテックスシステムコール」、「HWFコール」の3回である。このため、改良例2によれば、システムコールにともなうオーバーヘッドを1回分抑制できる。また、特殊タスクを実行する必要もない。退避レジスタに戻り値を書き込むことにより、タスクAはHWF500やタスク制御回路200に補助処理の結果を問い合わせる必要がない。   In the parallel auxiliary processing shown in relation to FIG. 40, a total of four system calls have been issued. On the other hand, the number of system calls of the parallel type auxiliary processing in the improved example 2 is “wait mutex system call”, “release mutex system call”, and “HWF call”. For this reason, according to the improvement example 2, the overhead accompanying a system call can be suppressed by one time. Also, there is no need to execute special tasks. By writing the return value in the save register, the task A does not need to inquire the result of the auxiliary processing to the HWF 500 or the task control circuit 200.

従来、OSをはじめとするソフトウェアを高速実行するためにさまざまな方法が試みられてきた。こういった試みは、CPUクロック数の増加、メモリ容量やレジスタ容量の増加、あるいは、複数のCPUによる並列処理、更には、ネットワーク分散処理といった大規模化・複雑化を指向することが多い。
これに対して、本実施例に示したタスク処理装置100の場合、既存のCPU150に退避回路120やタスク制御回路200を追加することにより、処理効率を飛躍的に向上させている。ソフトウェアOSの場合、本来実行したいタスクスイッチ等の処理を実現するために、TCBやタスクレディリストの管理といった付随的処理を実行せざるを得ない。これに対して、タスク処理装置100は、タスクスイッチやタスクの状態管理、割り込み処理をハードウェア・ロジックにより実現しているため、このようなソフトウェア特有のオーバーヘッドから解放されている。このため、消費電力やコストの増加を抑制しつつ高速化を実現するという理想的なシステムとなっている。
Conventionally, various methods have been attempted to execute software such as an OS at high speed. Such attempts are often directed to increase in scale and complexity such as increase in the number of CPU clocks, increase in memory capacity and register capacity, parallel processing by a plurality of CPUs, and further, network distributed processing.
On the other hand, in the case of the task processing device 100 shown in the present embodiment, the processing efficiency is dramatically improved by adding the save circuit 120 and the task control circuit 200 to the existing CPU 150. In the case of the software OS, in order to realize processing such as a task switch that is originally desired to be executed, incidental processing such as management of TCB and task ready list must be executed. On the other hand, the task processing apparatus 100 is freed from such software-specific overhead because the task switch, task state management, and interrupt processing are realized by hardware logic. For this reason, it is an ideal system that realizes high speed while suppressing increase in power consumption and cost.

更に、改良例2に示した補助処理制御によれば、補助処理にともなうオーバーヘッドを大きく抑制できる。従来、DMA転送などの補助処理を高速実行するため、ソフトウェアOSを介さずに、直接HWF500の内蔵レジスタを操作するプログラムが提供されることも多かった。しかし、このようなプログラムに不具合が発生すると、システム全体の挙動が不安定となってしまう。   Furthermore, according to the auxiliary process control shown in the improved example 2, the overhead associated with the auxiliary process can be greatly suppressed. Conventionally, in order to execute auxiliary processing such as DMA transfer at high speed, a program for directly operating a built-in register of the HWF 500 is often provided without using a software OS. However, if a problem occurs in such a program, the behavior of the entire system becomes unstable.

改良例2のタスク処理装置100においては、タスクがHWF500を直接操作することは物理的にできない構成となっている。タスク処理装置100自体の高速処理性能やシステムコール回数の減少等により、タスクがタスク処理装置100に補助処理を依頼する構成であっても、高速な補助処理を実現できる。改良例2のタスク処理装置100によれば補助処理制御における安全性と高速化を両立させることができる。   The task processing apparatus 100 of the improved example 2 has a configuration in which a task cannot physically operate the HWF 500 directly. Even if the task requests the task processing device 100 for auxiliary processing due to the high-speed processing performance of the task processing device 100 itself, a reduction in the number of system calls, etc., high-speed auxiliary processing can be realized. According to the task processing apparatus 100 of the improved example 2, it is possible to achieve both safety and speedup in the auxiliary process control.

以上、本発明について実施例をもとに説明した。実施の形態は例示であり、それらの各構成要素や各処理プロセスの組合せにいろいろな変形例が可能なこと、またそうした変形例も本発明の範囲にあることは当業者に理解されるところである。   The present invention has been described based on the embodiments. The embodiments are exemplifications, and it will be understood by those skilled in the art that various modifications can be made to combinations of the respective constituent elements and processing processes, and such modifications are within the scope of the present invention. .

請求項に記載の各構成要件が果たすべき機能は、本実施例において示された各機能ブロックの単体もしくはそれらの連係によって実現されることも当業者には理解されるところである。   It should also be understood by those skilled in the art that the functions to be fulfilled by the constituent elements recited in the claims are realized by the individual functional blocks shown in the present embodiment or their linkage.

なお、図12、図14、図28、図32に関連して、さまざまな判定回路について説明した。これらの判定回路は、比較回路群により比較・選択の対象となるタスクを選ぶ。
たとえば、図12の実行選択回路232は、RUN−タスクを選択するための回路であるが、RUN−タスクとなることができるのはREADY−タスクである。そこで、図12の判定回路296は、READY−タスクであることを条件として、CID信号「1」を出力する。実行選択回路232の比較回路群は、CID信号「1」となるタスク、すなわち、READY状態のタスクだけを対象として、タスク優先順位PRやREADY経過時間TIMに基づいて、次のRUN−タスクを選択する。
Various determination circuits have been described with reference to FIGS. 12, 14, 28, and 32. These determination circuits select a task to be compared and selected by a comparison circuit group.
For example, the execution selection circuit 232 in FIG. 12 is a circuit for selecting a RUN-task, but a RUN-task can be a READY-task. Therefore, the determination circuit 296 in FIG. 12 outputs the CID signal “1” on condition that the task is a READY-task. The comparison circuit group of the execution selection circuit 232 selects the next RUN-task based on the task priority order PR and the READY elapsed time TIM only for the task having the CID signal “1”, that is, the task in the READY state. To do.

図14のセマフォ選択回路234は、セマフォ解放時において、セマフォ待ちを解除されるべきタスクを選択するための回路である。セマフォ待ちを解除されるタスクは、解放セマフォを待機セマフォとしてWAIT状態にあるタスクである。そこで、図14の判定回路306は、解放セマフォを待機セマフォとするWAIT−タスクであることを条件として、CID信号「1」を出力する。セマフォ選択回路234の比較回路群は、CID信号「1」となるタスク、すなわち、「解放セマフォを待機セマフォとするWAIT−タスク」だけを対象として、タスク優先順位PRやWAIT経過時間TIMに基づいて、セマフォ待ちを解除されるべきタスクを選択する。   The semaphore selection circuit 234 in FIG. 14 is a circuit for selecting a task whose semaphore wait should be released when releasing the semaphore. The task whose semaphore wait is released is a task in the WAIT state with the released semaphore as a standby semaphore. Therefore, the determination circuit 306 in FIG. 14 outputs the CID signal “1” on condition that the WAIT-task has the release semaphore as a standby semaphore. The comparison circuit group of the semaphore selection circuit 234 is based on the task priority order PR and the WAIT elapsed time TIM only for the task for which the CID signal is “1”, that is, “WAIT-task with the released semaphore as a standby semaphore”. Select a task to be released from waiting for a semaphore.

判定回路のロジックを変更すれば、実行選択回路232とセマフォ選択回路234は比較回路群を共有可能である。ミューテックスやイベントについても同様である。図28の最大値選択回路406や、図32のタスク選択回路230についても同様である。このように、判定回路のロジックを追加・変更すれば、比較回路群を共有したかたちで、さまざまな選択論理を実装できる。以下、2例を挙げる。   If the logic of the determination circuit is changed, the execution selection circuit 232 and the semaphore selection circuit 234 can share the comparison circuit group. The same applies to mutexes and events. The same applies to the maximum value selection circuit 406 in FIG. 28 and the task selection circuit 230 in FIG. In this way, by adding / changing the logic of the determination circuit, various selection logics can be implemented in the form of sharing the comparison circuit group. Here are two examples.

1.ローテートシステムコール
このシステムコールは、READY状態に対応づけられる仮想キューのタスク群、すなわち、READY−タスクの順序値(ODR)を変更するためのシステムコールである。たとえば、図29に示したように、READY状態に対応づけられる仮想キュー(Q0)に、タスク(E6)、タスク(E3)、タスク(E2)、タスク(E0)、タスク(E5)の順に5つのタスクが投入されているとする。ここで、RUN−タスクが、タスク優先順位PR=1を指定してローテートシステムコールを発行したとする。
すると、PR=1に対応づけられる優先キュー(Q0:1)の先頭にあるタスク(E6)がいったん取り出され、タスク(E5)の後ろに順投入される。すなわち、タスク(E6)の順序値(ODR)は「0」となり、他のタスクの順序値もそれにあわせて調整される。
ローテートシステムコールは、パラメータにより指定されたタスク優先順位PR=1に対応づけられる優先キュー(Q0:1)について、先頭のタスクの順序を最後尾に変更するためのシステムコールである。ローテートシステムコールによれば、仮想キュー(Q0)に投入されているタスクの順序値(ODR)を外部からコントロールできる。
1. Rotate system call This system call is a system call for changing the task group of the virtual queue associated with the READY state, that is, the READY-task order value (ODR). For example, as shown in FIG. 29, in the virtual queue (Q0) associated with the READY state, the task (E6), the task (E3), the task (E2), the task (E0), and the task (E5) are in this order. Assume that one task is submitted. Here, it is assumed that the RUN-task issues a rotate system call with the task priority PR = 1 specified.
Then, the task (E6) at the head of the priority queue (Q0: 1) associated with PR = 1 is once taken out and sequentially inserted behind the task (E5). That is, the order value (ODR) of the task (E6) is “0”, and the order values of other tasks are adjusted accordingly.
The rotate system call is a system call for changing the order of the first task to the last for the priority queue (Q0: 1) associated with the task priority PR = 1 specified by the parameter. According to the rotate system call, the order value (ODR) of the task put in the virtual queue (Q0) can be controlled from the outside.

ローテートシステムコールを実現するための判定回路は、「READY状態であって、かつ、指定されたタスク優先順位PRのタスク」であることを条件として「1」を出力すればよい。あとは、比較回路群により、判定回路の出力信号が「1」となる該当タスクの中から、順序値(ODR)が最も大きいタスクをローテーションの対象として選択すればよい。   The determination circuit for realizing the rotate system call may output “1” on condition that “the task is in the READY state and has the designated task priority PR”. After that, the task having the largest order value (ODR) may be selected as a rotation target from among the corresponding tasks for which the output signal of the determination circuit is “1” by the comparison circuit group.

2.WAIT状態に対応づけられる仮想キューについての機能拡張
通常、あるセマフォが解放されたとき、セマフォ待ちに対応づけられる仮想キュー(Qn)において、タスク優先順位PRが最も高い優先キュー(Qn:Pn)の中から、このセマフォを獲得すべきタスクが選択される。しかし、タスク優先順位PRに関わらず、もっとも順序値(ODR)が大きなタスクにより獲得されるべき特殊なセマフォ(以下、「特殊セマフォ」とよぶ)を設定してもよい。
2. Function expansion for virtual queue associated with WAIT state Normally, when a semaphore is released, the priority queue (Qn: Pn) having the highest task priority PR in the virtual queue (Qn) associated with semaphore waiting The task from which this semaphore is to be acquired is selected. However, regardless of the task priority order PR, a special semaphore (hereinafter referred to as “special semaphore”) to be acquired by a task having the largest order value (ODR) may be set.

特殊セマフォを実装するために、「WAIT状態であって、かつ、解放セマフォを待機セマフォとするタスク」であるときに、「1」を出力する判定回路を用意すればよい。図32の判定回路434は、QID_S、CNDが入力され、EID_EN信号を出力する回路である。これを変更し、QID_S、CNDに加えてタスク優先順位PR_Sが入力され、EID_ENとPR_Aを出力する判定回路を想定する。この判定回路は、特殊セマフォの解放時においてはPR_Aに所定値xを出力し、通常のセマフォの解放時においてはPR_AとしてPR_Sをそのまま出力する。このため、比較回路群は、特殊セマフォ解放時においては、各タスクのタスク優先順位PRは、すべて所定値xであると認識することになる。結果として、比較回路群は、各タスクのタスク優先順位PRに関わらず、判定回路の出力信号が「1」となる該当タスクの中から、順序値(ODR)が最も小さなタスクを選択することになる。   In order to implement a special semaphore, a determination circuit that outputs “1” when a “task is in a WAIT state and a release semaphore is a standby semaphore” may be prepared. The determination circuit 434 in FIG. 32 is a circuit that receives QID_S and CND and outputs an EID_EN signal. This is changed, and a determination circuit is assumed that receives task priority PR_S in addition to QID_S and CND, and outputs EID_EN and PR_A. This determination circuit outputs a predetermined value x to PR_A when the special semaphore is released, and outputs PR_S as it is as PR_A when the normal semaphore is released. For this reason, the comparison circuit group recognizes that the task priority order PR of each task is the predetermined value x when the special semaphore is released. As a result, the comparison circuit group selects the task having the smallest order value (ODR) from the corresponding tasks for which the output signal of the determination circuit is “1” regardless of the task priority order PR of each task. Become.

以上の実施の形態および変形例から把握される発明のいろいろな態様をすでに特許請求の範囲に記載したものも含む形にて以下に例示する。改良例1に関連し、以下の発明が認識される。   Various aspects of the invention grasped from the above embodiments and modifications will be exemplified below in the form including those already described in the claims. In connection with the improved example 1, the following invention is recognized.

C1.キューIDにより識別される複数種類の仮想キューに対して、要素IDにより識別される複数個の要素の投入と抽出を制御するキュー制御回路と、
各要素に対応して設けられるレジスタであって、投入先となる仮想キューのキューIDと投入順位を示す順序値とを対応づけて保持する複数のキューレジスタと、を備え、
前記キュー制御回路は、
要素IDおよびキューIDを指定する順投入コマンドが入力されるとき、前記指定された要素IDの該当キューレジスタに対して、前記指定されたキューIDに対応する仮想キューの末尾への投入であることを示す末尾順序値と前記指定されたキューIDを設定し、
要素IDおよびキューIDを指定する逆投入コマンドが入力されるとき、前記指定された要素IDの該当キューレジスタに対して、前記指定されたキューIDに対応する仮想キューの先頭への投入であることを示す先頭順序値と前記指定されたキューIDを設定し、
キューIDを指定する抽出コマンドが入力されるとき、前記指定されたキューIDおよび先頭順序値を保持するキューレジスタからキューIDをクリアして該当要素を抽出対象とすることにより、各キューレジスタの設定情報に基づいて前記複数種類の仮想キューを管理することを特徴とする仮想キュー処理回路。
C1. A queue control circuit that controls input and extraction of a plurality of elements identified by an element ID for a plurality of types of virtual queues identified by a queue ID;
A register provided corresponding to each element, and includes a plurality of queue registers that associate and hold a queue ID of a virtual queue to be input and an order value indicating the input order,
The queue control circuit includes:
When a sequential input command for specifying an element ID and a queue ID is input, the input to the end of the virtual queue corresponding to the specified queue ID is performed for the corresponding queue register of the specified element ID. Set the end order value indicating the and the specified queue ID,
When a reverse submission command specifying an element ID and a queue ID is input, the input to the corresponding queue register of the specified element ID is input to the head of the virtual queue corresponding to the specified queue ID Set the head order value indicating the above and the specified queue ID,
When an extraction command for specifying a queue ID is input, the queue ID is cleared from the queue register holding the specified queue ID and the head order value, and the corresponding element is set as an extraction target. A virtual queue processing circuit that manages the plurality of types of virtual queues based on information.

C2.前記キュー制御回路は、前記順投入コマンドまたは前記逆投入コマンドのいずれかが入力されるときには、コマンドにより指定されたキューIDを保持する他のキューレジスタの順序値を調整することを特徴とするC1に記載の仮想キュー処理回路。   C2. The queue control circuit adjusts an order value of another queue register that holds a queue ID specified by a command when either the forward input command or the reverse input command is input. The virtual queue processing circuit according to 1.

C3.キューIDが指定されるとき、前記複数のキューレジスタからパラレルに出力されるキューIDと順序値を参照して、前記指定されたキューIDおよび先頭順序値に対応する要素IDを出力する抽出候補回路、を更に備え、
前記キュー制御回路は、前記抽出候補回路から出力された要素IDの該当キューレジスタからキューIDをクリアすることを特徴とするC3に記載の仮想キュー処理回路。
C3. An extraction candidate circuit for outputting an element ID corresponding to the designated queue ID and head order value with reference to the queue ID and order value output in parallel from the plurality of queue registers when the queue ID is designated Further comprising
The virtual queue processing circuit according to C3, wherein the queue control circuit clears the queue ID from the corresponding queue register of the element ID output from the extraction candidate circuit.

C4.仮想キューは、更に、抽出の優先度に応じて複数の優先キューの集合として定義され、
前記キューレジスタは、優先キューを特定するための優先度も保持し、
前記キュー制御回路は、
要素IDおよびキューIDに加えて優先度を指定する順投入コマンドが入力されるとき、前記指定された要素IDの該当キューレジスタに対して、前記指定された優先度も設定し、
要素IDおよびキューIDに加えて優先度を指定する逆投入コマンドが入力されるとき、前記指定された要素IDの該当キューレジスタに対して、前記指定された優先度も設定し、
キューIDを指定する抽出コマンドが入力されるとき、前記指定されたキューIDを保持し、そのうち最も高い優先度が設定され、かつ、そのうち最も先頭に近い順序値を設定されているキューレジスタからキューIDをクリアすることを特徴とするC1に記載の仮想キュー処理回路。
C4. A virtual queue is further defined as a set of multiple priority queues depending on the priority of extraction,
The queue register also holds a priority for identifying a priority queue,
The queue control circuit includes:
When a sequential input command specifying a priority in addition to an element ID and a queue ID is input, the specified priority is also set for the corresponding queue register of the specified element ID,
When a reverse input command specifying a priority in addition to an element ID and a queue ID is input, the specified priority is also set for the corresponding queue register of the specified element ID,
When an extraction command that specifies a queue ID is input, the queue is held from the queue register that holds the specified queue ID, has the highest priority among them, and has the order value closest to the head. The virtual queue processing circuit according to C1, wherein ID is cleared.

C5.前記キュー制御回路は、キューIDを指定する前記抽出コマンドが入力されるときには、前記指定されたキューIDを保持する他のキューレジスタの順序値を調整することを特徴とするC4に記載の仮想キュー処理回路。   C5. The virtual queue according to C4, wherein the queue control circuit adjusts an order value of another queue register holding the designated queue ID when the extraction command designating the queue ID is input. Processing circuit.

C6.キューIDが指定されるとき、前記複数のキューレジスタからパラレルに出力されるキューID、順序値および優先度に基づいて、前記指定されたキューIDを保持し、そのうち最も高い優先度が設定され、かつ、そのうち最も先頭に近い順序値を保持するキューレジスタに対応する要素IDを出力する抽出候補回路、を更に備え、
前記キュー制御回路は、前記抽出候補回路から出力された要素IDの該当キューレジスタからキューIDをクリアすることを特徴とするC5に記載の仮想キュー処理回路。
C6. When a queue ID is designated, based on the queue ID, order value and priority output in parallel from the plurality of queue registers, the designated queue ID is held, and the highest priority is set among them. And an extraction candidate circuit that outputs an element ID corresponding to a queue register that holds an order value closest to the top of the order values,
The virtual queue processing circuit according to C5, wherein the queue control circuit clears the queue ID from the corresponding queue register of the element ID output from the extraction candidate circuit.

C7.タスク実行のためのデータを一時的に保持する処理レジスタと、
命令(instruction)およびオペランドをメモリから前記処理レジスタにロードし、前記処理レジスタの命令とオペランドにしたがってタスクを実行する実行制御回路と、
タスクスケジューリングのための状態データを保持するレジスタであって、複数のタスクに対してそれぞれ対応づけられる複数の状態レジスタと、
タスクの実行状態に対応づけられる複数種類の仮想キューに対して、タスクIDにより識別される複数個のタスクの投入と抽出を制御することにより、タスクの実行状態を管理するタスク切換回路と、
複数の前記状態レジスタからパラレルに出力される状態データを入力として、所定の選択条件によりタスクを選択するタスク選択回路と、を備え、
前記状態レジスタは、状態データの一部として、該当タスクの実行状態に対応づけられる仮想キューのキューIDと仮想キューへの投入順位を示す順序値とを対応づけて保持し、
前記実行制御回路は、実行中の第1のタスクが所定のシステムコール命令を実行するとき、所定のシステムコール信号を前記タスク切換回路に送信し、
前記タスク選択回路は、READY(レディ)状態に対応する仮想キューであるレディキューのキューIDおよび前記レディキューの先頭位置を示す先頭順序値を保持する状態レジスタを特定し、前記特定した状態レジスタに対応する第2のタスクを次の実行対象として選択し、
前記タスク切換回路は、前記システムコール信号を受信するとき、前記第2のタスクの状態レジスタからキューIDをクリアし、前記第1のタスクの状態レジスタに対して、RUN(ラン)状態とは異なる別の実行状態に対応づけられる仮想キューのキューIDと順序値を設定し、前記処理レジスタのデータを所定の記憶領域に退避させると共に、前記第2のタスクについて前記記憶領域に退避されていたデータを前記処理レジスタにロードすることを特徴とするタスク制御装置。
C7. A processing register that temporarily holds data for task execution;
An execution control circuit for loading instructions and operands from memory into the processing register and executing a task in accordance with the instructions and operands of the processing register;
A register for holding state data for task scheduling, a plurality of state registers respectively associated with a plurality of tasks,
A task switching circuit that manages the task execution state by controlling the input and extraction of a plurality of tasks identified by a task ID for a plurality of types of virtual queues associated with the task execution state;
A task selection circuit for selecting a task according to a predetermined selection condition, with status data output in parallel from the plurality of status registers as an input; and
The status register holds, as a part of the status data, the queue ID of the virtual queue associated with the execution state of the corresponding task and the order value indicating the order of entry into the virtual queue in association with each other,
When the first task being executed executes a predetermined system call instruction, the execution control circuit transmits a predetermined system call signal to the task switching circuit,
The task selection circuit specifies a status register that holds a queue ID of a ready queue that is a virtual queue corresponding to a READY (ready) state and a head order value indicating a head position of the ready queue, and stores the status register in the specified status register. Select the corresponding second task as the next execution target,
When the task switching circuit receives the system call signal, the task switching circuit clears the queue ID from the state register of the second task, and is different from the RUN state with respect to the state register of the first task. The queue ID and order value of a virtual queue associated with another execution state are set, and the data in the processing register is saved in a predetermined storage area, and the data saved in the storage area for the second task Is loaded into the processing register.

C8.前記タスク切換回路は、前記第1のタスクを前記別の実行状態としてREADY状態に移行させるときには、前記第1のタスクの状態レジスタに対して前記レディキューのキューIDと先頭順序値を設定することを特徴とするC7に記載のタスク制御装置。   C8. When the task switching circuit shifts the first task to the READY state as the other execution state, the task switching circuit sets a queue ID and a head order value of the ready queue in the state register of the first task. The task control device according to C7, characterized by:

C9.前記タスク選択回路は、WAIT(ウェイト)解除条件の成立待機状態であるWAIT状態に対応づけられる仮想キューとしてウェイトキューが設定される場合において、前記WAIT解除条件が成立するとき、前記ウェイトキューのキューIDと先頭順序値を保持する状態レジスタに該当するタスクを選択し、
前記タスク切換回路は、前記選択されたタスクの状態レジスタに対して、レディキューのキューIDと前記レディキューの末尾への投入を示す末尾順序値を設定することを特徴とするC7に記載のタスク制御装置。
C9. The task selection circuit, when a wait queue is set as a virtual queue associated with a WAIT state that is a waiting state for establishing a WAIT (wait) release condition, when the WAIT release condition is satisfied, Select the task corresponding to the status register that holds the ID and head sequence value,
The task switching circuit according to C7, wherein the task switching circuit sets, for the status register of the selected task, a queue ID of a ready queue and a tail order value indicating insertion at the tail of the ready queue. Control device.

C10.前記状態レジスタは、状態データの一部としてタスク優先度を保持し、
前記タスク選択回路は、タスク切り換えに際してレディキューのキューIDを設定されているタスクが複数あるときには、それらのうち最も高いタスク優先度を設定され、かつ、それらのうち最も先頭に近い順序値を設定されているタスクを実行対象として選択することを特徴とするC7に記載のタスク処理装置。
C10. The status register holds task priority as part of the status data,
When there are a plurality of tasks for which the queue ID of the ready queue is set at the time of task switching, the task selection circuit sets the highest task priority among them and sets the order value closest to the top of them. The task processing device according to C7, wherein the task being selected is selected as an execution target.

本発明によれば、マルチタスク処理において、より効率的なタスクの実行制御が実現される。   According to the present invention, more efficient task execution control is realized in multitask processing.

Claims (13)

タスク実行のためのデータを一時的に保持する処理レジスタと、
命令(instruction)およびオペランドをメモリから前記処理レジスタにロードし、前記処理レジスタの命令とオペランドにしたがってタスクを実行する実行制御回路と、
タスクの実行状態を示す状態データを保持する状態レジスタと、
タスクの実行状態を制御するタスク切換回路と、
前記状態データに基づいて、所定の選択条件によりタスクを選択するタスク選択回路と、
前記タスク切換回路と信号線を介して接続され、タスクの一部として所定の補助処理を実行する補助処理回路と、を備え、
前記実行制御回路は、所定のシステムコール命令を実行するとき、所定のシステムコール信号を前記タスク切換回路に送信し、
前記タスク選択回路は、実行可能に待機している状態を示すREADY(レディ)状態のタスクの中から次の実行対象となるタスクを選択し、
前記タスク切換回路は、前記システムコール信号を受信したときの前記タスク選択回路からの出力により次の実行対象となるタスクを選択し、前記処理レジスタのデータを所定の記憶領域に退避させるとともに、実行中のタスクについての状態データをタスク実行中を示すRUN(ラン)状態から別の状態に設定変更し、選択したタスクについて前記記憶領域に退避されていたデータを前記処理レジスタにロードするとともにそのタスクについての状態データをREADY状態からRUN状態に変更することにより、実行対象となるタスクを切り換え、
前記実行制御回路において、実行中のタスクが前記所定の補助処理を実行させるためのシステムコール命令として補助処理命令を実行するとき、
前記タスク切換回路が、前記信号線に所定の信号を送信することにより、前記補助処理回路に前記補助処理の実行を指示することを特徴とするタスク処理装置。
A processing register that temporarily holds data for task execution;
An execution control circuit for loading instructions and operands from memory into the processing register and executing a task in accordance with the instructions and operands of the processing register;
A status register that holds status data indicating the task execution status;
A task switching circuit for controlling the task execution state;
A task selection circuit for selecting a task according to a predetermined selection condition based on the state data;
An auxiliary processing circuit that is connected to the task switching circuit via a signal line and executes predetermined auxiliary processing as a part of the task,
The execution control circuit, when executing a predetermined system call instruction, transmits a predetermined system call signal to the task switching circuit,
The task selection circuit selects a task to be executed next from a task in a READY state indicating a state waiting for execution,
The task switching circuit selects a task to be executed next by an output from the task selection circuit when the system call signal is received, saves the data in the processing register to a predetermined storage area, and executes the task The status data for the current task is changed from the RUN status indicating that the task is being executed to another status, and the data saved in the storage area for the selected task is loaded into the processing register and the task By changing the state data for the from the READY state to the RUN state, the task to be executed is switched,
In the execution control circuit, when a task being executed executes an auxiliary process instruction as a system call instruction for causing the predetermined auxiliary process to be executed,
The task processing device, wherein the task switching circuit instructs the auxiliary processing circuit to execute the auxiliary processing by transmitting a predetermined signal to the signal line .
タスク実行のためのデータを一時的に保持する処理レジスタと、
命令(instruction)およびオペランドをメモリから前記処理レジスタにロードし、前記処理レジスタの命令とオペランドにしたがってタスクを実行する実行制御回路と、
タスクの実行状態を示す状態データを保持する状態レジスタと、
タスクの実行状態を制御するタスク切換回路と、
前記状態データに基づいて、所定の選択条件によりタスクを選択するタスク選択回路と、
タスクの一部として所定の補助処理を実行する補助処理回路と、を備え、
前記実行制御回路は、所定のシステムコール命令を実行するとき、所定のシステムコール信号を前記タスク切換回路に送信し、
前記タスク選択回路は、実行可能に待機している状態を示すREADY(レディ)状態のタスクの中から次の実行対象となるタスクを選択し、
前記タスク切換回路は、前記システムコール信号を受信したときの前記タスク選択回路からの出力により次の実行対象となるタスクを選択し、前記処理レジスタのデータを所定の記憶領域に退避させるとともに、実行中のタスクについての状態データをタスク実行中を示すRUN(ラン)状態から別の状態に設定変更し、選択したタスクについて前記記憶領域に退避されていたデータを前記処理レジスタにロードするとともにそのタスクについての状態データをREADY状態からRUN状態に変更することにより、実行対象となるタスクを切り換え、
前記実行制御回路において、実行中のタスクが前記所定の補助処理を実行させるためのシステムコール命令として補助処理命令を実行するとき、
前記タスク切換回路が、前記補助処理回路に前記補助処理の実行を指示し、
前記補助処理命令を実行したタスクは、前記補助処理回路から前記補助処理の完了を示す補助完了信号が前記タスク切換回路により受信されるまで前記補助処理回路を占有することを特徴とするタスク処理装置。
A processing register that temporarily holds data for task execution;
An execution control circuit for loading instructions and operands from memory into the processing register and executing a task in accordance with the instructions and operands of the processing register;
A status register that holds status data indicating the task execution status;
A task switching circuit for controlling the task execution state;
A task selection circuit for selecting a task according to a predetermined selection condition based on the state data;
An auxiliary processing circuit that executes predetermined auxiliary processing as part of a task,
The execution control circuit, when executing a predetermined system call instruction, transmits a predetermined system call signal to the task switching circuit,
The task selection circuit selects a task to be executed next from a task in a READY state indicating a state waiting for execution,
The task switching circuit selects a task to be executed next by an output from the task selection circuit when the system call signal is received, saves the data in the processing register to a predetermined storage area, and executes the task The status data for the current task is changed from the RUN status indicating that the task is being executed to another status, and the data saved in the storage area for the selected task is loaded into the processing register and the task By changing the state data for the from the READY state to the RUN state, the task to be executed is switched,
In the execution control circuit, when a task being executed executes an auxiliary process instruction as a system call instruction for causing the predetermined auxiliary process to be executed,
The task switching circuit instructs the auxiliary processing circuit to execute the auxiliary processing;
The task executing the auxiliary processing instruction occupies the auxiliary processing circuit until an auxiliary completion signal indicating completion of the auxiliary processing is received from the auxiliary processing circuit by the task switching circuit. .
タスク実行のためのデータを一時的に保持する処理レジスタと、
命令(instruction)およびオペランドをメモリから前記処理レジスタにロードし、前記処理レジスタの命令とオペランドにしたがってタスクを実行する実行制御回路と、
タスクの実行状態を示す状態データを保持する状態レジスタと、
タスクの実行状態を制御するタスク切換回路と、
前記状態データに基づいて、所定の選択条件によりタスクを選択するタスク選択回路と、
タスクの一部として所定の補助処理を実行する補助処理回路と、を備え、
前記実行制御回路は、所定のシステムコール命令を実行するとき、所定のシステムコール信号を前記タスク切換回路に送信し、
前記タスク選択回路は、実行可能に待機している状態を示すREADY(レディ)状態のタスクの中から次の実行対象となるタスクを選択し、
前記タスク切換回路は、前記システムコール信号を受信したときの前記タスク選択回路からの出力により次の実行対象となるタスクを選択し、前記処理レジスタのデータを所定の記憶領域に退避させるとともに、実行中のタスクについての状態データをタスク実行中を示すRUN(ラン)状態から別の状態に設定変更し、選択したタスクについて前記記憶領域に退避されていたデータを前記処理レジスタにロードするとともにそのタスクについての状態データをREADY状態からRUN状態に変更することにより、実行対象となるタスクを切り換え、
前記実行制御回路において、実行中の第1のタスクが前記所定の補助処理を実行させるためのシステムコール命令として補助処理命令を実行するとき、
前記タスク切換回路が、前記補助処理回路に前記補助処理の実行を指示し、前記補助処理命令を実行した第1のタスクの前記補助処理回路に対する占有権を設定した上で前記第1のタスクとは異なる第2のタスクをRUN状態に設定し、前記補助処理回路から前記補助処理の完了を示す補助完了信号が受信されたことを条件として、前記第1のタスクの占有権を解除することを特徴とするタスク処理装置。
A processing register that temporarily holds data for task execution;
An execution control circuit for loading instructions and operands from memory into the processing register and executing a task in accordance with the instructions and operands of the processing register;
A status register that holds status data indicating the task execution status;
A task switching circuit for controlling the task execution state;
A task selection circuit for selecting a task according to a predetermined selection condition based on the state data;
An auxiliary processing circuit that executes predetermined auxiliary processing as part of a task,
The execution control circuit, when executing a predetermined system call instruction, transmits a predetermined system call signal to the task switching circuit,
The task selection circuit selects a task to be executed next from a task in a READY state indicating a state waiting for execution,
The task switching circuit selects a task to be executed next by an output from the task selection circuit when the system call signal is received, saves the data in the processing register to a predetermined storage area, and executes the task The status data for the current task is changed from the RUN status indicating that the task is being executed to another status, and the data saved in the storage area for the selected task is loaded into the processing register and the task By changing the state data for the from the READY state to the RUN state, the task to be executed is switched,
In the execution control circuit, when the first task being executed executes an auxiliary processing instruction as a system call instruction for causing the predetermined auxiliary processing to be executed,
The task switching circuit instructs the auxiliary processing circuit to execute the auxiliary processing, sets an occupation right for the auxiliary processing circuit of the first task that has executed the auxiliary processing instruction, and the first task and Sets a different second task to the RUN state, and releases the occupation right of the first task on condition that an auxiliary completion signal indicating completion of the auxiliary processing is received from the auxiliary processing circuit. A featured task processing device.
前記タスク切換回路は、前記補助処理の実行指示に際し、前記補助処理命令を実行した第1のタスクの前記補助処理回路に対する占有権を設定した上で前記第1のタスクとは異なる第2のタスクをRUN状態に設定し、前記補助処理回路から前記補助処理の完了を示す補助完了信号が受信されたことを条件として、前記第1のタスクの占有権を解除することを特徴とする請求項1または2に記載のタスク処理装置。The task switching circuit sets an occupation right for the auxiliary processing circuit of the first task that has executed the auxiliary processing instruction when instructing execution of the auxiliary processing, and is different from the first task. It was set to RUN state, claim 1, wherein the condition that the auxiliary completion signal indicating completion of the auxiliary processing from the auxiliary processing circuit is received, and cancels the exclusive rights of the first task Or the task processing apparatus of 2. 前記実行制御回路において、前記第1のタスクは前記補助処理回路の占有を要求するためのシステムコール命令として占有要求命令を実行し、
前記タスク切換回路は、前記補助処理回路について他のタスクによる占有権が設定されていないことを条件として前記第1のタスクの前記補助処理回路に対する占有権を設定し、
前記実行制御回路において、前記第1のタスクは、前記補助処理回路の占有権取得に成功したことを条件として前記補助処理命令を実行することを特徴とする請求項3または4に記載のタスク処理装置。
In the execution control circuit, the first task executes an occupation request instruction as a system call instruction for requesting the occupation of the auxiliary processing circuit,
The task switching circuit sets an occupation right for the auxiliary processing circuit of the first task on the condition that no occupation right by another task is set for the auxiliary processing circuit,
5. The task processing according to claim 3 , wherein in the execution control circuit, the first task executes the auxiliary processing instruction on the condition that acquisition of the occupation right of the auxiliary processing circuit is successful. apparatus.
前記タスク切換回路は、前記補助処理命令を実行した第1のタスクの状態レジスタに所定のデータを記録することにより、前記第1のタスクが前記補助処理回路の処理完了を待機中である旨を設定し、
前記タスク選択回路は、前記状態レジスタにおいて前記所定のデータを記録されているタスクを前記タスク切換回路に通知し、
前記タスク切換回路は、前記補助処理回路から前記補助処理の完了を示す補助完了信号が受信されたとき、前記タスク選択回路から通知された前記第1のタスクを再度RUN状態に設定することを特徴とする請求項1から3のいずれかに記載のタスク処理装置。
The task switching circuit records predetermined data in the status register of the first task that has executed the auxiliary processing instruction, thereby indicating that the first task is waiting for completion of processing of the auxiliary processing circuit. Set,
The task selection circuit notifies the task switching circuit of a task in which the predetermined data is recorded in the status register,
The task switching circuit sets the first task notified from the task selection circuit to the RUN state again when an auxiliary completion signal indicating completion of the auxiliary processing is received from the auxiliary processing circuit. The task processing device according to claim 1 .
前記補助処理回路は、複数種類の補助処理それぞれに対応して複数個設けられ、
前記実行制御回路において、実行中のタスクが補助処理の種類をパラメータとして前記補助処理命令を実行するとき、
前記タスク切換回路は、複数の補助処理回路のうちパラメータとして指定された補助処理に対応する補助処理回路を選択し、前記選択した補助処理回路に前記補助処理の実行を指示することを特徴とする請求項1から3のいずれかに記載のタスク処理装置。
A plurality of auxiliary processing circuits are provided corresponding to each of a plurality of types of auxiliary processing,
In the execution control circuit, when the task being executed executes the auxiliary processing instruction with the type of auxiliary processing as a parameter,
The task switching circuit selects an auxiliary processing circuit corresponding to an auxiliary process specified as a parameter from a plurality of auxiliary processing circuits, and instructs the selected auxiliary processing circuit to execute the auxiliary process. The task processing device according to claim 1 .
前記タスク切換回路は、前記補助処理回路の選択に際し、前記補助処理命令を実行したタスクの状態レジスタに対して前記選択した補助処理回路を一意に識別する補助処理IDを記録することにより、前記補助処理命令を実行したタスクが前記選択した補助処理回路
の処理完了を待機中である旨を設定し、前記選択した補助処理回路から前記補助処理の完了を示す補助完了信号が受信されたときには前記選択した補助処理回路の補助処理IDを前記タスク選択回路に通知し、
前記タスク選択回路は、前記通知された補助処理IDが記録されているタスクを選択し、
前記タスク切換回路は、前記補助完了信号が受信されたとき、前記選択されたタスクを再度RUN状態に設定することを特徴とする請求項7に記載のタスク処理装置。
When selecting the auxiliary processing circuit, the task switching circuit records an auxiliary processing ID for uniquely identifying the selected auxiliary processing circuit in a status register of a task that has executed the auxiliary processing instruction. The task that executed the processing instruction is set to wait for the completion of the processing of the selected auxiliary processing circuit, and when the auxiliary completion signal indicating the completion of the auxiliary processing is received from the selected auxiliary processing circuit, the selection is performed. Notifies the task selection circuit of the auxiliary processing ID of the auxiliary processing circuit,
The task selection circuit selects a task in which the notified auxiliary process ID is recorded,
8. The task processing device according to claim 7, wherein the task switching circuit sets the selected task to the RUN state again when the auxiliary completion signal is received.
前記処理レジスタのデータを退避させるためのレジスタであって、複数のタスクに対してそれぞれ対応づけられる複数の退避レジスタ、を更に備え、
前記タスク切換回路は、前記所定のシステムコール信号を受信すると、実行中のタスクに対応づけられている前記退避レジスタに前記処理レジスタのデータを退避させ、次の実行対象となるタスクに対応づけられている前記退避レジスタのデータを前記処理レジスタにロードすることを特徴とする請求項1から3のいずれかに記載のタスク処理装置。
A register for saving data of the processing register, further comprising a plurality of save registers respectively associated with a plurality of tasks;
When the task switching circuit receives the predetermined system call signal, the task switching circuit saves the data in the processing register in the save register associated with the task being executed, and is associated with the next task to be executed. The task processing apparatus according to claim 1 , wherein data in the save register is loaded into the processing register.
前記タスク切換回路は、前記補助処理回路から前記補助処理の完了を示す補助完了信号の受信に際して、前記補助処理の結果を示す戻り値を前記補助処理回路から取得し、前記補助処理命令を実行したタスクの退避レジスタに前記戻り値を書き込むことにより前記補助処理の結果を前記補助処理命令を実行したタスクに通知することを特徴とする請求項9に記載のタスク処理装置。The task switching circuit, when receiving an auxiliary completion signal indicating completion of the auxiliary processing from the auxiliary processing circuit, acquires a return value indicating the result of the auxiliary processing from the auxiliary processing circuit and executes the auxiliary processing instruction The task processing apparatus according to claim 9, wherein the return value is written to a task saving register to notify the result of the auxiliary processing to a task that has executed the auxiliary processing instruction. 前記タスク切換回路は、前記補助処理回路から前記補助処理の完了を示す補助完了信号を受信したときには、前記補助処理命令を実行したタスクを再度RUN状態に設定することを特徴とする請求項1から3のいずれかに記載のタスク処理装置。The task switching circuit, upon receiving an auxiliary completion signal indicating completion of the auxiliary processing from the auxiliary processing circuit, the claim 1, characterized in that to set the auxiliary processing instruction again RUN state and the task execution the 4. The task processing device according to any one of 3 . 前記タスク切換回路は、前記補助処理回路から前記補助処理の完了を示す補助完了信号が受信されたことを条件として次の実行対象となるタスクを選択してRUN状態に設定することにより、前記補助処理の実行中に前記実行制御回路においてタスクが実行されるのを抑止することを特徴とする請求項1から3のいずれかに記載のタスク処理装置。The task switching circuit selects the task to be executed next on the condition that an auxiliary completion signal indicating completion of the auxiliary processing is received from the auxiliary processing circuit, and sets the task to the RUN state. 4. The task processing apparatus according to claim 1 , wherein a task is prevented from being executed in the execution control circuit during execution of processing. 前記タスク切換回路は、前記補助処理命令が実行されるとき、前記実行制御回路に対して停止要求信号を送信し、
前記実行制御回路は、前記停止要求信号を受信するとタスクの実行プロセスを進めるための実行用クロックを供給停止させることにより、前記補助処理命令を実行したタスクの実行プロセスを一時停止させ、
前記タスク切換回路は、前記補助完了信号が受信されるとき、前記実行制御回路に対して停止解除信号を送信し、
前記実行制御回路は、前記停止解除信号を受信すると前記実行用クロックの供給停止を解除させることにより、前記補助処理命令を実行したタスクの実行プロセスを再開させることを特徴とする請求項12に記載のタスク処理装置。
The task switching circuit transmits a stop request signal to the execution control circuit when the auxiliary processing instruction is executed,
The execution control circuit, upon receiving the stop request signal, temporarily stops the execution process of the task that executed the auxiliary processing instruction by stopping the supply of an execution clock for advancing the execution process of the task,
The task switching circuit transmits a stop release signal to the execution control circuit when the auxiliary completion signal is received,
The execution control circuit, by which the releasing and receiving a stop release signal supply stop of the execution clock, according to claim 12, characterized in that to resume the execution process of the task that has executed the auxiliary processing instruction task processing apparatus.
JP2009549892A 2008-01-15 2008-01-15 Task processing device Active JP5155336B2 (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2008/000026 WO2009090684A1 (en) 2008-01-15 2008-01-15 Task processor

Publications (2)

Publication Number Publication Date
JPWO2009090684A1 JPWO2009090684A1 (en) 2011-05-26
JP5155336B2 true JP5155336B2 (en) 2013-03-06

Family

ID=40885097

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2009549892A Active JP5155336B2 (en) 2008-01-15 2008-01-15 Task processing device

Country Status (3)

Country Link
JP (1) JP5155336B2 (en)
TW (1) TWI476696B (en)
WO (1) WO2009090684A1 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012173870A (en) 2011-02-18 2012-09-10 Toshiba Corp Semiconductor device and memory protection method
EP2710849A1 (en) 2011-05-20 2014-03-26 Apple Inc. Apparatus and methods for optimizing scheduled operations in hybrid network environments
EP2710850B1 (en) 2011-05-20 2020-06-17 Apple Inc. Apparatus and method for priority based task scheduling in hybrid network operation
EP2857968B1 (en) * 2012-05-24 2023-07-05 Renesas Electronics Corporation Task processor
JP2017037370A (en) 2015-08-06 2017-02-16 富士通株式会社 Computing device, process control method and process control program
JP2017123190A (en) * 2017-03-08 2017-07-13 ルネサスエレクトロニクス株式会社 Task processing device
JP2018180768A (en) * 2017-04-07 2018-11-15 ルネサスエレクトロニクス株式会社 Semiconductor device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1139171A (en) * 1997-07-18 1999-02-12 Masaharu Imai Multitask processor, multitask processing control method and control program storing medium
JP2003263329A (en) * 2002-03-08 2003-09-19 Oki Electric Ind Co Ltd Task scheduler
JP2005346708A (en) * 2004-05-26 2005-12-15 Arm Ltd Data processor and its polling loop management method
WO2006072841A2 (en) * 2004-11-30 2006-07-13 Koninklijke Philips Electronics N.V. Efficient switching between prioritized tasks
JP2007317171A (en) * 2006-04-27 2007-12-06 Matsushita Electric Ind Co Ltd Multi-thread computer system and multi-thread execution control method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6986141B1 (en) * 1998-03-10 2006-01-10 Agere Systems Inc. Context controller having instruction-based time slice task switching capability and processor employing the same
US20060059372A1 (en) * 2004-09-10 2006-03-16 International Business Machines Corporation Integrated circuit chip for encryption and decryption having a secure mechanism for programming on-chip hardware
US7545381B2 (en) * 2005-11-10 2009-06-09 Via Technologies, Inc. Interruptible GPU and method for context saving and restoring

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1139171A (en) * 1997-07-18 1999-02-12 Masaharu Imai Multitask processor, multitask processing control method and control program storing medium
JP2003263329A (en) * 2002-03-08 2003-09-19 Oki Electric Ind Co Ltd Task scheduler
JP2005346708A (en) * 2004-05-26 2005-12-15 Arm Ltd Data processor and its polling loop management method
WO2006072841A2 (en) * 2004-11-30 2006-07-13 Koninklijke Philips Electronics N.V. Efficient switching between prioritized tasks
JP2007317171A (en) * 2006-04-27 2007-12-06 Matsushita Electric Ind Co Ltd Multi-thread computer system and multi-thread execution control method

Also Published As

Publication number Publication date
TW200937294A (en) 2009-09-01
WO2009090684A1 (en) 2009-07-23
JPWO2009090684A1 (en) 2011-05-26
TWI476696B (en) 2015-03-11

Similar Documents

Publication Publication Date Title
JP4088335B1 (en) Virtual queue processing circuit and task processing device
JP6153925B2 (en) Task processing device
JP4119945B2 (en) Task processing device
US10949249B2 (en) Task processor
JP4127848B2 (en) Task processing device
JP5155336B2 (en) Task processing device
JP2018180768A (en) Semiconductor device
JP2017123190A (en) Task processing device
JP5204740B2 (en) Task processing device
JP2008269597A (en) Task processor
JP2019003710A (en) Task processing device

Legal Events

Date Code Title Description
A711 Notification of change in applicant

Free format text: JAPANESE INTERMEDIATE CODE: A711

Effective date: 20101120

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20110111

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A821

Effective date: 20110111

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20120724

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20120910

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20120910

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20121206

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20151214

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Ref document number: 5155336

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

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

RD02 Notification of acceptance of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: R3D02