JP2010049700A - Task processing apparatus - Google Patents

Task processing apparatus Download PDF

Info

Publication number
JP2010049700A
JP2010049700A JP2009242328A JP2009242328A JP2010049700A JP 2010049700 A JP2010049700 A JP 2010049700A JP 2009242328 A JP2009242328 A JP 2009242328A JP 2009242328 A JP2009242328 A JP 2009242328A JP 2010049700 A JP2010049700 A JP 2010049700A
Authority
JP
Japan
Prior art keywords
task
circuit
interrupt
processing
register
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.)
Granted
Application number
JP2009242328A
Other languages
Japanese (ja)
Other versions
JP5204740B2 (en
Inventor
Nobutaka Maruyama
修孝 丸山
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.)
NET KURIASU SYSTEMS KK
Original Assignee
NET KURIASU SYSTEMS KK
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 NET KURIASU SYSTEMS KK filed Critical NET KURIASU SYSTEMS KK
Priority to JP2009242328A priority Critical patent/JP5204740B2/en
Publication of JP2010049700A publication Critical patent/JP2010049700A/en
Application granted granted Critical
Publication of JP5204740B2 publication Critical patent/JP5204740B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Executing Machine-Instructions (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To achieve efficient task execution control in multitask processing. <P>SOLUTION: A task processing apparatus includes a CPU 210, a save circuit, and a task control circuit 210. The task control circuit 210 includes a task selection circuit and status storage parts associated with respective tasks. When executing a prescribed system call instruction, the CPU notifies the task control circuit about the execution. When being notified about the execution of the system call instruction, the task control circuit selects a task to be next executed, in accordance with an output from the task selection circuit. When an interrupt circuit 400 receives a high speed interrupt request signal, the task control circuit 210 executes an interrupt operation instruction designated by the interrupt circuit 400 to control the status transition of tasks. <P>COPYRIGHT: (C)2010,JPO&INPIT

Description

この発明は、OS(Operating System)の機能に関し、特に、割り込み処理に関する。   The present invention relates to an OS (Operating System) function, and more particularly to interrupt processing.

パーソナルコンピュータのような汎用機器用の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のメリットはタスクスイッチにともなうオーバーヘッドを補って余りある。   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.

特開平11−272480号公報JP 11-272480 A 特開2001−75820号公報JP 2001-75820 A

森久直、坂巻佳壽美、重松宏志、「組込み制御システム向けリアルタイムOSのハードウェア化(Hardware implementation of a read-time operating system for embedded control system)」、東京都立産業技術研究所研究報告、日本、2005年8月4日(原稿受付)、8、p.55−58Naohisa 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)」)が組込システム(Enbeded System)を中心として普及しつつある。このような時間的要件の厳しいRTOSにおいては、タスクスイッチ時のオーバーヘッドがシステム全体のパフォーマンスに大きく影響することがある。   In recent years, a real-time OS (hereinafter referred to as “RTOS (Real-Time Operating System)”) that strictly requires processing to be completed within a predetermined time has become widespread mainly in embedded systems (Enbeded Systems). 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.

また、RTOSは、DMA(Direct Memory Access)転送の完了、通信パケットの受信、あるいは、キーボードの押下といった不定期的に発生するさまざまな外部要因にも即時的に対応しなければならない。通常、外部要因の発生を示す割込要求信号が受信されると、RTOSは、特別なタスクを起動して「割り込み処理」を実行する。RTOSのパフォーマンスを向上させる上では、このような外部要因対応時におけるオーバーヘッドの抑制は特に重要である。   Further, the RTOS must immediately cope with various external factors that occur irregularly, such as completion of DMA (Direct Memory Access) transfer, reception of a communication packet, or depression of a keyboard. Normally, when an interrupt request signal indicating the occurrence of an external factor is received, the RTOS activates a special task and executes “interrupt processing”. In order to improve the performance of the RTOS, it is particularly important to suppress overhead when dealing with such external factors.

本発明は、本発明者による上記課題認識に基づいて完成されたものであり、その目的は、マルチタスク処理においてより効率的にタスクを実行制御するための技術を提供することであり、特に、割り込み処理の高速化を実現するための技術、を提供することにある。   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, The object is to provide a technique for realizing high-speed interrupt processing.

本発明のある態様は、タスク処理装置である。
この装置は、処理レジスタと、メモリから処理レジスタにデータをロードし、処理レジスタのデータにしたがってタスクを実行する実行制御回路と、タスクごとの状態データを保持する状態レジスタと、タスクの実行状態を制御するタスク切換回路と、所定の選択条件によりタスクを選択するタスク選択回路と、外部からの割込要求信号を処理する割込回路と、を備える。
実行制御回路は、第1のタスクがシステムコール命令を実行するとき、その旨をタスク切換回路に通知する。タスク選択回路は、実行可能に待機している状態を示すREADY(レディ)状態のタスクの中から実行対象となるタスクを選択する。
タスク切換回路は、システムコール命令実行時におけるタスク選択回路からの出力により次の実行対象となる第2のタスクを選択し、処理レジスタのデータを所定の記憶領域に退避させるとともに、第1のタスクの状態データを設定変更し、選択した第2のタスクについて記憶領域に退避されていたデータを処理レジスタにロードするとともにその状態データをREADY状態からRUN(ラン)状態に変更したあと、実行制御回路にタスクの実行を許可する。実行制御回路は、システムコール信号を送信した後、この実行許可を条件として、第2のタスクを実行する。
一方、割込回路は、外部から割込要求信号を受信すると、その割込要求信号に対応づけられている割込操作命令をタスク切換回路に送信する。タスク切換回路は、この割込操作命令にしたがってタスクの状態データを設定変更することにより、割込要求信号に対応する。
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 to be controlled; a task selection circuit for selecting a task according to a predetermined selection condition; and an interrupt circuit for processing an interrupt request signal from the outside.
When the first task executes 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 tasks in a READY state indicating a state waiting for execution.
The task switching circuit selects the second task to be executed next by the output from the task selection circuit when the system call instruction is executed, saves the data in the processing register in a predetermined storage area, and The state control data is changed, the data saved in the storage area for the selected second task is loaded into the processing register, and the state data is changed from the READY state to the RUN state. Allow task execution. After transmitting the system call signal, the execution control circuit executes the second task on the condition that this execution is permitted.
On the other hand, when the interrupt circuit receives an interrupt request signal from the outside, the interrupt circuit transmits an interrupt operation command associated with the interrupt request signal to the task switching circuit. The task switching circuit responds to the interrupt request signal by changing the setting of the task status data in accordance with the interrupt operation instruction.

処理レジスタにロードされるデータは、命令(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 an interrupt request signal is received from the outside, the task switching circuit changes the status register data according to the interrupt operation instruction associated with the interrupt request signal. It will be possible to respond at high speed at the hardware level.

なお、以上の構成要素の任意の組合せ、本発明を方法、システム、記録媒体、コンピュータプログラムにより表現したものもまた、本発明の態様として有効である。   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 basic 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 | occurrence | production. システムコール実行時における各種信号の関係を示すタイムチャートである。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 the task switching circuit in the basic example. 図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. 一般的なソフトウェアOSによる割り込み処理のタイムチャートである。It is a time chart of the interruption process by general software OS. 改良例におけるタスク処理装置の回路図である。It is a circuit diagram of a task processing device in an improved example. 割込回路の回路図である。It is a circuit diagram of an interrupt circuit. 記憶部のデータ構造図である。It is a data structure figure of a memory | storage part. 割込操作命令のデータ構造である。It is a data structure of an interrupt operation instruction. 高速割り込み処理の過程を示すシーケンス図である。It is a sequence diagram which shows the process of a high-speed interruption process. 改良例におけるタスク切換回路の状態遷移図である。It is a state transition diagram of a task switching circuit in an improved example. 改良例のタスク処理装置による高速割り込み処理の処理過程を示すタイムチャートである。It is a time chart which shows the process of the high-speed interruption process by the task processing apparatus of an improved example.

本実施例のタスク処理装置100は、マルチタスクOSのタスクスケジューリングを電子回路により実現し、更に、割り込み処理アルゴリズムをハードウェア・ロジックとして実装することにより、マルチタスクOSとしての処理効率を向上させている。
まず、本実施例においてマルチタスクOSのタスクスケジューリングを電子回路により実現するタスク処理装置100について「基本例」として説明する。そのあと、割り込み処理アルゴリズムの実装により、更なる高速化を実現する方法を「改良例」として説明する。以下、「本実施例」というときには、原則として、「基本例」および「改良例」の両方を示すものとする。
{基本例}
The task processing apparatus 100 according to the present embodiment realizes task scheduling of the multitask OS by an electronic circuit, and further improves the processing efficiency as the multitask OS by implementing an interrupt processing algorithm as hardware logic. Yes.
First, a task processing apparatus 100 that implements task scheduling of a multitask OS by an electronic circuit in this embodiment will be described as a “basic example”. After that, a method for realizing higher speed by implementing an interrupt processing algorithm will be described as an “improved example”. Hereinafter, when referring to "this embodiment", in principle, both "basic example" and "improved example" 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. An interrupt request signal is a signal generated when predetermined data is received from a peripheral device, such as a keyboard press, 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 the 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 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 due to the execution of a system call, or when a special task in the RUN state finishes 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種類のシステムコールを対象として説明するが、これ以外にもさまざまなシステムコールを実装可能であることはいうまでもない。
たとえば、WAIT−タスクをREADY状態に無条件で遷移させる「リリースウェイトシステムコール」や、スリープコマンドによりWAIT状態にあるタスクをREADY状態に遷移させる「ウェイクアップタスクシステムコール」などを実装してもよい。
[一般的なRTOSの設計思想]
Next, let me 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 the WAIT cancellation condition is already satisfied when the 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 (or “signaling semaphore system call”)
A system call that releases a semaphore.
3-2. Release mutex system call This system call releases a mutex.
3-3. Set event system call (or “set flag system call”)
This is a system call for setting a 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 basic example, the above nine types of system calls will be described, but it goes without saying that various other system calls can be implemented.
For example, a “release wait system call” for unconditionally transitioning a WAIT-task to the READY state or a “wake-up task system call” for transitioning a task in the WAIT state to the READY state by a sleep command may 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 the 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 in accordance with 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 task A TCB 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 the user special register 88. The RTOS records in the TCB of the task B that the task B has made a state transition 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 system use to user use. 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 the basic example, 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 in the basic example realizes a higher-speed 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 RTOS in the basic example.
Unlike a general software RTOS, the RTOS in the basic example is mainly realized as hardware separate from the CPU. Hereinafter, RTOS realized by hardware is referred to as “hardware RTOS”. The RTOS in the basic example is mainly hardware that is separate from the CPU, and therefore requires substantially no CPU usage right 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 the basic example, 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 basic example 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 receives an interrupt request signal (INTR) from an interrupt controller (not shown), 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 transmitting a 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.
The task switch execution method for each of the system call and the interrupt request signal will be described below.
[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 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 processing 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 implemented by hardware, and some RTOS functions may be implemented by software 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. 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 to the processing register 154, respectively. The execution control circuit 152 inputs data of a desired register among the processing registers 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 the basic example 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 the basic example 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. Will not be 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 the CPU 150 does not stop because CBUSY = 1. 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, instead of being conditional on the detection of the fall of WT: 1 → 0, the task control circuit 200 completes the task switch and negates HR. 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): fetches 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 executing from instruction F 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 if 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 updating 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 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 priority priority pointer 280 of the task priority “0” addresses the TCB of the task A, and the priority priority pointer 280 of the task priority “1” addresses the TCB of the task B. 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 not the task A but the task D TCB. 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 with the highest task priority, the task that has entered 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 the basic example selects the RUN-task based on the state data constantly output from the state storage unit 220. is doing. 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 for task J and starts measuring the elapsed READY 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 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 the basic example 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. The RUN-task selection process 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. is doing. Here, although it has been described that there are eight tasks, it is possible to cope 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 every time acquisition is requested 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 has executed the wait semaphore system call transitions 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”) by 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 with 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 having 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 with 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, “waiting 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, only one task can acquire a mutex at any given time.
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, a flag pattern (hereinafter referred to as “current flag pattern”) is recorded in association with an event ID. 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 for the corresponding event is changed to a logical sum with the set flag pattern. 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 logical 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 a 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 designated 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, and the success or failure of the WAIT cancellation condition is determined.
(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 satisfied)
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が内蔵するセマフォテーブル212においては、イベント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 semaphore table 212 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 and 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 executing the WAIT system call, 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 execution of a task, that is, during operation of the CPU clock, it is possible to immediately interrupt the CPU 150 and execute task switching. Further, during the execution of the task, the task switching circuit 210 can independently execute the timeout value update process 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 basic example.
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 interchanges the task B process data in the process data holding unit 320 and the RTOS process data in the process 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 / saving of processing data can be controlled 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 is 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 that does not include the save circuit 120 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倍の速度で動作することが確認されている。
{改良例}
As described with reference to FIG. 5, in the case of the task processing device 100 equipped with 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 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 faster than the general software RTOS described with reference to FIG.
{Improvements}

次に、改良例として、割り込み処理をハードウェア・ロジックにより実現するタスク処理装置100について説明する。   Next, as an improved example, a task processing apparatus 100 that implements interrupt processing by hardware logic will be described.

図18は、一般的なソフトウェアOSによる割り込み処理のタイムチャートである。
ソフトウェアOSは、割込コントローラ(図示せず)から割込要求信号を受信すると、割込ハンドラ、すなわち、基本例でいう特殊タスクを起動する。キーボード押下、通信パケットの受信、DMA転送の完了、あるいは、単なる所定時間の経過といったさまざまな事象が割込要求信号の発生契機となり得る。特殊タスクはソフトウェアにより実装されるタスクであり、割込要因に対応してさまざまな割り込み処理を実行する。
FIG. 18 is a time chart of interrupt processing by a general software OS.
When the software OS receives an interrupt request signal from an interrupt controller (not shown), the software OS starts an interrupt handler, that is, a special task in the basic example. Various events such as pressing of the keyboard, reception of a communication packet, completion of DMA transfer, or mere passage of a predetermined time can trigger an interrupt request signal. The special task is a task implemented by software, and executes various interrupt processing corresponding to the interrupt factor.

同図においては、まず、一般タスク実行中に割込要求信号INTR検出されている。即時対応すべき割込要求信号である場合、実行中の一般タスクは中断され、OSに実行権が移る(S100)。OSは、一般タスクのコンテキスト情報をTCBに退避させ(S102)、特殊タスクを起動する(S104)。   In the figure, first, an interrupt request signal INTR is detected during execution of a general task. If it is an interrupt request signal that should be dealt with immediately, the general task being executed is interrupted and the execution right is transferred to the OS (S100). The OS saves the context information of the general task in the TCB (S102) and activates the special task (S104).

特殊タスクは、割込要因を解析する(S106)。割込要求信号により割込要因レジスタ(図示せず)へのさまざまな書き込みが実行されるため、割込要因レジスタを調べることにより割込要因を特定できる。特殊タスクは、割込要因に対応して実行すべき割り込み処理を判定し、割り込み処理を開始する。割り込み処理の過程においてはさまざまなシステムコール命令が実行されることになる。システムコール命令を実行するとき、再び、OSに実行権が移る(S108)。OSは、指定されたシステムコールを実行する(S110)。システムコール実行後、特殊タスクに実行権が再移行する(S112)。割り込み処理は優先度の高い処理であるため、通常、特殊タスクの処理が完了しない限り、一般タスクに実行権が移ることはない。   The special task analyzes the interrupt factor (S106). Since various writes to the interrupt factor register (not shown) are executed by the interrupt request signal, the interrupt factor can be specified by examining the interrupt factor register. The special task determines the interrupt process to be executed in response to the interrupt factor, and starts the interrupt process. Various system call instructions are executed in the process of interrupt processing. When the system call instruction is executed, the execution right is transferred again to the OS (S108). The OS executes the designated system call (S110). After executing the system call, the execution right is transferred again to the special task (S112). Since the interrupt process is a high-priority process, the execution right is not normally transferred to the general task unless the special task process is completed.

特殊タスクは、割り込み処理を継続し(S114)、再びシステムコール命令を実行するときには、OSに実行権が移行する(S116)。このように特殊タスクとOSが交代で実行権を取得しながら、特殊タスクに最後の実行権が移行し(S118)、特殊タスクは割り込み処理を完了する(S120)。割り込み処理が完了すると、OSに実行権が移行し(S122)、特殊タスクから一般タスクへのタスクスイッチが実行される(S124)。こうして、一般タスクによる通常処理が再開されることになる(S126)。   The special task continues the interrupt process (S114), and when executing the system call instruction again, the execution right is transferred to the OS (S116). As described above, while the special task and the OS alternately acquire the execution right, the last execution right shifts to the special task (S118), and the special task completes the interrupt process (S120). When the interrupt process is completed, the execution right is transferred to the OS (S122), and a task switch from the special task to the general task is executed (S124). Thus, normal processing by the general task is resumed (S126).

基本例に示したタスク処理装置100は、RTOSとしての機能をハードウェア・ロジックにより実現している点がソフトウェアOSと異なるが、割り込み処理における基本的な流れはソフトウェアOSとほぼ同様である。ただし、基本例に関連して説明したように、S102やS124におけるタスクスイッチやS110等のシステムコール実行は、ソフトウェアOSに比べて格段に高速化される。
基本例のタスク処理装置100の場合、S100、S108、S116、S122にてCPUクロック(CLK)を停止させた上で、RTOSの処理が実行されることになる。また、S104、S112、S118、S126によりCPUクロック(CLK)を再開させた上で、特殊タスクや一般タスクの処理が実行されることになる。特殊タスクは、タスク優先順位が特に高いタスクであるが、CPUクロック(CLK)にしたがって動作するコンテキストベースのタスクである点では一般タスクと同じである。
The task processing apparatus 100 shown in the basic example is different from the software OS in that functions as an RTOS are realized by hardware logic, but the basic flow in interrupt processing is almost the same as that of the software OS. However, as described in relation to the basic example, the task switch in S102 and S124 and the execution of system calls such as S110 are significantly faster than the software OS.
In the case of the task processing apparatus 100 of the basic example, the RTOS process is executed after the CPU clock (CLK) is stopped in S100, S108, S116, and S122. Further, after the CPU clock (CLK) is restarted in S104, S112, S118, and S126, the special task and the general task are executed. A special task is a task having a particularly high task priority, but is the same as a general task in that it is a context-based task that operates according to the CPU clock (CLK).

改良例においては、このような割り込み処理、具体的には特殊タスクの機能の一部をハードウェア・ロジックにより実現することにより、割り込み処理を更に高速化する。   In the improved example, such interrupt processing, specifically, a part of the function of the special task is realized by hardware logic, thereby further speeding up the interrupt processing.

割り込み処理の内容はさまざまであるが、割込要求信号によっては、単純で定型的な処理内容となることも多い。たとえば、ある一般タスクAがDMA転送を開始し、DMA転送の完了を待つという状況を想定する。一般タスクAはDMA転送開始時において、ウェイトイベントシステムコールを実行して、WAIT状態に移行する。DMA転送が完了すると、所定の割込要求信号が(基本例の)タスク切換回路210に入力される。このとき起動される特殊タスクは、セットイベントシステムコールを実行して、DMA転送完了の旨を示すフラグパターンをイベントテーブル214に設定する。イベントテーブル214のカレントフラグパターンが変化することにより、一般タスクAのWAIT解除条件が成立し、一般タスクAはREADY状態に移行する。このように、DMA転送完了にともなって実行される割り込み処理の内容は比較的単純である。   The contents of the interrupt process vary, but depending on the interrupt request signal, the process contents are often simple and routine. For example, assume a situation where a general task A starts DMA transfer and waits for completion of DMA transfer. At the start of DMA transfer, the general task A executes a wait event system call and shifts to the WAIT state. When the DMA transfer is completed, a predetermined interrupt request signal is input to the task switching circuit 210 (in the basic example). The special task activated at this time executes a set event system call and sets a flag pattern indicating completion of DMA transfer in the event table 214. When the current flag pattern in the event table 214 changes, the WAIT cancellation condition for the general task A is satisfied, and the general task A shifts to the READY state. As described above, the contents of the interrupt process executed upon completion of the DMA transfer are relatively simple.

そこで、改良例におけるタスク処理装置100は、割り込み処理の内容が比較的単純であり、好ましくは発生頻度の高い割込要求信号を「高速割込要求信号INTR(H)」として事前に登録しておく。改良例における割込要求信号は高速割込要求信号INTR(H)と「通常割込要求信号INTR(N)」の2種類に大別される。   Therefore, the task processing apparatus 100 according to the improved example has a relatively simple interrupt processing content, and preferably registers an interrupt request signal with a high occurrence frequency in advance as a “high-speed interrupt request signal INTR (H)”. deep. The interrupt request signals in the improved example are roughly classified into two types, a high-speed interrupt request signal INTR (H) and a “normal interrupt request signal INTR (N)”.

図19は、改良例におけるタスク処理装置100の回路図である。
改良例におけるタスク処理装置100も、CPU150に加えて退避回路120とタスク制御回路200を含む。改良例におけるタスク処理装置100には、更に、割込回路400が追加される。
FIG. 19 is a circuit diagram of the task processing apparatus 100 in the improved example.
The task processing apparatus 100 in the improved example also includes a save circuit 120 and a task control circuit 200 in addition to the CPU 150. An interrupt circuit 400 is further added to the task processing device 100 in the improved example.

高速割込要求信号INTR(H)は、割込回路400に入力される。割込回路400の構成および割込回路400による高速割込要求信号の処理方法については、後述する。通常割込要求信号INTR(N)は、基本例と同じく、タスク切換回路210に直接入力され、特殊タスクにより割り込み処理される。高速割込要求信号についての割り込み処理(以下、「高速割り込み処理」とよぶ)は通常割込要求信号についての割り込み処理(以下、「通常割り込み処理」とよぶ)よりも高速である。一方、通常割り込み処理の場合には、ソフトウェアの特殊タスクとして処理内容の詳細を柔軟に定義できるというメリットがある。改良例におけるタスク処理装置100は、高速割込要求信号と通常割込要求信号を併用することにより、RTOSとしての汎用性を維持しつつ高速化を図っている。   The high speed interrupt request signal INTR (H) is input to the interrupt circuit 400. The configuration of the interrupt circuit 400 and the processing method of the high-speed interrupt request signal by the interrupt circuit 400 will be described later. As in the basic example, the normal interrupt request signal INTR (N) is directly input to the task switching circuit 210 and is interrupted by a special task. Interrupt processing for a high-speed interrupt request signal (hereinafter referred to as “high-speed interrupt processing”) is faster than interrupt processing for a normal interrupt request signal (hereinafter referred to as “normal interrupt processing”). On the other hand, in the case of normal interrupt processing, there is an advantage that details of processing contents can be flexibly defined as a special task of software. The task processing apparatus 100 according to the improved example uses the high-speed interrupt request signal and the normal interrupt request signal in combination to increase the speed while maintaining versatility as an RTOS.

図20は、割込回路400の回路図である。
割込回路400は、信号選択回路402、操作回路404および記憶部406を含む。INTR(H)_0〜INTR(H)_i−1のi個の高速割込要求信号は、不定期的に信号選択回路402に入力される。短期間に複数の高速割込要求信号INTR(H)が入力されることもあるし、同時に複数の高速割込要求信号INTR(H)が入力されることもある。信号選択回路402は、受信した高速割込要求信号INTR(H)を一時的に蓄積できる。
FIG. 20 is a circuit diagram of the interrupt circuit 400.
The interrupt circuit 400 includes a signal selection circuit 402, an operation circuit 404, and a storage unit 406. The i high-speed interrupt request signals INTR (H) _0 to INTR (H) _i−1 are input to the signal selection circuit 402 irregularly. A plurality of high-speed interrupt request signals INTR (H) may be input in a short period of time, or a plurality of high-speed interrupt request signals INTR (H) may be input simultaneously. The signal selection circuit 402 can temporarily store the received high-speed interrupt request signal INTR (H).

信号選択回路402は、バッファリングしている高速割込要求信号INTR(H)の中から1つの高速割込要求信号INTR(H)を所定の選択規則に基づいて選択する。ここでいう選択規則は、設計要件に応じて任意に決定されればよい。たとえば、高速割込要求信号INTR(H)ごとに優先順位を設定しておき、複数の高速割込要求信号INTR(H)がバッファリングされているときには、そのうち優先順位が最も高い高速割込要求信号INTR(H)を選択するとしてもよい。あるいは、信号選択回路402への入力タイミングが最も古い高速割込要求信号INTR(H)を選択するとしてもよいし、ランダムに選択するとしてもよい。高速割込要求信号INTR(H)_n(nは0〜i-1までの整数)が選択されると、信号選択回路402は、対応する信号QINT_nをアサートする。   The signal selection circuit 402 selects one high-speed interrupt request signal INTR (H) from the buffered high-speed interrupt request signal INTR (H) based on a predetermined selection rule. The selection rule here may be arbitrarily determined according to the design requirements. For example, a priority is set for each high-speed interrupt request signal INTR (H), and when a plurality of high-speed interrupt request signals INTR (H) are buffered, a high-speed interrupt request with the highest priority among them. The signal INTR (H) may be selected. Alternatively, the fast interrupt request signal INTR (H) with the oldest input timing to the signal selection circuit 402 may be selected, or may be selected at random. When the high-speed interrupt request signal INTR (H) _n (n is an integer from 0 to i−1) is selected, the signal selection circuit 402 asserts the corresponding signal QINT_n.

操作回路404は、QINT_nをアサートされると、ISROP信号をアサートする。ISROP信号のアサートにより、高速割り込み処理中であることが信号選択回路402に伝えられる。ISROP信号がアサートされると、ISROP信号がネゲートされるまで信号選択回路402は次のQINTをアサートしない。ISROP信号がネゲートされると、信号選択回路402は次の処理対象となる高速割込要求信号INTR(H)を選択可能となる。   When QINT_n is asserted, the operation circuit 404 asserts the ISROP signal. By asserting the ISROP signal, the signal selection circuit 402 is informed that high-speed interrupt processing is in progress. When the ISROP signal is asserted, the signal selection circuit 402 does not assert the next QINT until the ISROP signal is negated. When the ISROP signal is negated, the signal selection circuit 402 can select the high-speed interrupt request signal INTR (H) to be processed next.

QINT_nがアサートされると、操作回路404は、高速割り込み処理の実行をタスク切換回路210に要求するためにISR_RQもアサートする。ISR_RQがアサートされると、タスク切換回路210は、CPUクロック(CLK)を供給停止させる。こうして、一般タスクは実行停止される。   When QINT_n is asserted, the operation circuit 404 also asserts ISR_RQ to request the task switching circuit 210 to execute high-speed interrupt processing. When ISR_RQ is asserted, the task switching circuit 210 stops supplying the CPU clock (CLK). Thus, the execution of the general task is stopped.

操作回路404は、QINT_nに応じて、いいかえれば、選択された高速割込要求信号INTR(H)_nに応じて、DSC_ADD[k−1:0]に所定のアドレスADD[n]を設定する。DSC_ADD[k−1:0]=ADD[n]の入力により、記憶部406のアドレスADD[n]に保持されている割込操作命令p0がISR_DT[31:0]としてタスク切換回路210に送信される。タスク切換回路210は、受信した割込操作命令p0にしたがって高速割り込み処理を実行する。   The operation circuit 404 sets a predetermined address ADD [n] in DSC_ADD [k−1: 0] according to QINT_n, in other words, according to the selected high-speed interrupt request signal INTR (H) _n. By inputting DSC_ADD [k−1: 0] = ADD [n], the interrupt operation instruction p0 held at the address ADD [n] in the storage unit 406 is transmitted to the task switching circuit 210 as ISR_DT [31: 0]. Is done. The task switching circuit 210 executes high-speed interrupt processing according to the received interrupt operation instruction p0.

本実施例における割込操作命令は、図22にて後述するように32ビットサイズに正規化されており、その最上位ビットISR_DT[31]により、後続の割込操作命令の存否が示される。なお、割込操作命令は、64ビット、128ビット等、32ビット以外の任意のサイズにて正規化されてもよい。最上位ビットISR_DT[31]=1のときには、タスク切換回路210はISR_NXをアサートして、後続の割込操作命令p1を操作回路404に要求する。操作回路404は、先ほどのアドレスADD[n]に1ワード(本実施例においては32ビット)を加算したアドレスADD[n]+1をDSC_ADD[k−1:0]に設定する。アドレスADD[n]+1に保持されている割込操作命令p1がISR_DT[31:0]としてタスク切換回路210に送信される。タスク切換回路210は、受信した割込操作命令p1にしたがって高速割り込み処理を続行する。   The interrupt operation instruction in this embodiment is normalized to a 32-bit size as will be described later with reference to FIG. 22, and the presence / absence of a subsequent interrupt operation instruction is indicated by the most significant bit ISR_DT [31]. Note that the interrupt operation instruction may be normalized with an arbitrary size other than 32 bits, such as 64 bits and 128 bits. When the most significant bit ISR_DT [31] = 1, the task switching circuit 210 asserts ISR_NX and requests the operation circuit 404 for a subsequent interrupt operation instruction p1. The operation circuit 404 sets an address ADD [n] +1 obtained by adding one word (32 bits in this embodiment) to the previous address ADD [n] to DSC_ADD [k−1: 0]. The interrupt operation instruction p1 held at the address ADD [n] +1 is transmitted to the task switching circuit 210 as ISR_DT [31: 0]. The task switching circuit 210 continues the high-speed interrupt process according to the received interrupt operation instruction p1.

最上位ビットISR_DT[31]=0のときには、タスク切換回路210はISR_ENDをアサートして、高速割り込み処理の完了を操作回路404に通知する。操作回路404は、ISROPをネゲートする。ISROPがネゲートされると、信号選択回路402は、別の高速割込要求信号INTR(H)を選択して、新たにQINTをアサート可能となる。
なお、本改良例においては、ISR_END信号が操作回路404に入力され、操作回路404がISROPをネゲートすることにより、信号選択回路402を制御している。変形例として、タスク切換回路210は、高速割り込み処理が完了したときには、直接、信号選択回路402にISR_END信号を送信して、信号選択回路402を制御してもよい。
When the most significant bit ISR_DT [31] = 0, the task switching circuit 210 asserts ISR_END and notifies the operation circuit 404 of completion of the high-speed interrupt processing. The operation circuit 404 negates ISROP. When ISROP is negated, the signal selection circuit 402 can select another high-speed interrupt request signal INTR (H) and newly assert QINT.
In this improved example, the ISR_END signal is input to the operation circuit 404, and the operation circuit 404 negates ISROP to control the signal selection circuit 402. As a modification, the task switching circuit 210 may control the signal selection circuit 402 by transmitting an ISR_END signal directly to the signal selection circuit 402 when the high-speed interrupt processing is completed.

図21は、記憶部406のデータ構造図である。
本改良例における記憶部406は、メモリである。アドレス「0x000〜0x0FF」には、高速割込要求信号INTR(H)_0に対応した割込操作命令群が保持されている。同様にして、アドレス「0x100〜0x1FF」には、高速割込要求信号INTR(H)_1に対応した割込操作命令群が保持されている。本改良例における割込操作命令は、システムコール命令である。たとえば、信号選択回路402が高速割込要求信号INTR(H)_0を選択すると、操作回路404は高速割込要求信号INTR(H)_0の最初のアドレスである「0x000」をDSC_ADD[k−1:0]に指定する。記憶部406からは、該当する割込操作命令「systemcall_00」がタスク切換回路210に送信される。割込操作命令「systemcall_00」には、後続の割込操作命令「systemcall_01」が存在するため、割込操作命令「systemcall_00」の最上位ビットには「1」が設定されている。タスク切換回路210は、割込操作命令「systemcall_00」を実行したあと、後続の割り込み操作命令を要求するためにISR_NXをアサートする。
FIG. 21 is a data structure diagram of the storage unit 406.
The storage unit 406 in this improved example is a memory. Addresses “0x000 to 0x0FF” hold an interrupt operation instruction group corresponding to the high-speed interrupt request signal INTR (H) _0. Similarly, an interrupt operation instruction group corresponding to the high-speed interrupt request signal INTR (H) _1 is held at addresses “0x100 to 0x1FF”. The interrupt operation instruction in this improved example is a system call instruction. For example, when the signal selection circuit 402 selects the high-speed interrupt request signal INTR (H) _0, the operation circuit 404 sets “0x000”, which is the first address of the high-speed interrupt request signal INTR (H) _0, to DSC_ADD [k−1. : 0]. The corresponding interrupt operation instruction “systemcall_00” is transmitted from the storage unit 406 to the task switching circuit 210. Since the interrupt operation instruction “systemcall_00” includes the subsequent interrupt operation instruction “systemcall_01”, the most significant bit of the interrupt operation instruction “systemcall_00” is set to “1”. After executing the interrupt operation instruction “systemcall_00”, the task switching circuit 210 asserts ISR_NX to request a subsequent interrupt operation instruction.

操作回路404は「0x000」に1ワードを加算したアドレス「0x001」をDSC_ADD[k−1:0]に新たに指定する。記憶部406からは、続きの割込操作命令「systemcall_01」がタスク切換回路210に送信されることになる。「syscall_01」の最上位ビットは「0」にセットされており、タスク切換回路210は、高速割込要求信号INTR(H)_0についての高速割り込み処理として、「syscall_01」が最後の割込操作命令であることを認識できる。タスク切換回路210は、割込操作命令「syscall_01」の実行を完了すると、ISR_ENDをアサートして、高速割り込み処理の終了を通知する。   The operation circuit 404 newly designates an address “0x001” obtained by adding one word to “0x000” in DSC_ADD [k−1: 0]. From the storage unit 406, a subsequent interrupt operation instruction “systemcall_01” is transmitted to the task switching circuit 210. The most significant bit of “syscall_01” is set to “0”, and the task switching circuit 210 sets “syscall_01” as the last interrupt operation instruction as high-speed interrupt processing for the high-speed interrupt request signal INTR (H) _0. Can be recognized. When the task switching circuit 210 completes execution of the interrupt operation instruction “syscall_01”, the task switching circuit 210 asserts ISR_END to notify the end of the high-speed interrupt processing.

図22は、割込操作命令のデータ構造を示す。
先述のように、ISR_DT[31]は後続の割込操作命令の有無を示す。ISR_DT[30:24]により、システムコールの種類が示される。ISR_DT[30:24]=0000001は「セットイベントシステムコール」を示す。このため、割込操作命令410aはセットイベントシステムコールの実行命令である。ISR_DT[23:8]はセットフラグパターン、ISR_DT[7:0]はイベントIDを示す。タスク切換回路210は、割込操作命令410aを受信すると、基本例と同様の処理方法にてイベントテーブル214を設定する。
FIG. 22 shows the data structure of an interrupt operation instruction.
As described above, ISR_DT [31] indicates the presence / absence of a subsequent interrupt operation instruction. The type of system call is indicated by ISR_DT [30:24]. ISR_DT [30:24] = 0000001 indicates a “set event system call”. Therefore, the interrupt operation command 410a is a set event system call execution command. ISR_DT [23: 8] indicates a set flag pattern, and ISR_DT [7: 0] indicates an event ID. When task switching circuit 210 receives interrupt operation instruction 410a, task switching circuit 210 sets event table 214 by the same processing method as in the basic example.

ISR_DT[30:24]=0000010は「リリースセマフォシステムコール」を示す。このため、割込操作命令410bはリリースセマフォシステムコールの実行命令である。ISR_DT[7:0]は、解放セマフォのセマフォIDを示す。ISR_DT[30:24]=0000011は「リリースウェイトシステムコール」を示す。このため、割込操作命令410cはリリースウェイトシステムコールの実行命令である。ISR_DT[4:0]は、WAIT状態から解放すべきタスクのタスクIDを示す。ISR_DT[30:24]=0000100は「ウェイクアップタスクシステムコール」を示す。このため、割込操作命令410dはウェイクアップタスクシステムコールの実行命令である。ISR_DT[4:0]は、WAIT状態から解放すべきタスクのタスクIDを示す。ISR_DT[30:24]=0000101は「起動システムコール」を示す。このため、割込操作命令410eは起動システムコールの実行命令である。ISR_DT[4:0]は、起動すべきタスクのタスクIDを示す。このほかにもさまざまなシステムコールが割込操作命令として記憶部406に登録されてもよい。   ISR_DT [30:24] = 0000010 indicates a “release semaphore system call”. Therefore, the interrupt operation instruction 410b is a release semaphore system call execution instruction. ISR_DT [7: 0] indicates the semaphore ID of the released semaphore. ISR_DT [30:24] = 0000011 indicates a “release wait system call”. Therefore, the interrupt operation instruction 410c is a release wait system call execution instruction. ISR_DT [4: 0] indicates the task ID of the task to be released from the WAIT state. ISR_DT [30:24] = 0000100 indicates a “wake-up task system call”. Therefore, the interrupt operation instruction 410d is an execution instruction for the wakeup task system call. ISR_DT [4: 0] indicates the task ID of the task to be released from the WAIT state. ISR_DT [30:24] = 0000101 indicates an “activation system call”. Therefore, the interrupt operation instruction 410e is an execution instruction for an activation system call. ISR_DT [4: 0] indicates the task ID of the task to be activated. Various other system calls may be registered in the storage unit 406 as interrupt operation instructions.

記憶部406は、ROM(Read Only Memory)として提供されてもよいし、読み書き可能なRAM(Random Access Memory)として提供されてもよい。記憶部406の内容をアプリケーションにより書き換え可能であれば、高速割り込み処理の内容をソフトウェアにより設定変更できる。   The storage unit 406 may be provided as a ROM (Read Only Memory) or a readable / writable RAM (Random Access Memory). If the contents of the storage unit 406 can be rewritten by an application, the contents of the high-speed interrupt process can be changed by software.

図23は、高速割り込み処理の過程を示すシーケンス図である。
まず、信号選択回路402は、処理対象となる高速割込要求信号INTR(H)_nを選択し(S130)、QINT_nをアサートする(S132)。操作回路404は、ISROPをアサートして、高速割り込み処理の最中である旨を信号選択回路402に通知する(S134)。信号選択回路402は、ISROPをアサートされると、新たな高速割込要求信号を受信しても、バッファリングしておき、QINTをアサートすることはない。
FIG. 23 is a sequence diagram showing the process of high-speed interrupt processing.
First, the signal selection circuit 402 selects the high-speed interrupt request signal INTR (H) _n to be processed (S130) and asserts QINT_n (S132). The operation circuit 404 asserts ISROP and notifies the signal selection circuit 402 that high-speed interrupt processing is in progress (S134). When ISROP is asserted, the signal selection circuit 402 does not assert QINT even if it receives a new high-speed interrupt request signal and buffers it.

一方、操作回路404は、QINT_nをアサートされると、ISR_RQをアサートして、高速割り込み処理の開始をタスク切換回路210に要求する(S136)。このとき、タスク切換回路210は、CPUクロック(CLK)を停止させ、高速割り込み処理の開始に備える。操作回路404は、QINT_nに対応するアドレスADD[n]をDSC_ADDに指定して、記憶部406から割込操作命令p0を読み出す(S138)。割込操作命令p0は、ISR_DT[31:0]として、タスク切換回路210に送信される(S140)。   On the other hand, when QINT_n is asserted, the operation circuit 404 asserts ISR_RQ and requests the task switching circuit 210 to start high-speed interrupt processing (S136). At this time, the task switching circuit 210 stops the CPU clock (CLK) and prepares for the start of high-speed interrupt processing. The operation circuit 404 specifies the address ADD [n] corresponding to QINT_n as DSC_ADD, and reads the interrupt operation instruction p0 from the storage unit 406 (S138). The interrupt operation instruction p0 is transmitted to the task switching circuit 210 as ISR_DT [31: 0] (S140).

タスク切換回路210は、受信した割込操作命令p0にしたがって、セマフォテーブル212やイベントテーブル214、状態記憶部220の設定内容を変更する。より具体的には、タスク切換回路210は、一般タスクが、リリースセマフォシステムコール(シグナリングセマフォシステムコール)やセットイベントシステムコール(セットフラグシステムコール)を発行するときと同等の処理プロセスを実行することにより、セマフォテーブル212やイベントテーブル214、状態記憶部220の設定内容を変更する。割込操作命令の処理内容については、基本例に示したシステムコール命令の処理内容と同様である。割込操作命令の最上位ビットに「1」が設定されていれば、タスク切換回路210は、ISR_NXをアサートして次の割込操作命令p1を操作回路404に要求する(S144)。操作回路404は、次の割込操作命令p1をロードし(S146)、割込操作命令p1はタスク切換回路210に送信される(S148)。   The task switching circuit 210 changes the setting contents of the semaphore table 212, the event table 214, and the state storage unit 220 according to the received interrupt operation command p0. More specifically, the task switching circuit 210 executes a processing process equivalent to when a general task issues a release semaphore system call (signaling semaphore system call) or a set event system call (set flag system call). Thus, the setting contents of the semaphore table 212, the event table 214, and the state storage unit 220 are changed. The processing contents of the interrupt operation instruction are the same as the processing contents of the system call instruction shown in the basic example. If “1” is set in the most significant bit of the interrupt operation instruction, the task switching circuit 210 asserts ISR_NX and requests the operation circuit 404 for the next interrupt operation instruction p1 (S144). The operation circuit 404 loads the next interrupt operation instruction p1 (S146), and the interrupt operation instruction p1 is transmitted to the task switching circuit 210 (S148).

タスク切換回路210が最後の割込操作命令pxを実行したとき、すなわち、最上位ビットに「0」が設定されている割込操作命令pxを実行したとき、タスク切換回路210はISR_ENDをアサートする(S152)。操作回路404は、高速割り込み処理の完了を認識し、ISROPをネゲートする(S154)。こうして、信号選択回路402は次の高速割込要求信号を選択可能となる。   When the task switching circuit 210 executes the last interrupt operation instruction px, that is, when executing the interrupt operation instruction px having the most significant bit set to “0”, the task switching circuit 210 asserts ISR_END. (S152). The operation circuit 404 recognizes the completion of the high-speed interrupt process and negates ISROP (S154). Thus, the signal selection circuit 402 can select the next high-speed interrupt request signal.

図24は、改良例におけるタスク切換回路210の状態遷移図である。
改良例においては、図15に示した状態遷移図に加えて、高速割り込み処理(A6)が追加されている。また、通常割り込み処理(A3)は、図15に示した割り込み処理(A3)と同じである。そのほかにも、基本例と同一の符号を付した構成は、同一の処理内容を示している。
FIG. 24 is a state transition diagram of the task switching circuit 210 in the improved example.
In the improved example, high-speed interrupt processing (A6) is added to the state transition diagram shown in FIG. The normal interrupt process (A3) is the same as the interrupt process (A3) shown in FIG. In addition, the configuration denoted by the same reference numerals as the basic example indicates the same processing content.

タスク実行中(A2)において、高速割込要求信号INTR(H)が検出されると(S24)、ISR_RQがアサートされて、高速割り込み処理(A6)が実行される。割込回路400がタスク切換回路210に割込操作命令を送信すると(S26)、タスク切換回路210は対応したシステムコール処理(A4)を実行する。システムコール命令の実行が完了すると、高速割り込み処理(A6)に状態遷移する(S28)。更に処理すべき割込操作命令が残っていなければ、高速割り込み処理は終了して(S30)、次に実行すべき一般タスクが選択される(A5)。   If a high-speed interrupt request signal INTR (H) is detected during task execution (A2) (S24), ISR_RQ is asserted and high-speed interrupt processing (A6) is executed. When the interrupt circuit 400 transmits an interrupt operation command to the task switching circuit 210 (S26), the task switching circuit 210 executes a corresponding system call process (A4). When the execution of the system call instruction is completed, state transition is made to high-speed interrupt processing (A6) (S28). If there are no more interrupt operation instructions to be processed, the high-speed interrupt process is terminated (S30), and the next general task to be executed is selected (A5).

図25は、改良例のタスク処理装置100による高速割り込み処理の処理過程を示すタイムチャートである。
同図においては、まず、一般タスク実行中に割込要求信号INTRが検出されている。即時対応すべき割込要求信号である場合、CPUクロック(CLK)の停止により、実行中の一般タスクは中断され、割込回路400とタスク切換回路210による高速割り込み処理が開始される(S160)。
FIG. 25 is a time chart showing the process of high-speed interrupt processing by the task processing apparatus 100 of the improved example.
In the figure, first, an interrupt request signal INTR is detected during execution of a general task. If the interrupt request signal is to be dealt with immediately, the general task being executed is interrupted by stopping the CPU clock (CLK), and high-speed interrupt processing by the interrupt circuit 400 and task switching circuit 210 is started (S160) .

割込回路400は、適宜、割込操作命令を読み出し、タスク切換回路210が割込操作命令として指定されるシステムコール命令を実行する。こうして一連のシステムコールにより実現される高速割り込み処理が完了すると(S162)、タスク切換回路210は次のRUN−タスクを選択する(S164)。選択後、CPUクロック(CLK)が再開され、一般タスクによる通常処理が再開される(S166)。   The interrupt circuit 400 appropriately reads out the interrupt operation instruction, and the task switching circuit 210 executes the system call instruction specified as the interrupt operation instruction. When the high-speed interrupt processing realized by a series of system calls is completed in this way (S162), the task switching circuit 210 selects the next RUN-task (S164). After the selection, the CPU clock (CLK) is restarted and normal processing by the general task is restarted (S166).

改良例に示したタスク処理装置100によれば、高速割り込み処理を割込回路400とタスク切換回路210の協働によりハードウェア・レベルで実現できる。本発明者らの実験によると、基本例におけるタスク処理装置100に比べて、改良例におけるタスク処理装置100は更に約4倍の速度で動作することが確認されている。記憶部406を書き込み可能メモリとして形成することにより、高速割り込み処理であっても、その処理内容をある程度柔軟に設定できる。   According to the task processing device 100 shown in the improved example, high-speed interrupt processing can be realized at the hardware level by the cooperation of the interrupt circuit 400 and the task switching circuit 210. According to the experiments by the present inventors, it has been confirmed that the task processing device 100 in the improved example operates at a speed about four times that of the task processing device 100 in the basic example. By forming the storage unit 406 as a writable memory, the processing content can be set to some degree of flexibility even in high-speed interrupt processing.

従来、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. As shown in the improved example, by realizing the high-speed interrupt processing algorithm with an electronic circuit, a higher speed can be realized.

以上、本発明を実施例をもとに説明した。実施の形態は例示であり、それらの各構成要素や各処理プロセスの組合せにいろいろな変形例が可能なこと、またそうした変形例も本発明の範囲にあることは当業者に理解されるところである。   In the above, this invention was demonstrated based on the Example. 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. .

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

Claims (7)

タスク実行のためのデータを一時的に保持する処理レジスタと、
命令(instruction)およびオペランドをメモリから前記処理レジスタにロードし、前記処理レジスタの命令とオペランドにしたがってタスクを実行する実行制御回路と、
タスクの実行状態を示す状態データを保持する状態レジスタと、
タスクの実行状態を制御するタスク切換回路と、
前記状態データに基づいて、所定の選択条件によりタスクを選択するタスク選択回路と、
外部からの割込要求信号を処理する割込回路と、を備え、
前記実行制御回路は、実行対象となる命令が所定のシステムコール命令であるか否かを判定する命令復号器を有し、実行中の第1のタスクが所定のシステムコール命令を実行するときには所定のシステムコール信号を前記タスク切換回路に送信し、
前記タスク選択回路は、実行可能に待機している状態を示すREADY(レディ)状態のタスクの中から次の実行対象となるタスクを選択し、
前記タスク切換回路は、前記システムコール信号を受信したときの前記タスク選択回路からの出力により次の実行対象となる第2のタスクを選択し、前記処理レジスタのデータを所定の記憶領域に退避させるとともに、前記第1のタスクについての状態データをタスク実行中を示すRUN(ラン)状態から別の状態に設定変更し、前記第2のタスクについて前記記憶領域に退避されていたデータを前記処理レジスタにロードするとともに前記第2のタスクについての状態データをREADY状態からRUN状態に変更した後、前記実行制御回路にタスクの実行を許可し、
前記実行制御回路は、前記システムコール信号を送信した後、前記タスク切換回路からタスクの実行を許可されたことを条件として、前記第2のタスクを実行し、
前記割込回路は、前記割込要求信号を受信したとき、前記割込要求信号にあらかじめ対応づけられている割込操作命令を前記タスク切換回路に送信し、
前記タスク切換回路は、前記割込操作命令にしたがってタスクの状態データを変更することを特徴とするタスク処理装置。
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 interrupt circuit for processing an external interrupt request signal,
The execution control circuit includes an instruction decoder that determines whether or not an instruction to be executed is a predetermined system call instruction, and is predetermined when the first task being executed executes the predetermined system call instruction. 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 second task to be executed next by an output from the task selection circuit when the system call signal is received, and saves data in the processing register to a predetermined storage area And changing the setting of the state data for the first task from the RUN state indicating that the task is being executed to another state, and storing the data saved in the storage area for the second task in the processing register And the state data for the second task is changed from the READY state to the RUN state, and the execution control circuit is allowed to execute the task,
The execution control circuit executes the second task on condition that the task switching circuit is permitted to execute the task after transmitting the system call signal.
When the interrupt circuit receives the interrupt request signal, the interrupt circuit transmits an interrupt operation command associated with the interrupt request signal in advance to the task switching circuit,
The task switching circuit changes task state data in accordance with the interrupt operation instruction.
前記割込回路は、
外部から割込要求信号を受信して一時的に保持し、保持されている1以上の割込要求信号の中からいずれかの割込要求信号を処理対象として選択する信号選択回路と、
前記選択された割込要求信号に対応する割込操作命令を前記タスク切換回路に送信する操作回路と、を含み、
前記タスク切換回路は、前記割込操作命令の実行を完了したとき、前記割込回路に対して操作完了信号を送信し、
前記信号選択回路は、前記操作完了信号が受信されたことを条件として、次の処理対象となる割込要求信号を前記操作回路に送信することを特徴とする請求項1に記載のタスク処理装置。
The interrupt circuit is
A signal selection circuit that receives and temporarily holds an interrupt request signal from the outside, and selects any one of the held interrupt request signals as a processing target from the held one or more interrupt request signals;
An operation circuit for transmitting an interrupt operation instruction corresponding to the selected interrupt request signal to the task switching circuit,
The task switching circuit transmits an operation completion signal to the interrupt circuit when the execution of the interrupt operation instruction is completed,
2. The task processing apparatus according to claim 1, wherein the signal selection circuit transmits an interrupt request signal to be processed next to the operation circuit on condition that the operation completion signal is received. .
前記タスク切換回路は、前記割込操作命令の実行を完了したとき、前記割込回路のうちの前記操作回路に前記操作完了信号を送信し、
前記操作回路は、前記操作完了信号を受信したとき、前記信号選択回路に選択可能信号を送信し、
前記信号選択回路は、前記選択可能信号を受信したこと条件として、次の処理対象となる割込要求信号を前記操作回路に送信することを特徴とする請求項2に記載のタスク処理装置。
The task switching circuit, when the execution of the interrupt operation instruction is completed, transmits the operation completion signal to the operation circuit of the interrupt circuit,
When the operation circuit receives the operation completion signal, the operation circuit transmits a selectable signal to the signal selection circuit,
The task processing apparatus according to claim 2, wherein the signal selection circuit transmits an interrupt request signal to be processed next to the operation circuit as a condition that the selectable signal has been received.
前記割込回路は、
割込要求信号と割込操作命令とを対応づけた割込テーブルを保持するメモリ、を更に含み、
前記操作回路は、前記割込テーブルを参照して、前記選択された割込要求信号に対応する割込操作命令を特定し、前記特定した割込操作命令を前記タスク切換回路に送信することを特徴とする請求項2に記載のタスク処理装置。
The interrupt circuit is
A memory that holds an interrupt table in which an interrupt request signal and an interrupt operation instruction are associated with each other;
The operation circuit refers to the interrupt table, specifies an interrupt operation instruction corresponding to the selected interrupt request signal, and transmits the specified interrupt operation instruction to the task switching circuit. 3. The task processing device according to claim 2, wherein
前記メモリは、一の割込要求信号に対して複数の割込操作命令を対応づけ可能なテーブルとして前記割込テーブルを保持し、
前記タスク切換回路は、前記割込回路から受信した割込操作命令において、後続の割込操作命令の存在が指定されているときには、前記操作回路に後続要求信号を送信し、
前記操作回路は、前記後続要求信号を受信したとき、前記割込テーブルを参照して、前記割込操作命令と同じ割込要求信号に対応づけられている後続の割込操作命令を前記タスク切換回路に送信し、
前記タスク切換回路は、前記割込回路から受信した割込操作命令において、後続の割込操作命令の不存在が指定されているときには、前記割込操作命令の実行を完了したときに前記操作完了信号を前記割込回路に送信することを特徴とする請求項4に記載のタスク処理装置。
The memory holds the interrupt table as a table capable of associating a plurality of interrupt operation instructions with one interrupt request signal,
The task switching circuit transmits a subsequent request signal to the operation circuit when the presence of a subsequent interrupt operation instruction is specified in the interrupt operation instruction received from the interrupt circuit,
When the operation circuit receives the subsequent request signal, it refers to the interrupt table and switches the subsequent interrupt operation command associated with the same interrupt request signal as the interrupt operation command to the task switching. To the circuit,
The task switching circuit completes the operation when execution of the interrupt operation instruction is completed when the absence of a subsequent interrupt operation instruction is specified in the interrupt operation instruction received from the interrupt circuit. The task processing device according to claim 4, wherein a signal is transmitted to the interrupt circuit.
前記割込回路は、複数種類の割込要求信号のうちの一部である高速割込要求信号についての割込操作命令を前記タスク切換回路に送信し、
前記タスク切換回路は、前記高速割込要求信号以外の通常割込要求信号を受信したときには、所定の割込タスクを実行するためのデータを前記処理レジスタにロードさせた上で、前記割込タスクにより前記通常割込要求信号に対応した処理を実行させることを特徴とする請求項1に記載のタスク処理装置。
The interrupt circuit transmits an interrupt operation instruction for a high-speed interrupt request signal that is a part of a plurality of types of interrupt request signals to the task switching circuit,
When the task switching circuit receives a normal interrupt request signal other than the high-speed interrupt request signal, the task switching circuit loads data for executing a predetermined interrupt task into the processing register, and then the interrupt task The task processing device according to claim 1, wherein a process corresponding to the normal interrupt request signal is executed by the step.
前記処理レジスタのデータを退避させるためのレジスタであって、複数のタスクに対してそれぞれ対応づけられる複数の退避レジスタ、を更に備え、
前記タスク切換回路は、前記システムコール信号を受信したとき、前記第1のタスクに対応づけられている退避レジスタに前記処理レジスタのデータを退避させ、前記第2のタスクに対応づけられている退避レジスタのデータを前記処理レジスタにロードすることを特徴とする請求項1に記載のタスク処理装置。
A register for saving data in the processing register, further comprising a plurality of save registers respectively associated with a plurality of tasks;
When the task switching circuit receives the system call signal, the task switching circuit saves the data in the processing register in the save register associated with the first task, and saves the data in the save task associated with the second task. The task processing apparatus according to claim 1, wherein data in a register is loaded into the processing register.
JP2009242328A 2009-10-21 2009-10-21 Task processing device Active JP5204740B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2009242328A JP5204740B2 (en) 2009-10-21 2009-10-21 Task processing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2009242328A JP5204740B2 (en) 2009-10-21 2009-10-21 Task processing device

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
JP2008522140A Division JPWO2009022371A1 (en) 2007-08-16 2007-08-16 Task processing device

Publications (2)

Publication Number Publication Date
JP2010049700A true JP2010049700A (en) 2010-03-04
JP5204740B2 JP5204740B2 (en) 2013-06-05

Family

ID=42066674

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2009242328A Active JP5204740B2 (en) 2009-10-21 2009-10-21 Task processing device

Country Status (1)

Country Link
JP (1) JP5204740B2 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013175610A1 (en) 2012-05-24 2013-11-28 カーネロンシリコン株式会社 Task processor
JP2017123190A (en) * 2017-03-08 2017-07-13 ルネサスエレクトロニクス株式会社 Task processing device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001075820A (en) * 1999-09-07 2001-03-23 Oki Electric Ind Co Ltd Real time os device
JP2003271399A (en) * 2002-01-09 2003-09-26 Matsushita Electric Ind Co Ltd Processor and program executing method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001075820A (en) * 1999-09-07 2001-03-23 Oki Electric Ind Co Ltd Real time os device
JP2003271399A (en) * 2002-01-09 2003-09-26 Matsushita Electric Ind Co Ltd Processor and program executing method

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
CSNG200000225021; 板橋 光義: 'リアルタイムOSのハードウェア化とその評価' 情報処理学会研究報告(93-ARC-103) 第93巻,第111号, 19931217, p.183-190, 財団法人情報処理学会 *
JPN6013005621; 板橋 光義: 'リアルタイムOSのハードウェア化とその評価' 情報処理学会研究報告(93-ARC-103) 第93巻,第111号, 19931217, p.183-190, 財団法人情報処理学会 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013175610A1 (en) 2012-05-24 2013-11-28 カーネロンシリコン株式会社 Task processor
US9753779B2 (en) 2012-05-24 2017-09-05 Renesas Electronics Corporation Task processing device implementing task switching using multiple state registers storing processor id and task state
JP2017123190A (en) * 2017-03-08 2017-07-13 ルネサスエレクトロニクス株式会社 Task processing device

Also Published As

Publication number Publication date
JP5204740B2 (en) 2013-06-05

Similar Documents

Publication Publication Date Title
US10949249B2 (en) Task processor
JP4119945B2 (en) Task processing device
JP6153925B2 (en) Task processing device
JP4088335B1 (en) Virtual queue processing circuit and task processing device
JP4127848B2 (en) Task processing device
JP5155336B2 (en) Task processing device
JP2018180768A (en) Semiconductor device
JP5204740B2 (en) Task processing device
JP2017123190A (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: 20100618

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20100816

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A821

Effective date: 20100816

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20100924

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20121106

RD03 Notification of appointment of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7423

Effective date: 20121109

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20121220

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20130215

R150 Certificate of patent or registration of utility model

Ref document number: 5204740

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20160222

Year of fee payment: 3

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313113

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