TWI476696B - Work processing device - Google Patents

Work processing device Download PDF

Info

Publication number
TWI476696B
TWI476696B TW098101355A TW98101355A TWI476696B TW I476696 B TWI476696 B TW I476696B TW 098101355 A TW098101355 A TW 098101355A TW 98101355 A TW98101355 A TW 98101355A TW I476696 B TWI476696 B TW I476696B
Authority
TW
Taiwan
Prior art keywords
work
circuit
processing
register
state
Prior art date
Application number
TW098101355A
Other languages
Chinese (zh)
Other versions
TW200937294A (en
Inventor
Naotaka Maruyama
Original Assignee
Kernelon Silicon Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kernelon Silicon Inc filed Critical Kernelon Silicon Inc
Publication of TW200937294A publication Critical patent/TW200937294A/en
Application granted granted Critical
Publication of TWI476696B publication Critical patent/TWI476696B/en

Links

Classifications

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Executing Machine-Instructions (AREA)

Description

工作處理裝置Work processing device

本發明係關於一種OS(作業系統:Operating System)的功能,特別是關於一種輔助處理器(co-processor)的控制。The present invention relates to the function of an OS (Operating System), and more particularly to the control of a co-processor.

不限於個人電腦等的汎用機器用OS,行動電話等的專用機器用OS亦要求具有高度的功能。特別是,能以1個CPU(Central Processing Unit)執行複數個工作的OS(以下,將此種類型之OS稱為「多工OS」)係裝載於大多電子機器。It is not limited to a general-purpose device OS such as a personal computer, and a dedicated device OS such as a mobile phone is also required to have a high level of function. In particular, an OS that can perform a plurality of operations with one CPU (Central Processing Unit) (hereinafter, this type of OS is referred to as a "multiplexed OS") is mounted on most electronic devices.

多工OS將CPU之處理時間分割成單位時間(時間片段:Time Slice),將時間片段依序分配至複數個工作。各工作僅能在被OS賦予時間片段時使用CPU。在各時間片段執行一個工作。由於對使用者而言時間片段為非常短的時間,因此複數個工作感覺似乎是同時執行。根據此種處理方法,工作A成為輸入待機狀態而暫時不需要CPU之處理能力時,將執行櫂賦予另一個工作B以有效活用CPU之處理能力。此處,所謂執行櫂係與CPU之使用櫂同義。The multiplexed OS divides the processing time of the CPU into unit time (time slice: Time Slice), and sequentially allocates time segments to a plurality of jobs. Each job can only use the CPU when it is given a time segment by the OS. Perform a job at each time segment. Since the time segment is very short time for the user, multiple work feelings seem to be performed simultaneously. According to this processing method, when the operation A becomes the input standby state and the processing capability of the CPU is not required for the time being, the execution is given to another job B to effectively utilize the processing power of the CPU. Here, the so-called execution system is synonymous with the use of the CPU.

將多工OS切換工作之執行權的動作稱為「工作切換」。工作切換,係在時間片段經過時、或在工作執行既定指令時產生。多工OS在工作切換之執行時序到達時,將執行中之工作之上下文資訊儲存於TCB(工作控制區塊:Task Control Block)。上下文資訊,係工作執行時儲存於CPU之暫存器的資料與工作執行狀態相關的資料。TCB係為了保持工作固有的資訊而由記憶體所確保的區域。多工OS將執行中之工作之上下文資訊儲存於TCB後,選擇下一個分配有執行櫂的工作,從該工作之TCB讀取上下文資訊,載入至CPU暫存器。以此方式,各工作以時間片段為單位逐漸執行本身的處理。The action of the execution right of the multiplexed OS switching operation is referred to as "work switching". Work switching occurs when a time segment passes, or when a job executes a given instruction. The multiplexed OS stores the context information of the work being performed in the TCB (Working Control Block: Task Control Block) when the execution timing of the work switching arrives. The context information is the data related to the work execution status of the data stored in the CPU's scratchpad during work execution. The TCB is an area secured by the memory in order to maintain the information inherent in the work. The multiplexed OS stores the context information of the work being performed in the TCB, selects the next work assigned to the execution ,, reads the context information from the TCB of the work, and loads it into the CPU scratchpad. In this way, each job gradually performs its own processing in units of time segments.

雖多工OS具有能高效率執行複數個工作的優點,但亦具有新產生上下文資訊之儲存、載入之酬載(Overhead)的缺點。然而,一般而言,即使工作切換伴隨有酬載,多工OS仍具有許多優點。Although the multiplexed OS has the advantage of being able to perform a plurality of tasks with high efficiency, it also has the disadvantage of newly generating contextual information storage and loading overhead (Overhead). However, in general, multiplexed OS has many advantages even if the work switching is accompanied by a payload.

專利文獻1:日本特開平11-272480號公報Patent Document 1: Japanese Laid-Open Patent Publication No. Hei 11-272480

專利文獻2:日本特開2001-75820號公報Patent Document 2: Japanese Laid-Open Patent Publication No. 2001-75820

專利文獻3:日本特開平11-234302號公報Patent Document 3: Japanese Laid-Open Patent Publication No. Hei 11-234302

專利文獻4:日本特開2000-10803號公報Patent Document 4: Japanese Laid-Open Patent Publication No. 2000-10803

專利文獻5:日本特開2000-276362號公報Patent Document 5: Japanese Laid-Open Patent Publication No. 2000-276362

非專利文獻1:森久直、坂卷佳壽美、重松宏志「用於箝入式控制系統之即時OS的硬體化(Hardware implementation of a real-time operating system for embedded control system)」、東京都立產業技術研究所研究報告、日本、2005年8月4日、p.55-58Non-Patent Document 1: Mori Katsuhisa, 坂卷佳寿美, 重松宏志 "Hardware implementation of a real-time operating system for embedded control system", Tokyo Metropolitan Industry Research Report of the Institute of Technology, Japan, August 4, 2005, p.55-58

近年來,嚴格要求在一定時間內完成處理之即時OS(以下,稱為「RTOS(Real-Time Operating System)」)以箝入式系統(Embedded System)為中心逐漸普及。在此種時間要求嚴格的RTOS,工作切換時之酬載有可能對系統整體之效能造成大的影響。In recent years, an instant OS (hereinafter referred to as "RTOS (Real-Time Operating System)" which is strictly required to be processed in a certain period of time has been gradually popularized with an embedded system (Embedded System). In such a time-critical RTOS, the payload of the work switching may have a large impact on the overall performance of the system.

又,亦有很多將工作之一部分交給CPU以外之輔助處理器的情形。輔助處理器有例如DMAC(直接記憶體存取控制器:Direct Memory Access Controller)、浮點運算單元(FPU:Floating-point Processing Unit)、密碼處理單元等。以下,將輔助處理器執行處理的動作稱為「輔助處理」。輔助處理器係特定之輔助處理的專用電路。因此,一般而言,相較於以CPU執行相同輔助處理,以輔助處理器執行較快速。然而,在利用CPU與輔助處理器之複數個硬體資源時會產生特有的酬載。為了進一步提升RTOS的效能,重要的課題在於抑制輔助處理伴隨的酬載。Also, there are many cases where one part of the work is handed over to an auxiliary processor other than the CPU. The auxiliary processor includes, for example, a DMAC (Direct Memory Access Controller), a Floating Point Processing Unit (FPU), a cryptographic processing unit, and the like. Hereinafter, an operation in which the auxiliary processor executes processing is referred to as "auxiliary processing". The auxiliary processor is a dedicated circuit that is specifically assisted in processing. Therefore, in general, the execution of the auxiliary processor is faster than performing the same auxiliary processing with the CPU. However, a unique payload is generated when utilizing multiple hardware resources of the CPU and the auxiliary processor. In order to further improve the performance of the RTOS, an important issue is to suppress the payload accompanying the auxiliary processing.

本發明人根據上述著眼點而完成本發明,其主要目的在於提供一種用以於多工處理更高效率執行控制工作的技術,特別是提供一種用以使輔助處理高速化的技術。The present inventors have completed the present invention in light of the above-described points, and a main object thereof is to provide a technique for performing control work with higher efficiency in multiplex processing, and more particularly to provide a technique for speeding up auxiliary processing.

本發明之形態為工作處理裝置。The form of the invention is a work processing device.

此裝置具備處理暫存器,將資料從記憶體載入至處理暫存器、依處理暫存器之資料執行工作的執行控制電路,儲存各工作之狀態資料的狀態暫存器,控制工作之執行狀態的工作切換電路,根據既定選擇條件選擇工作的工作選擇電路,及執行輔助處理的輔助處理電路。The device has a processing register, a data storage device from the memory to the processing register, an execution control circuit for performing work according to the data of the processing register, a state register for storing the status data of each job, and a control work. The operation switching circuit of the execution state selects the operation selection circuit for the operation according to the predetermined selection condition, and the auxiliary processing circuit that performs the auxiliary processing.

執行控制電路,當執行系統呼叫指令時,通知工作切換電路。工作選擇電路,從表示待機為可執行狀態之READY(準備)狀態之工作之中選擇成為執行對象的工作。The control circuit is executed to notify the work switching circuit when the system call instruction is executed. The work selection circuit selects an operation to be executed from among the operations indicating the READY state in which the standby state is the executable state.

工作切換電路,藉由系統呼叫指令執行時之工作選擇電路的輸出選擇成為下一個執行對象的工作,將處理暫存器之資料保留於既定記憶區域,且設定變更執行中之工作的狀態資料,對選擇之工作,將保留於記憶區域之資料載入至處理暫存器,且將該狀態資料從READY狀態變更為RUN狀態,藉此切換成為執行對象的工作。The work switching circuit selects the output of the work selection circuit when the system call instruction is executed to be the next execution target, retains the data of the processing register in the predetermined memory area, and sets the status data of the work in the change execution. For the selection work, the data retained in the memory area is loaded into the processing register, and the status data is changed from the READY state to the RUN state, thereby switching the operation to be performed.

工作要求執行輔助處理時,工作切換電路指示輔助處理電路執行輔助處理。When the work requires execution of the auxiliary processing, the work switching circuit instructs the auxiliary processing circuit to perform the auxiliary processing.

載入至處理暫存器之資料,可為指令(instruction)與運算元(Operand)、不具運算元的指令、或程式計數器與堆疊指標等單純的資料。根據此處理方法,由於以狀態暫存器管理工作的狀態,因此工作切換電路能根據來自工作選擇電路的輸出執行工作切換。工作要求執行輔助處理時,工作切換電路以一維方式接收此執行要求,對輔助處理電路指示執行輔助處理亦可。此時,藉由工作切換電路能以一維方式管理輔助處理控制。The data loaded into the processing register can be an instruction (instruction) and an operand (Operand), an instruction without an operand, or a simple data such as a program counter and a stacking indicator. According to this processing method, since the status is managed by the status register, the work switching circuit can perform the operation switching based on the output from the operation selection circuit. When the work requires execution of the auxiliary processing, the work switching circuit receives the execution request in a one-dimensional manner, and instructs the auxiliary processing circuit to perform the auxiliary processing. At this time, the auxiliary processing control can be managed in a one-dimensional manner by the work switching circuit.

此外,以上構成要素之任意組合,或以方法、系統、記錄媒體、電腦程式表現本發明者,作為本發明之形態亦有效。Further, any combination of the above constituent elements, or the present invention by a method, a system, a recording medium, or a computer program is also effective as an aspect of the present invention.

根據本發明,可於多工處理實現更高效率之工作的執行控制。According to the present invention, execution control of a more efficient work can be realized in multiplex processing.

首先,將藉由電子電路實現多工OS之工作排程之工作處理裝置100說明為「基本例」。之後,將對改良例2之工作處理裝置100而言較佳之「雙放入型佇列演算法(後述)」之硬體構裝說明為「改良例1」。最後,將使輔助處理高速化之工作處理裝置100說明為「改良例2」。First, the work processing device 100 that realizes the work scheduling of the multiplexed OS by the electronic circuit will be described as a "basic example." Then, the hardware configuration of the "double-input type array algorithm (described later)" which is preferable to the work processing apparatus 100 of the second modification is described as "modified example 1". Finally, the work processing apparatus 100 that speeds up the auxiliary processing is described as "Modification 2".

以下,「本實施例」之敘述原則上表示「基本例」及「改良例1」、「改良例2」全部。In the following, the description of "this embodiment" is in principle all the "basic examples", "improved example 1" and "modified example 2".

(基本例)(basic example)

本實施例所示之工作處理裝置100,以電子電路實現多工OS之工作排程功能。在詳細說明工作處理裝置100前,首先以圖1說明工作的狀態遷移。此處,雖說明一般之多工OS之工作的狀態遷移,但工作處理裝置100之工作的狀態遷移亦相同。又,亦概要說明於工作處理裝置100所執行之系統呼叫。除了以圖2及圖3說明一般之多工OS的設計思想之外,亦以圖4至圖10詳細說明本實施例之工作處理裝置100的處理方法。再者,亦適當將旗號(Semaphore)、互斥(Mutex)、及事件等相關處理與一般技術比較來說明工作處理裝置100的特徵。The work processing apparatus 100 shown in this embodiment realizes the work scheduling function of the multiplexed OS by an electronic circuit. Before explaining the work processing apparatus 100 in detail, first, the state transition of the operation will be described with reference to FIG. Here, although the state transition of the operation of the general multiplexed OS is described, the state transition of the operation of the work processing apparatus 100 is also the same. Also, the system call executed by the work processing apparatus 100 is also outlined. The processing method of the work processing apparatus 100 of this embodiment will be described in detail with reference to FIGS. 4 to 10, in addition to the design concept of a general multiplexed OS described with reference to FIGS. 2 and 3. Furthermore, the characteristics of the work processing apparatus 100 will be described by comparing the related processing of the Semaphore, the Mutex, and the event with the general technique as appropriate.

(工作的狀態遷移)(state transition of work)

圖1係工作的狀態遷移圖。Figure 1 is a state transition diagram of the work.

在多工處理,各工作具有「狀態(State)」。各工作在後述複數個狀態間遷移,而恆成為任一狀態。狀態遷移之契機,係「系統呼叫之執行」與「中斷要求訊號之檢測」。系統呼叫係各工作執行之指令中的特別指令。中斷要求訊號係按下鍵盤、敲擊滑鼠、接收通訊資料等,從周邊機器接收既定資料時產生的訊號。當然,分配至各工作的時間片段經過後亦產生狀態遷移。In multiplex processing, each job has a "state". Each operation moves between a plurality of states described later, and is always in any state. The opportunity for state transition is "execution of system call" and "detection of interrupt request signal". System calls are special instructions in the instructions for each job execution. The interrupt request signal is a signal generated when a predetermined data is received from a peripheral device by pressing a keyboard, tapping a mouse, receiving a communication data, and the like. Of course, state transitions are also generated after the time segments assigned to each job pass.

工作大致分為「一般工作」與「特殊工作」的2種類。一般工作係以系統呼叫為契機所執行之通常的工作。特殊工作係以中斷要求訊號之檢測為契機所執行的工作。即所謂中斷處理程式(Interrupt Handler)。首先,說明各工作狀態後,再說明各種系統呼叫指令。The work is broadly divided into two categories: "general work" and "special work." The general work is the usual work performed by the system call. The special work is the work performed by the detection of the interrupt request signal. This is called the Interrupt Handler. First, after explaining each operating state, various system call commands will be described.

(1)STOP狀態(停止狀態)(1) STOP status (stop status)

表示工作為停止狀態。一般工作與特殊工作皆有可能成為STOP狀態。以下,將處於STOP狀態之工作稱為「STOP-工作」。Indicates that the work is in a stopped state. Both normal work and special work may become STOP. Hereinafter, the work in the STOP state is referred to as "STOP-work".

1-1.一般工作1-1. General work

當工作執行指示另一個工作啟動之系統呼叫(以下,稱為「啟動系統呼叫」)時,處於STOP狀態之一般工作遷移至後述READY狀態。When the job execution indicates a system call initiated by another job (hereinafter referred to as "start system call"), the general work in the STOP state transitions to the READY state described later.

1-2.特殊工作1-2. Special work

特殊工作通常處於STOP狀態。藉由後述工作切換電路210檢測出中斷要求訊號時,特殊工作從STOP狀態遷移至後述RUN狀態。此時,原本處於RUN狀態之工作遷移至READY狀態。Special work is usually in STOP. When the interrupt request signal is detected by the operation switching circuit 210 described later, the special operation transitions from the STOP state to the RUN state described later. At this time, the work that was originally in the RUN state migrates to the READY state.

(2)RUN狀態(執行狀態)(2) RUN status (execution status)

表示工作正在執行中。亦即,將時間片段分配給工作而取得CPU之使用櫂的狀態。一般工作與特殊工作皆有可能成為RUN狀態。以下,將處於RUN狀態之工作稱為「RUN-工作」。複數個工作中,能成為RUN狀態之工作恆僅有1個,2個工作無法同時成為RUN狀態。Indicates that work is in progress. That is, the time segment is assigned to the work to obtain the state of use of the CPU. Both general work and special work may become RUN. Hereinafter, the operation in the RUN state is referred to as "RUN-work". In a plurality of jobs, there is only one operation that can be in the RUN state, and two jobs cannot simultaneously become the RUN state.

2-1.一般工作2-1. General work

處於RUN狀態之一般工作,當執行既定系統呼叫時從RUN狀態遷移至READY狀態或後述WAIT狀態。處於RUN狀態之一般工作,在時間片段經過後,亦遷移至READY狀態。不論是何種情形,處於READY狀態之一般工作遷移至RUN狀態以替換原本處於RUN狀態之一般工作。當檢測出中斷要求訊號時,RUN-工作遷移至READY狀態。此時,處於STOP狀態之特殊工作遷移至RUN狀態。The general operation in the RUN state transitions from the RUN state to the READY state or the WAIT state described later when a predetermined system call is executed. The general work in the RUN state also migrates to the READY state after the time segment has elapsed. In either case, the general work in the READY state transitions to the RUN state to replace the normal work that was originally in the RUN state. When the interrupt request signal is detected, the RUN-work transitions to the READY state. At this time, the special work in the STOP state transitions to the RUN state.

當RUN-工作執行使本身結束之系統呼叫(以下,稱為「結束系統呼叫」)時,RUN-工作遷移至STOP狀態。When the RUN-work performs a system call that ends itself (hereinafter referred to as "end system call"), the RUN-work transitions to the STOP state.

2-2.特殊工作2-2. Special work

因中斷要求訊號而從STOP狀態遷移至RUN狀態的特殊工作,當結束本身處理時回到STOP狀態。特殊工作有可能成為的狀態僅為STOP狀態與RUN狀態。The special operation of transitioning from the STOP state to the RUN state due to the interrupt request signal returns to the STOP state when the processing itself is terminated. The status that special work may become is only the STOP state and the RUN state.

(3)READY狀態(可執行狀態)(3) READY state (executable state)

表示工作為可執行狀態。處於READY狀態之工作,被OS賦予執行櫂時皆可遷移至RUN狀態。僅一般工作有可能成為READY狀態。以下,將處於READY狀態之工作稱為「READY-工作」。Indicates that the work is in an executable state. The work in the READY state can be migrated to the RUN state when it is executed by the OS. Only general work may become a READY state. Hereinafter, the work in the READY state is referred to as "READY-work".

處於RUN狀態之一般工作藉由系統呼叫之執行而遷移至RUN狀態以外的狀態時,或處於RUN狀態之特殊工作結束本身的處理而遷移至STOP狀態時,READY-工作遷移至RUN狀態。一般工作僅從READY狀態遷移至RUN狀態。當處於READY狀態之工作有複數個時,根據上下文資訊之一部分的工作優先順序,其中一個READY-工作遷移至RUN狀態。當工作優先順序相同之READY-工作有複數個時,最早移至READY狀態之工作遷移至RUN狀態。When the general operation in the RUN state transitions to a state other than the RUN state by the execution of the system call, or when the special operation of the RUN state ends, the process shifts to the STOP state, and the READY-work transitions to the RUN state. Normal work only moves from the READY state to the RUN state. When there are multiple jobs in the READY state, one of the READY-work moves to the RUN state according to the work priority of one of the context information. When there are multiple READY-work jobs with the same work priority, the work moving to the READY state at the earliest moves to the RUN state.

(4)WAIT狀態(待機狀態)(4) WAIT status (standby status)

表示工作正在等待既定WAIT解除條件成立的狀態。當WAIT解除條件成立時,處於WAIT狀態之工作遷移至READY狀態。僅一般工作有可能成為WAIT狀態。以下,將處於WAIT狀態之工作稱為「WAIT-工作」。關於WAIT解除條件將在之後詳細說明。Indicates that the work is waiting for the state in which the established WAIT release condition is established. When the WAIT release condition is established, the work in the WAIT state transitions to the READY state. Only general work may become a WAIT state. Hereinafter, the work in the WAIT state is referred to as "WAIT-work". The WAIT cancellation conditions will be described in detail later.

綜合上述,各工作僅能在處於RUN狀態時使用CPU執行本身的處理。RTOS一邊管理複數個工作的狀態,一邊適當切換RUN-工作。據此,可實現CPU隨時執行任一工作的處理形態。In summary, each job can only perform its own processing using the CPU when it is in the RUN state. The RTOS manages the status of a plurality of jobs while appropriately switching the RUN-work. According to this, it is possible to realize a processing form in which the CPU executes any work at any time.

(系統呼叫)(system call)

接著,說明系統呼叫。系統呼叫大致分為「啟動系統」、「WAIT系統」、「SET系統」的3種類。Next, the system call will be explained. System calls are roughly classified into three types: "Startup System", "WAIT System", and "SET System".

(1)啟動系統系統呼叫(1) Start system system call

STOP狀態與READY狀態之間之遷移相關的系統呼叫。System call related to the migration between the STOP state and the READY state.

1-1.啟動系統呼叫1-1. Start system call

RUN-工作之工作A使另一個一般工作B啟動的系統呼叫。此時,處於STOP狀態之一般工作B遷移至READY狀態。RUN-Working Work A makes another system call initiated by General Work B. At this time, the general work B in the STOP state transits to the READY state.

1-2.結束系統呼叫1-2. End system call

執行此系統呼叫之工作,結束本身的處理,從RUN狀態遷移至STOP狀態。結束系統呼叫亦可為某個工作使另一個工作結束的指令。Execute the work of this system call, end its own processing, and move from the RUN state to the STOP state. Ending a system call can also be an instruction to end another job for a job.

(2)WAIT系統系統呼叫(2) WAIT system system call

RUN狀態與WAIT狀態之間之遷移相關的系統呼叫。System call related to the migration between the RUN state and the WAIT state.

2-1.待幾旗號系統呼叫2-1. Waiting for several flag system calls

要求獲得旗號(後述)的系統呼叫。Ask for a system call with a banner (described later).

2-2.待幾互斥系統呼叫2-2. Waiting for several mutually exclusive system calls

要求獲得互斥(後述)的系統呼叫。Request for a system call that is mutually exclusive (described later).

2-3.待幾事件系統呼叫2-3. Waiting for several event system calls

等待事件(後述)成立的系統呼叫。除了事件ID之外,待幾旗標類型(後述)與旗標條件(後述)亦作為變數執行。A system call that is awaiting an event (described later). In addition to the event ID, the flag type (described later) and the flag condition (described later) are also executed as variables.

不論是何種情形,均藉由WAIT系統系統呼叫設定各種WAIT解除條件。當WAIT系統系統呼叫執行時,在WAIT解除條件已成立之狀況下,執行系統呼叫之RUN-工作遷移至READY狀態。另一方面,當WAIT解除條件不成立時,RUN-工作遷移至等待WAIT解除條件成立的WAIT狀態。In any case, various WAIT cancellation conditions are set by the WAIT system system call. When the WAIT system system call is executed, the RUN-work of the system call is moved to the READY state under the condition that the WAIT release condition is established. On the other hand, when the WAIT release condition is not established, the RUN-work transitions to the WAIT state in which the WAIT release condition is satisfied.

(3)SET系統系統呼叫(3) SET system system call

WAIT狀態與READY狀態之間之遷移相關的系統呼叫。SET系統系統呼叫之執行為WAIT解除條件的成立契機。A system call related to the migration between the WAIT state and the READY state. The execution of the SET system system call is an opportunity for the establishment of the WAIT cancellation condition.

3-1.解除旗號系統呼叫3-1. Unlocking the system call

解除旗號的系統呼叫。Unlock the system call.

3-2.解除互斥系統呼叫3-2. Disabling Mutual System Calls

解除互斥的系統呼叫。Unmutate system calls.

3-3.設定事件系統呼叫3-3. Setting the event system call

設定事件之現行旗標類型(後述)的系統呼叫。Set the system call for the current flag type (described later) of the event.

3-4.清除旗標系統呼叫3-4. Clearing the flag system call

用以將現行旗標類型清除為零的系統呼叫。A system call to clear the current flag type to zero.

於本實施例,以上述合計9種類之系統呼叫為對象進行說明,但除此以外當然亦可構裝各種系統呼叫。In the present embodiment, a description will be given of the total of nine types of system calls, but it is of course possible to construct various system calls.

(一般RTOS的設計思想)(General RTOS design ideas)

圖2係一般RTOS的概念圖。Figure 2 is a conceptual diagram of a general RTOS.

此RTOS係多工OS。一般RTOS係實現為軟體。以將RUN-工作從工作A切換至工作B之情形為例進行說明。由於工作A佔有CPU,因此RTOS對CPU發出中斷,從工作A拿回CPU之使用櫂。此外,將工作A之上下文資訊儲存於TCB。RTOS選擇工作B作為下一個RUN-工作,將上下文資訊從工作B之TCB載入至CPU的暫存器。當載入結束時,RTOS將CPU之使用櫂交給工作B。以此方式,藉由RTOS暫時取得CPU之使用櫂,執行工作A至工作B之工作切換。關於特殊工作的執行亦相同。此時,將RUN-工作之上下文資訊儲存於TCB後,將CPU之使用櫂交給特殊工作以實現工作切換。This RTOS is a multiplexed OS. The general RTOS is implemented as software. The case where the RUN-work is switched from the work A to the work B will be described as an example. Since the work A occupies the CPU, the RTOS issues an interrupt to the CPU and retrieves the use of the CPU from the work A. In addition, the context information of Work A is stored in the TCB. The RTOS selects Work B as the next RUN-work, loading context information from the TCB of Work B to the scratchpad of the CPU. When the loading is finished, the RTOS hands over the CPU to Work B. In this way, the work switching from work A to work B is performed by temporarily taking the CPU usage by the RTOS. The implementation of special work is also the same. At this time, after storing the context information of the RUN-work in the TCB, the usage of the CPU is handed over to the special work to realize the work switching.

由於RTOS係實現為軟體,因此為了執行本身之處理必須要CPU之使用櫂。亦即,RTOS與工作在CPU之使用上為競爭關係。以下,將以此方式藉由軟體實現之RTOS稱為「軟體RTOS」。Since the RTOS is implemented as software, it is necessary to use the CPU in order to perform its own processing. That is, the RTOS competes with the use of the CPU in its work. Hereinafter, the RTOS implemented by software in this manner is referred to as "software RTOS".

圖3係軟體RTOS所執行之一般CPU的電路圖。Figure 3 is a circuit diagram of a general CPU executed by the software RTOS.

CPU84包含統括地控制記憶體存取與指令之執行等的執行控制電路90、儲存工作之上下文資訊等各種資料的處理暫存器92、及執行運算的運算電路94。處理暫存器92係複數種類之暫存器的集合,大致分為特殊暫存器88與汎用暫存器86。特殊暫存器88係保持程式計數器、堆疊指標、旗標等的暫存器。汎用暫存器86係保持作業用之資料的暫存器,包含R0~R15的合計16個暫存器。雖特殊暫存器88有使用者用與系統用的二種,但汎用暫存器86僅有一種。以下,將儲存於處理暫存器92的資料稱為「處理資料」。The CPU 84 includes a processing register 90 that collectively controls the execution of the memory access and execution of the instructions, a processing register 92 that stores various kinds of data such as the context information of the operation, and an arithmetic circuit 94 that performs the calculation. The processing register 92 is a collection of a plurality of types of registers, and is roughly classified 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 indicator, a flag, and the like. The general-purpose register 86 is a register for holding data for operation, and includes a total of 16 registers of R0 to R15. Although the special register 88 has two types for the user and the system, the general-purpose register 86 has only one type. 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 outputs the processing data of the desired register in the processing register 92 to the arithmetic circuit 94 by the control signal (CTRL) of the output selector 98. The arithmetic circuit 94 performs operations on the processing data, that is, the instructions and variables. The result of the operation is output to the input selector 96. The execution control circuit 90 inputs the operation result to the desired register in the processing register 92 by the control signal (CTRL) to the input selector 96.

又,執行控制電路90,透過CPU資料匯流排從記憶體讀取資料,透過輸入選擇器96適當載入至處理暫存器92。執行控制電路90,同樣地透過CPU資料匯流排將處理資料適當紀錄於記憶體。執行控制電路90一邊更新特殊暫存器88的程式計數器一邊執行工作。Further, the execution control circuit 90 reads data from the memory through the CPU data bus and appropriately loads it into the processing register 92 through the input selector 96. The execution control circuit 90 similarly records the processing data in the memory through the CPU data bus. The execution control circuit 90 performs the operation while updating the program counter of the special register 88.

當產生工作切換時,執行控制電路90將處理資料儲存於記憶體上之區域的TCB。假設工作A執行系統呼叫,產生從工作A至工作B的工作切換。由於RTOS以系統呼叫執行為契機而取得CPU的使用櫂,因此CPU84暫時依RTOS用的程式執行動作。其處理過程如下述。When a work switching is generated, the execution control circuit 90 stores the processing data in the TCB of the area on the memory. Assume that job A performs a system call, resulting in a work switch from work A to work B. Since the RTOS acquires the CPU usage by taking the system call execution as an opportunity, the CPU 84 temporarily performs an operation in accordance with the program for the RTOS. The process is as follows.

(工作A之上下文資訊的儲存)(Storage of context information for Work A)

1.執行控制電路90,將特殊暫存器88從使用者用切換至系統用。RTOS處理用之處理資料係載入至系統用的特殊暫存器88。1. Execution control circuit 90 switches special register 88 from the user to the system. The processing data for RTOS processing is loaded into the special scratchpad 88 for the system.

2.執行控制電路90,將汎用暫存器86之資料儲存於未圖示的堆疊。2. Execution control circuit 90 stores the data of general purpose register 86 in a stack (not shown).

3.執行控制電路90,將RTOS用之處理資料從未圖示之記憶媒體、例如另一個暫存器載入至汎用暫存器86。在此階段,處理暫存器92之處理資料完全替換成RTOS用之處理資料。3. Execution control circuit 90 loads the processing data for the RTOS into a general purpose register 86 from a memory medium, such as another temporary memory, not shown. At this stage, the processing data of the processing register 92 is completely replaced with the processing data for the RTOS.

4.RTOS自記憶體檢測工作A之TCB,將儲存於堆疊的處理資料寫入TCB。又,使用者用特殊暫存器88之處理資料亦作為上下文資訊的一部分而寫入TCB。以此方式,將工作A之處理資料儲存於TCB。RTOS將工作A從「RUN」狀態遷移至「READY(或WAIT)」的動作儲存於工作A之TCB。4. The RTOS self-memory detects the TCB of the work A, and writes the processing data stored in the stack to the TCB. Moreover, the user uses the processing data of the special register 88 to also write to the TCB as part of the context information. In this way, the processing data of job A is stored in the TCB. The action of the RTOS to move the work A from the "RUN" state to the "READY (or WAIT)" is stored in the TCB of the work A.

(工作B之上下文資訊的載入)(Loading of context information for Work B)

1.RTOS自記憶體檢測工作B之TCB,將TCB之上下文資訊寫入堆疊與使用者用特殊暫存器88。RTOS將工作B從「READY」狀態遷移至「RUN」的動作記錄於工作B之TCB。1. The RTOS self-memory detects the TCB of the work B, and writes the context information of the TCB to the stack and the user-specific special register 88. The action of the RTOS to move the work B from the "READY" state to the "RUN" state is recorded in the TCB of the work B.

2.RTOS將RTOS處理用之資料從汎用暫存器86儲存至未圖示之記錄媒體。2. The RTOS stores the data for RTOS processing from the general purpose register 86 to a recording medium not shown.

3.執行控制電路90,將堆疊之上下文資訊載入至汎用暫存器86。執行控制電路90,將特殊暫存器88從系統用切換至使用者用。以此方式,將工作B之處理資料載入至處理暫存器92。3. Execution control circuit 90 loads the stacked context information into general purpose register 86. The control circuit 90 is executed to switch the special register 88 from the system to the user. In this way, the processing data of job B is loaded into the processing register 92.

經由以上處理過程可實現工作切換。一般而言,由於汎用暫存器86僅有一種,因此為了切換工作用之處理資料與RTOS用之處理資料而使用堆疊。若汎用暫存器86亦具有二種,則不需透過堆疊儲存、載入,因此可執行更快速的工作切換。Work switching can be achieved through the above process. In general, since there is only one type of general-purpose register 86, stacking is used in order to switch the processing data for work and the processing data for the RTOS. If the general purpose register 86 also has two types, it does not need to be stored and loaded through the stack, so that a faster work switching can be performed.

於本實施例,藉由進一步依各工作設置保留暫存器110,可實現更快速的工作切換。以圖5詳細說明使用保留暫存器110的工作切換。可知在以圖3說明之CPU84與一般軟體RTOS之情形,當工作切換時,頻繁產生對TCB的存取。在上述假設例,雖以從工作A工作切換至工作B為前題進行說明,但實際上,RTOS為選擇下一個待執行之工作B,亦須執行多數指令。此時,RTOS頻繁地存取記憶體。本實施例之工作處理裝置100,為了使後述工作控制電路200專用於工作選擇處理,實現更快速的工作切換。In this embodiment, by further retaining the temporary storage device 110 according to each work setting, a faster work switching can be realized. The work switching using the reservation register 110 is explained in detail in FIG. It can be seen that in the case of the CPU 84 and the general software RTOS illustrated in FIG. 3, access to the TCB is frequently generated when the operation is switched. In the above hypothetical example, although the work from the work A work to the work B is explained, in reality, the RTOS has to execute the majority of the work B to select the next work B to be executed. At this time, the RTOS frequently accesses the memory. The work processing apparatus 100 of the present embodiment realizes faster work switching in order to make the operation control circuit 200 to be described later dedicated to the work selection processing.

(工作處理裝置100之RTOS的硬體化)(hardware of RTOS of work processing apparatus 100)

圖4係本實施例之RTOS的概念圖。Fig. 4 is a conceptual diagram of the RTOS of the present embodiment.

與一般軟體RTOS不同,本實施例之RTOS主要實現為與CPU不同之另一個硬體。以下,將藉由硬體實現之RTOS稱為「硬體RTOS」。由於本實施例之RTOS主要為與CPU不同之另一個硬體,因此執行本身的處理時實質上幾乎不需要CPU的使用權。亦即,RTOS與工作在CPU之使用上幾乎不會成為競爭關係。圖2所示之一般軟體RTOS之情形,CPU為工作執行用電路亦為RTOS執行用電路。相對於此,本實施例之硬體RTOS之情形,CPU明確地為工作執行用電路,工作排程功能能以後述儲存電路120與工作控制電路200為中心實現。Unlike the general software RTOS, the RTOS of this embodiment is mainly implemented as another hardware different from the CPU. Hereinafter, the RTOS implemented by hardware is referred to as a "hard RTOS." Since the RTOS of the present embodiment is mainly another hardware different from the CPU, substantially no CPU usage right is required to execute the processing itself. That is, the RTOS will hardly compete with the use of the CPU. In the case of the general software RTOS shown in FIG. 2, the CPU is a circuit for executing the operation and is also an RTOS execution circuit. On the other hand, in the case of the hardware RTOS of the present embodiment, the CPU is clearly a work execution circuit, and the work scheduling function can be realized centering on the storage circuit 120 and the work control circuit 200 which will be described later.

圖5係本實施例之工作處理裝置100的電路圖。Fig. 5 is a circuit diagram of the work processing apparatus 100 of the present embodiment.

工作處理裝置100除了CPU150之外亦包含儲存電路120與工作控制電路200。CPU150係工作的執行主體,儲存電路120與工作控制電路200係具有圖4所示之RTOS之功能的電路。工作排程處理,係藉由工作控制電路200主導。The work processing apparatus 100 includes a storage circuit 120 and a work control circuit 200 in addition to the CPU 150. The CPU 150 is an execution body of the operation, and the storage circuit 120 and the operation control circuit 200 are circuits having the function of the RTOS shown in FIG. The work scheduling process is dominated by the work 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 can also be a general CPU illustrated in FIG. However, the CPU 150 of the present embodiment and the CPU 84 shown in FIG. 3 have some modifications in the method of connecting the signal lines and the like. The following Figure 6 details the specific circuit configuration.

工作控制電路200包含工作切換電路210、旗號表212、事件表214、工作選擇電路230、及狀態記憶部220。以圖13之後詳細說明旗號表212與事件表214。狀態記憶部220係與各工作相對應的單元。以下,將與工作A對應之狀態記憶部220表記為「狀態記憶部220_A」。各狀態記憶部220保持工作的狀態資料。狀態資料,係上下文資訊中,特別是表示工作優先順序與狀態等工作屬性的資訊。以圖10詳細說明具體資料的內容。所有工作之所有狀態資料係從各狀態記憶部220隨時輸出至工作選擇電路230。工作選擇電路230,係根據各工作的狀態資料執行RUN-工作之選擇等各種工作選擇的電路。亦以圖10之後詳細說明工作選擇電路230。工作切換電路210,當檢測出從執行控制電路152接收之系統呼叫訊號(SC)與來自外部裝置之中斷要求訊號(INTR)時,執行工作切換。The work control circuit 200 includes a work switching circuit 210, a flag table 212, an event table 214, a work selection circuit 230, and a state memory unit 220. The flag table 212 and the event table 214 will be described in detail later with reference to FIG. The state memory unit 220 is a unit corresponding to each operation. Hereinafter, the state memory unit 220 corresponding to the job A is referred to as "state memory unit 220_A". Each state memory unit 220 holds the state data of the operation. The status data is the context information, especially the information indicating the work attributes such as work priority and status. The contents of the specific materials will be described in detail with reference to FIG. All status data for all jobs is output from the status memory unit 220 to the work selection circuit 230 at any time. The work selection circuit 230 is a circuit that performs various work selections such as selection of a RUN-operation based on state data of each job. The work selection circuit 230 will also be described in detail later with reference to FIG. The work switching circuit 210 performs an operation switching when detecting a system call signal (SC) received from the execution control circuit 152 and an interrupt request signal (INTR) from an external device.

執行控制電路152,當系統呼叫執行時,將系統呼叫訊號(SC)傳至工作切換電路210。又,當工作切換電路210檢測出中斷要求訊號(INTR)時,工作切換電路210對執行控制電路152傳送停止要求訊號(HR)。執行控制電路152,當CPU150之動作停止時,將停止結束訊號(HC)傳至工作切換電路210。藉由此等3種類的訊號,CPU150與工作控制電路200產生連動動作。The execution control circuit 152 transmits the system call signal (SC) to the work switching circuit 210 when the system call is executed. Further, when the work switching circuit 210 detects the interrupt request signal (INTR), the work switching circuit 210 transmits a stop request signal (HR) to the execution control circuit 152. The execution control circuit 152 transmits the stop end signal (HC) to the work switching circuit 210 when the operation of the CPU 150 is stopped. The CPU 150 and the work control circuit 200 are interlocked by the three types of signals.

儲存電路120包含載入選擇電路112及複數個保留暫存器110。保留暫存器110亦為與各工作相對應的單元,為用以儲存處理暫存器154之處理資料的暫存器。是以,保留暫存器110具有與處理暫存器154相同、或處理暫存器154以上的資料容量。以下,將與工作A對應之保留暫存器110表記為「保留暫存器110_A」。載入選擇電路112,當接受工作切換電路210的指示時,將任一個保留暫存器110的資料(以下,將保留暫存器110保持的資料稱為「儲存資料」)載入至處理暫存器154。The storage circuit 120 includes a load selection circuit 112 and a plurality of reserved registers 110. The reserved register 110 is also a unit corresponding to each work, and is a register for storing processing data of the processing register 154. Therefore, the reservation register 110 has the same data capacity as the processing register 154 or the processing register 154 or more. Hereinafter, the reservation register 110 corresponding to the job A is referred to as "reserved register 110_A". The load selection circuit 112 loads the data of any of the reserved registers 110 (hereinafter, the data held by the reserved registers 110 is referred to as "storage data") to the processing temporary when the instruction of the work switching circuit 210 is accepted. 154.

各保留暫存器110將個別之儲存資料隨時輸出至載入選擇電路112。當工作切換電路210將指定工作ID之工作選擇訊號(TS)輸入至載入選擇電路112時,載入選擇電路112將與指定之工作對應之保留暫存器110之儲存資料輸出至處理暫存器154。再者,當工作切換電路210對處理暫存器154輸入寫入訊號(WT)時,該儲存資料實際上載入至處理暫存器154。Each of the reserved registers 110 outputs the individual stored data to the load selection circuit 112 at any time. When the work switching circuit 210 inputs the work selection signal (TS) of the designated work ID to the load selection circuit 112, the load selection circuit 112 outputs the stored data of the reserved register 110 corresponding to the designated work to the process temporary storage. 154. Moreover, when the work switching circuit 210 inputs the write signal (WT) to the processing register 154, the stored data is actually loaded into the processing register 154.

另一方面,處理暫存器154之所有處理資料亦隨時輸出至所有保留暫存器110。當工作切換電路210對所欲保留暫存器110傳送寫入訊號(WT)時,處理資料儲存於該保留暫存器110。此處,連接處理暫存器154與各保留暫存器110之匯流排一次可傳送的位元數,係設定成可平行傳送處理資料。因此,工作切換電路210僅將寫入訊號傳至保留暫存器110一次,即可將處理資料一次寫入保留暫存器110。又,連接保留暫存器110與載入選擇電路112、及連接載入選擇電路112與CPU150之匯流排的位元數亦同樣地設定。On the other hand, all processing data of the processing register 154 is also output to all the reserved registers 110 at any time. When the work switching circuit 210 transmits a write signal (WT) to the desired scratchpad 110, the processing data is stored in the reserved register 110. Here, the number of bits that can be transmitted by the connection processing register 154 and the bus pool of each of the reserved registers 110 is set to transmit the processing data in parallel. Therefore, the work switching circuit 210 only transfers the write signal to the reserved register 110 once, and the processed data can be written to the reserved register 110 at a time. Further, the number of bits connecting the reservation register 110 to the load selection circuit 112 and the bus line connecting the load selection circuit 112 and the CPU 150 is also set in the same manner.

以下,分別對系統呼叫與中斷要求訊號說明工作切換的執行方法。In the following, the system call and the interrupt request signal respectively describe the execution method of the work switching.

(1)系統呼叫執行(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)"). The specific stopping method will be described in detail later with reference to FIG. 7 and the like. The execution control circuit 152 transmits a system call signal (SC) indicating the execution of the system call to the work switching circuit 210 of the work control circuit 200. Further, when the stop of CLK is ended, the execution control circuit 152 transmits a stop end signal (HC) to the operation switching circuit 210.

在CPU150與工作切換電路210之間連接有用以傳送系統呼叫訊號的9條訊號線。9條訊號線與上述9種類的系統呼叫對應。執行控制電路152,依執行之系統呼叫的種類,在任一條系統呼叫訊號線傳送數位脈衝。工作切換電路210,能依從9條系統呼叫訊號線中哪一條訊號線檢測出數位脈衝,立即檢測出執行之系統呼叫的種類。工作切換電路210,依系統呼叫的種類,從工作選擇電路230之輸出資料選擇必要的資料,執行系統呼叫所指示的處理。此處理係以HC被傳送為條件執行。以圖10詳細說明工作切換電路210與工作選擇電路230的關係。此外,系統呼叫之參數與回傳值,係寫入處理暫存器154中之既定汎用暫存器158。工作切換電路210能對汎用暫存器158執行參數讀取與回傳值寫入。此處,假設RUN-工作之工作A執行待機旗號系統呼叫。是以,首先,必需儲存工作A的處理資料。Nine signal lines for transmitting system call signals are connected between the CPU 150 and the work switching circuit 210. The nine signal lines correspond to the above nine types of system calls. The execution control circuit 152 transmits a digital pulse on any of the system call signal lines depending on the type of system call being executed. The work switching circuit 210 can detect the digital pulse according to which one of the nine system call signal lines, and immediately detects the type of the system call executed. The work switching circuit 210 selects necessary data from the output data of the work selection circuit 230 depending on the type of system call, and performs processing indicated by the system call. This processing is performed on condition that the HC is transmitted. The relationship between the work switching circuit 210 and the operation selection circuit 230 will be described in detail with reference to FIG. In addition, the parameters of the system call and the return value are written to the predetermined general purpose register 158 in the processing register 154. The work switching circuit 210 can perform parameter reading and return value writing to the general purpose register 158. Here, it is assumed that the RUN-work A performs a standby flag system call. Therefore, first, it is necessary to store the processing data of the work A.

(工作A之上下文資訊的儲存)(Storage of context information for Work A)

執行控制電路152,將表示待機旗號系統呼叫之SC訊號輸入至工作切換電路210。執行控制電路152使CLK停止,停止結束時傳送HC。工作切換電路210,除了對工作選擇電路230所內建之各種選擇電路中之後述旗號選擇電路234輸出待機對象之旗號的旗號ID之外,亦選擇下一個待執行的工作B。工作切換電路210,對狀態記憶部220_A寫入既定資料。例如,將工作A之狀態從「RUN」變更設定成「READY」或「WAIT」。更具體而言,工作切換電路210,除了將「WAIT」輸出至所有狀態記憶部220以作為表示狀態資料中之工作狀態的資料外,亦將寫入訊號(WT_A)僅輸入至狀態記憶部220_A。以此方式,變更工作A之狀態設定。The execution control circuit 152 inputs the SC signal indicating the standby flag system call to the work switching circuit 210. The execution control circuit 152 stops CLK and transmits HC at the end of the stop. The work switching circuit 210 selects the next job B to be executed in addition to the flag ID of the flag of the standby object, which will be described later in the various selection circuits built in the operation selection circuit 230. The work switching circuit 210 writes the predetermined data to the state memory unit 220_A. For example, the status of the job A is changed from "RUN" to "READY" or "WAIT". More specifically, the job switching circuit 210 outputs the write signal (WT_A) to the state memory unit 220_A in addition to the "WAIT" output to all the state memory units 220 as the data indicating the operation state in the state data. . In this way, the status setting of the job A is changed.

接著,工作切換電路210,對保留暫存器110_A輸出寫入訊號(WT)。由於處理暫存器154之處理資料隨時輸出至各保留暫存器110,因此藉由此寫入訊號(WT)儲存於工作A的保留暫存器110_A。Next, the work switching circuit 210 outputs a write signal (WT) to the reserved register 110_A. Since the processing data of the processing register 154 is output to each of the reserved registers 110 at any time, it is stored in the reserved register 110_A of the job A by the write signal (WT).

(工作B之上下文資訊的載入)(Loading of context information for Work B)

當工作切換電路210結束工作A之狀態資料的變更、處理資料的儲存時,將指定工作B之工作選擇訊號(TS_B)輸出至載入選擇電路112。據此,保留暫存器110_B之儲存資料係輸出至處理暫存器154。當工作切換電路210將寫入訊號(WT)輸出至處理暫存器154時,工作B之儲存資料係載入至處理暫存器154。又,工作切換電路210,對工作B之狀態記憶部220寫入既定資料。例如,將工作B之狀態從「READY」變更設定成「RUN」。當結束以上處理時,執行控制電路152再開始CPU時脈。CPU150係藉由再開始之CPU時脈開始工作B的執行。之後以圖8(b)說明處理方法之更進一步的細節。When the work switching circuit 210 ends the change of the state data of the job A and the storage of the processing data, the job selection signal (TS_B) of the designated job B is output to the load selection circuit 112. Accordingly, the stored data of the reserved register 110_B is output to the processing register 154. When the work switching circuit 210 outputs the write signal (WT) to the processing register 154, the stored data of the work B is loaded into the processing register 154. Further, the work switching circuit 210 writes the predetermined data to the state memory unit 220 of the job B. For example, the status of the job B is changed from "READY" to "RUN". When the above processing is ended, the execution control circuit 152 restarts the CPU clock. The CPU 150 starts the execution of the operation B by restarting the CPU clock. Further details of the processing method will be described later with reference to Fig. 8(b).

(2)中斷要求訊號的產生(2) Interrupt request signal generation

工作切換電路210檢測來自周邊機器的中斷要求訊號(INTR)。更具體而言,中斷要求訊號(INTR),係從未圖示之中斷控制器傳至工作切換電路210。表示中斷要求訊號(INTR)之等級的參數,係紀錄於中斷控制器內建的暫存器。工作切換電路210將停止要求訊號(HR)傳至執行控制電路152,執行控制電路152使CPU時脈停止。與系統呼叫執行時相同,工作切換電路210將RUN-工作之處理資料儲存於保留暫存器110。接著,工作切換電路210啟動特殊工作。不論中斷要求訊號之參數如何,啟動之特殊工作為1種類。特殊工作從中斷控制器的內建暫存器讀取INTR的參數,依參數執行處理。特殊工作執行之處理有可能為設定事件系統呼叫或設定旗號系統呼叫的執行,亦有可能為一般工作的啟動。依據參數,特殊工作有可能未執行特殊的處理即結束。依據INTR的參數,執行何種處理係取決於特殊工作的構裝。當特殊工作之執行結束時,從READY-工作之中選擇下一個RUN-工作。The work switching circuit 210 detects an interrupt request signal (INTR) from a peripheral device. More specifically, the interrupt request signal (INTR) is transmitted to the work switching circuit 210 from an interrupt controller not shown. The parameter indicating the level of the interrupt request signal (INTR) is recorded in the scratchpad built into the interrupt controller. The work switching circuit 210 transmits a stop request signal (HR) to the execution control circuit 152, and the execution control circuit 152 stops the CPU clock. The work switching circuit 210 stores the RUN-work processing data in the reservation register 110 as in the case of the system call execution. Next, the work switching circuit 210 initiates a special job. Regardless of the parameters of the interrupt request signal, the special work to start is one type. Special work reads the INTR parameters from the built-in register of the interrupt controller and performs processing according to the parameters. The processing of special work execution may be performed for setting the event system call or setting the flag system call, or it may be the start of general work. Depending on the parameters, special work may end without special processing. Depending on the parameters of the INTR, what kind of processing is performed depends on the configuration of the particular job. When the execution of the special work ends, the next RUN-work is selected from the READY-work.

工作切換電路210將與特殊工作對應之保留暫存器110的處理資料載入至CPU150。此種從一般工作切換至特殊工作所需的時間,能依據工作控制電路200的動作時脈預測。將HR傳至執行控制電路152後,工作切換電路210之動作時脈經過既定時脈分時,工作切換電路210為了解除CPU時脈的停止而停止傳送HR。當執行控制電路152被停止傳送HR時,再開始CPU時脈。此時,結束工作切換電路210之從一般工作至特殊工作的工作切換。之後以圖8(a)說明處理方法的細節。The work switching circuit 210 loads the processing data of the reservation register 110 corresponding to the special operation to the CPU 150. The time required to switch from general work to special work can be predicted based on the operating clock of the work control circuit 200. When the HR is transmitted to the execution control circuit 152, and the operation clock of the operation switching circuit 210 passes the timed pulse, the operation switching circuit 210 stops the transmission of the HR in order to cancel the stop of the CPU clock. When the execution control circuit 152 is stopped transmitting HR, the CPU clock is restarted. At this time, the work switching of the work switching circuit 210 from the normal work to the special work is ended. Details of the processing method will be described later with reference to Fig. 8(a).

不論是何種情形,Whatever the case,

(A)處理資料之儲存、載入(A) Processing and loading of processed data

(B)工作的狀態遷移及RUN-工作的選擇(B) State transition of work and selection of RUN-work

等工作切換的核心處理係藉由硬體實現。關於(A)及(B),即使不需要存取記憶體上之TCB亦有助於工作切換的高速化。又,為實現工作處理裝置100,對CPU150僅追加停止及再開始CPU時脈的功能即可。此外,此等功能皆藉由硬體實現,並未限定本發明的範圍。例如,藉由硬體實現(A)或(B)的主要功能,為了輔助硬體功能,亦能以軟體實現RTOS的一部分功能,此為本發明所屬技術領域中具有通常知識者所應理解之事。The core processing of the work switching is implemented by hardware. Regarding (A) and (B), even if it is not necessary to access the TCB on the memory, the speed of the work switching is facilitated. Further, in order to realize the work processing apparatus 100, only the function of stopping and restarting the CPU clock may be added to the CPU 150. Moreover, these functions are implemented by hardware and do not limit the scope of the invention. For example, by implementing the main functions of (A) or (B) by hardware, in order to assist the hardware function, a part of the functions of the RTOS can also be implemented in software, which is understood by those having ordinary knowledge in the technical field to which the present invention pertains. thing.

圖6係圖5之CPU150的電路圖。FIG. 6 is a circuit diagram of the CPU 150 of FIG. 5.

與圖3之CPU84不同,於處理暫存器154,特殊暫存器156與汎用暫存器158皆僅有一種。於處理暫存器154,分別追加來自載入選擇電路112的輸入匯流排、至保留暫存器110的輸出匯流排、及來自工作切換電路210之寫入訊號(WT)用的訊號線。執行控制電路152,藉由對輸出選擇器164的控制訊號(CTRL),將處理暫存器92中之所欲暫存器的資料輸入至運算電路160。運算結果成為至輸入選擇器162的輸入。執行控制電路152,藉由對輸入選擇器162的控制訊號(CTRL),將運算結果輸入至處理暫存器154中之所欲暫存器。執行控制電路152一邊更新特殊暫存器156的程式計數器一邊執行工作。Unlike the CPU 84 of FIG. 3, there is only one type of special register 156 and special register 158 in the processing register 154. In the processing register 154, an input bus from the load selection circuit 112, an output bus to the reserved register 110, and a signal line for the write signal (WT) from the operation switching circuit 210 are added. The execution control circuit 152 inputs the data of the desired register in the processing register 92 to the arithmetic circuit 160 by the control signal (CTRL) of the output selector 164. The result of the operation becomes an input to the input selector 162. The execution control circuit 152 inputs the operation result to the desired register in the processing register 154 by the control signal (CTRL) to the input selector 162. The execution control circuit 152 performs the operation while updating the program counter of the special register 156.

處理資料並非儲存於記憶體上之TCB,而是儲存於保留暫存器110。處理資料隨時從處理暫存器154輸出至各保留暫存器110。實際上,處理資料在何時序儲存於何保留暫存器110,如上述係藉由工作切換電路210所控制。The processing data is not stored in the TCB on the memory, but stored in the reserved register 110. The processing data is output from the processing register 154 to each of the reserved registers 110 at any time. In fact, when the processing data is stored in the reservation register 110, as described above, it is controlled by the work switching circuit 210.

並非從記憶體上之TCB,而是從保留暫存器110將儲存資料載入至處理暫存器154。實際上,在何時序將何保留暫存器110的處理資料載入,如上述係藉由工作切換電路210所控制。Rather than from the TCB on the memory, the stored data is loaded from the scratchpad 110 to the processing register 154. In fact, when the processing data of the reservation register 110 is sequentially loaded, as described above, it is controlled by the work switching circuit 210.

連接處理暫存器154與載入選擇電路112、及連接處理暫存器154與保留暫存器110的匯流排,係能一次平行傳送處理資料之位元數的匯流排。因此,藉由工作切換電路210之寫入訊號(WT),能一次讀取與寫入。一般軟體RTOS,當工作切換時,必須暫時佔有處理暫存器154,相對於此,本實施例之硬體RTOS,不需將用於工作切換處理的特別處理資料載入至處理暫存器154。當從工作A切換至工作B時,由於儲存工作A的處理資料後僅載入工作B的處理資料,因此不需要將處理暫存器154分成系統用與使用者用的2種、或執行透過堆疊之資料的替換處理。The connection processing register 154 and the load selection circuit 112, and the bus line connecting the processing register 154 and the reserved register 110 are capable of transmitting the bus bars of the number of bits of the processing data in parallel at a time. Therefore, the write and write can be performed at one time by the write signal (WT) of the work switching circuit 210. The general software RTOS must temporarily occupy the processing register 154 when the operation is switched. In contrast, the hardware RTOS of the embodiment does not need to load the special processing data for the work switching processing into the processing register 154. . When switching from the work A to the work B, since only the processing data of the work B is loaded after the processing data of the job A is stored, it is not necessary to divide the processing register 154 into two types for the system and the user, or to perform the transmission. Replacement processing of stacked data.

圖7係顯示執行控制電路152使CPU時脈停止之構造的電路圖。Fig. 7 is a circuit diagram showing a configuration in which the execution control circuit 152 stops the CPU clock.

第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之輸出固定為0,CPU時脈(CLK)停止。The input of the second AND gate 174 is the output of the original clock (CLK0) and the first AND gate 172, the latter being negative logic. The output of the first AND gate 172 stops the end signal (HC). Since the stop end signal (HC) is normally 0, the second AND gate 174 directly outputs the input original clock (CLK0) as the CPU clock (CLK). The CPU 150 operates by receiving the CPU clock output from the second AND gate 174. When the output of the first AND gate 172 is "1", that is, when the stop signal (HC) = 1, the output of the second AND gate 174 is fixed to 0, and the CPU clock (CLK) is stopped.

第1AND閘172的輸入係OR閘176的輸出與CPU忙碌訊號(CBUSY)的輸出,後者係負邏輯。CBUSY,係從產生CPU150之內部周期的既知狀態機器輸出的訊號,當CPU150為可停止之狀態時為「1」的訊號。例如,運算電路94使執行中之單一指令或被鎖定之複數個指令的最後指令結束,當CPU為可停止之狀態時、或CPU時脈之供應已停止時為「0」。The input of the first AND gate 172 is the output of the OR gate 176 and the output of the CPU busy signal (CBUSY), which is 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 of "1" when the CPU 150 is in a stop state. For example, the arithmetic circuit 94 ends the execution of the single instruction or the last instruction of the locked plurality of instructions, and is "0" when the CPU is in a stop state or when the supply of the CPU clock has stopped.

OR閘176的輸入,係指令解碼器170的輸出(SC_DETECT)與來自工作切換電路210的停止要求訊號(HR)。指令解碼器170內建有保持SC_DETECT的鎖存器電路。指令解碼器170,以從CPU150讀取的資料(FD)為輸入,當FD為系統呼叫指令時輸出SC_DETECT=1。藉由內建鎖存器電路,即使之後FD變化,指令解碼器170亦隨時輸出SC_DETECT=1。工作切換電路210對處理暫存器154之寫入訊號(WT)亦輸入至指令解碼器170。當WT從0變成1時,如上述執行將儲存資料載入至處理暫存器154的動作。此WT係在既定時間後從1回到0的脈衝訊號。當WT從1變成0時,指令解碼器170的鎖存器電路被重設,指令解碼器170停止傳送SC_DETECT。以圖8(b)詳細說明SC_DETECT與寫入訊號(WT)的關係。本實施例之指令解碼器170,係為了判定執行對象指令是否為系統呼叫而專門設在執行控制電路152的裝置。作為變形例,指令解碼器170與擔當CPU150之解碼步驟的CPU解碼器共通化亦可。此時,指令解碼器170,可藉由在CPU解碼器追加當解碼之資料為系統呼叫指令時輸出SC_DETECT=1的功能來實現。The input of the OR gate 176 is the output of the command decoder 170 (SC_DETECT) and the stop request signal (HR) from the work switching circuit 210. The instruction decoder 170 has a built-in latch circuit that holds SC_DETECT. The instruction decoder 170 takes as input the data (FD) read from the CPU 150, and outputs SC_DETECT=1 when the FD is a system call instruction. With the built-in latch circuit, the instruction decoder 170 outputs SC_DETECT=1 at any time even if the FD changes thereafter. The write signal (WT) of the work switching circuit 210 to the processing register 154 is also input to the instruction decoder 170. When the WT changes from 0 to 1, the action of loading the stored data into the processing register 154 is performed as described above. This WT is a pulse signal that returns from 1 to 0 after a predetermined time. When the WT changes from 1 to 0, the latch circuit of the instruction decoder 170 is reset, and the instruction decoder 170 stops transmitting SC_DETECT. The relationship between SC_DETECT and the write signal (WT) is explained in detail in FIG. 8(b). The instruction decoder 170 of the present embodiment is a device specially provided for executing the control circuit 152 in order to determine whether or not the execution target instruction is a system call. As a modification, the command decoder 170 may be common to the CPU decoder that is the decoding step of the CPU 150. At this time, the command decoder 170 can be realized by adding a function of SC_DETECT=1 when the CPU decoder adds a data to be decoded when the decoded data is a system call command.

當產生中斷要求訊號(INTR)時,工作切換電路210將停止要求訊號(HR)傳至執行控制電路152。亦即,當執行系統呼叫時、或傳送停止要求訊號(HR)時,OR閘176的輸出為「1」。When the interrupt request signal (INTR) is generated, the work switching circuit 210 transmits the stop request signal (HR) to the execution control circuit 152. That is, when the system call is executed or the stop request signal (HR) is transmitted, the output of the OR gate 176 is "1".

綜上所述,當執行系統呼叫或產生中斷要求訊號,且CPU忙碌訊號為「0」時,第1AND閘172的輸出為「1」,CPU時脈不會從第2AND閘174輸出。As described above, when a system call or an interrupt request signal is generated and the CPU busy signal is "0", the output of the first AND gate 172 is "1", and the CPU clock is not output from the second AND gate 174.

圖8(a)係顯示中斷要求訊號產生時之各種訊號之關係的時序圖。Fig. 8(a) is a timing chart showing the relationship of various signals when the interrupt request signal is generated.

圖8(a)中,首先,在時刻t0,工作切換電路210檢測出來自外部的中斷要求訊號(INTR)。工作切換電路210,為執行特殊工作,將停止要求訊號(HR)傳至執行控制電路152。輸入時序t1,係與檢測時序t0大致同時。在時刻t1,CPU150之狀態機器係「工作執行中」、CBUSY=1。由於HR=1,因此OR閘176輸出「1」,但因CBUSY=1故CPU150不停止。因此,即使輸入HR=1,CPU時脈(CLK)亦暫時與原時脈(CLK)同步輸出。In Fig. 8(a), first, at time t0, the operation switching circuit 210 detects an interrupt request signal (INTR) from the outside. The work switching circuit 210 transmits a stop request signal (HR) to the execution control circuit 152 for performing a special operation. The input timing t1 is approximately the same as the detection timing t0. At time t1, the state machine of the CPU 150 is "work in progress" and CBUSY=1. Since HR=1, the OR gate 176 outputs "1", but the CPU 150 does not stop because CBUSY=1. Therefore, even if the input HR=1, the CPU clock (CLK) is temporarily output in synchronization with the original clock (CLK).

時間經過後,在時刻t2變化成CBUSY=0。由於已HR=1,因此第1AND閘172輸出HC=1,從第2AND閘174輸出之CPU時脈固定為0。另一方面,工作切換電路210,以HC被傳送為契機,開始從一般工作至特殊工作的工作切換。其詳細後述,但此工作切換所需時間以工作控制電路200的動作時脈需數次。從HC被傳送起,以工作控制電路200的動作時脈變化既定次數為條件(時刻t3),工作控制電路200停止傳送停止要求訊號(HR)。由於HR=0,因此執行控制電路152使CPU時脈(CLK)再開始。當CPU150再開始處理時,CPU150使CBUSY從0變成1(時刻t4)。以此方式,從CPU時脈停止的時刻t2至時刻t3之間,執行從一般工作至特殊工作的工作切換。After the elapse of time, it changes to CBUSY=0 at time t2. Since HR=1, the first AND gate 172 outputs HC=1, and the CPU clock output from the second AND gate 174 is fixed to zero. On the other hand, the work switching circuit 210 starts the operation switching from the normal work to the special work with the HC being transmitted as an opportunity. The details will be described later, but the time required for the operation switching is required to be several times in the operation clock of the operation control circuit 200. From the time when the HC is transmitted, the operation control circuit 200 stops the transmission stop request signal (HR) on the condition that the operation clock circuit changes the predetermined number of times of the operation control circuit 200 (time t3). Since HR=0, the execution control circuit 152 restarts the CPU clock (CLK). When the CPU 150 restarts the processing, the CPU 150 changes CBUSY from 0 to 1 (time t4). In this way, from the time t2 to the time t3 when the CPU clock is stopped, the work switching from the normal work to the special work is performed.

此外,另一個處理方法,取代工作控制電路200的動作時脈變化既定次數的條件,以工作控制電路200結束工作切換為條件,停止傳送HR亦可。又,執行控制電路152,以HR被停止傳送為條件,停止傳送HC亦可。當HC=0時,執行控制電路152使CPU時脈(CLK)再開始。以此方式使工作的執行再開始亦可。Further, another processing method may be used to stop the transmission of the HR by the condition that the operation control circuit 200 ends the operation switching, instead of the condition that the operation clock of the operation control circuit 200 changes by a predetermined number of times. Further, the execution control circuit 152 may stop the transmission of the HC on the condition that the HR is stopped. When HC = 0, the execution control circuit 152 restarts the CPU clock (CLK). In this way, the execution of the work can be resumed.

圖8(b)係顯示系統呼叫執行時之各種訊號之關係的時序圖。Figure 8(b) is a timing diagram showing the relationship of various signals when the system call is executed.

圖8(b)中,首先,在時刻t0,指令解碼器170檢測出系統呼叫,使SC_DETECT從0變成1。在時刻t0,CPU150之狀態機器係「工作執行中」、CBUSY=1。由於SC_DETECT=1,因此OR閘176輸出「1」,但因CBUSY=1故CPU150不停止。因此,即使輸出SC_DETECT=1,CPU時脈(CLK)亦暫時與原時脈(CLK0)同步輸出。In FIG. 8(b), first, at time t0, the command decoder 170 detects a system call and changes SC_DETECT from 0 to 1. At time t0, the state machine of the CPU 150 is "work in progress" 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 the output SC_DETECT=1, the CPU clock (CLK) is temporarily output in synchronization with the original clock (CLK0).

時間經過後,在時刻t1變化成CBUSY=0。由於SC_DETECT=1且CBUSY=1,因此HC被停止傳送,CPU時脈停止。工作切換電路210,當輸入HC=0時,開始工作切換處理,將寫入訊號(WT)輸出至CPU150。在WT從0變成1之時刻t2,儲存資料係載入至處理暫存器154。寫入訊號(WT),因脈衝訊號在既定時間經過後的時刻t3變成WT=0。藉由此WT:1→0的下降檢測,鎖存於指令解碼器170之SC_DETECT被重設(時刻t4)。此時,CBUSY從0變成1。由於CBUSY=1,因此HC=0,再開始CPU時脈。從CPU時脈停止的時刻t1至時刻t4之間,執行工作切換。After the elapse of time, it changes to CBUSY=0 at time t1. Since SC_DETECT=1 and CBUSY=1, the HC is stopped and the CPU clock is stopped. The operation switching circuit 210 starts the operation switching process when the input HC=0, and outputs the write signal (WT) to the CPU 150. At time t2 when the WT changes from 0 to 1, the stored data is loaded into the processing register 154. The write signal (WT) is changed to WT=0 at the time t3 after the pulse signal has passed at a predetermined time. By the falling detection of WT:1→0, the SC_DETECT latched in the instruction decoder 170 is reset (time t4). At this time, CBUSY changes from 0 to 1. Since CBUSY=1, HC=0, and then start the CPU clock. The operation switching is performed from the time t1 to the time t4 when the CPU clock is stopped.

此外,另一個處理方法,取代WT:1→0的下降檢測條件,以工作控制電路200結束工作切換,停止傳送HR為條件,執行控制電路152停止傳送HC亦可。以HC=0為條件,重設SC_DETECT。執行控制電路152使CPU時脈(CLK)再開始,CBUSY從0變成1。Further, in another processing method, instead of the falling detection condition of WT:1→0, the operation control circuit 200 ends the operation switching, the transmission of the HR is stopped, and the execution control circuit 152 stops the transmission of the HC. Reset SC_DETECT with HC=0 as a condition. The execution control circuit 152 restarts the CPU clock (CLK) and changes CBUSY from 0 to 1.

不論是何種情形,CPU150皆不需在CPU時脈停止期間辨識RUN-工作之切換的執行。由於工作切換電路210,在CPU時脈停止,亦即CPU150凍結(Freeze)的期間執行工作切換處理,因此CPU150之處理與工作控制電路200之處理在程序控制上係分離。In either case, the CPU 150 does not need to recognize the execution of the RUN-work switch during the CPU clock stop. Since the work switching circuit 210 performs the work switching process while the CPU clock is stopped, that is, the CPU 150 freezes (Freeze), the processing of the CPU 150 and the processing of the work control circuit 200 are separated in program control.

圖9係用以說明管線處理之CPU時脈之停止時序的示意圖。Fig. 9 is a schematic diagram for explaining the stop timing of the CPU clock of the pipeline processing.

CPU150一邊將複數個指令從記憶體依序讀取至處理暫存器154一邊執行,以執行工作。此工作之執行單位的指令可分解成以下4個階段。The CPU 150 executes while executing a plurality of instructions from the memory sequentially to the processing register 154. The instructions of the execution unit of this work can be broken down into the following four stages.

1.F(Fetch:讀取):從記憶體取出指令。1.F (Fetch: Read): Take the instruction from the memory.

2.D(Decode:解碼):解釋指令。2.D (Decode: Decode): Interpret the instruction.

3.E(Execution:執行):執行指令。3.E (Execution: Execution): Execute the instruction.

4.WB(Write Back:寫入):將執行結果寫入記憶體。4.WB (Write Back: Write): Write the execution result to the memory.

某個工作依序從指令1執行至指令5時,在執行指令1之F至WB之後,執行指令2之F亦可。然而,為了高效率執行,大多在指令1執行中即開始指令2的執行。此種處理方法稱為管線處理。例如,當指令1執行至D階段時,開始指令2之F階段。當指令1執行至E階段時,執行指令2之D階段、指令3之F階段。以此方式,藉由增加每單位時間所執行之指令數,可減少每個工作的執行時間。When a certain operation is executed from the instruction 1 to the instruction 5 in sequence, after executing the F to WB of the instruction 1, the F of the instruction 2 may be executed. However, for efficient execution, the execution of the instruction 2 is mostly started during the execution of the instruction 1. This type of processing is called pipeline processing. For example, when instruction 1 is executed to stage D, the F phase of instruction 2 is started. When the instruction 1 is executed to the E stage, the D stage of the instruction 2 and the F stage of the instruction 3 are executed. In this way, by increasing the number of instructions executed per unit time, the execution time of each job can be reduced.

再者,亦可將各階段細分成2個階段。例如,將F階段分離成F1:F2的2個階段。當指令1執行至F2階段時,開始指令2之F1階段。當指令1執行至D1階段時,執行指令2之F2階段、指令3之F1階段。藉由將階段細分,可更高效率地利用CPU150之計算資源。圖9係說明在將各階段細分成2個階段而進行之管線處理,產生系統呼叫時的CPU時脈停止時序。Furthermore, each stage can be subdivided into two stages. For example, the F phase is separated into two phases of F1:F2. When instruction 1 is executed to the F2 stage, the F1 phase of instruction 2 is started. When the instruction 1 is executed to the D1 phase, the F2 phase of the instruction 2 and the F1 phase of the instruction 3 are executed. By subdividing the stages, the computing resources of the CPU 150 can be utilized more efficiently. Fig. 9 is a diagram showing the CPU clock stop timing when a system call is made by subdividing each stage into two stages.

圖9中,指令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 Fig. 9, the command 1 starts processing at the timing of the CPU clock "0". At the timing of the CPU clock "4", the decoding of the command 1 is ended. Assume that instruction 1 is a system call. The instruction decoder 170 changes SC_DETECT from 0 to 1. Next, the condition that SC_DETECT returns from 0 to 0 is that the write signal (WT) from the work switching circuit 210 to the processing register 154 is changed from 1 to 0. Even if SC - DETECT = 1, CBUSY = 1 because instructions 2 - 5 have been executed or have been executed. Therefore, the second AND gate 174 starts outputting following the CPU clock. However, the execution control circuit 152 temporarily stops the update of the program counter when SC - DETECT = 1 so that the new instruction is not read. Therefore, after instruction 6, it will not be read from the memory and read.

雖在CPU時脈「8」的時序指令1執行結束,但由於指令2~5在執行中,因此CPU忙碌訊號維持「1」。至CPU時脈「12」的時序時指令5執行結束。此時,CPU忙碌訊號為「0」。之後,依圖8(b)之處理,停止CPU時脈的供應。工作切換電路210,將指令5結束為止之階段的處理資料儲存於保留暫存器110。依據此種停止方法,可不浪費系統呼叫執行後之指令的執行結果執行工作切換。當工作切換結束時,CPU忙碌訊號再次被設定成「1」,指令解碼器170的處理亦再開始。以此方式,再次供應CPU時脈。Although the execution of the sequence command 1 of the CPU clock "8" is completed, since the commands 2 to 5 are being executed, the CPU busy signal is maintained at "1". The execution of the instruction 5 ends when the timing of the CPU clock "12" is reached. At this time, the CPU busy signal is "0". Thereafter, according to the processing of FIG. 8(b), the supply of the CPU clock is stopped. The work switching circuit 210 stores the processing data at the stage until the end of the command 5 in the reservation register 110. According to this stop method, the work switching can be performed without wasting the execution result of the instruction after the execution of the system call. When the work switching is completed, the CPU busy signal is set to "1" again, and the processing of the command decoder 170 is resumed. In this way, the CPU clock is supplied again.

此外,另一個處理方法,在系統呼叫指令執行結束之時序,設CPU忙碌訊號為「0」,停止CPU時脈的供應亦可。此時,與系統呼叫指令同時執行之其他指令在執行途中即停止。將中途停止之指令的中間處理結果記錄於處理暫存器154後,儲存於保留暫存器110。此工作下一次成為RUN-工作時,執行中途停止之指令的後續處理。例如,某個指令在結束讀取之階段中途停止時,將從記憶體讀取之指令或運算元儲存於保留暫存器110。當工作再開始時,保留暫存器110的資料係載入至處理暫存器154,從解碼步驟執行後續處理。In addition, another processing method, when the system call instruction is executed, sets the CPU busy signal to “0” to stop the supply of the CPU clock. At this time, other instructions executed simultaneously with the system call instruction are stopped during execution. The intermediate processing result of the instruction that has been stopped midway is recorded in the processing register 154 and stored in the reserved register 110. When this work becomes RUN-work next time, the subsequent processing of the instruction that is stopped midway is executed. For example, when an instruction stops in the middle of the end of reading, the instruction or operand read from the memory is stored in the reserved register 110. When the work resumes, the data of the reserved scratchpad 110 is loaded into the processing register 154, and subsequent processing is performed from the decoding step.

圖10係顯示狀態記憶部220與工作切換電路210之關係的電路圖。FIG. 10 is a circuit diagram showing the relationship between the state memory unit 220 and the operation switching circuit 210.

狀態記憶部220包含狀態暫存器250與計時器252,狀態記憶部220保持工作的狀態資料。又,計時器252,係工作遷移至READY狀態或WAIT狀態時開始的計時器。將工作遷移至READY狀態後經過的時間稱為「READY經過時間」,將工作遷移至WAIT狀態後經過的時間稱為「WAIT經過時間」。計時器252之值係作為TIM訊號而隨時輸出。工作切換電路210,當執行工作切換時,某個工作變成READY狀態或WAIT狀態時,驅動此工作之計時器252再開始時間測量。The state memory unit 220 includes a state register 250 and a timer 252, and the state memory unit 220 maintains the state data of the operation. Further, the timer 252 is a timer that starts when the operation transitions to the READY state or the WAIT state. The elapsed time after the work is moved to the READY state is called "READY elapsed time", and the elapsed time after the work is moved to the WAIT state is called "WAIT elapsed time". The value of the timer 252 is output as a TIM signal at any time. The work switching circuit 210, when a certain work becomes a READY state or a WAIT state when the work switching is performed, the timer 252 that drives the work restarts the time measurement.

狀態記憶部220係以下所示暫存器的集合。The state memory unit 220 is a set of registers shown below.

(A)工作ID暫存器254:保持工作ID。表示工作ID之ID訊號係從工作ID暫存器254隨時輸出至工作選擇電路230。以下,將從工作A之工作ID暫存器254輸出至工作選擇電路230的ID訊號表記為「ID_A訊號」。從狀態記憶部220輸出之其他訊號亦相同。(A) Work ID register 254: Keep the work ID. The ID signal indicating the job ID is output from the job ID register 254 to the job selection circuit 230 at any time. Hereinafter, the ID signal table outputted from the job ID register 254 of the job A to the job selection circuit 230 is referred to as "ID_A signal". The other signals output from the state memory unit 220 are also the same.

(B)工作優先順序暫存器256:保持工作優先順序。表示工作優先順序之PR訊號係從工作優先順序暫存器256隨時輸出。「0」為最高優先順序,值愈大表示工作優先順序愈低。(B) Work Priority Order 256: Maintain work priority. The PR signal indicating the priority of the work is output from the work priority register 256 at any time. "0" is the highest priority, and the larger the value, the lower the job priority.

(C)工作狀態暫存器258:表示工作狀態。STOP、READY、RUN、WAIT、IDLE其中之一係作為ST訊號而隨時輸出。此外,IDLE係工作初始化之前的狀態。(C) Working Status Register 258: Indicates the operating status. One of STOP, READY, RUN, WAIT, and IDLE is output as an ST signal at any time. In addition, IDLE is the state before the work is initialized.

(D)工作啟動位址暫存器260:表示記憶體中工作之TCB位址。輸出為AD訊號。(D) Work Start Address Register 260: indicates the TCB address of the work in the memory. The output is an AD signal.

(E)待機理由暫存器262:當工作為WAIT狀態時,表示WAIT解除條件之一部分的待機理由。待機理由為「旗號等待」、「事件等待」、「互斥等待」其中之一。輸出為WR訊號。(E) Standby reason register 262: When the operation is in the WAIT state, it indicates the reason for the standby of one of the WAIT cancellation conditions. The standby reason is one of "flag waiting", "event waiting", and "mutual exclusion". The output is a WR signal.

(F)旗號ID暫存器264:工作以旗號等待為理由處於WAIT狀態時,保持等待對象之旗號(以下,稱為「待機旗號」)的旗號ID。輸出為SID訊號。(F) Flag ID register 264: When the job is in the WAIT state for the reason of waiting for the flag, the flag ID of the flag of the waiting object (hereinafter referred to as "standby flag") is held. The output is a SID signal.

(G)互斥ID暫存器265:工作以互斥等待為理由處於WAIT狀態時,保持等待對象之互斥(以下,稱為「待機互斥」)的互斥ID。輸出為MID訊號。(G) Mutually exclusive ID register 265: When the operation is in the WAIT state for the reason of mutual exclusion waiting, the mutual exclusion ID of the mutually exclusive object (hereinafter referred to as "standby mutual exclusion") is held. The output is a MID signal.

(H)事件ID暫存器266:工作以事件等待為理由處於WAIT狀態時,保持等待對象之事件(以下,稱為「待機事件」)的事件ID。輸出為EID訊號。(H) Event ID register 266: An event ID of an event (hereinafter referred to as a "standby event") that holds a waiting object when the operation is in the WAIT state for the purpose of event waiting. The output is an EID signal.

(I)待機旗標暫存器268:工作以事件等待為理由處於WAIT狀態時,保持待機旗標類型。輸出為FL訊號。(I) Standby flag register 268: When the operation is in the WAIT state for the reason of event waiting, the standby flag type is maintained. The output is the FL signal.

(J)旗標條件暫存器270:工作以事件等待為理由處於WAIT狀態時,保持旗標條件。輸出為FLC訊號。關於待機旗標類型與旗標條件將於後述。(J) Flag condition register 270: When the job is in the WAIT state for the reason of event waiting, the flag condition is maintained. The output is the FLC signal. The standby flag type and flag conditions will be described later.

(K)旗標初始化暫存器272:保持表示有無待機旗標類型的資料。輸出為FLI訊號。(K) Flag Initialization Register 272: Holds data indicating whether or not there is a standby flag type. The output is an FLI signal.

(L)暫停計數器274:於WAIT系系統呼叫暫停值被指定為變數。暫停計數器274保持暫停值。工作切換電路210定期減少各暫停計數器274的暫停值。輸出為TO訊號。取代工作切換電路210減少暫停值,暫停計數器274本身自律地定期減少本身的暫停值亦可。(L) Pause counter 274: The call pause value in the WAIT system is designated as a variable. The pause counter 274 holds the pause value. The work switching circuit 210 periodically reduces the pause value of each of the pause counters 274. The output is a TO signal. Instead of the work switching circuit 210, the pause value is reduced, and the pause counter 274 itself autonomously periodically reduces its own pause value.

工作選擇電路230根據從各狀態記憶部220輸出的各種訊號,執行工作的選擇。工作選擇電路230包含以下所示電路。The job selection circuit 230 performs selection of an operation based on various signals output from the respective state memory sections 220. The work selection circuit 230 includes the circuit shown below.

(A)執行選擇電路232:當工作切換時,選擇下一個RUN-工作。執行選擇電路232,藉由從狀態記憶部220隨時輸出之狀態資料恆選擇任-個工作作為RUN-工作。執行選擇電路232之輸入訊號為ID、ST、PR、TIM的4種類。輸出為下一個RUN-工作的工作ID。以圖12詳細說明詳細的電路構成。(A) Execution selection circuit 232: When the operation is switched, the next RUN-operation is selected. The execution selection circuit 232 constantly selects any one of the operations as the RUN-operation by the state data outputted from the state memory unit 220 at any time. The input signals of the execution selection circuit 232 are four types of ID, ST, PR, and TIM. The output is the work ID of the next RUN-work. The detailed circuit configuration will be described in detail with reference to FIG.

(B)旗號選擇電路234:藉由解除旗號系統呼叫的執行,選擇待從WAIT狀態遷移至READY狀態的工作。藉由解除旗號系統呼叫解除之旗號(以下,稱為「解除旗號」)的旗號ID係從工作切換電路210輸入。來自狀態記憶部220的輸入訊號為ID、ST、W R、PR、SID、TIM的6種類。輸出訊號為從WAIT狀態遷移至READY狀態之工作的工作ID。該工作不存在時,輸出-1等的既定值。以圖13詳細說明更具體的電路構成。(B) Flag selection circuit 234: Selects a job to be transitioned from the WAIT state to the READY state by releasing the execution of the flag system call. The flag ID of the flag for canceling the flag system call release (hereinafter referred to as "release flag") is input from the work switching circuit 210. The input signals from the state memory unit 220 are six types of ID, ST, W R, PR, SID, and TIM. The output signal is the work ID of the job moving from the WAIT state to the READY state. When the job does not exist, a predetermined value of -1 or the like is output. A more specific circuit configuration will be described in detail with reference to FIG.

(C)事件選擇電路236:藉由設定事件系統呼叫的執行,選擇從WAIT狀態遷移至READY狀態的工作。藉由設定事件系統呼叫設定之事件(以下,稱為「設定事件」)的事件ID係從工作切換電路210輸入。來自狀態記憶部220的輸入訊號為ID、ST、WR、EID、FL、FLC的6種類。輸出訊號為從WAIT狀態遷移至READY狀態之工作的工作ID、及該工作的FL、FLC。(C) Event Selection Circuit 236: Selecting the transition from the WAIT state to the READY state by setting the execution of the event system call. The event ID by setting an event system call setting event (hereinafter referred to as "set event") is input from the work switching circuit 210. The input signals from the state storage unit 220 are six types of ID, ST, WR, EID, FL, and FLC. The output signal is the work ID of the work of transitioning from the WAIT state to the READY state, and the FL and FLC of the job.

(D)暫停檢測電路238:檢測WAIT狀態之工作中、暫停計數器274之暫停值為0的工作。暫停檢測電路238每於更新暫停值時被驅動。暫停檢測電路238的輸入訊號為ID、ST、TO的3種類。輸出訊號為該工作的工作ID。該工作不存在時,輸出-1等的既定值。(D) Pause detection circuit 238: The operation of suspending the counter 274 during the operation of detecting the WAIT state is 0. The pause detection circuit 238 is driven each time the pause value is updated. The input signals of the pause detecting circuit 238 are three types of ID, ST, and TO. The output signal is the work ID of the job. When the job does not exist, a predetermined value of -1 or the like is output.

(E)互斥電路240:藉由解除互斥系統呼叫的執行,選擇從WAIT狀態遷移至READY狀態的工作。藉由解除互斥系統呼叫解除之互斥(以下,稱為「解除互斥」)的互斥ID係從工作切換電路210輸入。來自狀態記憶部220的輸入訊號為ID、ST、WR、PR、SID、TIM的6種類。輸出訊號為從WAIT狀態遷移至READY狀態之工作的工作ID。該工作不存在時,輸出-1等的既定值。(E) Mutual exclusion circuit 240: The operation of transitioning from the WAIT state to the READY state is selected by releasing the execution of the mutex system call. The mutual exclusion ID of the mutual exclusion of the mutual exclusion system call release (hereinafter referred to as "disarming") is input from the work switching circuit 210. The input signals from the state storage unit 220 are six types of ID, ST, WR, PR, SID, and TIM. The output signal is the work ID of the job moving from the WAIT state to the READY state. When the job does not exist, a predetermined value of -1 or the like is output.

(F)檢索電路242:當從工作切換電路210輸入工作ID時,輸出該工作的所有狀態資料。(F) Retrieval circuit 242: When the work ID is input from the work switching circuit 210, all state data of the job is output.

以下,說明工作切換相關之RUN-工作選擇、旗號、事件、互斥、暫停,特別是以工作選擇電路230之處理為中心,與一般技術比較並說明。Hereinafter, the RUN-operation selection, the flag, the event, the mutual exclusion, and the pause related to the work switching will be described, and in particular, the processing of the work selection circuit 230 will be mainly described and compared with the general technique.

(RUN-工作選擇)(RUN-work selection)

(1)一般軟體RTOS之RUN-工作的選擇(1) RUN-work selection of general software RTOS

圖11係顯示一般RTOS之RUN-工作選擇時所利用之工作準備串列的圖。Figure 11 is a diagram showing the work preparation sequence used in the RUN-operation selection of a general RTOS.

工作準備串列,係形成於記憶體上、以指標連結各READY-工作之TCB的串列。優先順序指標280,係按各工作優先順序設置、表示該工作優先順序之工作之TCB的前端位址。圖11中之工作準備串列的情形,工作優先順序「0」之優先順序指標280指向工作A之TCB的位址,工作優先順序「1」之優先順序指標280指向工作B之TCB的位址。工作A之TCB進一步指向工作D之TCB的位址。The work preparation sequence is formed in the memory, and the READY-working TCB is connected in series by an index. The priority indicator 280 is a front end address of the TCB that is set in accordance with each work priority order and indicates the work priority order. In the case of the work preparation sequence in FIG. 11, the priority order indicator 280 of the work priority order “0” points to the address of the TCB of the work A, and the priority order indicator 280 of the work priority order “1” points to the address of the TCB of the work B. . The TCB of Work A further points to the address of the TCB of Work D.

一般軟體RTOS一邊掃描此工作準備串列一邊選擇下一個RUN-工作。此時,RTOS執行下述2階段的處理。The general software RTOS scans this work preparation string while selecting the next RUN-work. At this time, the RTOS performs the following two stages of processing.

A.將RUN-工作從RUN狀態遷移至READY。A. Migrate RUN-work from RUN to READY.

B.選擇下一個RUN-工作,將此工作之工作狀態從READY狀態遷移至RUN。B. Select the next RUN-work and move the working state of this work from the READY state to RUN.

若分解軟體RTOS之各處理則如下所示。The processing of the decomposed software RTOS is as follows.

(RUN-工作之狀態遷移)(RUN-work state transition)

此處,RUN-工作係以工作J說明。Here, the RUN-work is described in Work J.

A1.RTOS將RUN-工作之工作ID保持於記憶體。根據此工作ID取得工作J之TCB的位址。A1. The RTOS keeps the RUN-working ID in memory. According to this work ID, the address of the TCB of the work J is obtained.

A2.存取TCB,取得工作J之工作優先順序。假設工作優先順序為「0」。A2. Access the TCB and get the work priority of the job J. Assume that the work priority order is "0".

A3.取得圖11所示之工作準備串列中、與工作J之工作優先順序對應的優先順序指標280。A3. The priority order indicator 280 corresponding to the work priority order of the job J in the work preparation sequence shown in FIG. 11 is obtained.

A4.檢測取得之優先順序指標280所表示的TCB。此處檢測出工作A之TCB。A4. TCB indicated by the priority indicator 280 obtained by the detection. The TCB of job A is detected here.

A5.順著工作A之TCB具有的指標檢測最後端的TCB。圖11中,工作F為最後端。A5. Detect the last TCB along the indicator of the TCB of Work A. In Figure 11, the work F is the last end.

A6.將工作F之TCB的指標設定成指向工作J之TCB的位址。以此方式,工作J之TCB追加至工作準備串列。A6. Set the indicator of the TCB of the work F to the address of the TCB pointing to the work J. In this way, the TCB of job J is appended to the work preparation list.

A7.將工作J之TCB設定成「READY」。又,將處理資料複製至TCB的暫存器儲存區。A7. Set the TCB of job J to "READY". Also, the processing data is copied to the register storage area of the TCB.

(READY-工作之狀態遷移)(READY-work state migration)

B1.RTOS檢測工作優先順序「0」之優先順序指標280表示哪一個TCB。未找到TCB時,檢測工作優先順序「1」之優先順序指標280表示哪一個TCB。在找到TCB之前,一邊降低工作優先順序一邊特定任一個工作。圖11中,特定工作A。B1. The priority order indicator 280 of the RTOS detection work priority "0" indicates which TCB. When the TCB is not found, the priority index 280 of the detection work priority "1" indicates which TCB. Before you find the TCB, you can work at a specific level while reducing your work priorities. In Figure 11, specific work A.

B2.將工作A從工作準備串列移除。具體而言,將工作優先順序「0」之優先順序指標280覆寫成不是指向工作A而是指向工作D之TCB的位址。又,將工作A之指標設定成NULL以不指向工作D的位址。以此方式,將工作A之TCB從工作準備串列移除。B2. Remove Work A from the work preparation list. Specifically, the priority order indicator 280 of the work priority order "0" is overwritten with the address of the TCB that is not directed to the work A but to the work D. Also, the indicator of job A is set to NULL so as not to point to the address of the work D. In this way, the TCB of job A is removed from the work preparation list.

B3.將工作A之TCB設定成「RUN」。又,將儲存於工作A之TCB之暫存器儲存區的處理資料載入至處理暫存器。B3. Set the TCB of job A to "RUN". Moreover, the processing data stored in the scratchpad storage area of the TCB of the work A is loaded into the processing register.

一般軟體RTOS,藉由此種工作準備串列執行工作切換。亦即,RTOS從複數個READY-工作中選擇RUN-工作的規則如下。In general software RTOS, work switching is performed by this type of work preparation. That is, the rules for the RTOS to select RUN-work from a plurality of READY-work are as follows.

1.為READY-工作(第1條件)。1. Work for READY - (1st condition).

2.為READY-工作中工作優先順序最高的工作(第2條件)。2. The work with the highest priority (READ 2) for READY-work.

3.當工作優先順序最高的工作存在複數個時,為變成READY狀態時間最早的工作(第3條件)。3. When there are a plurality of jobs with the highest work priority order, the work that is the earliest in the READY state (the third condition).

將此等3個條件總稱為「RUN工作選擇條件」。工作處理裝置100之執行選擇電路232,藉由硬體實現此種RTOS之工作排程功能。These three conditions are collectively referred to as "RUN work selection conditions". The execution selection circuit 232 of the work processing apparatus 100 implements the work scheduling function of the RTOS by hardware.

(2)本實施例之硬體RTOS之RUN-工作的選擇(2) Selection of RUN-work of the hardware RTOS of this embodiment

圖12係執行選擇電路232的電路圖。FIG. 12 is a circuit diagram of the execution selection circuit 232.

此處,說明從工作0~工作7的8個工作選擇RUN-工作。執行選擇電路232包含4個第1比較電路290(290a~290d)、2個第2比較電路292(292a,292b)、1個第3比較電路294。又,亦包含8個判定電路296(296a~296h)。Here, it is explained that RUN-operation is selected from eight operations of work 0 to work 7. The execution selection circuit 232 includes four first comparison circuits 290 (290a to 290d), two second comparison circuits 292 (292a, 292b), and one third comparison circuit 294. Further, eight determination circuits 296 (296a to 296h) are also included.

判定電路296以表示工作狀態的ST訊號為輸入,輸出READY時表示「1」、READY以外時表示「0」的CID訊號。判定電路296根據上述RUN工作選擇條件中的第1條件進行判定。第1比較電路290以2個工作的ID、PR、TIM、及來自判定電路296的CID訊號為輸入。The determination circuit 296 receives the ST signal indicating the operation state as an input, and outputs a READY indicating "1" or a CID signal indicating "0" when the READY is not. The determination circuit 296 makes a determination based on the first condition in the RUN operation selection condition. The first comparison circuit 290 inputs the ID, PR, TIM, and CID signal from the decision circuit 296 of two operations.

著眼於第1比較電路290a來說明。第1比較電路290a比較工作0與工作1,根據上述RUN工作選擇條件選擇較佳的工作。The first comparison circuit 290a will be described with a focus. The first comparison circuit 290a compares the operation 0 with the operation 1, and selects a preferred operation based on the RUN operation selection condition.

第1判定:首先,比較分別從判定電路296a與判定電路296b輸出的CID訊號。其中一者為「1」時,亦即,僅其中一者之工作為READY狀態時,第1比較電路290a輸出該工作之ID、PR、TIM。皆為「0」時,亦即,任一工作皆非READY狀態時,第1比較電路290a輸出ID=PR=TIM=NULL。此係表示任一工作皆未被選擇。皆為「1」時,亦即,任一工作皆為READY狀態時,進行接下來的第2判定。First determination: First, the CID signals output from the determination circuit 296a and the determination circuit 296b are compared. When one of them is "1", that is, when only one of the operations is in the READY state, the first comparison circuit 290a outputs the ID, PR, and TIM of the job. When all are "0", that is, when any of the operations is not in the READY state, the first comparison circuit 290a outputs ID = PR = TIM = NULL. This means that no work has been selected. When all are "1", that is, when any of the jobs is in the READY state, the next second determination is made.

第2判定:比較工作0的PR訊號與工作1的PR訊號,選擇工作優先順序高的工作。例如,工作0的工作優先順序為「1」、工作1的工作優先順序為「2」時,輸出工作0之ID、PR、TIM。藉由第2判定,可選擇工作優先順序高的工作作為RUN-工作的候補。工作0與工作1之工作優先順序相同時,進行接下來的第3判定。The second determination: comparing the PR signal of the work 0 with the PR signal of the work 1, and selecting the work with a higher priority of work. For example, when the job priority of job 0 is "1" and the job priority of job 1 is "2", the ID, PR, and TIM of job 0 are output. According to the second determination, the work with a high priority of work can be selected as a candidate for the RUN-work. When the work 0 and work 1 work priorities are the same, the next third decision is made.

第3判定:比較工作0的TIM訊號與工作1的TIM訊號,選擇READY經過時間長的工作。READY經過時間相同時,假設選擇工作0。由於僅比較經過時間的大小即可判定,因此不需要工作準備串列般的TCB順序管理。The third decision: compare the TIM signal of the work 0 with the TIM signal of the work 1, and select the READY to work for a long time. When the READY elapsed time is the same, it is assumed that work 0 is selected. Since it can be determined only by comparing the elapsed time, there is no need to work in tandem TCB order management.

以此方式,藉由RUN工作選擇條件分別比較工作0與工作1、工作2與工作3、工作4與工作5、工作6與工作7。第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, work 0 and work 1, work 2 and work 3, work 4 and work 5, work 6 and work 7 are respectively compared by the RUN work selection condition. The second comparison circuit 292 further filters the candidates of the RUN-operation by the outputs of the two first comparison circuits 290. The second comparison circuit 292a performs operation selection by the outputs of the first comparison circuit 290a and the first comparison circuit 290b. Therefore, the second comparison circuit 292a outputs the ID, PR, and TIM of the operations most suitable for the RUN operation selection condition from the work 0 to the work 3. The third comparison circuit 294 is also the same, and the third comparison circuit 294 outputs the operation ID of any of the operations 0 to 7.

依據此種處理方法,能以硬體實現RUN工作選擇條件。雖一般軟體RTOS一邊存取工作準備串列一邊選擇RUN-工作,但本實施例之執行選擇電路232,藉由從狀態記憶部220隨時輸出之狀態資料選擇RUN-工作。綜合執行選擇電路232的處理則如下述。According to this processing method, the RUN operation selection condition can be realized by hardware. Although the general software RTOS selects the RUN-operation while accessing the work preparation sequence, the execution selection circuit 232 of the present embodiment selects the RUN-operation by the status data output from the state memory unit 220 at any time. The processing of the integrated execution selection circuit 232 is as follows.

(RUN-工作的狀態遷移)(RUN-work state transition)

此處,RUN-工作係以工作J說明。Here, the RUN-work is described in Work J.

A1.工作切換電路210將工作J之工作狀態暫存器258設定成「READY」。A1. The operation switching circuit 210 sets the operation state register 258 of the job J to "READY".

A2.工作切換電路210設定工作J之計時器252開始測量READY經過時間。A2. The work switching circuit 210 sets the timer 252 of the job J to start measuring the READY elapsed time.

以此方式,工作J從RUN狀態遷移至READY。如上述,將處理資料儲存於工作J之保留暫存器110。由於連接處理暫存器154與保留暫存器110的匯流排可平行傳送處理資料,因此可在1個時脈時間執行A1與A2的處理。In this way, job J migrates from the RUN state to READY. As described above, the processing data is stored in the reservation register 110 of the job J. Since the connection processing register 154 and the bus bar of the reservation register 110 can transfer the processing data in parallel, the processing of A1 and A2 can be performed at one clock time.

(READY-工作的狀態遷移)(READY-Working state transition)

B1.工作切換電路210,當工作J之狀態遷移結束時,從執行選擇電路232輸出之工作ID特定RUN-工作。將此工作之工作狀態暫存器258設定成「RUN」。B1. The work switching circuit 210, when the state transition of the job J ends, the work ID output from the execution selection circuit 232 is specified to be RUN-operated. The work status register 258 of this job is set to "RUN".

以此方式,特定之工作從READY狀態遷移至RUN。將特定之工作之處理資料從保留暫存器110載入至處理暫存器154。由於連接保留暫存器110與處理暫存器154的匯流排亦為可平行傳送處理資料的位元數,因此可在1個時脈時間執行B1的處理。In this way, the specific work is moved from the READY state to the RUN. The processing data for a particular job is loaded from the reservation register 110 to the processing register 154. Since the bus bar connecting the reservation register 110 and the processing register 154 is also the number of bits in which the processing data can be transferred in parallel, the processing of B1 can be performed at one clock time.

軟體RTOS,當工作切換時,由於對工作準備串列的存取,消費較多CPU的CPU時脈時間。相對於此,本實施例之工作控制電路200,能以些微時間結束工作切換。由於狀態記憶部220將狀態資料隨時輸出至執行選擇電路232,因此執行選擇電路232隨時輸出任一工作之工作ID。並不是在產生工作切換後開始RUN-工作的選擇處理,而是在產生工作切換時以執行選擇電路232之輸出執行RUN-工作的選擇,此點亦有助於增加工作切換的速度。此處,雖說明工作為8個,但藉由增加比較電路的段數,亦可對應更多的工作。The software RTOS, when the work is switched, consumes more CPU CPU clock time due to access to the work preparation serial. On the other hand, the operation control circuit 200 of the present embodiment can end the operation switching with a slight time. Since the state memory unit 220 outputs the state data to the execution selection circuit 232 at any time, the execution selection circuit 232 outputs the job ID of any job at any time. Rather than starting the RUN-work selection process after the work switch is generated, the RUN-work selection is performed by executing the output of the selection circuit 232 when the work switch is generated, which also helps to increase the speed of the work switch. Here, although the operation is described as eight, by increasing the number of segments of the comparison circuit, it is possible to perform more work.

(旗號處理)(flag processing)

圖13係顯示一般RTOS之旗號處理所利用之待機旗號串列的圖。Figure 13 is a diagram showing a list of standby flag numbers used for flag processing of a general RTOS.

在說明待機旗號串列之前,先簡單說明旗號。在旗號表212,旗號ID與旗號計數器係相對應紀錄。旗號計數器之初始值係設定成有限數。例如,假設設定成旗號ID=4、旗號計數器=3。當任一工作以旗號ID=4之旗號作為待機旗號執行待機旗號系統呼叫時,工作切換電路210減少待機旗號的旗號計數器。旗號計數器,係每當因待機旗號系統呼叫而被要求獲得時減少,變成0時則無法獲得。以旗號計數器為0之旗號作為待機旗號執行待機旗號系統呼叫的工作,狀態遷移至WAIT狀態。Before describing the standby flag sequence, simply explain the flag. In the flag table 212, the flag ID is corresponding to the flag counter. The initial value of the flag counter is set to a finite number. For example, assume that the flag ID = 4 and the flag counter = 3 are set. When any of the jobs performs the standby flag system call with the flag of the flag ID=4 as the standby flag, the work switching circuit 210 reduces the flag counter of the standby flag. The flag counter is reduced each time it is requested to be acquired due to a standby flag system call, and becomes unavailable when it becomes 0. The flag of the flag counter is 0 as the standby flag to perform the operation of the standby flag system call, and the state transitions to the WAIT state.

另一方面,當任一工作以旗號ID=4之旗號作為解除旗號執行解除旗號系統呼叫時,工作切換電路210增加旗號表212的旗號計數器。綜合來說,On the other hand, when any of the operations is performed with the flag of the flag ID=4 as the release flag, the work switching circuit 210 increases the flag counter of the flag table 212. In summary,

旗號計數器>0時:執行待機旗號系統呼叫的工作從RUN遷移至READY。此時,減少旗號計數器。When the flag counter>0: The work of executing the standby flag system call is moved from RUN to READY. At this point, reduce the flag counter.

旗號計數器=0時:執行待機旗號系統呼叫的工作從RUN遷移至WAIT。不減少旗號計數器。When the flag counter = 0: The work of executing the standby flag system call is migrated from RUN to WAIT. Do not reduce the flag counter.

執行待機旗號系統呼叫的工作為了從WAIT狀態遷移至READY狀態,另一個工作必須執行解除旗號系統呼叫。Performing a Standby Flag System Call In order to migrate from the WAIT state to the READY state, another job must perform a de-flag system call.

(1)一般軟體RTOS之旗號處理(1) General software RTOS flag processing

一般軟體RTOS藉由待機旗號串列管理以旗號等待為理由而處於WAIT狀態之工作(以下,特別稱為「旗號等待工作」)的TCB。待機旗號串列係與圖11之工作準備串列形狀相同的串列,形成於記憶體上。各旗號等待工作的TCB係藉由指標連結。優先順序指標280指向該工作優先順序之旗號等待工作之TCB的前端位址。The general software RTOS manages the TCB in the WAIT state (hereinafter, particularly referred to as "flag waiting work") for the purpose of waiting for the flag by the standby flag string management. The standby flag series is formed in the same memory as the serial shape of the work preparation sequence of FIG. 11 and is formed on the memory. The TCBs whose flags are waiting to work are linked by indicators. The priority indicator 280 points to the front end address of the TCB waiting for the work priority flag.

一般軟體RTOS,當執行解除旗號系統呼叫時,一邊掃描此待機旗號串列一邊選擇待從WAIT狀態遷移至READY狀態的旗號等待工作。待機旗號系統呼叫及解除旗號系統呼叫執行時之RTOS的處理係如下述。The general software RTOS, when performing the un-flag system call, scans the standby flag sequence while selecting the flag to be migrated from the WAIT state to the READY state to wait for work. The processing of the RTOS during the standby flag system call and the release of the flag system call is as follows.

(待機旗號系統呼叫的執行)(execution of standby flag system call)

此處,RUN-工作係以工作J說明。Here, the RUN-work is described in Work J.

A1.RTOS將RUN-工作的工作ID保持在記憶體。根據此工作ID取得工作J之TCB的位址。A1. The RTOS keeps the RUN-working work ID in memory. According to this work ID, the address of the TCB of the work J is obtained.

A2.檢測於待機旗號系統呼叫指定之待機旗號的旗號計數器。以下,依旗號計數器的值處理產生分歧。A2. Detect the flag counter of the standby flag specified by the standby flag system call. In the following, the difference is handled by the value processing of the flag counter.

(旗號計數器>0時)(When the flag counter > 0)

A3.RTOS減少待機旗號的旗號計數器。A3.RTOS reduces the flag counter of the standby flag.

A4.將工作J之TCB設定成「READY」。此時,工作J之TCB追加至工作準備串列。A4. Set the TCB of the job J to "READY". At this time, the TCB of the job J is added to the work preparation sequence.

(旗號計數器=0時)(When the flag counter = 0)

A3.存取TCB以取得工作J的工作優先順序。假設工作優先順序為「0」。A3. Access the TCB to get the work priority of the work J. Assume that the work priority order is "0".

A4.取得待機旗號串列中、與工作J的工作優先順序對應的優先順序指標。A4. Obtain the priority order indicator corresponding to the work priority order of the job J in the standby flag series.

A5.檢測取得之優先順序指標表示的TCB。此處,檢測出工作A的TCB。A5. TCB indicated by the priority indicator obtained by the test. Here, the TCB of the work A is detected.

A6.順著工作A之TCB具有的指標檢測最後端的TCB。圖13中,工作F為最後端。A6. Detect the last TCB along the indicator of the TCB of Work A. In Figure 13, the work F is the last end.

A7.將工作F之TCB的指標設定成指向工作J之TCB的位址。以此方式,工作J之TCB追加至待機旗號串列。A7. Set the indicator of the TCB of the work F to the address of the TCB pointing to the work J. In this way, the TCB of the job J is appended to the standby flag string.

A8.將工作J之TCB設定成「WAIT」。又,亦設定待機旗號的旗號ID。A8. Set the TCB of the job J to "WAIT". Also, the flag ID of the standby flag is set.

(解除旗號系統的執行)(Remove the execution of the flag system)

B1.RTOS依序順著工作優先順序「0」的工作檢索以解除旗號為待機旗號的旗號等待工作。不存在時,以工作優先順序「1」的工作為檢索對象。依據是否檢測出以解除旗號為待機旗號的旗號等待工作,處理產生分歧。B1. The RTOS sequentially searches for the job with the work priority "0" to cancel the flag with the flag as the standby flag. When it does not exist, the work with the work priority order "1" is the search target. According to whether it is detected that the flag with the flag is the standby flag is awaiting work, the processing is divided.

(檢測出時)(when detected)

B2.以檢測出之工作為工作E來說明。將工作E之TCB設定成「READY」。又,清除待機旗號的旗號ID。B2. Explain that the detected work is work E. Set the TCB of job E to "READY". Also, the flag ID of the standby flag is cleared.

B3.將工作E之TCB從待機旗號串列移除。B3. Remove the TCB of the work E from the standby flag series.

B4.將解除旗號之工作的狀態從RUN狀態遷移至READY。將此工作之TCB追加至工作準備串列。B4. The state of the work of releasing the flag is moved from the RUN state to the READY. Add the TCB of this job to the work preparation list.

(未檢測出時)(when not detected)

B2.增加旗號計數器。B2. Increase the flag counter.

B3.將解除旗號之工作的狀態從RUN狀態遷移至READY。將此工作之TCB追加至工作準備串列。B3. Move the state of the work of releasing the flag from the RUN state to READY. Add the TCB of this job to the work preparation list.

一般軟體RTOS,藉由管理此種待機旗號串列,執行旗號相關處理。當解除旗號時,RTOS從複數個WAIT-工作中選擇READY-工作的規則如下。The general software RTOS performs flag-related processing by managing such a list of standby flag numbers. When the flag is removed, the RTOS selects the READY-work rule from a plurality of WAIT-work as follows.

1.為WAIT-工作(第1條件)。1. Work for WAIT- (1st condition).

2.為WAIT-工作中以解除旗號為待機旗號的工作(第2條件)。2. For the WAIT-work, the work of releasing the flag as the standby flag (the second condition).

3.當此種工作存在複數個時,為工作優先順序最高的工作(第3條件)。3. When there are a plurality of such jobs, the work with the highest priority of work (the third condition).

4.當工作優先順序最高的工作存在複數個時,為變成WAIT狀態時間最早的工作(第4條件)。4. When there are a plurality of jobs with the highest work priority order, the work that becomes the earliest in the WAIT state time (the fourth condition).

將此等4個條件總稱為「旗號待機解除條件」。工作處理裝置100之旗號選擇電路234,藉由硬體實現此種RTOS之工作排程功能。These four conditions are collectively referred to as "flag standby cancellation conditions". The flag selection circuit 234 of the work processing apparatus 100 implements the work scheduling function of the RTOS by hardware.

(2)本實施例之硬體RTOS之旗號處理(2) The flag processing of the hardware RTOS of this embodiment

圖14係旗號選擇電路234的電路圖。FIG. 14 is a circuit diagram of the flag selection circuit 234.

此處,亦說明工作0~工作7的8個工作。旗號選擇電路234包含4個第1比較電路300(300a~300d)、2個第2比較電路302(302a,302b)、1個第3比較電路304。又,亦包含8個判定電路306(306a~306h)。Here, eight jobs from work 0 to work 7 are also explained. The flag selection circuit 234 includes four first comparison circuits 300 (300a to 300d), two second comparison circuits 302 (302a, 302b), and one third comparison circuit 304. Further, eight determination circuits 306 (306a to 306h) are also included.

判定電路306,係以來自狀態記憶部220之ST、WR、SID訊號與來自工作切換電路210之表示旗號ID之訊號為輸入的電路。此處輸入之旗號ID,係解除旗號的旗號ID。判定電路306輸出為以解除旗號為待機旗號的旗號等待工作時表示「1」、不是以解除旗號為待機旗號的旗號等待工作時表示「0」的CID訊號。判定電路306,係輸出上述旗號待機解除條件中之第1條件與第2條件相關之判定結果的電路。第1比較電路300以2個工作的ID、PR、TIM及來自判定電路306的CID訊號為輸入。The decision circuit 306 is a circuit that inputs the ST, WR, SID signals from the state memory unit 220 and the signals from the work switching circuit 210 indicating the flag ID. The flag ID entered here is the flag ID of the flag. The determination circuit 306 outputs a CID signal indicating that "1" is displayed when the flag is the flag of the standby flag, and "0" is not used when the flag is the flag of the standby flag. The determination circuit 306 is a circuit that outputs a determination result relating to the first condition and the second condition in the flag standby cancellation condition. The first comparison circuit 300 takes as input two IDs, PR, TIM, and CID signals from the decision circuit 306.

第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相同的判定處理,從第3比較電路304輸出任一工作ID。待機旗號系統呼叫與解除旗號系統呼叫執行時之處理如下述。The first comparison circuit 300 is a circuit that performs determination regarding the third condition and the fourth condition in the flag standby cancellation condition. The second comparison circuit 302 is also the same as the third comparison circuit 304. As described above, the second condition and the third condition of the RUN operation selection condition are the same as the third condition and the fourth condition of the flag standby cancellation condition. Each of the comparison circuits that execute the selection circuit 232 is a circuit that compares the operational status data (PR, TIM). On the other hand, each comparison circuit of the flag selection circuit 234 is also a circuit for comparing the operational status data (PR, TIM). Therefore, the first comparison circuit 290 of the selection circuit 232 and the first comparison circuit 300 of the flag selection circuit 234 are internally built with the same logic and can be shared. In addition to the determination by the determination circuit 306 under the first condition and the second condition, each operation is also transmitted to the determination processing of the first comparison circuit 300. Thereafter, any of the job IDs is output from the third comparison circuit 304 by the same determination process as the execution of the selection circuit 232. The processing of the standby flag system call and the unloading system call execution is as follows.

(待機旗號系統呼叫的執行)(execution of standby flag system call)

此處,RUN-工作係以工作J說明。Here, the RUN-work is described in Work J.

A1.工作切換電路210從旗號表212檢測於待機旗號系統呼叫指定之旗號的旗號計數器。以下,依旗號計數器的值,處理產生分歧。A1. The work switching circuit 210 detects the flag counter of the flag designated by the standby flag system call from the flag table 212. Hereinafter, the processing differs depending on the value of the flag counter.

(旗號計數器>0時)(When the flag counter > 0)

A2.工作切換電路210減少旗號表212的旗號計數器。A2. The work switching circuit 210 reduces the flag counter of the flag table 212.

A3.將工作J之工作狀態暫存器258設定成「READY」。此時,工作切換電路210設定RUN-工作之計時器252,開始測量READY經過時間。A3. Set the working state register 258 of the job J to "READY". At this time, the work switching circuit 210 sets the RUN-operation timer 252 to start measuring the READY elapsed time.

(旗號計數器=0時)(When the flag counter = 0)

A2.工作切換電路210,將工作J之工作狀態暫存器258設定成「WAIT」、待機理由暫存器262設定成「旗號等待」、旗號ID暫存器264設定成待機旗號的旗號ID,設定計時器252,開始測量WAIT經過時間。A2. The operation switching circuit 210 sets the operation state register 258 of the operation J to "WAIT", the standby reason register 262 is set to "flag waiting", and the flag ID register 264 is set to the flag ID of the standby flag. The timer 252 is set to start measuring the WAIT elapsed time.

以此方式,執行待機旗號系統呼叫的工作從RUN狀態遷移至READY或WAIT。In this way, the work of executing the standby flag system call is migrated from the RUN state to READY or WAIT.

(解除旗號系統呼叫的執行)(Remove the execution of the flag system call)

B1.工作切換電路210將解除旗號的旗號ID輸入至各判定電路306。各判定電路306以此旗號ID為對象判定旗號解除條件中之第1條件及第2條件是否成立。是以,各第1比較電路300根據第3條件及第4條件選擇工作。B1. The work switching circuit 210 inputs the flag ID of the release flag to each determination circuit 306. Each of the determination circuits 306 determines whether or not the first condition and the second condition in the flag release condition are satisfied by using the flag ID as a target. Therefore, each of the first comparison circuits 300 selects an operation based on the third condition and the fourth condition.

(任一個判定電路306輸出「1」、第3比較電路304輸出任一個工作ID時)(When any one of the determination circuits 306 outputs "1" and the third comparison circuit 304 outputs any one of the job IDs)

B2.將檢測出之工作之工作狀態暫存器258設定成「READY」,清除待機理由暫存器262與旗號ID暫存器264,以計時器252測量READY經過時間。B2. The detected work status register 258 is set to "READY", the standby reason register 262 and the flag ID register 264 are cleared, and the READY elapsed time is measured by the timer 252.

B3.將執行系統呼叫之工作之工作狀態暫存器258設定成「READY」,開始測量READY經過時間。B3. The work status register 258 for performing the system call operation is set to "READY", and the measurement of the READY elapsed time is started.

(任一個判定電路306皆未輸出「1」、第3比較電路304亦未輸出任一個工作ID時)(Each of the determination circuits 306 does not output "1", and the third comparison circuit 304 does not output any of the operation IDs)

B2.工作切換電路210增加旗號表212的旗號計數器。B2. The work switching circuit 210 increases the flag counter of the flag table 212.

B3.將執行系統呼叫之工作之狀態從RUN狀態遷移至READY。B3. Migrate the state of the work of performing the system call from the RUN state to READY.

由於狀態記憶部220將狀態資料隨時輸出至旗號選擇電路234,因此當工作切換電路210將旗號ID輸入至判定電路306時,旗號選擇電路234可立即執行選擇處理。Since the state memory unit 220 outputs the state data to the flag selection circuit 234 at any time, when the work switching circuit 210 inputs the flag ID to the determination circuit 306, the flag selection circuit 234 can immediately perform the selection process.

(互斥處理)(mutual exclusion processing)

互斥亦與旗號相同,利用工作間之同步處理。互斥與旗號在以下幾點不同。The mutual exclusion is also the same as the flag, using the synchronization process of the workplace. Mutual exclusion and flag are different in the following points.

1.旗號計數器可設定成1以上的整數。相對於此,互斥係旗號計數器為1或0的特殊旗號。當旗號計數器為2以上時,2個以上的工作可獲得相同旗號。然而,當互斥時,可獲得某個互斥的工作恆僅有1個。1. The flag counter can be set to an integer of 1 or more. In contrast, the mutex flag counter is a special flag of 1 or 0. When the flag counter is 2 or more, the same flag can be obtained for more than 2 jobs. However, when mutually exclusive, only one of the mutually exclusive jobs can be obtained.

2.可藉由解除旗號系統呼叫解除旗號的工作,並不限於藉由待機旗號系統呼叫獲得旗號的工作。相對於此,可藉由解除互斥系統呼叫解除互斥的工作,僅為藉由待機互斥系統呼叫獲得互斥的工作。2. The work of releasing the flag by canceling the flag system call is not limited to the work of obtaining the flag by calling the standby flag system. In contrast, the mutual exclusion operation can be cancelled by releasing the mutual exclusion system call, and only the mutual exclusion work is obtained by the standby mutual exclusion system call.

當解除互斥時,從複數個WAIT-工作中選擇READY-工作的規則如下。When the mutual exclusion is released, the rules for selecting READY-work from a plurality of WAIT-work are as follows.

1.為WAIT-工作(第1條件)。1. Work for WAIT- (1st condition).

2.為WAIT-工作中以解除互斥為待機互斥的工作(第2條件)。2. For the WAIT-work, the mutual exclusion is mutually exclusive (second condition).

3.當此種工作存在複數個時,為工作優先順序最高的工作(第3條件)。3. When there are a plurality of such jobs, the work with the highest priority of work (the third condition).

4.當工作優先順序最高的工作存在複數個時,為變成WAIT狀態時間最早的工作(第4條件)。4. When there are a plurality of jobs with the highest work priority order, the work that becomes the earliest in the WAIT state time (the fourth condition).

將此等4個條件總稱為「互斥待機解除條件」。These four conditions are collectively referred to as "mutual exclusion standby cancellation conditions".

是以,待機互斥系統呼叫及解除互斥系統呼叫執行時之本實施例之硬體RTOS的處理如下述。在旗號表212,互斥ID與表示該互斥是否佔有任一個工作的佔有狀態資料係相對應保持。佔有狀態資料,當未佔有時為「0」、當佔有時為佔有互斥之工作的工作ID。Therefore, the processing of the hardware RTOS of the present embodiment when the standby mutual exclusion system calls and releases the mutual exclusion system call is as follows. In the flag table 212, the mutex ID is held in correspondence with the possession status data indicating whether the mutex occupies any one of the jobs. Occupancy status data, when not occupied, sometimes "0", when it is occupied as a work ID that occupies a mutually exclusive work.

(待機互斥系統呼叫的執行)(Execution of standby mutual exclusion system call)

此處,RUN-工作係以工作J說明。Here, the RUN-work is described in Work J.

A1.工作切換電路210檢測是否佔有於待機互斥系統呼叫指定的互斥。以下,依互斥的佔有狀態,處理產生分歧。A1. The work switching circuit 210 detects whether or not the exclusive exclusion of the standby mutual exclusion system call is occupied. In the following, depending on the state of possession of the mutual exclusion, the processing is divided.

(未佔有互斥時)(when there is no exclusive exclusion)

A2.工作切換電路210記錄執行系統呼叫之工作的工作ID以作為互斥的佔有資料。A2. The work switching circuit 210 records the work ID of the work for performing the system call as the mutually exclusive possession data.

A3.將工作J之工作狀態暫存器258設定成「READY」。此時,工作切換電路210設定RUN-工作之計時器252,開始測量READY經過時間。A3. Set the working state register 258 of the job J to "READY". At this time, the work switching circuit 210 sets the RUN-operation timer 252 to start measuring the READY elapsed time.

(佔有互斥時)(when possessing mutual exclusion)

A2.工作切換電路210,將工作J之工作狀態暫存器258設定成「WAIT」、待機理由暫存器262設定成「互斥等待」、互斥ID暫存器265設定成待機互斥的互斥ID,設定計時器252,開始測量WAIT經過時間。A2. The operation switching circuit 210 sets the operation state register 258 of the operation J to "WAIT", the standby reason register 262 is set to "mutual exclusion wait", and the exclusive ID register 265 is set to standby mutual exclusion. The mutual exclusion ID, the timer 252 is set, and the WAIT elapsed time is measured.

(解除互斥系統呼叫的執行)(Unblocking the execution of the mutual exclusion system call)

B1.工作切換電路210,以執行系統呼叫之工作佔有解除互斥為條件,將解除旗號ID輸入至互斥電路240。互斥電路240亦與圖14相同,包含多段連接的比較電路與判定互斥待機解除條件中之第1條件及第2條件是否成立的判定電路。此判定電路,以此互斥為對象,僅於互斥待機解除條件中之第1條件及第2條件皆成立時輸出「1」。此外,當未佔有解除互斥之工作執行解除互斥系統呼叫時,將該工作之狀態從RUN狀態遷移至READY。B1. The work switching circuit 210 inputs the release flag ID to the exclusive circuit 240 on condition that the work of the system call is released from the mutual exclusion. Similarly to FIG. 14, the exclusive circuit 240 includes a comparison circuit that is connected in multiple stages and a determination circuit that determines whether or not the first condition and the second condition in the mutual exclusion standby cancellation condition are satisfied. This determination circuit is used for exclusive exclusion, and outputs "1" only when both the first condition and the second condition in the mutual exclusion standby release condition are satisfied. In addition, when the work of releasing the mutual exclusion system is performed without the work of releasing the mutual exclusion, the state of the operation is transferred from the RUN state to the READY.

(任一個判定電路輸出「1」、互斥電路240輸出任一個工作ID時)(When any one of the determination circuits outputs "1" and the exclusive circuit 240 outputs any one of the job IDs)

B2.將檢測出之工作之工作狀態暫存器258設定成「READY」,清除待機理由暫存器262與互斥ID暫存器265,以計時器252測量READY經過時間。B2. The detected work status register 258 is set to "READY", the standby reason register 262 and the exclusive ID register 265 are cleared, and the READY elapsed time is measured by the timer 252.

B3.將執行系統呼叫之工作之工作狀態暫存器258設定成「READY」,開始測量READY經過時間。B3. The work status register 258 for performing the system call operation is set to "READY", and the measurement of the READY elapsed time is started.

(任一個判定電路皆未輸出「1」、互斥電路240亦未輸出任一個工作ID時)(If either of the decision circuits does not output "1", the mutex circuit 240 does not output any of the job IDs)

B2.工作切換電路210於旗號表212,將互斥設定成非佔有狀態。B2. The work switching circuit 210 sets the mutual exclusion to the non-occupied state in the flag table 212.

B3.將執行系統呼叫之工作之狀態從RUN狀態遷移至READY。B3. Migrate the state of the work of performing the system call from the RUN state to READY.

(事件處理)(event processing)

簡單說明本實施例之事件管理。在事件表214,事件ID與旗標類型(以下,稱為「現行旗標類型」)係相對應記錄。旗標類型係8位元的位元類型。The event management of this embodiment will be briefly described. In the event table 214, the event ID is recorded in correspondence with the flag type (hereinafter, referred to as "current flag type"). The flag type is an 8-bit bit type.

設定事件系統呼叫,係變更現行旗標類型之設定的系統呼叫,以事件ID與旗標類型(以下,稱為「設定旗標類型」)為參數。當執行設定事件系統呼叫時,就該事件,現行旗標類型變更成與設定旗標類型的邏輯和。例如,當現行旗標類型為「00001100」、設定旗標類型為「00000101」時,現行旗標類型變成「00001101」。以下,對各旗標類型,從左依序稱為第0位元、第1位元、…、第7位元。Setting an event system call is a system call that changes the current flag type setting, with the event ID and flag type (hereinafter referred to as "set flag type") as parameters. When the set event system call is executed, the current flag type is changed to the logical sum of the set flag type for the event. For example, when the current flag type is "00001100" and the flag type is "00000101", the current flag type becomes "00001101". Hereinafter, each flag type is sequentially referred to as a 0th bit, a 1st bit, ..., a 7th bit from the left.

待機事件系統呼叫,係用以等待待機事件之現行旗標類型滿足既定條件的系統呼叫,以事件ID、旗標類型(以下,稱為「待機旗標類型」)、旗標條件為參數。當執行待機事件系統呼叫時,判定在現行旗標類型與待機旗標類型之間旗標條件是否成立。旗標條件係邏輯和(OR)或邏輯積(AND)。當旗標條件為邏輯積(AND)時,WAIT解除條件,係就待機旗標類型為「1」的所有位元,現行旗標類型之該位元亦皆為「1」。當旗標條件為邏輯和(OR)時,WAIT解除條件,係就待機旗標類型為「1」的任一位元,現行旗標類型之該位元為「1」。例如,當現行旗標類型為「00001101」、待機旗標類型為「00000011」、旗標條件為「邏輯和(OR)」時,由於待機旗標類型之第6位元及第7位元中,現行旗標類型之第7位元為「1」,因此,此時待機事件系統呼叫之WAIT解除條件成立。另一方面,當旗標條件為「邏輯積(AND)」時,由於現行旗標類型之第6位元為「0」,因此WAIT解除條件不成立。The standby event system call is a system call for waiting for the current flag type of the standby event to satisfy the predetermined condition, and the event ID, the flag type (hereinafter referred to as "standby flag type"), and the flag condition are parameters. When a standby event system call is performed, it is determined whether the flag condition is established between the current flag type and the standby flag type. The flag condition is a logical sum (OR) or a logical product (AND). When the flag condition is logical product (AND), the WAIT release condition is that all the bits of the standby flag type are "1", and the bit of the current flag type is also "1". When the flag condition is logical OR (OR), the WAIT release condition is any bit of the standby flag type "1", and the bit of the current flag type is "1". For example, when the current flag type is "00001101", the standby flag type is "00000011", and the flag condition is "logical (OR)", since the 6th and 7th bits of the standby flag type are The 7th bit of the current flag type is "1". Therefore, the WAIT release condition of the standby event system call is established at this time. On the other hand, when the flag condition is "AND", since the 6th bit of the current flag type is "0", the WAIT release condition is not established.

(1)一般軟體RTOS之事件處理(1) Event processing of general software RTOS

待機事件系統呼叫及設定事件系統呼叫執行時之一般RTOS的處理如下述。一般RTOS為了管理事件,將事件表保持在記憶體上。於此事件表,不僅事件ID、現行旗標類型,通常,以此事件為待機事件之處於WAIT狀態之工作(以下,稱為「事件等待工作」)的工作ID、待機旗標類型、旗標條件係相對應保持。Standby Event System Call and Set Event System The general RTOS processing when the call is executed is as follows. In order to manage events, the RTOS keeps the event table in memory. In this event table, not only the event ID, the current flag type, but also the work ID, standby flag type, flag of the work in the WAIT state (hereinafter, referred to as "event waiting work") for this event as a standby event. The conditions are correspondingly maintained.

(待機事件系統呼叫的執行)(execution of standby event system call)

A1.RTOS從事件表讀取於系統呼叫指定之事件的現行旗標類型。A1. The RTOS reads the current flag type of the event specified by the system call from the event table.

A2.依旗標條件比較現行旗標類型與待機旗標類型,判定WAIT解除條件是否成立。A2. Compare the current flag type with the standby flag type according to the flag condition, and determine whether the WAIT cancellation condition is established.

(WAIT解除條件成立時)(When the WAIT cancellation condition is established)

A3.將執行系統呼叫之工作之工作狀態從RUN狀態遷移至READY。A3. Migrate the working state of the work of performing the system call from the RUN state to READY.

(WAIT解除條件不成立時)(When the WAIT release condition is not established)

A3.在事件表記錄執行系統呼叫之工作的工作ID。A3. Record the work ID of the work that performs the system call in the event table.

A4.在事件表記錄待機旗標類型。A4. Record the standby flag type in the event table.

A5.在事件表記錄旗標條件。A5. Record the flag conditions in the event table.

A6.將執行系統呼叫之工作之工作狀態從RUN狀態遷移至WAIT。A6. Migrate the working state of the work of performing the system call from the RUN state to the WAIT.

(設定事件系統呼叫的執行)(Setting the execution of the event system call)

B1.RTOS就系統呼叫指定之設定事件,從事件表讀取現行旗標類型、工作ID、待機旗標類型、旗標條件。B1. The RTOS records the current flag type, work ID, standby flag type, and flag condition from the event table for the specified event of the system call.

B2.將現行旗標類型與設定旗標類型的邏輯和記錄成新的現行旗標類型。B2. Record the logical sum of the current flag type and the set flag type into a new current flag type.

(設定事件不存在事件等待工作時,或即使存在、依據待機旗標類型與旗標條件WAIT解除條件亦不成立時)(When the setting event does not exist, the event waits for work, or even if it exists, according to the standby flag type and the flag condition WAIT release condition is not established)

B3.將執行系統呼叫之工作之工作狀態從RUN狀態遷移至READY。B3. Migrate the working state of the work of performing the system call from the RUN state to READY.

(設定事件存在事件等待工作、WAIT解除條件成立時)(When the event is set, the event is waiting for work, and the WAIT release condition is established)

B3.將待機事件之工作之工作狀態從WAIT狀態遷移至READY。B3. Migrate the working state of the standby event from the WAIT state to READY.

B4.清除事件表之待機工作ID、待機旗標類型、旗標條件。B4. Clear the standby work ID, standby flag type, and flag condition of the event table.

B5.將執行系統呼叫之工作之工作狀態從RUN狀態遷移至READY。且執行RUN-工作的選擇。B5. Migrate the working state of the work of performing the system call from the RUN state to READY. And perform the RUN-work selection.

當執行設定事件系統呼叫時,從複數個WAIT-工作中選擇READY-工作的規則如下。When performing a set event system call, the rules for selecting READY-work from a plurality of WAIT-work are as follows.

1.為WAIT-工作(第1條件)。1. Work for WAIT- (1st condition).

2.為WAIT-工作中以設定事件為待機事件的工作(第2條件)。2. For the WAIT-work, the event is set as the standby event (the second condition).

3.為比較待機旗標類型、現行旗標類型、旗標條件後,WAIT解除條件成立的工作(第3條件)。3. After comparing the standby flag type, the current flag type, and the flag condition, the WAIT release condition is established (the third condition).

將此等3個條件總稱為「事件待機解除條件」。These three conditions are collectively referred to as "event standby cancellation conditions".

(2)本實施例之硬體RTOS之事件處理(2) Event processing of the hardware RTOS of this embodiment

工作處理裝置100之待機事件系統呼叫及設定事件系統呼叫執行時之處理如下述。於工作處理裝置100內建之旗號表212,事件ID與現行旗標類型係相對應。待機工作ID與待機旗標類型等的資訊係儲存於狀態記憶部220。The standby event system call of the work processing apparatus 100 and the process of setting the event system call execution are as follows. In the flag table 212 built in the work processing apparatus 100, the event ID corresponds to the current flag type. Information such as the standby work ID and the standby flag type is stored in the state storage unit 220.

(待機事件系統呼叫的執行)(execution of standby event system call)

A1.工作切換電路210從事件表214讀取現行旗標類型。A1. The work switching circuit 210 reads the current flag type from the event table 214.

A2.工作切換電路210依旗標條件比較現行旗標類型與待機旗標類型,判定WAIT解除條件是否成立。A2. The work switching circuit 210 compares the current flag type with the standby flag type according to the flag condition, and determines whether the WAIT release condition is established.

(WAIT解除條件成立時)(When the WAIT cancellation condition is established)

A3.將執行系統呼叫之工作之工作狀態暫存器258設定成「READY」。A3. The work status register 258 that performs the system call operation is set to "READY".

(WAIT解除條件不成立時)(When the WAIT release condition is not established)

A3.工作切換電路210,分別將執行系統呼叫之工作之工作狀態暫存器258設定成「WAIT」、待機理由暫存器262設定成「事件等待」、事件ID暫存器266設定成待機事件的事件ID、待機旗標暫存器268設定成待機旗標類型、旗標條件暫存器270設定成旗標條件。A3. The work switching circuit 210 sets the work state register 258 for performing the system call operation to "WAIT", the standby reason register 262 to "event wait", and the event ID register 266 to the standby event. The event ID, the standby flag register 268 is set to the standby flag type, and the flag condition register 270 is set to the flag condition.

(設定事件系統呼叫的執行)(Setting the execution of the event system call)

B1.工作切換電路210從事件表214讀取現行旗標類型,且將於系統呼叫指定之設定事件的事件ID輸入至事件選擇電路236。B1. The work switching circuit 210 reads the current flag type 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.工作切換電路210,將設定旗標類型邏輯累加至事件表214的現行旗標類型。B2. The work switching circuit 210 accumulates the set flag type logic to the current flag type of the event table 214.

B3.事件選擇電路236,就輸入之事件ID,選擇事件待機條件成立的工作。此時,不論工作優先順序與WAIT經過時間如何,選擇複數個工作亦可。B3. The event selection circuit 236 selects the event in which the event standby condition is established in response to the input event ID. At this time, regardless of the work priority and the WAIT elapsed time, a plurality of jobs can be selected.

(滿足事件待機解除條件的工作存在時)(When the job that satisfies the event standby cancellation condition exists)

B4.將事件等待工作之工作狀態暫存器258設定成「READY」,清除事件ID暫存器266、待機旗標暫存器268、旗標條件暫存器270。B4. The event waiting register 258 is set to "READY", and the event ID register 266, the standby flag register 268, and the flag condition register 270 are cleared.

B5.將執行系統呼叫之工作之工作狀態從RUN狀態遷移至READY。B5. Migrate the working state of the work of performing the system call from the RUN state to READY.

(滿足事件待機解除條件的工作不存在時)(When the job that satisfies the event standby cancellation condition does not exist)

B4.將執行系統呼叫之工作之工作狀態從RUN狀態遷移至READY。B4. Migrate the working state of the work of performing the system call from the RUN state to READY.

(暫停處理)(suspended processing)

移至WAIT狀態之工作,當WAIT解除條件成立時遷移至READY狀態。然而,由於某些外部因素或應用程式的錯誤(Bug),而妨礙WAIT解除條件成立時,工作無法離開WAIT狀態。因此,一般而言,將工作遷移至WAIT狀態時設定暫停值。暫停值係定期減少,當成為0時,即使WAIT解除條件不成立,工作亦可從WAIT狀態遷移至READY狀態。亦即,可防止工作停止在WAIT狀態暫停值以上的時間。Move to the WAIT state and move to the READY state when the WAIT release condition is established. However, due to some external factors or application bugs, the WAIT release condition is prevented, and the work cannot leave the WAIT state. Therefore, in general, the pause value is set when the job is migrated to the WAIT state. The pause value is periodically decreased. When it is 0, the job can be moved from the WAIT state to the READY state even if the WAIT release condition is not established. That is, it is possible to prevent the work from being stopped for a time above the WAIT state pause value.

(1)一般軟體RTOS之暫停處理(1) Suspend processing of general software RTOS

軟體構成之一般RTOS之情形,在WAIT狀態之工作的TCB設定暫停值,此暫停值係定期減少。RTOS周期性對CPU之處理發出中斷,檢查所有TCB,檢測出暫停值成為0的WAIT-工作。當檢測出此種工作時,RTOS將該工作之工作狀態從WAIT狀態遷移至READY。In the case of a general RTOS composed of software, the TCB in the WAIT state works to set a pause value, which is periodically reduced. The RTOS periodically issues an interrupt to the processing of the CPU, checks all TCBs, and detects a WAIT-work with a pause value of zero. When such a job is detected, the RTOS migrates the working state of the job from the WAIT state to READY.

(2)本實施例之硬體RTOS之暫停處理(2) Suspending processing of the hardware RTOS of this embodiment

另一方面,本實施例之情形,工作切換電路210定期減少各暫停計數器274的暫停值。暫停值,當執行WAIT系系統呼叫時係設定為參數,工作切換電路210在執行該系統呼叫之工作的暫停計數器274設定暫停值。On the other hand, in the case of the present embodiment, the work switching circuit 210 periodically reduces the pause value of each of the pause counters 274. The pause value is set as a parameter when the WAIT system call is executed, and the work switching circuit 210 sets the pause value in the pause counter 274 that performs the operation of the system call.

由於CPU150不介入暫停值的減少處理,因此工作切換電路210能與工作執行處理獨立,更新暫停值。因此,即使CPU150正執行工作時,在工作控制電路200亦自律地執行暫停值的更新。由於狀態資料係隨時輸入至暫停檢測電路238,因此暫停檢測電路238,能以與暫停值更新時序大致相同的時序,檢測暫停值成為0的工作。暫停檢測電路238輸出此種工作的工作ID。工作切換電路210,當從暫停檢測電路238輸入工作ID時,認知產生暫停,傳送HC以停止供應CPU時脈。工作控制電路200將產生暫停之WAIT-工作遷移至READY狀態,且將RUN-工作遷移至READY狀態。工作切換電路210從READY-工作之中選擇下一個待執行工作。又,工作切換電路210再啟動產生暫停之工作的計時器252,測量READY經過時間。Since the CPU 150 does not intervene in the reduction processing of the pause value, the work switching circuit 210 can update the pause value independently of the job execution processing. Therefore, even when the CPU 150 is performing work, the work control circuit 200 autonomously performs the update of the pause value. Since the status data is input to the pause detecting circuit 238 at any time, the pause detecting circuit 238 can detect that the pause value becomes 0 at substantially the same timing as the pause value update timing. The pause detection circuit 238 outputs the work ID of such work. The work switching circuit 210, when inputting the work ID from the suspension detecting circuit 238, recognizes that a pause has occurred, and transmits HC to stop supplying the CPU clock. The work control circuit 200 migrates the WAIT-work that caused the pause to the READY state and transitions the RUN-work to the READY state. The work switching circuit 210 selects the next work to be performed from among the READY-work. Further, the work switching circuit 210 restarts the timer 252 which generates the pause operation, and measures the READY elapsed time.

依據此種處理方法,當工作執行中,亦即,當CPU時脈動作中產生暫停時,可即時對CPU150發出中斷,執行工作切換。又,在工作執行中,工作切換電路210不需借助CPU150的處理能力即可獨立執行暫停值的更新處理。According to this processing method, when the work is being executed, that is, when a pause occurs in the CPU clock operation, the CPU 150 can be immediately interrupted to perform the work switching. Further, in the work execution, the work switching circuit 210 can independently perform the update processing of the pause value without the processing capability of the CPU 150.

(有限狀態機器之工作切換電路210)(Working circuit 210 of the finite state machine)

圖15係工作切換電路210的狀態遷移圖。FIG. 15 is a state transition diagram of the work switching circuit 210.

於初始化處理(A1),所有工作處於IDLE狀態。當初始化處理結束時(S10),任一個工作成為RUN-工作、而成為工作執行狀態(A2)。當檢測出中斷要求訊號時(S12),特殊工作成為RUN-工作、執行中斷處理(A3)。當中斷處理結束時(S14),工作切換電路210從一般工作選擇RUN-工作,遷移至A2。In the initialization process (A1), all jobs are in the IDLE state. When the initialization process is completed (S10), any one of the jobs becomes the RUN-work and becomes the work execution state (A2). When the interrupt request signal is detected (S12), the special operation becomes RUN-operation and execution interrupt processing (A3). When the interrupt processing ends (S14), the work switching circuit 210 selects RUN-work from the normal operation and shifts to A2.

又,於工作執行中(A2),當執行系統呼叫時(S16),執行系統呼叫處理(A4)。當未產生工作切換、亦即RUN-工作的切換時(S18),返回A2。另一方面,當藉由系統呼叫處理(A4)產生工作切換時(S20),工作切換電路210根據執行選擇電路232的輸出執行RUN-工作的選擇(A5)。當工作切換結束時(S22),處理狀態移至A2。Further, during the execution of the work (A2), when the system call is executed (S16), the system call processing (A4) is executed. When the work switching, that is, the switching of the RUN-work is not generated (S18), it returns to A2. On the other hand, when the work switching is generated by the system call processing (A4) (S20), the work switching circuit 210 performs the selection of the RUN-operation in accordance with the output of the execution selection circuit 232 (A5). When the work switching ends (S22), the processing state moves to A2.

最後,說明僅構裝工作處理裝置100之主要元件之儲存電路120與工作控制電路200之其中一者的情形。Finally, the case where only one of the storage circuit 120 and the work control circuit 200 of the main components of the work processing apparatus 100 is constructed will be described.

(未裝載工作控制電路200之類型的工作處理裝置100)(Work processing apparatus 100 of the type not loaded with the work control circuit 200)

圖16係圖5之工作處理裝置100中,未裝載工作控制電路200之工作處理裝置100的電路圖。16 is a circuit diagram of the work processing apparatus 100 in which the work control circuit 200 is not loaded in the work processing apparatus 100 of FIG.

替代未裝載工作控制電路200,追加暫存器切換控制電路322與處理資料保持部320。由於未裝載工作控制電路200,因此工作排程功能係藉由軟體RTOS實現。是以,當工作切換時,RTOS必須暫時取得CPU150的使用櫂。一般而言,處理資料保持部320保持RTOS用的處理資料。當RTOS取得CPU150的使用櫂時,處理資料保持部320替換處理資料保持部320之RTOS用的處理資料與特殊暫存器156之工作用的處理資料。以下,以從工作A至工作B的工作切換說明其處理過程。Instead of the unloaded work control circuit 200, the register switching control circuit 322 and the processed data holding unit 320 are added. Since the work control circuit 200 is not loaded, the work scheduling function is implemented by the software RTOS. Therefore, when the work is switched, the RTOS must temporarily obtain the use of the CPU 150. In general, the processed material holding unit 320 holds processing data for the RTOS. When the RTOS acquires the use of the CPU 150, the processing data holding unit 320 replaces the processing data for the RTOS of the processing material holding unit 320 and the processing data for the operation of the special temporary memory 156. Hereinafter, the processing will be described by switching from work A to work B.

A1.當工作A執行系統呼叫時,將系統呼叫之變數與系統呼叫之ID記錄於汎用暫存器158的一部分。A1. When Work A performs a system call, the system call variable and the system call ID are recorded in a portion of the general purpose register 158.

A2.暫存器切換控制電路322將工作A之處理資料移至處理資料保持部320,將處理資料保持部320之RTOS用處理資料載入至處理暫存器154。在此階段,RTOS取得CPU150的使用權。A2. The scratchpad switching control circuit 322 shifts the processing data of the job A to the processing data holding unit 320, and loads the processing data for the RTOS of the processing data holding unit 320 into the processing register 154. At this stage, the RTOS takes the right to use the CPU 150.

A3.暫存器切換控制電路322將寫入訊號輸入至保留暫存器110a,將處理資料保持部320之工作A用處理資料儲存至保留暫存器110。A3. The register switching control circuit 322 inputs the write signal to the reserved register 110a, and stores the work A processing data of the processed data holding unit 320 to the reserved register 110.

A4.RTOS根據記錄於汎用暫存器158之系統呼叫的變數與ID,執行對應於系統呼叫的處理。又,將工作A之TCB之工作狀態資料設定成「READY」,在工作準備串列追加工作A之TCB。A4. The RTOS performs processing corresponding to the system call based on the variables and IDs of the system calls recorded in the general purpose register 158. Further, the work status data of the TCB of the work A is set to "READY", and the TCB of the work A is added in the work preparation series.

B1.接著,RTOS依據上述RUN工作選擇條件選擇RUN-工作,此處,選擇工作B。B1. Next, the RTOS selects RUN-work according to the above RUN work selection condition, where work B is selected.

B2.RTOS指示暫存器切換控制電路322,將指定工作B之工作選擇訊號輸入至載入選擇電路112。將處理資料從保留暫存器110b移至處理資料保持部320。The B2.RTOS instructs the scratchpad switching control circuit 322 to input the job selection signal of the designated job B to the load selection circuit 112. The processing data is moved from the reservation register 110b to the processing material holding unit 320.

B3.暫存器切換控制電路322替換處理資料保持部320之工作B用處理資料與處理暫存器154之RTOS用處理資料。據此,工作B取得CPU150的使用櫂。B3. The scratchpad switching control circuit 322 replaces the processing data for the operation B of the processing data holding unit 320 and the processing data for the RTOS of the processing register 154. According to this, the work B obtains the use of the CPU 150.

依據此種處理方法,相較於裝載工作控制電路200之圖5的工作處理裝置100,可縮小工作處理裝置100整體的電路尺寸。雖RTOS實現為軟體,但能以來自暫存器切換控制電路322之訊號硬體地控制處理資料的載入、儲存。將分別連接處理暫存器154、處理資料保持部320、載入選擇電路112、保留暫存器110之匯流排設定成可平行傳送處理資料的位元數時,相較於將處理資料儲存至TCB及從TCB載入處理資料,可實現高速的工作切換。According to this processing method, the overall circuit size of the work processing apparatus 100 can be reduced as compared with the work processing apparatus 100 of FIG. 5 in which the work control circuit 200 is mounted. Although the RTOS is implemented as a software, the loading and storing of the processing data can be controlled by the signal from the register switching control circuit 322. When the bus bars respectively connected to the processing register 154, the processing data holding unit 320, the load selection circuit 112, and the reserved register 110 are set to the number of bits in which the processing data can be transmitted in parallel, the processing data is stored as compared with TCB and loading processing data from TCB enable high-speed work switching.

(未裝載儲存電路120之類型的工作處理裝置100)(Work processing device 100 of the type not loaded with storage circuit 120)

圖17係圖5之工作處理裝置100中,未裝載儲存電路120之工作處理裝置100的電路圖。17 is a circuit diagram of the work processing apparatus 100 in which the storage circuit 120 is not loaded in the work processing apparatus 100 of FIG.

替代未裝載儲存電路120,追加中斷介面電路324。由於未裝載儲存電路120,處理資料係儲存於記憶體的TCB。處理資料的載入、儲存係藉由軟體庫的RTOS實現。是以,當工作切換時,RTOS必須暫時取得CPU150的使用權。以下,以從工作A至工作B的工作切換說明其處理過程。Instead of the unloaded storage circuit 120, an interrupt interface circuit 324 is added. Since the storage circuit 120 is not loaded, the processing data is stored in the TCB of the memory. The loading and storage of processing data is realized by the RTOS of the software library. Therefore, when the work is switched, the RTOS must temporarily obtain the usage rights of the CPU 150. Hereinafter, the processing will be described by switching from work A to work B.

當藉由執行系統呼叫產生工作切換時,首先,軟體RTOS將工作A的處理資料儲存於工作A的TCB。接著,將RTOS用的處理資料載入至處理暫存器154。此時的處理方法,與以圖3說明之內容相同。When a work switch is generated by executing a system call, first, the software RTOS stores the processing data of the work A in the TCB of the work A. Next, the processing data for the RTOS is loaded into the processing register 154. The processing method at this time is the same as that described with reference to FIG.

軟體RTOS將系統呼叫之參數寫入中斷介面電路324。執行控制電路152停止CPU150之CPU時脈。中斷介面電路324使工作控制電路200執行工作切換。首先,工作切換電路210將工作A之工作狀態暫存器258設定成READY,藉由來自工作選擇電路230的輸出選擇下一個RUN一工作之工作B。工作切換電路210指示中斷介面電路324以載入工作B的處理資料。此處,中斷介面電路324使執行控制電路152再開始CPU時脈。又,中斷介面電路324通知軟體RTOS工作B已被選擇。軟體RTOS存取工作B的TCB,將工作B的處理資料載入至處理暫存器154。The software RTOS writes the parameters of the system call to the interrupt interface circuit 324. The execution control circuit 152 stops the CPU clock of the CPU 150. Interrupt interface circuit 324 causes work control circuit 200 to perform an operational switch. First, the work switching circuit 210 sets the operation state register 258 of the operation A to READY, and selects the next RUN-operation job B by the output from the operation selection circuit 230. The work switching circuit 210 instructs the interrupt interface circuit 324 to load the processing data of the job B. Here, the interrupt interface circuit 324 causes the execution control circuit 152 to restart the CPU clock. Also, the interrupt interface circuit 324 notifies the software RTOS that the work B has been selected. The software RTOS accesses the TCB of the work B, and loads the processing data of the work B into the processing register 154.

依據此種處理方法,相較於裝載儲存電路120之圖5的工作處理裝置100,可縮小工作處理裝置100整體的電路尺寸。雖RTOS之功能的一部分係實現為軟體,但工作選擇處理能藉由工作控制電路200實現。According to this processing method, the overall circuit size of the work processing apparatus 100 can be reduced as compared with the work processing apparatus 100 of FIG. 5 in which the storage circuit 120 is loaded. Although part of the functionality of the RTOS is implemented as software, the job selection process can be implemented by the work control circuit 200.

相較於圖2及圖3所說明之軟體RTOS,圖16及圖17之工作處理裝置100,皆能使RTOS之功能的一部分硬體化。如圖16所說明,由於存在儲存電路120,因此處理資料的儲存、載入不需存取TCB。因此,能藉由暫存器切換控制電路322執行處理資料的儲存、載入處理。又,如圖17所說明,由於存在工作控制電路200,因此軟體RTOS能將工作選擇功能讓給工作控制電路200。Compared with the software RTOS described with reference to FIGS. 2 and 3, the work processing apparatus 100 of FIGS. 16 and 17 can harden a part of the functions of the RTOS. As illustrated in FIG. 16, since the storage circuit 120 is present, the storage and loading of the processing data does not require access to the TCB. Therefore, the storage and loading processing of the processing data can be performed by the scratchpad switching control circuit 322. Further, as illustrated in FIG. 17, since the work control circuit 200 is present, the software RTOS can give the work selection function to the work control circuit 200.

如圖5所說明,裝載儲存電路120與工作控制電路200之工作處理裝置100的情形,可將RTOS之工作排程功能完全硬體化。由於當工作切換時不需存取記憶體的TCB,因此工作切換處理可更快速。依據本發明人的實驗,相較於圖3等所說明之一般軟體RTOS,確認本實施例之工作處理裝置100能以大約100倍的速度動作。As illustrated in FIG. 5, in the case of loading the storage circuit 120 and the work processing device 100 of the work control circuit 200, the RTS work scheduling function can be completely hardened. Since the TCB of the memory is not required to be accessed when the work is switched, the work switching process can be faster. According to the experiment of the present inventors, it was confirmed that the work processing apparatus 100 of the present embodiment can operate at a speed of about 100 times as compared with the general software RTOS described with reference to FIG.

(改良例1)(Modification 1)

在作成電腦程式時,「佇列(Queue)」係固定使用且使用頻率高的演算法。因此,佇列處理之高速化,有助於電腦程式之處理速度的提升。然而,即使是FIFO(先進先出:First-In First-Out)之佇列,視情形有時亦會有欲進行LIFO(後進先出:Last-In First-Out)之動作的情形。或者,有時亦會有以LIFO為基本而欲進行FIFO之動作的情形。於改良例1,對亦可對應LIFO之特殊佇列的演算法(以下,稱為「雙放入型佇列演算法」)之硬體構裝之工作處理裝置100進行說明。When creating a computer program, the "Queue" is a fixed-use algorithm that uses a high frequency. Therefore, the speed of the processing of the queue helps the processing speed of the computer program to increase. However, even in the case of FIFO (First-In First-Out), there may be cases where LIFO (Last-In First-Out) action is required depending on the situation. Or, there may be cases where the FIFO operation is performed based on LIFO. In the first modification, the work processing apparatus 100 of the hardware configuration which can also correspond to the special array of LIFO (hereinafter referred to as "double-input type array algorithm") will be described.

基本例之工作處理裝置100,裝載根據計時器管理之工作排程功能。基本例之工作排程,係「只有在工作優先順序相同時,優先將執行櫂分配至等待時間長的工作」之演算法。以下,將此種工作排程稱為「公平型工作排程」。The work processing apparatus 100 of the basic example loads a work scheduling function managed according to a timer. The basic work schedule is "the algorithm that assigns execution to the long-waiting work with priority when the work priorities are the same." Hereinafter, this work schedule is referred to as "fair work schedule".

圖11中,說明了根據公平型工作排程之概念之工作準備串列的管理方法。當RUN-工作之工作J返回READY狀態時,係連結至最後端之工作F之後。由於在工作J之後是工作A成為RUN-工作,因此各工作之TCB,依工作D、…、工作F、工作J之順序連結至工作優先順序「0」的優先順序指標280。工作J,至少在工作F之執行結束前不會被賦予執行櫂。公平型工作排程之處理方法,近似於FIFO,亦即佇列之演算法。由於為時間管理之演算法,因此可藉由計時器管理將公平型工作排程進行硬體構裝。In Fig. 11, a management method of the work preparation sequence according to the concept of fair work schedule is explained. When the RUN-working work J returns to the READY state, it is connected to the last working F. Since the job A becomes the RUN-work after the job J, the TCB of each job is linked to the priority index 280 of the work priority order "0" in the order of the work D, ..., the work F, and the work J. Work J, at least until the end of the execution of work F will not be given execution. The processing method of fair work scheduling is similar to FIFO, which is the algorithm of the queue. Due to the algorithm of time management, the fair work schedule can be hardware-structured by timer management.

另一方面,於軟體OS,亦大多採用「只有在工作優先順序相同時,優先將執行權分配至暫時成為RUN-工作的工作」的工作排程。以下,將此種工作排程稱為「再執行優先型工作排程」。於再執行優先型工作排程,當RUN-工作之工作J返回READY狀態時,不是連結至最後端,而是插入至前端。由於在工作J之後是工作A成為RUN-工作,因此各工作之TCB,依工作J、工作D、…、工作F之順序連結至工作優先順序「0」的優先順序指標280。工作J,在工作A結束後,在工作D、工作F之前再次被賦予執行權。當存在有暫時被賦予執行權後,僅可能總合執行之類型的工作時,再執行優先型工作排程是有效的。再執行優先型工作排程,包含LIFO,亦即堆疊的演算法。於改良例1,藉由以FIFO為基本、亦可對應LIFO之雙放入型佇列演算法之硬體構裝,來實現再執行優先型工作排程。On the other hand, in the software OS, "work schedules in which the execution right is preferentially assigned to the work that temporarily becomes the RUN-work is preferentially used only when the work priorities are the same." Hereinafter, this work schedule is referred to as "re-execution priority work schedule". When the priority work schedule is executed again, when the RUN-work job J returns to the READY state, it is not connected to the last end but is inserted into the front end. Since the job A becomes the RUN-work after the job J, the TCB of each job is linked to the priority index 280 of the work priority order "0" in the order of the job J, the job D, ..., and the work F. Work J, after the end of work A, is given the right to execute again before work D and work F. It is effective to perform a priority work schedule when there is a type of work that is only possible to perform the execution right after being temporarily given the execution right. Perform the prioritized work schedule, including LIFO, which is the stacked algorithm. In the first modification, the priority work scheduling is realized by the hardware configuration of the double-input type array algorithm which is based on the FIFO and can also correspond to the LIFO.

此外,不限於再執行優先型工作排程,雙放入型佇列演算法於一般應用程式亦有用。因此,雙放入型佇列演算法之硬體構裝,於提昇各種電腦程式之處理速度上是有效的。In addition, it is not limited to re-execute the priority work schedule, and the double-input queue algorithm is also useful for general applications. Therefore, the hardware configuration of the dual-input array algorithm is effective in improving the processing speed of various computer programs.

圖18係改良例1之工作處理裝置100的電路圖。Fig. 18 is a circuit diagram of the work processing apparatus 100 of the first modification.

改良例1之工作處理裝置100,亦包含CPU150、儲存電路120、及工作控電路200。然而,改良例1之工作切換電路210,包含主電路400、寫入電路402、佇列控制電路404、及最大值選擇電路406。主電路400,係具備與基本例之工作切換電路210大致相同功能的電路。因此,改良例1之工作切換電路210之構成,係作為基本例之工作切換電路210之主電路400外追加寫入電路402、佇列控制電路404、及最大值選擇電路406。所有工作之所有狀態資料,從各狀態記憶部220不僅隨時輸出至工作選擇電路230,亦隨時輸出至最大值選擇電路406或佇列控制電路404。The work processing apparatus 100 of the first modification also includes a CPU 150, a storage circuit 120, and a work control circuit 200. However, the operation switching circuit 210 of the first modification includes the main circuit 400, the write circuit 402, the array control circuit 404, and the maximum value selection circuit 406. The main circuit 400 is provided with a circuit having substantially the same function as the operation switching circuit 210 of the basic example. Therefore, in the configuration of the work switching circuit 210 of the first modification, the write circuit 402, the queue control circuit 404, and the maximum value selection circuit 406 are added to the main circuit 400 of the work switching circuit 210 as a basic example. All state data of all the operations are outputted from the state memory unit 220 to the work selection circuit 230 at any time, and are output to the maximum value selection circuit 406 or the queue control circuit 404 at any time.

圖19係改良例1之工作控制電路200之一部分的電路圖。Fig. 19 is a circuit diagram showing a part of the operation control circuit 200 of the first modification.

工作控制電路200之基本構成,與圖10所示之電路構成大致相同。對應各工作之狀態暫存器250,包含工作ID暫存器410、工作優先順序暫存器412、佇列順序暫存器414、及佇列辨別暫存器416。狀態暫存器250亦可包含其他暫存器,但此處以雙放入型佇列演算法相關之暫存器群組為中心來說明。The basic configuration of the operation control circuit 200 is substantially the same as that of the circuit shown in FIG. The status register 250 corresponding to each operation includes a work ID register 410, a work priority register 412, a queue sequential register 414, and a queue identification register 416. The state register 250 can also include other registers, but here is centered on the register group associated with the dual-input array algorithm.

(A)工作ID暫存器410:作為要素ID的一種,儲存工作ID。與基本例所示之工作ID暫存器254相同。從工作ID暫存器410隨時輸出表示工作ID的EID_S訊號。(A) Work ID register 410: As a type of element ID, a job ID is stored. The same as the job ID register 254 shown in the basic example. The EID_S signal indicating the job ID is output from the job ID register 410 at any time.

(B)工作優先順序暫存器412:儲存工作優先順序(PR)。與基本例所示之工作優先順序暫存器256相同。隨時輸出PR_S訊號。(B) Work Priority Order 412: Store Work Priority (PR). It is the same as the work priority register 256 shown in the basic example. The PR_S signal is output at any time.

(C)佇列順序暫存器414:儲存表示對後述虛擬佇列之放入順序的「順序值(ODR)」。順序值愈大,表示放入至虛擬佇列愈深,詳細後述。順序值,係作為ODR_S訊號而隨時輸出。(C) Array Sequence Register 414: Stores "Order Value (ODR)" indicating the order in which the virtual queues described later are placed. The larger the order value is, the deeper it is placed into the virtual queue, which will be described later in detail. The sequence value is output as an ODR_S signal at any time.

(D)佇列辨別暫存器416:儲存用以辨別虛擬佇列之「佇列ID(QID)」。作為QID_S訊號而隨時輸出。(D) Array Discriminating Register 416: Stores the "Queue ID (QID)" for identifying the virtual queue. It is output as a QID_S signal at any time.

工作優先順序暫存器412、佇列順序暫存器414、及佇列辨別暫存器416,特別具有用以管理虛擬佇列之佇列暫存器的功能。The work priority register 412, the queue sequential register 414, and the queue identification register 416 have a function of managing the queue register of the virtual queue.

虛擬佇列係對應工作狀態之佇列。例如,QID=0之虛擬佇列(以下,表記為「虛擬佇列(0)」)對應READY狀態,虛擬佇列(1)對應旗號等待狀態,虛擬佇列(2)對應互斥等待狀態。或者,虛擬佇列(1)對應旗號ID=0的旗號等待狀態,虛擬佇列(2)對應旗號ID=1的旗號等待狀態。QID與工作狀態之對應,以軟體任意設定即可。The virtual queue is the queue corresponding to the working state. For example, a virtual queue with QID=0 (hereinafter, referred to as "virtual queue (0)") corresponds to the READY state, a virtual queue (1) corresponds to the flag wait state, and a virtual queue (2) corresponds to the mutual exclusion wait state. Alternatively, the virtual queue (1) corresponds to the flag waiting state of the flag ID=0, and the virtual queue (2) corresponds to the flag waiting state of the flag ID=1. The correspondence between the QID and the working state can be arbitrarily set by the software.

當工作A為READY狀態時,在佇列辨別暫存器416_A設定對應READY狀態之虛擬佇列的QID。工作選擇電路230或佇列控制電路404,藉由參照各佇列辨別暫存器416,可判別各工作的工作狀態。因此,佇列辨別暫存器416,具有與基本例之工作狀態暫存器258、待機理由暫存器262、旗號ID暫存器264、及互斥ID暫存器265、事件ID暫存器266等相同的功能。When the job A is in the READY state, the QID of the virtual queue corresponding to the READY state is set in the queue identifying buffer 416_A. The operation selection circuit 230 or the array control circuit 404 can determine the operation state of each operation by referring to each of the array identification registers 416. Therefore, the queue identifying buffer 416 has a working state register 258, a standby reason register 262, a flag ID register 264, a mutually exclusive ID register 265, and an event ID register. 266 and other similar functions.

虛擬佇列並非物理上存在,係藉由佇列順序暫存器414或佇列辨別暫存器416之設定內容而想像之概念性佇列,此點非常重要。例如,對各佇列辨別暫存器416與佇列順序暫存器414進行下述設定時,It is important that the virtual queue is not physically present, and is conceptually imagined by the queued sequence register 414 or the array of identification registers 416. For example, when each of the queue identifying buffer 416 and the array sequence register 414 is set as described below,

工作A:QID=0、ODR=0Work A: QID=0, ODR=0

工作B:QID=0、ODR=1Work B: QID=0, ODR=1

工作C:QID=0、ODR=2Work C: QID=0, ODR=2

工作D:QID=1、ODR=0Work D: QID=1, ODR=0

表示在虛擬佇列(0)依序放入工作C、B、A,在虛擬佇列(1)僅放入工作D。根據QID與ODR之數值範圍可彈性變更虛擬佇列之數量與尺寸。It means that the work C, B, and A are placed in the virtual queue (0), and the work D is placed in the virtual queue (1). The number and size of the virtual queues can be flexibly changed according to the range of values of QID and ODR.

工作選擇電路230,根據從狀態暫存器250輸出之狀態資料,選擇待狀態遷移之工作。主電路400將CND訊號輸入至工作選擇電路230。CND係表示工作選擇條件的訊號,包含表示佇列ID之QID_C與表示工作優先順序之PR_C。例如,從虛擬佇列(0)欲取出工作時,主電路400在CND設定QID_C=0。工作選擇電路230,將指定之虛擬佇列(0)中成為取出對象之工作(以下,簡稱為「取出工作」)之工作ID輸出至EID_A1,傳送EID_A1_EN。又,在PR_A1、ODR_A1,輸出取出工作之工作優先順序與順序值。以此方式,主電路400,指定QID_C=Qn並詢問工作選擇電路230,藉此得知虛擬佇列(Qn)的取出工作。工作選擇電路230具有選擇取出工作之取出候補電路的功能。更詳細以圖32後述。The job selection circuit 230 selects the operation to be migrated based on the status data output from the status register 250. The main circuit 400 inputs the CND signal to the work selection circuit 230. The CND is a signal indicating a job selection condition, and includes a QID_C indicating a queue ID and a PR_C indicating a job priority. For example, when the virtual queue (0) is to be taken out of the work, the main circuit 400 sets QID_C=0 at the CND. The job selection circuit 230 outputs the job ID of the operation (hereinafter, simply referred to as "takeout operation") of the specified virtual queue (0) to the EID_A1, and transmits the EID_A1_EN. Further, in PR_A1 and ODR_A1, the work priority order and the sequence value of the fetch operation are output. In this manner, the main circuit 400 specifies QID_C = Qn and interrogates the job selection circuit 230, thereby knowing the fetch operation of the virtual queue (Qn). The work selection circuit 230 has a function of selecting a take-out candidate circuit for taking out the work. More details will be described later with reference to FIG.

CND訊號從主電路400輸入至最大值選擇電路406。最大值選擇電路406,當以CND指定QID- C=Qn時,將虛擬佇列(Qn)之最大順序值輸出至ODR- A2,傳送EID-A2-EN。更詳細以圖28後述。The CND signal is input from the main circuit 400 to the maximum value selection circuit 406. The maximum value selection circuit 406 outputs the maximum sequence value of the virtual queue (Qn) to the ODR - A2 and transmits the EID-A2-EN when the QID - C=Qn is specified by CND. More details will be described later with reference to FIG. 28.

佇列控制電路404,藉由設定各狀態暫存器250的狀態資料,控制各工作之狀態遷移。從主電路400將CMD及EID- C輸入至佇列控制電路404,除此之外,亦輸入CND(QID-C、PR-C)、ODR-A1、ODR-A2、ODR-A2-EN與各狀態暫存器250的狀態資料。The queue control circuit 404 controls the state transition of each operation by setting the state data of each state register 250. The CMD and EID - C are input from the main circuit 400 to the array control circuit 404, and in addition, CND (QID-C, PR-C), ODR-A1, ODR-A2, ODR-A2-EN are input. Status data of each state register 250.

CMD係表示用以操作虛擬佇列的指令。CMD之對象之虛擬佇列的佇列ID、工作的工作ID、工作優先順序,係分別藉由QID-C、EID-C、PR-C指定。指令係ENQ-TL、ENQ- TP、DEQ之3種類中的一種。CMD is an instruction to operate a virtual queue. The queue ID of the virtual queue of the CMD object, the job ID of the job, and the work priority are specified by QID-C, EID-C, and PR-C, respectively. The command is one of three types of ENQ-TL, ENQ - TP, and DEQ.

當輸入順向放入指令ENQ- TL時,從虛擬佇列之最後端放入EID- C訊號所指定之工作。以下,將從佇列之最後端之放入稱為「順向放入」。當輸入取出指令DEQ時,從虛擬佇列之前端取出工作。藉由ENQ- TL與 DEQ,執行FIFO的佇列控制。當輸入逆向放入指令ENQ- TP時,從虛擬佇列之前端放入EID- C訊號所指定之工作。以下,將此種從佇列之前端之放入稱為「逆向放入」。逆向放入,不是FIFO之放入,為特殊的放入方法。When the input is placed in the instruction ENQ - TL, the job specified by the EID - C signal is placed from the last end of the virtual queue. Hereinafter, the placement from the last end of the queue is referred to as "positive insertion". When the fetch instruction DEQ is input, the work is taken out from the front end of the virtual queue. The FIFO queue control is performed by ENQ - TL and DEQ. When the reverse input command ENQ - TP is input, the job specified by the EID - C signal is placed from the front of the virtual queue. Hereinafter, such insertion from the front end of the array is referred to as "reverse insertion". Reverse insertion, not the FIFO, is a special placement method.

從主電路400輸入CMD時,寫入電路402傳送WT,執行佇列控制電路404所輸出之各資料至狀態暫存器250的寫入。佇列控制電路404、寫入電路402、工作選擇電路230、最大值選擇電路406等,具有用以控制虛擬佇列之虛擬佇列處理電路的功能。When the CMD is input from the main circuit 400, the write circuit 402 transmits the WT, and performs writing of the data output from the queue control circuit 404 to the state register 250. The array control circuit 404, the write circuit 402, the operation selection circuit 230, the maximum value selection circuit 406, and the like have a function of controlling the virtual array processing circuit of the virtual array.

以接下來之圖20詳細說明佇列控制電路404之電路構成。The circuit configuration of the array control circuit 404 will be described in detail with reference to FIG. 20 below.

圖20係佇列控制電路404的電路圖。FIG. 20 is a circuit diagram of the train control circuit 404.

佇列控制電路404,係複數個暫存器值產生電路420的集合體。各暫存器值產生電路420為相同電路。暫存器值產生電路420係對應各工作。亦可說為對應各狀態暫存器250。暫存器值產生電路420_EN,對應工作ID=En的工作(以下,表記為「工作(En)」)。該工作之工作ID係作為ELM_ID訊號而固定輸入至暫存器值產生電路420。The queue control circuit 404 is an aggregate of a plurality of register value generation circuits 420. Each of the register value generating circuits 420 is the same circuit. The register value generating circuit 420 corresponds to each operation. It can also be said that it corresponds to each state register 250. The register value generating circuit 420_EN corresponds to the operation of the work ID = En (hereinafter, referred to as "operation (En)"). The job ID of this job is fixedly input to the scratchpad value generating circuit 420 as an ELM_ID signal.

ODR_S、QID_S、PR_S,係從狀態暫存器250輸出之狀態資料,分別表示順序值、佇列ID、工作優先順序。工作(En)之順序值、佇列ID、工作優先順序分別作為ODR_S_En、QID_S_En、PR_S_En而輸入至對應工作(En)之暫存器值產生電路420_EN。CMD、EID_C係從主電路400輸入。ODR_A2_EN與ODR_A2係從最大值選擇電路406輸入。表示最大順序值之ODR_A2,當傳送ODR_A2_EN時成為有效的輸入。ODR_A1係從工作選擇電路230輸入。ODR_A1係表示取出工作的工作ID。QID_C與PR_C係從主電路400輸入之CND訊號,分別表示作為工作選擇條件的QID與PR。ODR_S, QID_S, and PR_S are state data outputted from the state register 250, and represent order values, queue IDs, and work priorities, respectively. The sequence value, the queue ID, and the job priority of the operation (En) are input to the register value generation circuit 420_EN of the corresponding operation (En) as ODR_S_En, QID_S_En, and PR_S_En, respectively. CMD and EID_C are input from the main circuit 400. ODR_A2_EN and ODR_A2 are input from the maximum value selection circuit 406. The ODR_A2 indicating the maximum order value becomes a valid input when the ODR_A2_EN is transmitted. The ODR_A1 is input from the work selection circuit 230. ODR_A1 indicates the job ID of the job taken out. QID_C and PR_C are CND signals input from the main circuit 400, and represent QIDs and PRs as work selection conditions, respectively.

暫存器值產生電路420_EN,將工作(En)之順序值、佇列ID、工作優先順序分別輸出為QID_N_En、ODR_N_En、PR_N_En,當寫入電路402傳送WT時,寫入至狀態暫存器250_En。The register value generating circuit 420_EN outputs the order value of the operation (En), the queue ID, and the work priority order as QID_N_En, ODR_N_En, and PR_N_En, respectively. When the write circuit 402 transmits the WT, it writes to the state register 250_En. .

當寫入電路402傳送WT時,所有暫存器值產生電路420之QID_N_En、ODR_N_En、PR_N_En係寫入至所有狀態暫存器250。因CMD而受到影響之工作相關之暫存器值產生電路420,將後述演算法所指定之新的資料寫入至狀態暫存器250。另一方面,不因CMD而受到影響之工作相關之暫存器值產生電路420,亦再次輸出與寫入至狀態暫存器250之資料相同的資料,以執行寫入。When the write circuit 402 transmits the WT, the QID_N_En, ODR_N_En, and PR_N_En of all the register value generating circuits 420 are written to all of the state registers 250. The scratchpad value generating circuit 420 related to the work affected by the CMD writes new data designated by the algorithm described later to the state register 250. On the other hand, the job-related register value generating circuit 420 which is not affected by the CMD also outputs the same material as the data written to the status register 250 again to perform writing.

此外,暫存器值產生電路420之WT,直接輸入佇列控制電路404而非各狀態暫存器250亦可。此時,內建於佇列控制電路404之暫存器值產生電路420之中,僅因CMD而待狀態變更之工作相關之暫存器值產生電路420,將新的資料寫入至狀態暫存器250亦可。In addition, the WT of the register value generating circuit 420 may be directly input to the array control circuit 404 instead of the state registers 250. At this time, among the scratchpad value generating circuits 420 built in the array control circuit 404, only the work related register value generating circuit 420 for the state change due to the CMD writes new data to the state temporarily. The memory 250 is also available.

暫存器值產生電路420之具體處理內容於後述。The specific processing contents of the register value generating circuit 420 will be described later.

圖21係顯示虛擬佇列與工作之關係的概念圖。Figure 21 is a conceptual diagram showing the relationship between a virtual queue and work.

此處,假設虛擬佇列(Q0)與虛擬佇列(Q1)的2個虛擬佇列。虛擬佇列(Q0),係用以放入工作優先順序PR=0之工作之優先佇列(以下,表記為「優先佇列(Q0:0)」)與用以放入工作優先順序PR=1之工作之優先佇列(Q0:1)之2個優先佇列的集合。虛擬佇列(Q1)亦相同,假設實質上有4個優先佇列。例如,虛擬佇列(Q0)對應READY狀態,虛擬佇列(Q1)對應WAIT狀態亦可。Here, it is assumed that two virtual queues of the virtual queue (Q0) and the virtual queue (Q1). The virtual queue (Q0) is used to put the priority queue for the work priority PR=0 (hereinafter, the table is referred to as "priority queue (Q0:0)") and is used to put the work priority PR= The priority of the work of 1 (Q0:1) is a set of two priority queues. The virtual queue (Q1) is also the same, assuming that there are essentially four priority queues. For example, the virtual queue (Q0) corresponds to the READY state, and the virtual queue (Q1) corresponds to the WAIT state.

各虛擬佇列,係面向圖示左側為放入口,右側為取出口的佇列。於順向放入從左側放入工作,於逆向放入從右側放入工作。取出工作則恆從右側。Each virtual queue is placed on the left side of the illustration and the right side is the exit line. Put it into the work from the left side and put it in the reverse direction. Take out the work and keep it from the right side.

同圖中,將工作ID=E0、E1、E2、E3之4個工作放入虛擬佇列。工作(E0)與工作(E2)、工作(E3)係放入虛擬佇列(Q0)。之中,由於工作(E0)與工作(E3)係工作優先順序PR=0之工作,因此放入優先佇列(Q0:0)。由於工作(E2)係PR=1之工作,因此放入優先佇列(Q0:1)。放入虛擬佇列(Q0)之工作(E3)、工作(E2)、工作(E0)之順序值ODR為2、1、0。工作優先順序PR=0之工作(E1),係放入虛擬佇列(Q1)。ODR為「0」。In the same figure, four jobs of work ID=E0, E1, E2, and E3 are placed in the virtual queue. Work (E0), work (E2), and work (E3) are placed in the virtual queue (Q0). Among them, since the work (E0) and the work (E3) work in the work priority order PR=0, the priority queue (Q0:0) is placed. Since the work (E2) is a work of PR=1, the priority queue (Q0:1) is placed. The order value ODR of the work (E3), work (E2), and work (E0) placed in the virtual queue (Q0) is 2, 1, and 0. The work (E1) with the work priority PR=0 is placed in the virtual queue (Q1). ODR is "0".

圖22係對應圖21之狀態暫存器250的資料結構圖。FIG. 22 is a data structure diagram corresponding to the state register 250 of FIG. 21.

圖21所示之對虛擬佇列之各工作的放入狀態,係藉由狀態暫存器250之設定來表現。圖21所示之狀態,工作(E0)~工作(E7)之中,放入虛擬佇列者為工作(E0)~工作(E3)。因此,其他工作之佇列辨別暫存器416係設定成表示未放入的「Non」。放入虛擬佇列(Q0)之工作(E0)、工作(E3)、工作(E2)之佇列辨別暫存器416係設定成「Q0」。又,放入虛擬佇列(Q1)之工作(E1)之佇列辨別暫存器416係設定成「Q1」。藉由佇列辨別暫存器416的設定內容,表現哪個工作放入哪個虛擬佇列。The put-in state of each job for the virtual queue shown in FIG. 21 is represented by the setting of the state register 250. In the state shown in Fig. 21, among the operations (E0) to (E7), the virtual queue is placed as the work (E0) to the work (E3). Therefore, the other work queues 412 are set to indicate "Non" that is not placed. The queue discrimination register 416 of the work (E0), the work (E3), and the work (E2) placed in the virtual queue (Q0) is set to "Q0". Further, the queue discrimination register 416 of the operation (E1) in which the virtual queue (Q1) is placed is set to "Q1". By identifying the setting contents of the register 416, it is indicated which work is placed in which virtual queue.

放入虛擬佇列(Q0)之3個工作(E0)、工作(E3)、工作(E2)之佇列順序暫存器414,分別設定0、2、1作為ODR。放入虛擬佇列(Q1)之工作,由於僅有工作(E1),因此順序值設定成最小的「0」。藉由佇列順序暫存器414的設定內容,表現各工作在虛擬佇列的位置。The three sequence (E0), the work (E3), and the work (E2) queue order register 414 are placed in the virtual queue (Q0), and 0, 2, and 1 are set as the ODRs, respectively. In the work of placing the virtual queue (Q1), since only the work (E1) is performed, the order value is set to the minimum "0". The position of each of the virtual queues is represented by the setting contents of the queue sequential register 414.

工作(E0)、工作(E1)、工作(E3)之工作優先順序PR為「0」。因此,在該等工作之工作優先順序暫存器412設定「0」。由於工作(E2)之工作優先順序PR為「1」,因此在工作優先順序暫存器412_E2設定「1」。藉由工作優先順序暫存器412的設定,表現各工作放入哪個優先佇列。The work priority order PR of work (E0), work (E1), and work (E3) is "0". Therefore, the job priority register 412 is set to "0" in these jobs. Since the work priority order PR of the work (E2) is "1", "1" is set in the work priority register 412_E2. By the setting of the work priority register 412, it is indicated which priority queue is placed for each job.

根據以上設定,詳細說明順向放入、逆向放入、取出之處理內容。According to the above settings, the processing contents of the forward insertion, the reverse insertion, and the removal are described in detail.

(順向放入)(put in the direction)

圖23係將工作(E4)順向放入圖21之虛擬佇列時的概念圖。Fig. 23 is a conceptual diagram when the work (E4) is placed in the virtual queue of Fig. 21 in the forward direction.

此處,說明將工作優先順序PR=0之工作(E4)順向放入虛擬佇列(Q1)的情形。主電路400,CMD=ENQ_TL(順向放入指令),設定EID_C=E4、QID_C= Q1、PR_C=0。內建於佇列控制電路404之暫存器值產生電路420_E4,檢測到EID_C=ELM_ID=E4時,輸出QID_N_E4=QID_C=Q1、ODR_N_E4=0、PR_N_E4=PR_C=0。QID_N_E4係工作(E4)之放入對象之虛擬佇列的QID、ODR_N_E4係放入時的順序值、PR_N_E4係工作(E4)的工作優先順序。順向放入之工作相關之ODR_N,恆設定為「0」。此係表示對佇列之最新放入的順序值。Here, a case where the work (E4) of the work priority order PR=0 is placed in the virtual queue (Q1) will be described. The main circuit 400, CMD = ENQ_TL (direct input command), sets EID_C = E4, QID_C = Q1, PR_C = 0. The register value generating circuit 420_E4 built in the queue control circuit 404 outputs QID_N_E4=QID_C=Q1, ODR_N_E4=0, and PR_N_E4=PR_C=0 when EID_C=ELM_ID=E4 is detected. QID_N_E4 is the work order (E4) in which the QID and ODR_N_E4 of the virtual queue are placed, and the order of the PR_N_E4 system (E4) is prioritized. The ODR_N related to the job placed in the forward direction is always set to "0". This is the order value for the most recent placement of the queue.

不僅暫存器值產生電路420_E4,亦會反應到QID_S_En=QID_C=Q1之暫存器值產生電路420_En。暫存器值產生電路420_En,輸出ODR_N_En=ODR_S_En+1。此處,暫存器值產生電路420_E1檢測到QID_S_E1=QID_C=Q1,輸出ODR_N_E1=0+1=1。ODR_N_E1係工作(E1)放入後的順序值。已經放入工作(E4)之順向放入對象之虛擬佇列(Q1)之工作,其順序值受到影響。經過此種處理過程,調整虛擬佇列(Q1)之要素之工作(E4)與工作(E1)的狀態資料。Not only the scratchpad value generating circuit 420_E4 but also the register value generating circuit 420_En of QID_S_En = QID_C = Q1. The register value generating circuit 420_En outputs ODR_N_En=ODR_S_En+1. Here, the register value generating circuit 420_E1 detects that QID_S_E1=QID_C=Q1, and outputs ODR_N_E1=0+1=1. ODR_N_E1 is the sequence value after the work (E1) is placed. The work that has been placed in the work (E4) is placed in the virtual queue (Q1) of the object, and the order value is affected. After this process, the status data of the work (E4) and work (E1) of the elements of the virtual queue (Q1) are adjusted.

圖24係對應圖23之狀態暫存器250的資料結構圖。FIG. 24 is a data structure diagram corresponding to the state register 250 of FIG.

同圖中,附加底線之部分,為圖22所示之狀態暫存器250之設定內容改變的部位。由於工作(E4)對虛擬佇列(Q1)之順向放入,因此佇列辨別暫存器416_E4係藉由QID_N_E4設定成「Q1」。工作(E4)之ODR為「0」,PR為「0」。由於工作(E4)之順向放入,已放入虛擬佇列(Q1)之工作(E1)之ODR從「0」增加為「1」。藉由變更後之狀態暫存器250的設定內容,表現圖23所示之虛擬佇列(Q1)的狀態。In the same figure, the portion to which the bottom line is attached is the portion where the setting contents of the state register 250 shown in Fig. 22 are changed. Since the work (E4) is placed in the forward direction of the virtual queue (Q1), the queue identification register 416_E4 is set to "Q1" by QID_N_E4. The ODR of the work (E4) is "0" and the PR is "0". Since the work (E4) is placed in the forward direction, the ODR of the work (E1) that has been placed in the virtual queue (Q1) is increased from "0" to "1". The state of the virtual queue (Q1) shown in Fig. 23 is expressed by the setting contents of the state register 250 after the change.

圖25係將工作(E5)順向放入圖23之虛擬佇列時的概念圖。Fig. 25 is a conceptual diagram when the work (E5) is placed in the virtual queue of Fig. 23 in the forward direction.

此處,說明將工作優先順序PR=1之工作(E5)順向放入虛擬佇列(Q0)的情形。主電路400,CMD=ENQ_TL(順向放入指令),設定EID_C=E5、QID_C=Q0、PR_C=1。暫存器值產生電路420_E5,輸出QID_N_E5=QID_C=Q0、ODR_N_E5=0、PR_N_E5=PR_C=1。Here, a case where the work (E5) of the work priority order PR=1 is placed in the virtual queue (Q0) will be described. The main circuit 400, CMD=ENQ_TL (direct input instruction), sets EID_C=E5, QID_C=Q0, PR_C=1. The register value generating circuit 420_E5 outputs QID_N_E5=QID_C=Q0, ODR_N_E5=0, and PR_N_E5=PR_C=1.

不僅暫存器值產生電路420_E5,QID_C=QID_S_En=Q0之暫存器值產生電路420_En,檢測到QID_C=QID_S_En時,輸出ODR_N_En=ODR_S_En+1。此例中,為對應工作(E0)、工作(E2)、工作(E3)之暫存器值產生電路420。如此,調整虛擬佇列(Q0)之要素之工作(E5)與工作(E0)、工作(E2)、工作(E3)的狀態資料。Not only the scratchpad value generating circuit 420_E5, the register value generating circuit 420_En of QID_C=QID_S_En=Q0, but when detecting QID_C=QID_S_En, the output ODR_N_En=ODR_S_En+1. In this example, it is a register value generating circuit 420 corresponding to the work (E0), the work (E2), and the work (E3). In this way, the status data of the work (E5) and work (E0), work (E2), and work (E3) of the elements of the virtual queue (Q0) are adjusted.

圖26係對應圖25之狀態暫存器250的資料結構圖。FIG. 26 is a data structure diagram corresponding to the state register 250 of FIG. 25.

同圖中,附加底線之部分,為圖24所示之狀態暫存器250之設定內容改變的部位。首先,由於工作(E5)對虛擬佇列(Q0)之順向放入,因此佇列辨別暫存器416_E5係新設定成「Q0」。工作(E5)之ODR為「0」,PR為「1」。由於工作(E5)之順向放入,已放入虛擬佇列(Q0)之工作(E0)、工作(E1)、工作(E3)之ODR分別增加。In the same figure, the portion to which the bottom line is attached is the portion where the setting contents of the state register 250 shown in Fig. 24 are changed. First, since the work (E5) puts the virtual queue (Q0) in the forward direction, the queue identification register 416_E5 is newly set to "Q0". The ODR of the work (E5) is "0" and the PR is "1". Since the work (E5) is placed in the forward direction, the ODRs of the work (E0), the work (E1), and the work (E3) that have been placed in the virtual queue (Q0) are respectively increased.

圖27係顯示順向放入之處理過程的流程圖。Figure 27 is a flow chart showing the processing of the forward insertion.

主電路400,設定順向放入之工作(以下,稱為「順向放入工作」)相關之放入條件(S10)。具體而言,CMD=ENQ_TL,設定EID_C、QID_C、PR_C。佇列控制電路404之中,對應順向放入工作之暫存器值產生電路420,將順向放入工作之工作優先順序暫存器412、佇列順序暫存器414、佇列辨別暫存器416分別設定成PR_C、0、QID_C(S12)。The main circuit 400 sets the loading condition (S10) related to the work of the forward insertion (hereinafter referred to as "the forward loading operation"). Specifically, CMD=ENQ_TL, and EID_C, QID_C, and PR_C are set. Among the queue control circuit 404, a register value generating circuit 420 corresponding to the forward direction is placed, and the work priority order register 412, the queue sequential register 414, and the queue identification are placed in the forward direction. The registers 416 are set to PR_C, 0, and QID_C, respectively (S12).

虛擬佇列(QID_C)已放入其他工作時(S14之是),對已放入之各工作增加ODR(S16)。圖25所示之例之情形,對工作(E0)、工作(E2)、工作(E3)增加ODR。S12、S14、S16之處理在時間上大致同時執行。When the virtual queue (QID_C) has been put into other work (Yes in S14), the ODR is added to each work that has been placed (S16). In the case of the example shown in Fig. 25, the ODR is added to the work (E0), the work (E2), and the work (E3). The processing of S12, S14, and S16 is performed substantially simultaneously in time.

(逆向放入)(reverse insertion)

圖28係最大值選擇電路406之一部分的電路圖。28 is a circuit diagram of a portion of the maximum value selection circuit 406.

最大值選擇電路406,係用以進行逆向放入處理而由主電路400驅動的電路。最大值選擇電路406,當輸入QID_C=Qn作為CND訊號時,將虛擬佇列(Qn)之最大順序值輸出至ODR_A2,傳送ODR_A2_EN。最大值選擇電路406,與基本例所示之執行選擇電路232與旗號選擇電路234相同,係由複數段之比較電路構成。最大值選擇電路406,包含4個第1比較電路422(422a,422b等)、2個第2比較電路424(424a等)、1個第3比較電路(未圖示)。又,包含8個判定電路426(426a,426b,426c,426d等)。The maximum value selection circuit 406 is a circuit for performing the reverse insertion processing and being driven by the main circuit 400. The maximum value selection circuit 406 outputs the maximum sequence value of the virtual array (Qn) to the ODR_A2 and transmits the ODR_A2_EN when the QID_C=Qn is input as the CND signal. The maximum value selection circuit 406 is the same as the execution selection circuit 232 and the flag selection circuit 234 shown in the basic example, and is constituted by a comparison circuit of a plurality of stages. The maximum value selection circuit 406 includes four first comparison circuits 422 (422a, 422b, etc.), two second comparison circuits 424 (424a, etc.), and one third comparison circuit (not shown). Further, eight decision circuits 426 (426a, 426b, 426c, 426d, etc.) are included.

著眼於第1比較電路422a進行說明。第1比較電路422a比較工作0與工作1,兩者皆放入虛擬佇列(Qn)時,選擇順序值大的工作。工作0與工作1的工作ID與順序值作為EID_S、ODR_S而輸入至第1比較電路422a。The description will be focused on the first comparison circuit 422a. The first comparison circuit 422a compares the operation 0 and the operation 1, and when both of them are placed in the virtual queue (Qn), the operation with a large sequence value is selected. The work ID and the sequence value of the work 0 and the work 1 are input to the first comparison circuit 422a as EID_S and ODR_S.

第1判定:判定電路426a,若工作0已放入虛擬佇列(Qn),則傳送EID_11A_EN。判定電路426b,若工作1已放入虛擬佇列(Qn),則傳送EID_11B_EN。第1比較電路422a,首先,參照分別從判定電路426a與判定電路426b輸出之EID_11_EN訊號。其中一者為「1」時,僅其中一者之工作已放入虛擬佇列(Qn)。此時,第1比較電路422a,將已放入虛擬佇列(Qn)之工作之工作ID(EID_S)與順序值(ODR_S)分別輸出作為EID_21A、ODR_21A,傳送EID_21A_EN。First determination: The determination circuit 426a transmits EID_11A_EN if the operation 0 has been placed in the virtual queue (Qn). The decision circuit 426b transmits EID_11B_EN if the job 1 has been placed in the virtual queue (Qn). The first comparison circuit 422a first refers to the EID_11_EN signals output from the determination circuit 426a and the determination circuit 426b, respectively. When one of them is "1", only one of the jobs has been placed in the virtual queue (Qn). At this time, the first comparison circuit 422a outputs the work ID (EID_S) and the order value (ODR_S) of the work in which the virtual queue (Qn) has been placed as EID_21A and ODR_21A, and transmits EID_21A_EN.

判定電路426a與判定電路426b皆輸出「0」時,兩個工作皆未放入虛擬佇列(Qn)。此時,停止傳送EID_21A_EN,以後,工作0與工作1皆不成為第2比較電路424a的考慮對象。When both the decision circuit 426a and the decision circuit 426b output "0", neither of the two jobs is placed in the virtual queue (Qn). At this time, the transmission of the EID_21A_EN is stopped, and thereafter, neither the operation 0 nor the operation 1 is considered as the second comparison circuit 424a.

判定電路426a與判定電路426b皆輸出「1」時,兩個工作皆已放入虛擬佇列(Qn),此時,執行接下來的第2判定。When both the determination circuit 426a and the determination circuit 426b output "1", both operations are placed in the virtual queue (Qn), and at this time, the next second determination is executed.

第2判定:比較工作0之ODR_S_0與工作1之ODR_S_1,選擇順序值大的工作。第1比較電路422a,將順序值大的工作的工作ID(EID_S)與順序值(ODR_S)分別輸出作為EID_21A、ODR_21A,傳送EID_21A_EN。The second determination: comparing the ODR_S_0 of the work 0 with the ODR_S_1 of the work 1, and selecting the work with a large sequence value. The first comparison circuit 422a outputs the operation ID (EID_S) and the sequence value (ODR_S) of the operation having a large sequence value as EID_21A and ODR_21A, respectively, and transmits EID_21A_EN.

其他之第1比較電路422之處理內容亦相同,分別比較工作0與工作1、工作2與工作3、工作4與工作5、工作6與工作7。第2比較電路424,從來自2個第1比較電路422的輸出,進一步選擇順序值大的工作。著眼於第2比較電路424a進行說明。第2比較電路424a比較第1比較電路422a的輸出訊號與第1比較電路422b的輸出訊號,選擇順序值大的工作。從第1比較電路422a與第1比較電路422b分別輸入EID_21、ODR_21、EID_EN至第2比較電路424a。第2比較電路424,選擇工作0~工作3之中,在虛擬佇列(Qn)之中順序值最大的工作。其他之第2比較電路424亦相同,最後,將虛擬佇列(Qn)之最大順序值輸出作為ODR_A2訊號。當選擇任一個工作時傳送ODR_A2_EN,當任一個工作皆不存在於虛擬佇列(Qn)時停止傳送ODR_A2_EN。The processing contents of the other first comparison circuit 422 are also the same, and the work 0 and the work 1, the work 2 and the work 3, the work 4 and the work 5, the work 6 and the work 7 are respectively compared. The second comparison circuit 424 further selects an operation having a large sequence value from the outputs from the two first comparison circuits 422. The second comparison circuit 424a will be described with a focus. The second comparison circuit 424a compares the output signal of the first comparison circuit 422a with the output signal of the first comparison circuit 422b, and selects an operation having a large sequence value. EID_21, ODR_21, and EID_EN are input from the first comparison circuit 422a and the first comparison circuit 422b to the second comparison circuit 424a, respectively. The second comparison circuit 424 selects the operation in which the order value is the largest among the virtual queues (Qn) among the operations 0 to 3. The other second comparison circuit 424 is also the same. Finally, the maximum sequence value of the virtual queue (Qn) is output as the ODR_A2 signal. When any one of the jobs is selected, the ODR_A2_EN is transmitted, and when any of the jobs does not exist in the virtual queue (Qn), the transmission of the ODR_A2_EN is stopped.

此外,用以使優先順序判定無效化之PR無效訊號亦可輸入至第1比較電路422、第2比較電路424、第3比較電路。當傳送PR無效訊號時,各比較電路將優先順序從判定條件除去來選擇工作。圖32所示之各比較電路亦相同。Further, the PR invalid signal for invalidating the priority order determination may be input to the first comparison circuit 422, the second comparison circuit 424, and the third comparison circuit. When the PR invalid signal is transmitted, each comparison circuit selects the priority by removing the priority order from the determination condition. The comparison circuits shown in Fig. 32 are also the same.

圖29係將工作(E6)逆向放入圖25之虛擬佇列時的概念圖。Fig. 29 is a conceptual diagram when the work (E6) is reversely placed in the virtual queue of Fig. 25.

此處,說明將工作優先順序PR=1之工作(E6)逆向放入虛擬佇列(Q0)之情形。首先,主電路400,藉由QID_C訊號將放入對象之QID=Q0輸入至最大值選擇電路406。最大值選擇電路406,將虛擬佇列(Q0)之最大順序值作為ODR_A2輸出至佇列控制電路404,傳送ODR_A2_EN。如圖25所示,由於虛擬佇列(Q0)之最大順序值為工作(E3)的「3」,因此ODR_A2=3。Here, a case where the work (E6) of the work priority order PR=1 is reversely placed in the virtual queue (Q0) will be described. First, the main circuit 400 inputs the QID=Q0 of the placed object to the maximum value selection circuit 406 by the QID_C signal. The maximum value selection circuit 406 outputs the maximum sequence value of the virtual matrix (Q0) as the ODR_A2 to the array control circuit 404, and transmits the ODR_A2_EN. As shown in FIG. 25, since the maximum order value of the virtual queue (Q0) is "3" of the operation (E3), ODR_A2 = 3.

接著,主電路400,CMD=ENQ_TP(逆向放入指令),設定EID_C=E6、QID_C=Q0、PR_C=1。此時,內建於佇列控制電路404之暫存器值產生電路420_E6,檢測到EID_C=ELM_ID=E6時,輸出QID_N_E6=QID_C=Q0、ODR_N_E6=ODR_A2+1=3+1=4、PR_N_E6=PR_C=1。Next, the main circuit 400, CMD=ENQ_TP (reverse insertion command), sets EID_C=E6, QID_C=Q0, and PR_C=1. At this time, the scratchpad value generating circuit 420_E6 built in the queue control circuit 404 outputs QID_N_E6=QID_C=Q0, ODR_N_E6=ODR_A2+1=3+1=4, PR_N_E6=PR_C=1 when EID_C=ELM_ID=E6 is detected.

CMD=ENQ_TP(逆向放入指令)時,僅對應EID_C所指定之工作之暫存器值產生電路420會動作。因此,僅逆向放入之工作(E6)之狀態資料會設定變更。When CMD=ENQ_TP (reverse input instruction), only the register value generation circuit 420 corresponding to the operation specified by EID_C operates. Therefore, only the status data of the work (E6) placed in the reverse direction is changed.

圖30係對應圖29之狀態暫存器250的資料結構圖。FIG. 30 is a data structure diagram corresponding to the state register 250 of FIG.

同圖中,附加底線之部分,為圖26所示之狀態暫存器250之設定內容改變的部位。首先,由於工作(E6)對虛擬佇列(Q0)之逆向放入,因此佇列辨別暫存器416_E6係新設定成「Q0」。工作(E6)之ODR為「4」,PR為「1」。由於工作(E6)之逆向放入,其他工作之狀態資料不受影響。In the same figure, the portion to which the bottom line is attached is the portion where the setting contents of the state register 250 shown in Fig. 26 are changed. First, since the work (E6) is placed in the reverse direction of the virtual queue (Q0), the queue identifying buffer 416_E6 is newly set to "Q0". The ODR of the work (E6) is "4" and the PR is "1". Due to the reverse placement of work (E6), the status data of other jobs is not affected.

圖31係顯示逆向放入之處理過程的流程圖。Figure 31 is a flow chart showing the processing of the reverse insertion.

主電路400,首先,將逆向放入對象之虛擬佇列之QID=Qn輸入至最大值選擇電路406(S20)。主電路400,將虛擬佇列(Qn)之最大順序值輸出至佇列控制電路404(S22)。主電路400,設定逆向放入之工作(以下,稱為「逆向放入工作」)相關之放入條件(S24)。具體而言,CMD=ENQ_TP(逆向放入指令),設定EID_C、QID_C、PR_C。佇列控制電路404之中,對應逆向放入工作之暫存器值產生電路420,分別在逆向放入工作之工作優先順序暫存器412、佇列順序暫存器414、佇列辨別暫存器416設定PR_C、最大順序值+1、QID_C(S26)。然而,當最大順序值=0、停止傳送ODR_A2_EN時,亦即,當工作未放入虛擬佇列(Qn)時,在佇列順序暫存器414設定表示初放入的順序值「0」。The main circuit 400 first inputs QID=Qn, which is reversely placed in the virtual queue of the object, to the maximum value selection circuit 406 (S20). The main circuit 400 outputs the maximum order value of the virtual queue (Qn) to the array control circuit 404 (S22). The main circuit 400 sets a loading condition (S24) related to the reverse insertion operation (hereinafter referred to as "reverse insertion operation"). Specifically, CMD=ENQ_TP (reverse insertion command) sets EID_C, QID_C, and PR_C. Among the array control circuits 404, the register value generating circuit 420 corresponding to the reverse loading operation is respectively placed in the work priority order register 412, the queue sequential register 414, and the queue identification temporary storage. The 416 sets PR_C, maximum order value +1, and QID_C (S26). However, when the maximum order value = 0 and the transmission of the ODR_A2_EN is stopped, that is, when the operation is not placed in the virtual queue (Qn), the order sequence register 414 is set to indicate the initial value "0".

如上述,在順向放入時,有可能產生其他工作之順序值的調整,但在逆向放入時不需要此種調整。以FIFO為前提觀察虛擬佇列時,愈早放入之工作設定愈大的順序值。亦即,放入虛擬佇列愈深的工作順序值愈大。相反地,亦可設定為放入虛擬佇列愈深的工作順序值愈小。此時,在順向放入時,不需要其他工作之順序值的調整,但在逆向放入時有可能產生其他工作之順序值的調整。As described above, when placed in the forward direction, adjustment of the order value of other work may occur, but such adjustment is not required in the reverse insertion. When observing the virtual queue on the premise of FIFO, the earlier the job is set, the larger the order value is set. That is, the deeper the work order value is, the deeper the virtual queue is placed. Conversely, the smaller the work order value that is set to be placed in the virtual queue, the smaller. At this time, when the forward direction is placed, adjustment of the order value of other work is not required, but adjustment of the order value of other work may occur at the time of reverse insertion.

(取出)(take out)

圖32係工作選擇電路230之一部分的電路圖。32 is a circuit diagram of a portion of the operation selection circuit 230.

工作選擇電路230之基本構成,如圖12說明之基本例。改良例1之工作選擇電路230,當接受來自主電路400的詢問時,特定取出工作。此處,說明用以特定此取出工作之構造相關的電路構成。工作選擇電路230,當輸入QID_C=Qn作為CND訊號時,於虛擬佇列(Qn),從工作優先順序最高的優先佇列選擇取出工作,將取出工作之工作ID、工作優先順序、順序值分別輸出至EID_A1、PR_A1、ODR_A1,傳送EID_A1_EN。工作選擇電路230,與基本例所示之執行選擇電路232及旗號選擇電路234相同,係由複數段之比較電路構成。工作選擇電路230,包含4個第1比較電路430(430a,430b等)、2個第2比較電路432(432a等)、1個第3比較電路(未圖示)。又,包含8個判定電路434(434a,434b,434c,434d等)。The basic configuration of the work selection circuit 230 is as shown in the basic example of FIG. The job selection circuit 230 of the modified example 1 performs a specific take-out operation when receiving an inquiry from the main circuit 400. Here, a circuit configuration related to the configuration for specifying this take-out operation will be described. When the QID_C=Qn is input as the CND signal, the work selection circuit 230 selects the work from the priority queue with the highest priority in the virtual queue (Qn), and extracts the job ID, work priority, and sequence value respectively. Output to EID_A1, PR_A1, ODR_A1, and transmit EID_A1_EN. The operation selection circuit 230 is the same as the execution selection circuit 232 and the flag selection circuit 234 shown in the basic example, and is constituted by a comparison circuit of a plurality of stages. The operation selection circuit 230 includes four first comparison circuits 430 (430a, 430b, etc.), two second comparison circuits 432 (432a, etc.), and one third comparison circuit (not shown). Further, eight determination circuits 434 (434a, 434b, 434c, 434d, etc.) are included.

著眼於第1比較電路430a進行說明。第1比較電路430a比較工作0與工作1,兩者皆放入虛擬佇列(Qn)時,選擇工作優先順序高的工作。工作優先順序相同時,選擇順序值大的工作。工作0與工作1的工作ID、工作優先順序、順序值作為EID_S、PR_S、ODR_S而輸入至第1比較電路430a。The first comparison circuit 430a will be described with a focus. The first comparison circuit 430a compares the operation 0 and the operation 1, and when both are placed in the virtual queue (Qn), the operation with the highest priority is selected. When the work priorities are the same, select a job with a large order value. The work ID, the work priority, and the sequence value of the work 0 and the work 1 are input to the first comparison circuit 430a as EID_S, PR_S, and ODR_S.

第1判定:判定電路434a,若工作0已放入虛擬佇列(Qn),則傳送EID_11A_EN。判定電路434b,若工作1已放入虛擬佇列(Qn),則傳送EID_11B_EN。第1比較電路430a,首先,參照分別從判定電路434a與判定電路434b輸出之EID_11_EN訊號。其中一者為「1」時,僅其中一者之工作已放入虛擬佇列(Qn)。此時,第1比較電路430a,將已放入虛擬佇列(Qn)之工作之工作ID(EID_S)、工作優先順序(PR_S)、順序值(ODR_S)分別輸出作為EID_21A、PR_11A、ODR_21A,傳送EID_21A_EN。First determination: The determination circuit 434a transmits EID_11A_EN if the operation 0 has been placed in the virtual queue (Qn). The decision circuit 434b transmits EID_11B_EN if the job 1 has been placed in the virtual queue (Qn). The first comparison circuit 430a first refers to the EID_11_EN signals output from the determination circuit 434a and the determination circuit 434b, respectively. When one of them is "1", only one of the jobs has been placed in the virtual queue (Qn). At this time, the first comparison circuit 430a outputs the work ID (EID_S), the work priority order (PR_S), and the order value (ODR_S) of the work in which the virtual queue (Qn) has been placed as EID_21A, PR_11A, and ODR_21A, respectively. EID_21A_EN.

判定電路434a與判定電路434b皆輸出「0」時,兩個工作皆未放入虛擬佇列(Qn)。此時,停止傳送EID_21A_EN,以後,工作0與工作1皆不成為第2比較電路432a的考慮對象。When both the decision circuit 434a and the decision circuit 434b output "0", neither of the two jobs are placed in the virtual queue (Qn). At this time, the transmission of the EID_21A_EN is stopped, and thereafter, neither the operation 0 nor the operation 1 is considered as the second comparison circuit 432a.

判定電路434a與判定電路434b皆輸出「1」時,兩個工作皆已放入虛擬佇列(Qn),此時,執行接下來的第2判定。When both the determination circuit 434a and the determination circuit 434b output "1", both operations are placed in the virtual queue (Qn), and at this time, the next second determination is executed.

第2判定:比較工作0之PR_S_0與工作1之PR_S_1,選擇工作優先順序高,亦即,PR_S小的工作。第1比較電路430a,將工作優先順序高之工作之工作ID(EID_S)、工作優先順序(PR_S)、順序值(ODR_S)分別輸出作為EID_21A、PR_21A、ODR_21A,傳送EID_21A_EN。兩個工作之工作優先順序相同時,執行接下來的第3判定。The second determination: comparing the PR_S_0 of the work 0 with the PR_S_1 of the work 1, the work priority is selected to be high, that is, the PR_S is small. The first comparison circuit 430a outputs the work ID (EID_S), the work priority order (PR_S), and the order value (ODR_S) of the work having the highest priority of operation as EID_21A, PR_21A, and ODR_21A, and transmits EID_21A_EN. When the work priorities of the two jobs are the same, the next third decision is executed.

第3判定:比較工作0之ODR_S_0與工作1之ODR_S_1,選擇順序值大的工作。第1比較電路430a,將順序值大的工作的工作ID(EID_S)、工作優先順序(PR_S)、順序值(ODR_S)分別輸出作為EID_21A、PR_21A、ODR_21A,傳送EID_21A_EN。The third determination: comparing the ODR_S_0 of the work 0 with the ODR_S_1 of the work 1, and selecting the work with a large sequence value. The first comparison circuit 430a outputs the operation ID (EID_S), the operation priority (PR_S), and the sequence value (ODR_S) of the operation having a large sequence value as EID_21A, PR_21A, and ODR_21A, and transmits EID_21A_EN.

其他之第1比較電路430之處理內容亦相同,分別比較工作0與工作1、工作2與工作3、工作4與工作5、工作6與工作7。第2比較電路432,從來自2個第1比較電路430的輸出,進一步鎖定取出工作的候補。最後,從虛擬佇列(Qn)中之工作優先順序最高的優先佇列,選擇取出工作。當選擇任一個工作時傳送EID_A1_EN,當任一個工作皆不存在於虛擬佇列(Qn)時停止傳送EID_A1_EN。The processing contents of the other first comparison circuit 430 are also the same, and the work 0 and the work 1, the work 2 and the work 3, the work 4 and the work 5, the work 6 and the work 7 are respectively compared. The second comparison circuit 432 further locks the candidates for the fetch operation from the outputs from the two first comparison circuits 430. Finally, the job is selected from the highest priority queue in the virtual queue (Qn). EID_A1_EN is transmitted when any one of the jobs is selected, and EID_A1_EN is stopped when any of the jobs does not exist in the virtual queue (Qn).

圖33係從圖29之虛擬佇列取出工作(E3)時的概念圖。Fig. 33 is a conceptual diagram when the work (E3) is taken out from the virtual queue of Fig. 29.

此處,以從虛擬佇列(Q0)取出1個工作之情形進行說明。主電路400,將QID- C=Q0輸入至工作選擇電路230。如圖29所示,在對應虛擬佇列(Q0)之中之最高優先順序的優先佇列(QO:0),放入順序值「1」的工作(EO)與順序值「3」的工作(E3)。工作選擇電路230,選擇順序值大的工作(E3)作為取出工作。工作選擇電路230,設EID- A1=E3、PR- A1=0、ODR-A1=3,傳送EID-A1-EN。Here, a case where one job is taken out from the virtual queue (Q0) will be described. The main circuit 400 inputs QID - C = Q0 to the operation selection circuit 230. As shown in FIG. 29, the work (EO) of the order value "1" and the work of the order value "3" are placed in the priority queue (QO: 0) of the highest priority among the virtual queues (Q0). (E3). The work selection circuit 230 selects the work (E3) having a large sequence value as the take-out work. The operation selection circuit 230 sets EID - A1 = E3, PR - A1 = 0, ODR - A1 = 3, and transmits EID-A1 - EN.

接著,主電路400,CMD=DEQ(取出指令),設定EID- C=EID-A1= E3、QID-C=QO。暫存器值產生電路420-E3,輸出QID-N-E3=Non、ODR-N-E3=0(重設)、PR-N-E3=0(重設)。以此方式,在狀態暫存器250解除工作(E3)與虛擬佇列(Q0)的關係。Next, the main circuit 400, CMD = DEQ (fetch instruction), sets EID - C = EID - A1 = E3, QID - C = QO. The register value generating circuit 420-E3 outputs QID-N-E3=Non, ODR-N-E3=0 (reset), and PR-N-E3=0 (reset). In this manner, the relationship between the operation (E3) and the virtual queue (Q0) is released in the state register 250.

不僅暫存器值產生電路420-E3,QID-S-En=QID-C=Q0之暫存器值產生電路420- En,當檢測出QID- C=QID-S-En時,判定為ODR-S-En>ODR-A1。此處,ODR-A1係取出工作(E3)之取出前的順序值。若ODR- S- En>ODR- A1,亦即,順序值較取出工作之順序值大之工作(En)的暫存器值產生電路420-En,輸出ODR-N-En=ODR-S-En-1。圖29所示之例,相當於工作(E6)之暫存器值產生電路420-E6。暫存器值產生電路420-E6,輸出ODR-N-E6=ODR- S- E6-1=4-1=3。以此方式,調整虛擬佇列(Q0)之要素之工作(E6)的狀態資料。Not only the register value generating circuit 420-E3, QID-S- En = QID-C = Q0 of register value generating circuit 420 - En, is detected when the QID - when C = QID-S-En, is determined ODR -S-En>ODR-A1. Here, the ODR-A1 is the sequence value before the take-out operation (E3) is taken out. If ODR - S - En > ODR - A1, that is, the register value generating circuit 420-En of the operation (En) whose order value is larger than the order value of the fetch operation, the output ODR-N-En=ODR-S- En-1. The example shown in Fig. 29 corresponds to the register value generating circuit 420-E6 of the operation (E6). The register value generating circuit 420-E6 outputs ODR-N-E6=ODR - S - E6-1=4-1=3. In this way, the status data of the work (E6) of the elements of the virtual queue (Q0) is adjusted.

圖34係對應圖33之狀態暫存器250的資料結構圖。FIG. 34 is a data structure diagram corresponding to the state register 250 of FIG.

同圖中,附加底線之部分,為圖30所示之狀態暫存器250之設定內容改變的部位。首先,由於從虛擬佇列(Q0)取出工作(E3),因此在佇列辨別暫存器416_E3新設定「Non」。又,在佇列順序暫存器414與工作優先順序暫存器412分別設定「0」作為重設值。由於取出工作(E3),因此原本放入虛擬佇列(Q0)之工作(E0)、工作(E2)、工作(E5)、工作(E6)之中,順序值較取出工作(E3)大的工作(E6)的ODR減少。In the same figure, the portion to which the bottom line is attached is the portion where the setting contents of the state register 250 shown in Fig. 30 are changed. First, since the operation (E3) is taken out from the virtual queue (Q0), "Non" is newly set in the queue identifying buffer 416_E3. Further, "0" is set as the reset value in the queue sequential register 414 and the work priority register 412, respectively. Due to the take-out work (E3), the work (E0), work (E2), work (E5), and work (E6) that were originally placed in the virtual queue (Q0) is larger than the take-out work (E3). Work (E6) has a reduced ODR.

圖35係顯示取出之處理過程的流程圖。Figure 35 is a flow chart showing the process of taking out.

主電路400,首先,將取出對象之虛擬佇列之QID=Qn輸入至工作選擇電路230(S30)。工作選擇電路230,從虛擬佇列(Qn)選擇取出工作(S32)。主電路400,將取出工作之工作ID=En輸入至佇列控制電路404時,佇列控制電路404,從取出工作(En)之狀態資料清除QID=Qn(S34)。此時,將PR與ODR重設成「0」,但亦可不重設。The main circuit 400 first inputs QID=Qn of the virtual queue of the extracted object to the work selection circuit 230 (S30). The job selection circuit 230 selects the fetch operation from the virtual queue (Qn) (S32). When the main circuit 400 inputs the work ID=En of the fetch operation to the train control circuit 404, the train control circuit 404 clears QID=Qn from the state data of the fetch operation (En) (S34). At this time, the PR and ODR are reset to "0", but they may not be reset.

在虛擬佇列(Qn)亦放入其他工作(S36之是),ODR_S_En>ODR_A1之工作存在時(S38之是),減少該工作的順序值(S40)。此外,從S30至S40所示之處理不一定要序列執行,在時間上並行執行亦可。When the virtual queue (Qn) is also placed in other work (YES in S36), when the work of ODR_S_En>ODR_A1 exists (YES in S38), the order value of the job is reduced (S40). Further, the processing shown from S30 to S40 does not have to be performed in sequence, and may be performed in parallel in time.

在構裝上,亦可從虛擬佇列之途中取出工作。例如,圖33中,產生要從虛擬佇列(Q0)之正中央取出工作(E2)的必要性。工作(E2),係以某旗標A設定為導通為條件而可動作的工作。此旗標A斷開時,產生要從虛擬佇列(Q0)之途中取出工作(E2)的必要性。或者,工作(E2)預先設定之等待時間暫停時,亦產生要從虛擬佇列(Q0)之途中取出工作(E2)的必要性。此時,清除工作(E2)的QID,藉由減少順序值較工作(E2)之順序值「2」大的工作的ODR,亦可從虛擬佇列(Q0)之途中取出工作(E2)。圖33之情形,工作(E6)的ODR成為「2」。由於虛擬佇列係形成為不受硬體的物理性限制,因此亦可從佇列途中進行放入、取出處理。In the construction, the work can also be taken out from the virtual queue. For example, in Fig. 33, the necessity of taking out the work (E2) from the center of the virtual queue (Q0) is generated. The work (E2) is a work that can be operated under the condition that a flag A is set to be on. When this flag A is disconnected, the necessity to take out the work (E2) from the virtual queue (Q0) is generated. Alternatively, when the predetermined waiting time for the work (E2) is suspended, the necessity of taking out the work (E2) from the virtual queue (Q0) is also generated. At this time, the QID of the work (E2) is cleared, and the work (E2) can be taken out from the virtual queue (Q0) by reducing the ODR of the work whose sequence value is larger than the order value "2" of the work (E2). In the case of Fig. 33, the ODR of the work (E6) becomes "2". Since the virtual array is formed so as not to be physically restricted by the hardware, the insertion and removal processing can be performed from the middle of the queue.

根據以上所示虛擬佇列控制,可藉由硬體邏輯實現以FIFO為基本,且實現LIFO動作的特殊佇列。若以軟體構裝雙放入型佇列演算法,則通常為連結串列的構裝。然而,只要是軟體進行的處理,則必定會產生對記憶體之存取與位址之管理所伴隨的酬載。相對於此,改良例1所示之虛擬佇列控制,由於藉由硬體邏輯實現,因此可實現特別簡單且高速的控制。特別是,於時間要求嚴格的RTOS,將雙放入型佇列演算法進行硬體構裝的意義非常大。接著,說明藉由上述虛擬佇列控制方法實現再執行優先型工作排程的形態。According to the virtual queue control shown above, a special queue based on FIFO and implementing LIFO action can be realized by hardware logic. If the double-input type array algorithm is configured in a soft body, it is usually a structure in which a series is connected. However, as long as it is processed by the software, it is necessary to generate a payload accompanying the management of the access and address of the memory. On the other hand, the virtual queue control shown in the first modification is realized by hardware logic, so that particularly simple and high-speed control can be realized. In particular, in a time-critical RTOS, the dual-input-type array algorithm is very important for hardware assembly. Next, a mode in which the priority work scheduling is re-executed by the above-described virtual queue control method will be described.

圖36係顯示再執行優先型工作排程中之虛擬佇列與工作之關係的第1概念圖。Fig. 36 is a first conceptual diagram showing the relationship between the virtual queue and the work in the re-execution of the priority work schedule.

此處,假設對應READT狀態之虛擬佇列(Q0)與對應WAIT旗號狀態之虛擬佇列(Q1)的2個虛擬佇列。虛擬佇列(Q0),係用以放入工作優先順序PR=0之工作的優先佇列(以下,表記成「優先佇列(Q0:0)」)與用以放入工作優先順序PR=1之工作的優先佇列(Q0:1)之2個優先佇列的集合體。虛擬佇列(Q1)亦相同,假設實質上有4個優先佇列。Here, assume that the virtual queue (Q0) corresponding to the READT state and the two virtual queues of the virtual queue (Q1) corresponding to the WAIT flag state. The virtual queue (Q0) is used to put the priority queue of the work priority PR=0 (hereinafter, the table is referred to as "priority queue (Q0:0)") and is used to put the work priority PR= The priority queue of the work of 1 (Q0:1) is a collection of two priority queues. The virtual queue (Q1) is also the same, assuming that there are essentially four priority queues.

同圖中,PR=1之工作(E1)為RUN狀態,同樣PR=1之工作(E0)、工作(E2),在優先佇列(Q0:1)以READY狀態待機。又,PR=0之工作(E3)在優先佇列(Q1:0)以WAIT旗號狀態待機。此處,設工作(E1)為一執行後即集中優先執行的工作。In the same figure, the operation (E1) of PR=1 is the RUN state, and the operation (E0) and the operation (E2) of the same PR=1, and the priority queue (Q0:1) stands by in the READY state. Further, the work of PR=0 (E3) stands by in the priority queue (Q1:0) in the WAIT flag state. Here, it is assumed that the work (E1) is a work that is preferentially executed after execution.

首先,RUN狀態之工作(E1)執行解除旗號系統呼叫,返回READY狀態(S1)。由於工作(E1)為僅快再執行的工作,因此「逆向放入」優先佇列(Q0:1)。另一方面,藉由解除旗號系統呼叫,工作(E3)之WAIT解除條件成立。從優先佇列(Q1:0)取出工作(E3),順向放入優先佇列(Q0:0)(S2)。接著,工作選擇電路230選擇新的RUN-工作。工作選擇電路230,從READY狀態之工作之中,選擇工作優先順序最高的工作(E3)作為取出工作。以此方式,從WAIT狀態移至READY狀態之工作(E3),從優先佇列(Q0:0)被取出而成為新的RUN-工作。根據此種工作排程,工作優先順序高的工作,WAIT解除條件成立時可較快取得執行權。First, the RUN state operation (E1) executes the canceling the flag system call and returns to the READY state (S1). Since the work (E1) is a work that is performed only quickly, the "reverse put" priority queue (Q0: 1). On the other hand, by releasing the flag system call, the WAIT release condition of the work (E3) is established. The work (E3) is taken out from the priority queue (Q1:0), and the priority queue (Q0:0) (S2) is placed in the forward direction. Next, the work selection circuit 230 selects a new RUN-work. The work selection circuit 230 selects the work (E3) having the highest work priority from the work in the READY state as the take-out work. In this way, the operation (E3) of moving from the WAIT state to the READY state is taken out from the priority queue (Q0:0) to become a new RUN-work. According to this work schedule, work with a high priority of work can obtain execution rights faster when the WAIT release condition is established.

圖37係顯示再執行優先型工作排程中之虛擬佇列與工作之關係的第2概念圖。Fig. 37 is a second conceptual diagram showing the relationship between the virtual queue and the work in the re-execution of the priority work schedule.

工作(E3)執行待機旗號系統呼叫時,工作(E3)被順向放入優先佇列(Q1:0)(S4)。接著,工作選擇電路230選擇新的RUN-工作。工作選擇電路230,從READY狀態之工作之中,選擇工作優先順序最高的工作,但此處工作(E0)、工作(E2)、工作(E1)之工作優先順序相同。此時,從優先佇列(Q0:1)取出工作(E1)(S5)。工作(E1)成為新的RUN-工作。根據此種處理方法,雖不致像設定成工作優先順序PR=0,但可對應一執行後即僅可能連續執行的工作(E1)。When the work (E3) executes the standby flag system call, the work (E3) is placed in the priority queue (Q1:0) (S4). Next, the work selection circuit 230 selects a new RUN-work. The work selection circuit 230 selects the work with the highest work priority from the work of the READY state, but the work priorities of the work (E0), the work (E2), and the work (E1) are the same. At this time, the job (E1) is taken out from the priority queue (Q0:1) (S5). Work (E1) becomes the new RUN-work. According to this processing method, although it is not set to the work priority order PR=0, it is possible to correspond to an operation (E1) which is only possible to be continuously executed after execution.

於再執行優先型工作排程,依據執行狀況與工作種類分別使用順向放入與逆向放入,藉此可控制工作的執行順序。因此,可維持基本例所示之工作處理裝置100的高速處理性能的特徵,並可實現更精緻的工作排程。The priority work schedule is executed again, and the forward and reverse insertions are respectively used according to the execution status and the work type, thereby controlling the execution order of the work. Therefore, the characteristics of the high-speed processing performance of the work processing apparatus 100 shown in the basic example can be maintained, and a more elaborate work schedule can be realized.

(改良例2)(Modification 2)

接著,作為改良例2,說明工作處理裝置100之輔助處理的高速化。於改良例2之工作處理裝置100,HWF(硬體功能模組:Hardware Function Module)執行輔助處理。此處所謂HWF,係所謂輔助處理器,具有輔助處理電路的功能。輔助處理係執行為工作的一部分,例如浮點運算、DMA傳輸、加密解密處理、3D影像之座標計算等,有各種處理內容。Next, as an improvement example 2, the speeding up of the auxiliary processing of the work processing apparatus 100 is demonstrated. In the work processing apparatus 100 of the second modification, the HWF (Hardware Function Module) performs auxiliary processing. Here, HWF is a so-called auxiliary processor and has a function of an auxiliary processing circuit. The auxiliary processing is performed as part of the work, such as floating point arithmetic, DMA transfer, encryption and decryption processing, coordinate calculation of 3D video, and the like, and various processing contents are available.

首先,說明軟體OS之一般輔助處理的控制方法。之後,說明改良例2之工作處理裝置100之輔助處理的控制方法。First, a control method of the general auxiliary processing of the software OS will be described. Next, a control method of the auxiliary processing of the work processing apparatus 100 of the second modification will be described.

圖38係顯示藉由軟體OS執行輔助處理時之一般電路構成的圖。Fig. 38 is a view showing a general circuit configuration when the auxiliary processing is executed by the software OS.

CPU84係透過CPU匯流排512與未圖示之記憶體與HWF500連接。又,CPU84連接有中斷控制器502。中斷控制器502,從HWF500等接收各種中斷訊號,將中斷訊號(INTR)傳至CPU84。CPU84接收中斷訊號(INTR)後,適當藉由特殊工作執行對應中斷訊號(INTR)的處理。The CPU 84 is connected to the HWF 500 via a CPU bus 512 and a memory (not shown). Further, the CPU 84 is connected to the interrupt controller 502. The interrupt controller 502 receives various interrupt signals from the HWF 500 or the like, and transmits an interrupt signal (INTR) to the CPU 84. After receiving the interrupt signal (INTR), the CPU 84 appropriately performs the processing of the corresponding interrupt signal (INTR) by special work.

如圖2所示,藉由CPU84執行軟體OS,在其上位階層執行一般工作或特殊工作。As shown in FIG. 2, the CPU 84 executes the software OS, and performs general work or special work at its upper level.

輔助處理可大分為「串列型輔助處理」與「並列型輔助處理」的2種。串列型輔助處理之情形,在執行中無法執行其他工作。並列型輔助處理之情形,即使在執行中亦可並列執行其他工作。The auxiliary processing can be broadly classified into two types of "serial type auxiliary processing" and "parallel type auxiliary processing". In the case of tandem type auxiliary processing, other work cannot be performed during execution. In the case of side-by-side auxiliary processing, other work can be performed side by side even during execution.

圖39係顯示一般串列型輔助處理之控制方法的時序圖。Fig. 39 is a timing chart showing a control method of the general serial type auxiliary processing.

首先,工作A發出「中斷禁止指令」作為用以佔有HWF500的系統呼叫(S100)。此處,成為對象之HWF500,係設為FPU(浮點運算單元)。發出「中斷禁止指令」後,在後述「中斷解除指令」發出之前,停止工作切換。以下,將藉由中斷禁止指令設定成中斷禁止後,至藉由中斷解除指令解除中斷禁止為止的期間稱為「中斷禁止期間」。在中斷禁止期間中即使輸入中斷訊號(INTR),特殊工作亦不會起動。在中斷禁止期間中,工作A獨佔CPU84的使用櫂。是以,工作A以外之工作亦不會存取HWF500、亦即FPU。First, the job A issues an "interrupt prohibition command" as a system call for occupying the HWF 500 (S100). Here, the target HWF 500 is an FPU (Floating Point Arithmetic Unit). When the "interrupt prohibition command" is issued, the operation switching is stopped until the "interrupt release command" is issued later. Hereinafter, a period in which the interrupt prohibition command is set to the interrupt prohibition until the interrupt disable command is released by the interrupt cancel command is referred to as an "interrupt prohibit period". Even if an interrupt signal (INTR) is input during the interrupt disable period, special work will not start. During the interrupt prohibition period, the work A monopolizes the use of the CPU 84. Therefore, work outside of Work A will not access HWF500, or FPU.

軟體OS設定中斷禁止後,工作A返回處理(S102)。工作A對HWF500指示執行輔助處理(S104)。為了抑制輔助處理控制所伴隨的酬載,工作A不透過軟體OS將參數直接寫入至HWF500的內建暫存器,指示執行輔助處理。HWF500,執行工作A所指示的輔助處理。After the software OS setting interrupt is disabled, the job A returns to processing (S102). The job A instructs the HWF 500 to perform the auxiliary processing (S104). In order to suppress the payload accompanying the auxiliary processing control, the work A does not directly write the parameters to the built-in register of the HWF 500 through the software OS, and instructs the execution of the auxiliary processing. The HWF 500 performs the auxiliary processing indicated by the work A.

工作A,一邊定期檢查HWF500的內建暫存器,一邊等待輔助處理結束。檢測出輔助處理結束後(S106),工作A發出中斷解除指令(S108)。軟體OS接收中斷解除指令後,解除中斷禁止(S110)。以此方式結束中斷禁止期間。軟體OS執行工作切換,選擇下一個待執行的工作,例如工作B(S112)。之後,將執行權分配至工作B。工作B亦可藉由同樣方法利用HWF500。Work A, while periodically checking the built-in scratchpad of the HWF500 while waiting for the end of the auxiliary processing. When it is detected that the auxiliary processing is completed (S106), the work A issues an interrupt release command (S108). After receiving the interrupt release command, the software OS releases the interrupt prohibition (S110). In this way, the interrupt prohibition period is ended. The software OS performs a work switching, and selects the next work to be executed, such as job B (S112). After that, the execution right is assigned to work B. Work B can also utilize HWF500 in the same way.

假設,在藉由工作A之委託HWF500執行輔助處理時,另一個工作,例如特殊工作覆寫HWF500的內建暫存器,則工作A無法接收正確的處理結果。因此,有必要嚴格以排他方式控制HWF500的佔有權。然而,各工作即使不透過軟體OS亦可存取HWF500。例如,在S104,工作A不透過軟體OS直接存取HWF500。因此,為了能使軟體OS正確管理HWF500的佔有權,對工作發出「中斷禁止指令」與「中斷解除指令」。軟體OS,藉由中斷禁止指令可預先防止在輔助處理中發生工作切換。以此方式,工作A在使用HWF500時,不會有其他工作獲得CPU84的使用權,干涉HWF500的情形。圖39之情形,從S102之時序至S110之時序為止成為中斷禁止期間。It is assumed that when the auxiliary processing is performed by the commissioning HWF 500 of the work A, another work, such as special work overwriting the built-in register of the HWF 500, the work A cannot receive the correct processing result. Therefore, it is necessary to strictly control the possession of the HWF500 in an exclusive manner. However, the HWF500 can be accessed even if the software does not pass through the software OS. For example, at S104, Work A does not directly access the HWF 500 through the software OS. Therefore, in order to enable the software OS to properly manage the possession of the HWF 500, an "interrupt prohibition command" and an "interrupt release command" are issued for the job. The software OS can prevent the work switching from occurring in the auxiliary processing in advance by the interrupt prohibition instruction. In this way, when the work A uses the HWF 500, there is no other work to obtain the use rights of the CPU 84 and interfere with the HWF 500. In the case of FIG. 39, the interrupt prohibition period is reached from the timing of S102 to the timing of S110.

串列型輔助處理之情形,於中斷禁止期間中,實質上無法執行其他工作。亦即,於串列型輔助處理,在輔助處理中其他工作無法取得CPU84的使用權。因此,浮點運算般較短時間可結束之輔助處理,以串列型輔助處理為佳。In the case of tandem type auxiliary processing, during the interrupt prohibition period, substantially no other work can be performed. That is, in the tandem type auxiliary processing, other work cannot obtain the use right of the CPU 84 in the auxiliary processing. Therefore, the auxiliary processing that can be ended in a short time like floating-point operation is preferable to the tandem type auxiliary processing.

圖40係顯示一般並列型輔助處理之控制方法的時序圖。Fig. 40 is a timing chart showing a control method of the general side-by-side auxiliary processing.

首先,工作A以HWF500的使用權為等待條件,發出待機旗號系統呼叫或待機互斥系統呼叫等之WAIT系系統呼叫(S120)。此處,以待機互斥系統呼叫為對象來說明。此待機互斥系統呼叫,係發出為用以要求佔有HWF500的指令。又,此處成為對象之HWF500,係設為DMAC(DMA控制器)。軟體OS接收待機互斥系統呼叫時,藉由互斥,存取工作A以外之工作的HWF500,亦即,設定禁止存取DMAC(S122)。以此方式,HWF500暫時被工作A佔有。軟體OS選擇下一個待執行的工作。此處,以再次選擇工作A來繼續說明。工作A對HWF500指示執行輔助處理(S124)。此處,工作A亦不透過軟體OS對HWF500直接指示執行輔助處理。HWF500執行指示的輔助處理。First, the job A issues a WAIT system call such as a standby flag system call or a standby exclusive system call with the use right of the HWF 500 as a waiting condition (S120). Here, the standby mutual system call is described as an object. This standby mutual exclusion system call is issued as an instruction to request possession of the HWF500. Further, the HWF 500 to be used here is a DMAC (DMA controller). When the software OS receives the standby mutual system call, the HWF 500 that operates other than the work A is accessed by mutual exclusion, that is, the DMAC is prohibited from being accessed (S122). In this way, the HWF 500 is temporarily occupied by the work A. The software OS selects the next work to be performed. Here, the description is continued by selecting the work A again. The job A instructs the HWF 500 to perform the auxiliary processing (S124). Here, the work A does not directly perform the auxiliary processing on the HWF 500 through the software OS. The HWF 500 performs the auxiliary processing indicated.

工作A以輔助處理結束為待機條件,發出待機事件系統呼叫等之WAIT系系統呼叫(S126)。工作A遷移至WAIT狀態。軟體OS執行工作切換,選擇下一個RUN一工作,例如工作B(S128)。工作B與輔助處理並行執行。然而,由於HWF500被工作A佔有,工作B無法使用HWF500。The job A ends the standby processing as a standby condition, and issues a WAIT system call such as a standby event system call (S126). Work A migrates to the WAIT state. The software OS performs a work switch and selects the next RUN-one work, such as work B (S128). Work B is executed in parallel with the auxiliary processing. However, since the HWF500 is occupied by the work A, the work B cannot use the HWF500.

HWF500,當輔助處理結束後傳送中斷訊號(INTR)(S130)。軟體OS檢測出中斷訊號(INTR)時,起動作為中斷處理程式的特殊工作(S132)。特殊工作,首先,藉由設定事件系統呼叫等之SET系系統呼叫,將輔助處理結束進行事件通知(S134)。以此方式,工作A發出之待機事件系統呼叫的待機條件成立。再次,執行權從軟體OS移至特殊工作(S136)。特殊工作執行剩餘的處理後,遷移至STOP狀態(S138)。軟體OS再次取得執行櫂,使特殊工作結束後,執行工作切換(S140)。此處,再次選擇工作A。The HWF 500 transmits an interrupt signal (INTR) when the auxiliary processing ends (S130). When the software OS detects the interrupt signal (INTR), it starts a special operation as an interrupt handler (S132). In the special work, first, by setting a call to the SET system such as an event system call, the auxiliary processing ends the event notification (S134). In this way, the standby condition of the standby event system call issued by the work A is established. Again, the execution right moves from the software OS to the special job (S136). After the special work performs the remaining processing, it moves to the STOP state (S138). After the software OS obtains the execution again, the work switching is performed after the special work is completed (S140). Here, work A is selected again.

由於工作A委託之輔助處理已結束,工作A從HWF500的內建暫存器讀取處理結果(S142)。或,工作A讀取HWF500寫入至記憶體之既定區域之處理結果亦可。工作A發出解除互斥系統呼叫(S144)。軟體OS接收解除互斥系統呼叫後,解除工作A對HWF500的佔有權(S146)。軟體OS執行工作切換,選擇下一個待執行的工作,例如工作C(S148)。以後,執行櫂分配至工作C。由於HWF500的佔有權已解除,工作C亦可藉由同樣方法利用HWF500。Since the auxiliary processing of the work A delegation has ended, the work A reads the processing result from the built-in register of the HWF 500 (S142). Or, the work A reads the processing result of the HWF 500 writing to the predetermined area of the memory. Work A issues a disengagement system call (S144). After receiving the call to release the mutual exclusion system, the software OS releases the possession of the work A to the HWF 500 (S146). The software OS performs a work switching and selects the next work to be performed, such as job C (S148). Later, the execution is assigned to work C. Since the possession of the HWF500 has been removed, Work C can also utilize the HWF500 in the same way.

即使於並列型,一般工作直接存取HWF500之點亦與串列型相同。於並列型輔助處理,雖輔助處理中其他工作無法使用HWF500,但其他工作取得CPU84之使用櫂本身是可能的。以此方式,工作A在使用HWF500時,其他工作不會干涉HWF500。Even in the side-by-side type, the point at which the general work directly accesses the HWF 500 is the same as that of the tandem type. In the parallel type auxiliary processing, although the HWF500 cannot be used for other work in the auxiliary processing, it is possible to obtain the use of the CPU 84 by other work itself. In this way, when Work A uses the HWF500, other work does not interfere with the HWF500.

於並列型輔助處理之執行中,如S128所示可並列執行其他工作。然而,由於S126或S134的系統呼叫、特殊工作之起動等,較串列型輔助處理的酬載更大。因此,DMA傳輸般較花時間之輔助處理,以並列型輔助處理為佳。In the execution of the parallel type auxiliary processing, other work can be performed in parallel as shown in S128. However, due to the system call of S126 or S134, the start of special work, etc., the payload of the tandem type auxiliary processing is larger. Therefore, DMA transfer is more time-consuming auxiliary processing, and parallel-type auxiliary processing is preferred.

圖39所示之串列型輔助處理之情形,工作必須合計2次發出系統呼叫。又,輔助處理開始後,亦必須定期檢查HWF500,偵測輔助處理是否結束。實際上,輔助處理結束之時序與工作偵測到輔助處理結束之時序易產生「偏差」,其結果,處理效率降低。In the case of the tandem type auxiliary processing shown in Fig. 39, it is necessary to make a system call 2 times in total. Also, after the auxiliary processing starts, the HWF 500 must also be checked periodically to detect whether the auxiliary processing is finished. Actually, the timing at which the auxiliary processing ends and the timing at which the work detection is completed are liable to cause "deviation", and as a result, the processing efficiency is lowered.

圖40所示之並列型輔助處理之情形,工作A必須合計4次發出系統呼叫。再者,輔助處理結束時,為了對工作A通知輔助處理結束,必須起動特殊工作。In the case of the parallel type auxiliary processing shown in Fig. 40, the work A must issue a system call a total of four times. Further, when the auxiliary processing ends, in order to notify the work A that the auxiliary processing is completed, it is necessary to start a special work.

一般而言,1次系統呼叫花費500~1000次程度之CPU時脈。輔助處理係執行頻率高的處理,對時間要件嚴格之RTOS而言,能將此種酬載抑制到何種程度為重要的設計課題。In general, a system call takes 500 to 1000 CPU cycles per call. Auxiliary processing is a high-frequency processing, and it is an important design issue to be able to suppress such a payload to an RTOS with strict time requirements.

圖41係顯示藉由基本例之工作處理裝置100實現圖38至圖40所示之輔助處理控制時之電路構成的圖。Fig. 41 is a view showing the circuit configuration when the auxiliary processing control shown in Figs. 38 to 40 is realized by the work processing apparatus 100 of the basic example.

如基本例所說明,工作處理裝置100主要包含CPU150、儲存電路120、及工作控制電路200。圖38所示之一般電路構成的情形,CPU84執行軟體OS與工作的兩者。相對於此,於工作處理裝置100,CPU150執行工作,OS之功能係藉由儲存電路120及工作控制電路200實現。藉由使OS之功能自CPU150外部化,整體之處理效率大幅提升之點如基本例所說明。圖41中,CPU150亦透過CPU匯流排512與HWF500連接。As explained in the basic example, the work processing apparatus 100 mainly includes a CPU 150, a storage circuit 120, and a work control circuit 200. In the case of the general circuit configuration shown in Fig. 38, the CPU 84 executes both the software OS and the operation. On the other hand, in the work processing apparatus 100, the CPU 150 performs an operation, and the function of the OS is realized by the storage circuit 120 and the operation control circuit 200. By externalizing the functions of the OS from the CPU 150, the overall processing efficiency is greatly improved as explained in the basic example. In FIG. 41, the CPU 150 is also connected to the HWF 500 through the CPU bus 512.

工作處理裝置100之硬體OS之情形,系統呼叫執行,特別是工作切換與軟體OS相較大幅地高速化。工作處理裝置100為了執行1次系統呼叫,CPU時脈僅需12時脈程度。因此,即使以圖41之電路構成,藉由工作處理裝置100執行圖39及圖40所示之輔助處理控制,亦可大幅抑制輔助處理所伴隨的酬載。In the case of the hardware OS of the work processing apparatus 100, the system call execution, particularly the work switching, is speeded up by the software OS. In order to perform a system call, the work processing device 100 requires only 12 clock cycles. Therefore, even with the circuit configuration of Fig. 41, by the work processing apparatus 100 executing the auxiliary processing control shown in Figs. 39 and 40, the payload associated with the auxiliary processing can be greatly suppressed.

於改良例2,藉由重新檢視工作處理裝置100與HWF500,特別是CPU150與HWF500的關係,能使輔助處理進一步高速化。In the second modification, by re-examining the relationship between the work processing apparatus 100 and the HWF 500, particularly the CPU 150 and the HWF 500, the auxiliary processing can be further speeded up.

圖42係顯示於改良例2工作處理裝置100與HWF500之關係的電路構成圖。Fig. 42 is a circuit configuration diagram showing the relationship between the work processing apparatus 100 and the HWF 500 of the second modification.

同圖中,複數個HWF500(HWF500_0、…、HWF 500_k:k為任意自然數),不與CPU150連接而是與工作控制電路200連接。各HWF500係分別與不同輔助處理對應設計的專用電路。例如,HWF500_0為FPU、HWF500_1為DMAC亦可。各HWF500,係藉由0~k之範圍之HWFID一意辨識。In the same figure, a plurality of HWFs 500 (HWF500_0, ..., HWF 500_k: k are arbitrary natural numbers) are connected to the work control circuit 200 without being connected to the CPU 150. Each HWF500 is a dedicated circuit designed corresponding to different auxiliary processes. For example, HWF500_0 is FPU, and HWF500_1 is DMAC. Each HWF 500 is intentionally identified by a HWFID ranging from 0 to k.

以CPU150執行之工作,透過工作控制電路200,使各HWF500執行輔助處理。工作無法直接存取HWF500的內建暫存器。於改良例2,工作控制電路200一元管理各HWF500。With the work performed by the CPU 150, the HWF 500 is caused to perform auxiliary processing through the work control circuit 200. Work can not directly access the HWF500's built-in scratchpad. In the second modification, the work control circuit 200 manages each of the HWFs 500 in unary.

圖43係顯示改良例2之狀態記憶部220與工作切換電路210之關係的電路圖。Fig. 43 is a circuit diagram showing the relationship between the state memory unit 220 and the operation switching circuit 210 of the second modification.

在改良例2之工作選擇電路230追加HWF待機選擇電路510。又,在工作切換電路210新連接有複數個HWF500。The HWF standby selection circuit 510 is added to the operation selection circuit 230 of the second modification. Further, a plurality of HWFs 500 are newly connected to the work switching circuit 210.

工作控制電路200之基本構成,與圖10所示之基本例之電路構成大致相同。各工作所對應之狀態暫存器250,除了工作ID暫存器254、工作優先順序暫存器256等之外,追加HWFID暫存器504、佇列順序暫存器506、及佇列辨別暫存器508。The basic configuration of the operation control circuit 200 is substantially the same as that of the basic example shown in FIG. In addition to the work ID register 254, the work priority register 256, and the like, the state register 250 corresponding to each work adds the HWFID register 504, the queue sequential register 506, and the queue identification. 508.

(A)HWFID暫存器504:當某個工作指示執行輔助處理時,設定該輔助處理之執行主體之HWF500的HWFID。HWFID係作為HID_S訊號隨時輸出。於改良例2,在HWFID暫存器504,僅並列型輔助處理時寫入HWFID。(A) HWFID register 504: When a certain work instruction performs auxiliary processing, the HWFID of the HWF 500 of the execution subject of the auxiliary processing is set. The HWFID is output as a HID_S signal at any time. In the second modification, in the HWFID register 504, the HWFID is written only in the parallel type auxiliary processing.

(B)佇列順序暫存器506:儲存表示對虛擬佇列之工作之放入順序的「順序值(ODR)」。順序值愈大,表示放入至虛擬佇列愈深。順序值,係作為ODR_S訊號而隨時輸出。改良例2之順序值ODR,與改良例1說明之「順序值ODR」為同一概念。(B) Array Sequence Register 506: Stores the "Order Value (ODR)" indicating the order in which the work of the virtual queue is placed. The larger the order value, the deeper it is placed into the virtual queue. The sequence value is output as an ODR_S signal at any time. The order value ODR of the second modification is the same as the "order value ODR" described in the first modification.

(C)佇列辨別暫存器508:儲存用以辨別虛擬佇列之「佇列ID(QID)」。作為QID_S訊號而隨時輸出。佇列ID,與改良例1說明之「佇列ID(QID)」為同一概念。(C) Alignment Discriminator 508: Stores the "Queue ID (QID)" for identifying the virtual queue. It is output as a QID_S signal at any time. The queue ID is the same as the "queue ID (QID)" described in the first modification.

虛擬佇列,與改良例1所示之虛擬佇列相同,係工作狀態所對應的虛擬佇列。以此方式,佇列ID與工作狀態之對應無須固定化為硬體構裝。工作選擇電路230藉由參照各佇列辨別暫存器508,可判別各工作的工作狀態。The virtual queue is the same as the virtual queue shown in the modified example 1, and is a virtual queue corresponding to the working state. In this way, the correspondence between the queue ID and the working state does not need to be fixed to the hardware configuration. The work selection circuit 230 can determine the operating state of each job by referring to each of the queues identifying the register 508.

工作選擇電路230,根據從狀態暫存器250輸出之狀態資料,選擇待狀態遷移的工作。工作切換電路210將HWFID輸入至HWF待機選擇電路510後,HWF待機選擇電路510將該HWFID對應之HWFID暫存器504所設定之工作的工作ID輸出。亦即,將「等待指定之HWF500之處理結束之工作」通知至工作切換電路210。若指定之HWF500未處理中,亦即,任一工作皆未委託處理,則HWF待機選擇電路510輸出「-1」等的既定值。The job selection circuit 230 selects the operation to be migrated based on the state data output from the state register 250. After the work switching circuit 210 inputs the HWFID to the HWF standby selection circuit 510, the HWF standby selection circuit 510 outputs the operation ID of the operation set by the HWFID register 504 corresponding to the HWFID. That is, the "work waiting for the processing of the designated HWF 500 to end" is notified to the work switching circuit 210. If the designated HWF 500 is not being processed, that is, if no processing is requested for any of the jobs, the HWF standby selection circuit 510 outputs a predetermined value such as "-1".

各HWF500係與工作切換電路210直接連接。各HWF500,係藉由工作切換電路210與以下所示6種訊號線連接。以下,設i為0~k的任意數。Each HWF 500 is directly connected to the work switching circuit 210. Each of the HWFs 500 is connected to the six types of signal lines shown below by the work switching circuit 210. Hereinafter, i is an arbitrary number from 0 to k.

a.HFi_REQ:工作切換電路210,對HWF500_i指示執行輔助處理時,傳送HFi_REQ。a. HFi_REQ: The work switching circuit 210 transmits HFi_REQ when the HWF 500_i is instructed to perform auxiliary processing.

b.HFi_ARG[m-1:0]:傳送輔助處理的參數。根據輔助處理的內容有各種HFi_ARG[m-1:0]的尺寸,亦有各種參數的個數。當傳送HFi_REQ時,將HFi_ARG[m-1:0]寫入至HWF500_i的內建暫存器。b.HFi_ARG[m-1:0]: Transfer the parameters of the auxiliary processing. There are various HFi_ARG[m-1:0] sizes depending on the content of the auxiliary processing, and there are also various parameters. When HFi_REQ is transmitted, HFi_ARG[m-1:0] is written to the built-in register of HWF500_i.

c.HFi_RQACK:傳送HFi_REQ,寫入HFi_ARG[m-1:0]後,HWF500_i開始輔助處理。輔助處理開始時,HWF500_i傳送HFi_RQACK。藉由HFi_RQACK,工作切換電路210認知開始輔助處理。c. HFi_RQACK: After transmitting HFi_REQ and writing HFi_ARG[m-1:0], HWF500_i starts auxiliary processing. When the auxiliary processing starts, the HWF500_i transmits HFi_RQACK. With HFi_RQACK, the work switching circuit 210 recognizes that the auxiliary processing is started.

d.HFi_CMPLT:輔助處理結束後,HWF500_i除了將輔助處理的結果寫入至內建暫存器之外,傳送HFi_CMPLT。藉由HFi_CMPLT,工作切換電路210認知結束輔助處理。d.HFi_CMPLT: After the auxiliary processing ends, the HWF500_i transfers the HFi_CMPLT in addition to writing the result of the auxiliary processing to the built-in scratchpad. The work switching circuit 210 recognizes the end of the auxiliary processing by HFi_CMPLT.

e.HFi_RSLT[m-1:0]:表示輔助處理的結果的回傳值。根據輔助處理的內容有各種HFi_RSLT[m-1:0]的尺寸,亦有各種回傳值的個數。對HWF500_i的內建暫存器傳送寫入的回傳值。工作切換電路210,在傳送HFi_CMPLT後,取得HFi_RSLT[m-1:0]的回傳值。e.HFi_RSLT[m-1:0]: indicates the return value of the result of the auxiliary processing. There are various HFi_RSLT[m-1:0] sizes depending on the content of the auxiliary processing, and there are also various numbers of return values. The returned value of the write to the HWF500_i's built-in scratchpad. The work switching circuit 210 obtains the return value of HFi_RSLT[m-1:0] after transmitting HFi_CMPLT.

f.HFi_CMPACK:工作切換電路210,在取得回傳值後,傳送HFi_CMPACK。藉由HFi_CMPACK,HWF500_i認知正常取得回傳值。f. HFi_CMPACK: The work switching circuit 210 transmits HFi_CMPACK after obtaining the return value. With HFi_CMPACK, HWF500_i recognizes that the return value is normally obtained.

圖44係顯示改良例2之串列型輔助處理之控制方法的時序圖。Fig. 44 is a timing chart showing a control method of the tandem type auxiliary processing in the second modification.

改良例2之工作處理裝置100,除了基本例說明之9個系統呼叫之外,追加「HWF呼叫」。「HWF呼叫」,係工作指示執行輔助處理的系統呼叫。In the work processing apparatus 100 of the second modification, a "HWF call" is added in addition to the nine system calls described in the basic example. "HWF Call" is a system call that indicates the execution of auxiliary processing.

首先,工作A以成為對象之輔助處理之種類為參數發出HWF呼叫(S100)。例如,藉由浮點運算指令、DMA傳輸指令、加密處理指令等指定輔助處理之種類。工作切換電路210,根據指定為參數之輔助處理,選擇成為對象之HWF500,特定該HWFID。此外,將HWFID本身作為參數發出HWF呼叫亦可。此處,以特定HWFID=i來說明。作為HWF呼叫之參數,指定輔助處理之引數亦可。此種參數,係寫入至CPU150之既定汎用暫存器158。工作切換電路210,接收HWF呼叫時,從汎用暫存器158讀取該等參數。First, the job A issues an HWF call with the type of the auxiliary processing to be the object (S100). For example, the type of the auxiliary processing is specified by a floating point arithmetic instruction, a DMA transfer instruction, an encryption processing instruction, or the like. The work switching circuit 210 selects the target HWF 500 based on the auxiliary processing designated as the parameter, and specifies the HWFID. In addition, it is also possible to issue a HWF call by using the HWFID itself as a parameter. Here, the description is made with a specific HWFID=i. As a parameter of the HWF call, the argument of the auxiliary processing may also be specified. Such parameters are written to the predetermined general purpose register 158 of the CPU 150. The work switching circuit 210 reads the parameters from the general purpose register 158 when receiving the HWF call.

工作切換電路210,對HWF500_i指示執行輔助處理(S102)。工作切換電路210,藉由HC訊號使CPU150停止。因此,工作A在RUN狀態下被迫停止。The work switching circuit 210 instructs the HWF 500_i to execute the auxiliary processing (S102). The work switching circuit 210 stops the CPU 150 by the HC signal. Therefore, the work A is forced to stop in the RUN state.

於S102,並非如圖39般工作A存取HWF500,而是工作切換電路210對HWF500指示執行輔助處理。具體而言,在HFi_ARG[m-1:0]設定引數且傳送HFi_REQ。HWF500_i,開始輔助處理,傳送HFi_RQACK。由於CPU150已停止,因此輔助處理中工作A不會被執行。當然,包含特殊工作之其他工作亦不會被執行。In S102, instead of operating A to access the HWF 500 as shown in FIG. 39, the work switching circuit 210 instructs the HWF 500 to perform auxiliary processing. Specifically, the argument is set in HFi_ARG[m-1:0] and HFi_REQ is transmitted. HWF500_i, start auxiliary processing, and transmit HFi_RQACK. Since the CPU 150 has stopped, the work A in the auxiliary processing is not executed. Of course, other work that includes special work will not be performed.

輔助處理結束後,HWF500_i對HFi_RSLT[m-1:0]輸出回傳值,傳送HFi_CMPLT。工作切換電路210,接收回傳值,傳送HFi_CMPACK(S104)。工作切換電路210,將回傳值記錄在處理暫存器92。工作切換電路210,停止傳送停止要求訊號(HR),再次開始工作A的執行(S106)。After the auxiliary processing ends, the HWF500_i outputs a return value to HFi_RSLT[m-1:0] and transmits HFi_CMPLT. The work switching circuit 210 receives the return value and transmits HFi_CMPACK (S104). The work switching circuit 210 records the return value in the processing register 92. The work switching circuit 210 stops the transmission stop request signal (HR) and restarts the execution of the work A (S106).

改良例2之串列型輔助處理之情形,僅需1次系統呼叫。又,由於在輔助處理執行中使CPU150停止,因此可抑制耗電。再者,委託輔助處理之工作A,不需對HWF500詢問輔助處理之結束時序,因此輔助處理結束之時序與工作處理裝置100偵測到輔助處理結束之時序幾乎不產生偏差。In the case of the tandem type auxiliary processing of the second modification, only one system call is required. Further, since the CPU 150 is stopped during the execution of the auxiliary processing, power consumption can be suppressed. Further, the work A for requesting the auxiliary processing does not need to inquire the HWF 500 about the end timing of the auxiliary processing, and therefore the timing at which the auxiliary processing ends is almost not deviated from the timing at which the work processing apparatus 100 detects the end of the auxiliary processing.

於改良例2,工作無法直接存取HWF500,而是工作切換電路210存取HWF500。因此,藉由中斷禁止指令或中斷解除指令,工作不需要用以對OS控制中斷禁止期間的處理。工作處理裝置100,接收HWF呼叫後,僅藉由停止要求訊號(HR)控制CPU時脈之停止、再次開始。工作處理裝置100,將輔助處理之結果作為回傳值寫入至處理暫存器92,因此委託輔助處理之工作A,在執行再次開始時已成為取得輔助處理之結果的狀態。由於工作A不需對HWF500或工作控制電路200詢問輔助處理之結果,因此不僅處理效率提升,工作A之程式碼亦可簡化。In the second modification, the work cannot directly access the HWF 500, but the work switching circuit 210 accesses the HWF 500. Therefore, by interrupting the disable instruction or the interrupt release instruction, the operation does not need to be used to control the interrupt during the OS control interrupt. After receiving the HWF call, the work processing device 100 controls the CPU clock to stop and restarts only by the stop request signal (HR). The work processing device 100 writes the result of the auxiliary processing to the processing register 92 as a return value. Therefore, the work A for requesting the auxiliary processing is in a state in which the result of the auxiliary processing is obtained when the execution is restarted. Since the work A does not need to inquire about the result of the auxiliary processing of the HWF 500 or the work control circuit 200, not only the processing efficiency is improved, but also the code of the work A can be simplified.

圖45係顯示改良例2之並列型輔助處理之控制方法的時序圖。Fig. 45 is a timing chart showing a control method of the parallel type auxiliary processing in the second modification.

此處,設成為對象之HWF500為FPU(浮點運算單元)。又,設相當於FPU之HWF500的HWFID為「i」。首先,工作A以FPU之使用權為等待條件,發出待機互斥系統呼叫(S120)。藉由互斥與旗號管理各HWF的佔有權。不需要互斥等之HWF的排他控制。例如,只要是僅使用特定工作之HWF,則不需要排他控制。Here, it is assumed that the target HWF 500 is an FPU (Floating Point Arithmetic Unit). Further, the HWFID of the HWF 500 corresponding to the FPU is "i". First, the job A issues a standby mutual exclusion system call with the use right of the FPU as a waiting condition (S120). The ownership of each HWF is managed by mutual exclusion and slogan. There is no need for exclusive control of HWF such as mutual exclusion. For example, as long as it is a HWF that uses only a specific job, no exclusive control is required.

若未設定成HWF500_i由互斥佔有中,則工作處理裝置100藉由互斥設定工作A以外之工作禁止存取HWF500_i(S122)。If it is not set that the HWF 500_i is occupied by the exclusive exclusion, the work processing apparatus 100 prohibits access to the HWF 500_i by the work other than the exclusive setting work A (S122).

以此方式,HWF500_i暫時被工作A佔有。接著,工作A發出HWF呼叫(S124)。工作A從RUN狀態遷移至WAIT狀態。WAIT解除的條件,係HWF500_i之輔助處理結束。工作切換電路210,接收HWF呼叫時,對工作A之HWFID暫存器504設定HWFID=i。In this way, the HWF500_i is temporarily occupied by the work A. Next, the job A issues a HWF call (S124). Work A migrates from the RUN state to the WAIT state. The condition for the WAIT release is the end of the auxiliary processing of the HWF500_i. The work switching circuit 210 sets HWFID=i to the HWFID register 504 of the work A when receiving the HWF call.

於改良例2,並非如圖40般執行櫂返回工作A,工作切換電路210本身對HWF500指示開始輔助處理(S126)。HWF500_i開始輔助處理。工作切換電路210選擇下一個RUN-工作,例如工作B(S128)。工作B與輔助處理並列執行。然而,工作B無法使用HWF500_i。其原因在於,工作A藉由互斥確保HWF500_i的佔有權。In the second modification, the work return circuit A is not executed as shown in FIG. 40, and the work switching circuit 210 itself instructs the HWF 500 to start the auxiliary process (S126). HWF500_i starts the auxiliary processing. The work switching circuit 210 selects the next RUN-work, such as work B (S128). Work B is executed side by side with auxiliary processing. However, Work B cannot use HWF500_i. The reason is that Work A ensures the possession of HWF500_i by mutual exclusion.

輔助處理結束後,HWF500_i對HFi_RSLT[m-1:0]輸出回傳值,傳送HFi_CMPLT。工作切換電路210,接收回傳值,傳送HFi_CMPACK(S130)。工作B從RUN狀態遷移至READY狀態。具體而言,工作處理裝置100傳送停止要求訊號(HR)以要求停止CPU時脈,等待停止結束訊號(HC)的傳送,將工作B之處理資料保留至保留暫存器。工作B被逆向放入至與READY狀態對應的虛擬佇列。工作切換電路210,將HWFID=i輸入至HWF待機選擇電路510,取得對HWF500_i委託輔助處理之工作A的工作ID。接著,將表示輔助處理之結果的回傳值記錄在與工作A對應的保留暫存器,將工作A設定在READY狀態。此處,如改良例1所示,將工作A逆向放入至與READY狀態對應的虛擬佇列亦可。工作切換電路210,選擇下一個待執行的工作,例如工作A(S132)。以後,將執行權分配至工作A。輔助處理結束時,一定選擇委託該輔助處理之工作A亦可。根據此種工作切換規則,可提升委託輔助處理之工作的效率。工作A,藉由解除互斥系統呼叫,解除HWF500_i的佔有權(S134)。工作處理裝置100,再次執行工作切換,選擇下一個待執行的工作,例如在S128~S130執行的工作B(S136)。以後,將執行櫂分配至工作B。由於解除HWF500_i的佔有權,工作B亦可藉由同樣方法利用HWF500_i。After the auxiliary processing ends, the HWF500_i outputs a return value to HFi_RSLT[m-1:0] and transmits HFi_CMPLT. The work switching circuit 210 receives the return value and transmits HFi_CMPACK (S130). Work B transitions from the RUN state to the READY state. Specifically, the work processing apparatus 100 transmits a stop request signal (HR) to request to stop the CPU clock, waits for the stop end signal (HC) transmission, and retains the processing data of the work B to the reserved register. Work B is reversely placed into a virtual queue corresponding to the READY state. The work switching circuit 210 inputs HWFID=i to the HWF standby selection circuit 510, and acquires the work ID of the job A that has requested the auxiliary processing for the HWF 500_i. Next, the return value indicating the result of the auxiliary processing is recorded in the reserved register corresponding to the work A, and the operation A is set in the READY state. Here, as shown in the first modification, the operation A may be reversely placed in the virtual queue corresponding to the READY state. The work switching circuit 210 selects the next work to be performed, such as job A (S132). Later, the execution rights are assigned to Work A. When the auxiliary processing ends, the work A that has requested the auxiliary processing must be selected. According to this work switching rule, the efficiency of the work of entrusted auxiliary processing can be improved. The work A releases the possession of the HWF 500_i by releasing the mutual exclusion system call (S134). The work processing apparatus 100 performs the work switching again, and selects the next work to be executed, for example, the work B performed at S128 to S130 (S136). In the future, the execution will be assigned to work B. By releasing the possession of HWF500_i, Work B can also utilize HWF500_i in the same way.

於圖40所示之並列型輔助處理,發出合計4次的系統呼叫。相對於此,改良例2之並列型輔助處理之系統呼叫次數為「待機互斥系統呼叫」、「解除互斥系統呼叫」、「HWF呼叫」的3次。因此,根據改良例2,可1次控制系統呼叫所伴隨的酬載。又,不需執行特殊工作。藉由將回傳值寫入至保留暫存器,工作A不需對HWF500或工作控制電路200詢問輔助處理的結果。In the side-by-side auxiliary processing shown in Fig. 40, a total of 4 system calls are issued. On the other hand, the system call count of the parallel type auxiliary processing in the second modification is three times of "standby exclusive system call", "disarming system call", and "HWF call". Therefore, according to the modified example 2, the payload accompanying the system call can be controlled once. Also, no special work is required. By writing the return value to the reserved register, the job A does not need to interrogate the HWF 500 or the work control circuit 200 for the result of the auxiliary processing.

以往,為了高速執行包含OS之軟體,嘗試各種方法。上述嘗試大多為CPU時脈數的增加、記憶體容量或暫存器容量的增加、或複數個CPU之平行處理、再者為網路分散處理等大規模化、複雜化者。In the past, various methods have been tried in order to execute a software including an OS at high speed. Most of the above attempts are for the increase in the number of CPU clocks, the increase in the memory capacity or the scratchpad capacity, or the parallel processing of a plurality of CPUs, and the large-scale and complicated processing such as network distributed processing.

相對於此,本實施例所示之工作處理裝置100之情形,藉由在既有之CPU150外追加儲存電路120或工作控制電路200,大幅提升處理效率。軟體OS之情形,為了實現原本欲執行之工作切換等的處理,必須執行TCB或工作準備串列之管理等附加處理。相對於此,工作處理裝置100,由於藉由硬體邏輯實現工作切換、工作之狀態管理、中斷處理,因此可解除此種軟體特有的酬載。因此,可構成抑制耗電與成本增加、且實現高速化的理想系統。On the other hand, in the case of the work processing apparatus 100 shown in this embodiment, by adding the storage circuit 120 or the work control circuit 200 to the existing CPU 150, the processing efficiency is greatly improved. In the case of the software OS, in order to perform processing such as job switching that is to be performed, it is necessary to perform additional processing such as management of the TCB or the work preparation serial. On the other hand, in the work processing apparatus 100, since the work switching, the state management of the operation, and the interrupt processing are realized by the hardware logic, the payload unique to the software can be released. Therefore, it is possible to configure an ideal system that suppresses power consumption and cost increase and achieves high speed.

再者,根據改良例2所示之輔助處理控制,可大幅抑制輔助處理所伴隨的酬載。以往,為了高速執行DMA傳輸等的輔助處理,大多提供不透過軟體OS,直接操作HWF500的內建暫存器的程式。然而,此種程式產生缺陷時,系統整體的動作會變不穩定。Further, according to the auxiliary processing control shown in the second modification, the payload associated with the auxiliary processing can be greatly suppressed. Conventionally, in order to perform auxiliary processing such as DMA transfer at a high speed, a program that directly operates the built-in register of the HWF 500 without the software OS is provided. However, when such a program generates a defect, the overall operation of the system becomes unstable.

於改良例2之工作處理裝置100,工作直接操作HWF500的動作成為物理上不可能的構成。藉由工作處理裝置100本身的高速處理性能與系統呼叫次數的減少等,即使是工作對工作處理裝置100委託輔助處理的構成,亦可實現高速的輔助處理。根據改良例2之工作處理裝置100,能使輔助處理控制具有安全性且高速化。In the work processing apparatus 100 of the second modification, the operation of directly operating the HWF 500 becomes a physically impossible configuration. By the high-speed processing performance of the work processing apparatus 100 itself and the reduction in the number of system calls, the high-speed auxiliary processing can be realized even if the work is configured to request the auxiliary processing by the work processing apparatus 100. According to the work processing apparatus 100 of the second modification, the auxiliary processing control can be made safe and high speed.

以上,根據實施例說明本發明。實施形態係例示,此等各構成要素與各處理步驟的組合能有各種變形例,且此等變形例亦在本發明的範圍內,此為本發明所屬技術領域中具有通常知識者應當理解之事。Hereinabove, the present invention has been described based on the embodiments. The embodiment is exemplified, and various modifications can be made to the combination of these components and the respective processing steps, and such modifications are also within the scope of the present invention, which should be understood by those having ordinary knowledge in the technical field to which the present invention pertains. thing.

請求項記載之各構成元件應達成的功能,係藉由本實施例所示之各功能方塊的單體、或此等的連動而實現,此亦為本發明所屬技術領域中具有通常知識者應當理解之事。The functions to be achieved by the respective constituent elements described in the claims are achieved by the single elements of the functional blocks shown in the present embodiment, or the linkages thereof, which are also understood by those having ordinary knowledge in the technical field to which the present invention pertains. Things.

此外,以圖12、圖14、圖28、圖32說明各種判定電路。此等判定電路,係藉由比較電路群選擇成為比較、選擇對象的工作。Further, various determination circuits will be described with reference to FIGS. 12, 14, 28, and 32. These determination circuits select the operation to be compared and selected by the comparison circuit group.

例如,圖12之執行選擇電路232,係用以選擇RUN-工作的電路,但能成為RUN-工作者為READY-工作。因此,圖12之判定電路296,以為READY-工作為條件,輸出CID訊號「1」。執行選擇電路232的比較電路群,僅以成為CID訊號「1」的工作、亦即READY狀態的工作為對象,根據工作優先順序PR或READY經過時間TIM,選擇下一個RUN-工作。For example, the execution selection circuit 232 of FIG. 12 is used to select a RUN-operating circuit, but can be a RUN-worker for READY-operation. Therefore, the decision circuit 296 of Fig. 12 outputs the CID signal "1" on the condition that the READY-operation is performed. The comparison circuit group that executes the selection circuit 232 selects the next RUN-operation based on the work priority order PR or the READY elapsed time TIM only for the operation of the CID signal "1", that is, the READY state operation.

圖14之旗號選擇電路234,係於旗號解除時,用以選擇待解除旗號等待之工作的電路。解除旗號等待之工作,係以解除旗號為待機旗號而處於WAIT狀態的工作。因此,圖14之判定電路306,以為解除旗號為待機旗號之WAIT-工作為條件,輸出CID訊號「1」。旗號選擇電路234的比較電路群,僅以成為CID訊號「1」的工作、亦即「以解除旗號為待機旗號之WAIT-工作」為對象,根據工作優先順序PR或WAIT經過時間TIM,選擇待解除旗號等待之工作。The flag selection circuit 234 of FIG. 14 is used to select a circuit to be cancelled when the flag is released. To cancel the work of waiting for the flag, it is to work in the WAIT state to release the flag as the standby flag. Therefore, the decision circuit 306 of Fig. 14 outputs the CID signal "1" on the condition that the WAIT-operation in which the flag is the standby flag is released. The comparison circuit group of the flag selection circuit 234 is selected only for the operation of the CID signal "1", that is, "the WAIT-operation with the flag is the standby flag", and the time preference TIM is selected according to the work priority order PR or WAIT. Unlock the work waiting for the flag.

若變更判定電路的邏輯,則執行選擇電路232與旗號選擇電路234可共有比較電路群。對互斥或事件而言亦相同。對圖28之最大值選擇電路406、圖32之工作選擇電路230而言亦相同。以此方式,若追加、變更判定電路的邏輯,則以共有比較電路群之形式,可構裝各種選擇邏輯。以下,舉2例說明。When the logic of the decision circuit is changed, the execution selection circuit 232 and the flag selection circuit 234 can share the comparison circuit group. The same is true for mutual exclusion or events. The same applies to the maximum value selection circuit 406 of FIG. 28 and the operation selection circuit 230 of FIG. In this way, if the logic of the determination circuit is added or changed, various selection logics can be constructed in the form of a shared comparison circuit group. Hereinafter, two examples will be described.

1.旋轉系統呼叫1. Rotate the system call

此系統呼叫,係用以變更與READY狀態對應之虛擬佇列的工作群、亦即READY-工作的順序值(ODR)的系統呼叫。例如,如圖29所示,在與READY狀態對應之虛擬佇列(Q0),以工作(E6)、工作(E3)、工作(E2)、工作(E0)、工作(E5)之順序放入5個工作。此處,RUN-工作指定工作優先順序PR=1發出旋轉系統呼叫。This system call is used to change the system call of the work queue of the virtual queue corresponding to the READY state, that is, the READY-Work Order Value (ODR). For example, as shown in FIG. 29, the virtual queue (Q0) corresponding to the READY state is placed in the order of work (E6), work (E3), work (E2), work (E0), and work (E5). 5 jobs. Here, the RUN-work specifies the work priority PR = 1 to issue a rotating system call.

接著,與PR=1對應之優先佇列(Q0:1)之前端的工作(E6)暫時被取出,順向放入至工作(E5)之後。亦即,工作(E6)的順序值(ODR)成為「0」,其他工作之順序值亦配合調整。Next, the operation (E6) at the front end of the priority queue (Q0:1) corresponding to PR=1 is temporarily taken out, and is placed in the forward direction after the operation (E5). That is, the order value (ODR) of the work (E6) becomes "0", and the order values of other jobs are also adjusted.

旋轉系統呼叫,係對與藉由參數所指定之工作優先順序PR=1對應之優先佇列(Q0:1),將前端工作之順序變更成最後端的系統呼叫。根據旋轉系統呼叫,可從外部控制放入至虛擬佇列(Q0)之工作的順序值(ODR)。The system call is rotated, and the priority queue (Q0:1) corresponding to the work priority sequence PR=1 specified by the parameter is changed, and the order of the front end operation is changed to the last system call. According to the rotating system call, the order value (ODR) of the work placed in the virtual queue (Q0) can be externally controlled.

用以實現旋轉系統呼叫的判定電路,只要以為「READY狀態,且指定之工作優先順序PR的工作」為條件輸出「1」即可。接著,藉由比較電路群,從判定電路之輸出訊號成為「1」之該工作之中,將順序值(ODR)最大之工作選擇為旋轉的對象即可。The determination circuit for realizing the call of the rotating system may output "1" as a condition in the "READY state and the operation of the designated work priority PR". Next, by comparing the circuit group, the operation in which the output signal of the determination circuit becomes "1" is selected, and the operation of maximizing the order value (ODR) is selected as the object of rotation.

2.與WAIT狀態對應之虛擬佇列的功能擴充2. Functional expansion of the virtual queue corresponding to the WAIT state

一般而言,解除某個旗號時,於與旗號等待對應之虛擬佇列(Qn),從工作優先順序PR最高之優先佇列(Qn:Pn)之中,選擇待獲得該旗號的工作。然而,與工作優先順序PR無關,藉由順序值(ODR)最大之工作設定待獲得之特殊旗號(以下,稱為「特殊旗號」)亦可。Generally, when a certain flag is released, in the virtual queue (Qn) corresponding to the flag waiting, the work to be obtained is selected from the highest priority queue (Qn: Pn) of the work priority PR. However, regardless of the work priority PR, the special flag to be obtained (hereinafter, referred to as "special flag") may be set by the work having the largest order value (ODR).

為了構裝特殊旗號,為「WAIT狀態,且以解除旗號為待機旗號之工作」時,準備輸出「1」之判定電路即可。圖32之判定電路434,係QID_S、CND輸入、輸出EID_EN訊號的電路。將此變更,假設為除了QID_S、CND外亦輸入工作優先順序PR_S,輸出EID_EN與PR_A的判定電路。此判定電路,於解除特殊旗號時,對PR_A輸出既定值x,於解除通常旗號時,直接輸出PR_S作為PR_A。因此,比較電路群,於解除特殊旗號時,將各工作之工作優先順序PR全部辨識為既定值x。其結果,比較電路群,與各工作之工作優先順序PR無關,從判定電路之輸出訊號成為「1」之該工作之中,選擇順序值(ODR)最小之工作。In order to construct a special flag, the "WAIT state, and the work of releasing the flag as the standby flag" is prepared to output a determination circuit of "1". The decision circuit 434 of FIG. 32 is a circuit for inputting and outputting an EID_EN signal by QID_S and CND. This change is assumed to be a decision circuit that outputs a work priority order PR_S in addition to QID_S and CND, and outputs EID_EN and PR_A. This determination circuit outputs a predetermined value x to PR_A when the special flag is released, and directly outputs PR_S as PR_A when the normal flag is released. Therefore, in the comparison circuit group, when the special flag is released, all the work priority sequences PR of the respective jobs are recognized as the predetermined value x. As a result, the comparison circuit group is independent of the duty priority PR of each job, and the operation in which the order value (ODR) is the smallest is selected from the operation in which the output signal of the determination circuit becomes "1".

將從以上實施形態及變形例所掌握之發明的各種形態、及已揭示於申請專利範圍者例示如下。從改良例1可認知以下發明。Various aspects of the inventions obtained from the above embodiments and modifications, and those disclosed in the claims are exemplified as follows. The following invention can be recognized from Modification 1.

C1.一種虛擬佇列處理電路,其特徵在於,具備:C1. A virtual queue processing circuit, comprising:

佇列控制電路,對藉由佇列ID來辨別之複數種類之虛擬佇列,控制藉由要素ID來辨別之複數個要素之放入與取出;以及a queue control circuit that controls the insertion and removal of a plurality of elements identified by the element ID for a virtual array of plural types identified by the queue ID;

複數個佇列暫存器,係對應各要素而設置,使放入對象之虛擬佇列之佇列ID與表示放入順序之順序值相對應而保持;A plurality of queue registers are set corresponding to each element, so that the queue ID of the virtual queue placed in the object is maintained corresponding to the order value indicating the placement order;

該佇列控制電路,The queue control circuit,

當輸入指定要素ID及佇列ID之順向放入指令時,對該指定之要素ID之該佇列暫存器,設定表示對與該指定之佇列ID對應之虛擬佇列之末端放入的末端順序值與該指定之佇列ID;When the forward input instruction of the specified element ID and the queue ID is input, the end register of the specified element ID is set to indicate the end of the virtual queue corresponding to the specified queue ID. The end sequence value and the specified queue ID;

當輸入指定要素ID及佇列ID之逆向放入指令時,對該指定之要素ID之該佇列暫存器,設定表示對與該指定之佇列ID對應之虛擬佇列之前端放入的前端順序值與該指定之佇列ID;When the reverse placement instruction of the specified element ID and the queue ID is input, the array register of the specified element ID is set to indicate the position of the virtual queue corresponding to the specified queue ID. The front end order value and the specified queue ID;

當輸入指定佇列ID之取出指令時,從儲存該指定之佇列ID及前端順序值之佇列暫存器清除佇列ID,藉由以該要素作為取出對象,根據各佇列暫存器之設定資訊來管理該複數種類之虛擬佇列。When the fetch instruction of the specified queue ID is input, the queue ID is cleared from the queue register storing the specified queue ID and the front end order value, and the element is taken as the object to be extracted, according to each queue register The setting information is used to manage the virtual queue of the plural type.

C2.如C1記載之虛擬佇列處理電路,其中,該佇列控制電路,當輸入該順向放入指令或該逆向放入指令其中之一時,藉由指令調整儲存指定之佇列ID之其他佇列暫存器的順序值。C2. The virtual queue processing circuit of C1, wherein the queue control circuit adjusts the storage of the specified queue ID by the instruction when inputting one of the forward insertion instruction or the reverse insertion instruction The order value of the queue.

C3.如C1記載之虛擬佇列處理電路,其進一步具備取出候補電路,該取出候補電路,當指定佇列ID時,參照從該複數個佇列暫存器平行輸出之佇列ID與順序值,輸出對應該指定之佇列ID及前端順序值的要素ID;C3. The virtual queue processing circuit according to C1, further comprising: a take-out candidate circuit that refers to the queue ID and the sequence value outputted in parallel from the plurality of queue registers when the queue ID is specified , output the feature ID corresponding to the queue ID and the front end order value;

該佇列控制電路,從該取出候補電路所輸出之要素ID之該佇列暫存器清除佇列ID。The queue control circuit clears the queue ID from the queue register of the element ID output from the extraction candidate circuit.

C4.如C1記載之虛擬佇列處理電路,其中,虛擬佇列係進一步依據取出之優先度被定義成複數個優先佇列的集合;C4. The virtual queue processing circuit of C1, wherein the virtual queue is further defined as a set of a plurality of priority queues according to the priority of the extraction;

該佇列暫存器亦儲存用以特定優先佇列的優先度;The queue register also stores the priority for the particular priority queue;

該佇列控制電路,The queue control circuit,

當輸入指定要素ID、佇列ID、及優先度之順向放入指令時,對該指定之要素ID之該佇列暫存器,亦設定該指定之優先度;When a specified element ID, a queue ID, and a priority direction input instruction are input, the priority of the specified element ID is also set to the priority of the specified register;

當輸入指定要素ID、佇列ID、及優先度之逆向放入指令時,對該指定之要素ID之該佇列暫存器,亦設定該指定之優先度;When the reverse input instruction of the specified element ID, the queue ID, and the priority is input, the priority of the designated element ID is also set to the priority of the specified register;

當輸入指定佇列ID之取出指令時,儲存該指定之佇列ID,從其中設定最高之優先度,且其中設定最接近前端之順序值之佇列暫存器清除佇列ID。When the fetch instruction of the specified queue ID is input, the specified queue ID is stored, and the highest priority is set therefrom, and the queue register with the sequence value closest to the front end is set to clear the queue ID.

C5.如C4記載之虛擬佇列處理電路,其中,該佇列控制電路,輸入指定佇列ID之該取出指令時,調整儲存該指定之佇列ID之其他佇列暫存器的順序值。C5. The virtual queue processing circuit according to C4, wherein the queue control circuit adjusts a sequence value of another queue register storing the specified queue ID when the instruction for specifying the queue ID is input.

C6.如C5記載之虛擬佇列處理電路,其進一步具備取出候補電路,該取出候補電路,當指定佇列ID時,根據從該複數個佇列暫存器平行輸出之佇列ID、順序值、及優先度,儲存該指定之佇列ID,輸出對應其中設定最高之優先度,且其中儲存最接近前端之順序值之佇列暫存器的要素ID;C6. The virtual queue processing circuit according to C5, further comprising: a take-out candidate circuit that, when specifying the queue ID, outputs the queue ID and the sequence value in parallel from the plurality of queue registers And priority, storing the specified queue ID, outputting the element ID corresponding to the highest priority set therein, and storing the sequence register value closest to the front end;

該佇列控制電路,從該取出候補電路所輸出之要素ID之該佇列暫存器清除佇列ID。The queue control circuit clears the queue ID from the queue register of the element ID output from the extraction candidate circuit.

C7.一種工作處理裝置,其特徵在於,具備:C7. A work processing apparatus, comprising:

處理暫存器,暫時儲存用以執行工作的資料;Processing the scratchpad to temporarily store the data used to perform the work;

執行控制電路,將指令及運算元從記憶體載入至該處理暫存器,依該處理暫存器之指令及運算元執行工作;Executing a control circuit, loading instructions and operands from the memory into the processing register, and performing operations according to the instructions and the operation elements of the processing register;

複數個狀態暫存器,係用以儲存工作排程之狀態資料的暫存器,與複數個工作分別相對應;a plurality of state registers, which are temporary registers for storing state data of the work schedule, corresponding to a plurality of jobs respectively;

工作切換電路,對與工作之執行狀態相對應之複數種類之虛擬佇列,控制藉由工作ID來辨別之複數個工作之放入與取出,以管理工作的執行狀態;以及The work switching circuit controls a plurality of types of virtual queues corresponding to the execution state of the work, and controls the execution and execution of the plurality of jobs by the work ID to manage the execution state of the work;

工作選擇電路,以從複數個該狀態暫存器平行輸出之狀態資料作為輸入,藉由既定選擇條件來選擇工作;The work selection circuit takes as input the state data output from the plurality of state buffers in parallel, and selects the work by the predetermined selection condition;

該狀態暫存器,使對應該工作之執行狀態之虛擬佇列之佇列ID與表示對虛擬佇列之放入順序之順序值相對應而保持,以作為狀態資料的一部分;The state register holds the queue ID of the virtual queue corresponding to the execution state of the work and the sequence value indicating the order in which the virtual queue is placed, as part of the status data;

該執行控制電路,當執行中之第1工作執行既定系統呼叫指令時,將既定系統呼叫訊號傳至該工作切換電路;The execution control circuit transmits the predetermined system call signal to the work switching circuit when the first operation in execution executes the predetermined system call instruction;

該工作選擇電路,特定儲存對應READY(準備)狀態之虛擬佇列之準備佇列之佇列ID及表示該準備佇列之前端位置之前端順序值的狀態暫存器,將對應該特定之狀態暫存器的第2工作選擇作為下一個執行對象;The job selection circuit stores a column ID of the preparation queue corresponding to the virtual queue corresponding to the READY state and a state register indicating the previous order value of the front end position of the preparation queue, corresponding to the specific state The second job selection of the scratchpad is selected as the next execution object;

該工作切換電路,在接收該系統呼叫訊號時,從該第2工作之狀態暫存器清除佇列ID,對該第1工作之狀態暫存器,設定與RUN狀態不同之其他執行狀態所對應之虛擬佇列的佇列ID與順序值,使該處理暫存器之資料保留在既定記憶區域,且將該第2工作相關之保留在該記憶區域之資料載入至該處理暫存器。The work switching circuit clears the queue ID from the state register of the second operation when receiving the system call signal, and sets the state register of the first job to correspond to another execution state different from the RUN state. The queue ID and the sequence value of the virtual queue are such that the data of the processing register is retained in the predetermined memory area, and the data retained in the memory area related to the second job is loaded into the processing register.

C8.如C7記載之工作處理裝置,其中,該工作切換電路,使該第1工作移至READY狀態以作為該其他執行狀態時,對該第1工作之狀態暫存器設定該準備佇列之佇列ID及前端順序值。C8. The work processing apparatus according to C7, wherein the operation switching circuit sets the preparation queue to the state register of the first operation when the first operation is moved to the READY state to be the other execution state. Queue ID and front end order value.

C9.如C7記載之工作處理裝置,其中,該工作選擇電路,當設定待機佇列作為對應WAIT解除條件之成立待機狀態之WAIT狀態之虛擬佇列時,該WAIT解除條件成立時,在儲存該待機佇列之佇列ID及前端順序值之狀態暫存器選擇該工作;(C9) The work processing device according to C7, wherein the operation selection circuit stores the standby queue as a virtual queue of a WAIT state in a standby state corresponding to a WAIT release condition, and when the WAIT release condition is satisfied, storing the The status register of the queue ID and the front end sequence value of the standby queue selects the work;

該工作切換電路,對該選擇之工作之狀態暫存器,設定準備佇列之佇列ID及表示對該準備佇列之末端放入之末端順序值。The operation switching circuit sets a queue ID of the preparation queue and a terminal sequence value indicating the end of the preparation queue for the selected state register.

C10.如C7記載之工作處理裝置,其中,該狀態暫存器,儲存工作優先度作為狀態資料的一部分;C10. The work processing apparatus of C7, wherein the state register stores a work priority as part of the status data;

該工作選擇電路,於切換工作之際,設定為準備佇列之佇列ID之工作有複數個時,將該等之中設定最高之工作優先度,且該等之中設定最接近前端之順序值之工作選擇作為執行對象。The work selection circuit sets the highest priority of work among the plurality of jobs for setting the queue ID when the switch is to be performed, and sets the order closest to the front end among the ones. The work selection of the value is the execution object.

根據本發明,可於多工處理實現更高效率之工作的執行控制。According to the present invention, execution control of a more efficient work can be realized in multiplex processing.

84...CPU84. . . CPU

86...汎用暫存器86. . . Universal register

88...特殊暫存器88. . . Special register

90...執行控制電路90. . . Execution control circuit

92...處理暫存器92. . . Processing register

94...運算電路94. . . Operation circuit

96...輸入選擇器96. . . Input selector

98...輸出選擇器98. . . Output selector

100...工作處理裝置100. . . Work processing device

110...保留暫存器110. . . Reserved register

110_0~110_n...保留暫存器110_0~110_n. . . Reserved register

112...載入選擇電路112. . . Load selection circuit

120...儲存電路120. . . Storage circuit

150...CPU150. . . CPU

152...執行控制電路152. . . Execution control circuit

154...處理暫存器154. . . Processing register

156...特殊暫存器156. . . Special register

158...汎用暫存器158. . . Universal register

160...運算電路160. . . Operation circuit

162...輸入選擇器162. . . Input selector

164...輸出選擇器164. . . Output selector

170...指令解碼器170. . . Instruction decoder

172...第1AND閘172. . . 1st gate

174...第2AND閘174. . . 2nd gate

176...OR閘176. . . OR gate

200...工作控制電路200. . . Work control circuit

210...工作切換電路210. . . Working switching circuit

212...旗號表212. . . Flag table

214...事件表214. . . Event table

220...狀態記憶部220. . . State memory

220_0~220_n...狀態記憶部220_0~220_n. . . State memory

230...工作選擇電路230. . . Work selection circuit

232...執行選擇電路232. . . Execution selection circuit

234...旗號選擇電路234. . . Flag selection circuit

236...事件選擇電路236. . . Event selection circuit

238...暫停檢測電路238. . . Pause detection circuit

240...互斥電路240. . . Mutual exclusion circuit

242...檢測電路242. . . Detection circuit

250,250_0,250_1,250_2,250_3...狀態暫存器250,250_0,250_1,250_2,250_3. . . Status register

252...計時器252. . . Timer

254...工作ID暫存器254. . . Job ID register

256...工作優先順序暫存器256. . . Work priority register

258...工作狀態暫存器258. . . Working state register

260...工作啟動位址暫存器260. . . Work start address register

262...待機理由暫存器262. . . Standby reason register

264...旗號ID暫存器264. . . Flag ID register

265...互斥ID暫存器265. . . Mutually exclusive ID register

266...事件ID暫存器266. . . Event ID register

268...待機旗標暫存器268. . . Standby flag register

270...旗標條件暫存器270. . . Flag condition register

272...旗標初始化暫存器272. . . Flag initialization register

274...暫停計數器274. . . Pause counter

280...優先順序指標280. . . Priority indicator

290a~290d...第1比較電路290a~290d. . . First comparison circuit

292a,292b...第2比較電路292a, 292b. . . Second comparison circuit

294...第3比較電路294. . . Third comparison circuit

296a~296h...判定電路296a~296h. . . Decision circuit

300a~300d...第1比較電路300a ~ 300d. . . First comparison circuit

302a,302b...第2比較電路302a, 302b. . . Second comparison circuit

304...第3比較電路304. . . Third comparison circuit

306a~306h...判定電路306a~306h. . . Decision circuit

320...處理資料保持部320. . . Processing data retention department

322...暫存器切換控制電路322. . . Register switch control circuit

324...中斷介面電路324. . . Interrupt interface circuit

400...主電路400. . . The main circuit

402...寫入電路402. . . Write circuit

404...佇列控制電路404. . . Queue control circuit

406...最大值選擇電路406. . . Maximum selection circuit

410_0,410_1,410_2,410_3...工作ID暫存器410_0,410_1,410_2,410_3. . . Job ID register

412_0,412_1,412_2,412_3...工作優先順序暫存器412_0,412_1,412_2,412_3. . . Work priority register

414_0,414_1,414_2,414_3...佇列順序暫存器414_0,414_1,414_2,414_3. . . Queue sequential register

416_0,416_1,416_2,416_3...佇列辨別暫存器416_0,416_1,416_2,416_3. . .辨 column discriminator

420_0,420_1...暫存器值產生電路420_0,420_1. . . Register value generating circuit

422a,422b...第1比較電路422a, 422b. . . First comparison circuit

424a...第2比較電路424a. . . Second comparison circuit

426a~426d...判定電路426a~426d. . . Decision circuit

430a,430b...第1比較電路430a, 430b. . . First comparison circuit

432a...第2比較電路432a. . . Second comparison circuit

434a~434d...判定電路434a~434d. . . Decision circuit

500...HWF500. . . HWF

500_0~500_k...HWF500_0~500_k. . . HWF

502...中斷控制器502. . . Interrupt controller

504...HWFID暫存器504. . . HWFID register

506...佇列順序暫存器506. . . Queue sequential register

508...佇列辨別暫存器508. . .辨 column discriminator

510...HWF待機選擇電路510. . . HWF standby selection circuit

512...CPU匯流排512. . . CPU bus

圖1係工作的狀態遷移圖。Figure 1 is a state transition diagram of the work.

圖2係一般RTOS的概念圖。Figure 2 is a conceptual diagram of a general RTOS.

圖3係軟體RTOS所執行之一般CPU的電路圖。Figure 3 is a circuit diagram of a general CPU executed by the software RTOS.

圖4係本實施例之RTOS的概念圖。Fig. 4 is a conceptual diagram of the RTOS of the present embodiment.

圖5係本實施例之工作處理裝置的電路圖。Fig. 5 is a circuit diagram of the work processing apparatus of the embodiment.

圖6係圖5之CPU的電路圖。Figure 6 is a circuit diagram of the CPU of Figure 5.

圖7係顯示執行控制電路152使CPU時脈停止之構造的電路圖。Fig. 7 is a circuit diagram showing a configuration in which the execution control circuit 152 stops the CPU clock.

圖8(a)係顯示中斷要求訊號產生時之各種訊號之關係的時序圖。Fig. 8(a) is a timing chart showing the relationship of various signals when the interrupt request signal is generated.

圖8(b)係顯示系統呼叫執行時之各種訊號之關係的時序圖。Figure 8(b) is a timing diagram showing the relationship of various signals when the system call is executed.

圖9係用以說明管線處理之CPU時脈之停止時序的示意圖。Fig. 9 is a schematic diagram for explaining the stop timing of the CPU clock of the pipeline processing.

圖10係顯示狀態記憶部與工作切換電路之關係的電路圖。Fig. 10 is a circuit diagram showing the relationship between the state memory unit and the operation switching circuit.

圖11係顯示一般RTOS之RUN-工作選擇時所利用之工作準備串列的圖。Figure 11 is a diagram showing the work preparation sequence used in the RUN-operation selection of a general RTOS.

圖12係執行選擇電路的電路圖。Figure 12 is a circuit diagram of a selection circuit.

圖13係顯示一般RTOS之旗號處理所利用之待機旗號串列的圖。Figure 13 is a diagram showing a list of standby flag numbers used for flag processing of a general RTOS.

圖14係旗號選擇電路的電路圖。Figure 14 is a circuit diagram of the flag selection circuit.

圖15係工作切換電路的狀態遷移圖。Figure 15 is a state transition diagram of the work switching circuit.

圖16係圖5之工作處理裝置中,未裝載工作控制電路之工作處理裝置的電路圖。Figure 16 is a circuit diagram of a work processing apparatus in which the work control circuit is not loaded in the work processing apparatus of Figure 5.

圖17係圖5之工作處理裝置中,未裝載儲存電路之工作處理裝置的電路圖。Figure 17 is a circuit diagram of a work processing apparatus in which the storage circuit is not loaded in the work processing apparatus of Figure 5.

圖18係改良例1之工作處理裝置的電路圖。Fig. 18 is a circuit diagram of the work processing apparatus of the first modification.

圖19係改良例1之工作控制電路之一部分的電路圖。Fig. 19 is a circuit diagram showing a part of the operation control circuit of the first modification.

圖20係佇列控制電路的電路圖。Figure 20 is a circuit diagram of a train control circuit.

圖21係顯示虛擬佇列與工作之關係的概念圖。Figure 21 is a conceptual diagram showing the relationship between a virtual queue and work.

圖22係對應圖21之狀態暫存器的資料結構圖。Figure 22 is a data structure diagram corresponding to the state register of Figure 21.

圖23係將工作(E4)順向放入圖21之虛擬佇列時的概念圖。Fig. 23 is a conceptual diagram when the work (E4) is placed in the virtual queue of Fig. 21 in the forward direction.

圖24係對應圖23之狀態暫存器的資料結構圖。Figure 24 is a data structure diagram corresponding to the state register of Figure 23.

圖25係將工作(E5)順向放入圖23之虛擬佇列時的概念圖。Fig. 25 is a conceptual diagram when the work (E5) is placed in the virtual queue of Fig. 23 in the forward direction.

圖26係對應圖25之狀態暫存器的資料結構圖。Figure 26 is a data structure diagram corresponding to the state register of Figure 25.

圖27係顯示順向放入之處理過程的流程圖。Figure 27 is a flow chart showing the processing of the forward insertion.

圖28係最大值選擇電路之一部分的電路圖。Figure 28 is a circuit diagram of a portion of the maximum selection circuit.

圖29係將工作(E6)逆向放入圖25之虛擬佇列時的概念圖。Fig. 29 is a conceptual diagram when the work (E6) is reversely placed in the virtual queue of Fig. 25.

圖30係對應圖29之狀態暫存器的資料結構圖。Figure 30 is a data structure diagram corresponding to the state register of Figure 29.

圖31係顯示逆向放入之處理過程的流程圖。Figure 31 is a flow chart showing the processing of the reverse insertion.

圖32係工作選擇電路之一部分的電路圖。Figure 32 is a circuit diagram of a portion of the operational selection circuit.

圖33係從圖29之虛擬佇列取出工作(E3)時的概念圖。Fig. 33 is a conceptual diagram when the work (E3) is taken out from the virtual queue of Fig. 29.

圖34係對應圖33之狀態暫存器的資料結構圖。Figure 34 is a data structure diagram corresponding to the state register of Figure 33.

圖35係顯示取出之處理過程的流程圖。Figure 35 is a flow chart showing the process of taking out.

圖36係顯示再執行優先型工作排程中之虛擬佇列與工作之關係的第1概念圖。Fig. 36 is a first conceptual diagram showing the relationship between the virtual queue and the work in the re-execution of the priority work schedule.

圖37係顯示再執行優先型工作排程中之虛擬佇列與工作之關係的第2概念圖。Fig. 37 is a second conceptual diagram showing the relationship between the virtual queue and the work in the re-execution of the priority work schedule.

圖38係顯示藉由軟體OS執行輔助處理時之一般電路構成的圖。Fig. 38 is a view showing a general circuit configuration when the auxiliary processing is executed by the software OS.

圖39係顯示一般串列型輔助處理之控制方法的時序圖。Fig. 39 is a timing chart showing a control method of the general serial type auxiliary processing.

圖40係顯示一般並列型輔助處理之控制方法的時序圖。Fig. 40 is a timing chart showing a control method of the general side-by-side auxiliary processing.

圖41係顯示藉由基本例之工作處理裝置實現圖38至圖40所示之輔助處理控制時之電路構成的圖。Fig. 41 is a view showing the circuit configuration when the auxiliary processing control shown in Figs. 38 to 40 is realized by the work processing apparatus of the basic example.

圖42係顯示於改良例2工作處理裝置與HWF之關係的電路構成圖。Fig. 42 is a circuit configuration diagram showing the relationship between the work processing apparatus of the modified example 2 and the HWF.

圖43係顯示改良例2之狀態記憶部與工作切換電路之關係的電路圖。Fig. 43 is a circuit diagram showing the relationship between the state memory unit and the operation switching circuit of the second modification.

圖44係顯示改良例2之串列型輔助處理之控制方法的時序圖。Fig. 44 is a timing chart showing a control method of the tandem type auxiliary processing in the second modification.

圖45係顯示改良例2之並列型輔助處理之控制方法的時序圖。Fig. 45 is a timing chart showing a control method of the parallel type auxiliary processing in the second modification.

100...工作處理裝置100. . . Work processing device

120...儲存電路120. . . Storage circuit

150...CPU150. . . CPU

200...工作控制電路200. . . Work control circuit

500_0~500_k...HWF500_0~500_k. . . HWF

502...中斷控制器502. . . Interrupt controller

512...CPU匯流排512. . . CPU bus

Claims (11)

一種工作處理裝置,其特徵在於,具備:處理暫存器,暫時儲存用以執行工作的資料;執行控制電路,將指令及運算元從記憶體載入至該處理暫存器,依該處理暫存器之指令及運算元執行工作;狀態暫存器,係用以儲存表示工作之執行狀態的狀態資料;工作切換電路,係用以控制工作的執行狀態;工作選擇電路,根據該狀態資料,藉由既定選擇條件來選擇工作;以及輔助處理電路,執行既定輔助處理作為工作之一部分;該執行控制電路,當執行既定系統呼叫指令時,將既定系統呼叫訊號傳至該工作切換電路;該工作選擇電路,從表示待機為可執行狀態之READY狀態之工作之中選擇成為下一個執行對象的工作;該工作切換電路,藉由接收該系統呼叫訊號時之該工作選擇電路的輸出選擇成為下一個執行對象的工作,將該處理暫存器之資料保留於既定記憶區域,且將執行中之工作之狀態資料從表示工作執行中之RUN狀態設定變更為另一狀態,對選擇之工作,將保留於該記憶區域之資料載入至該處理暫存器,且將該工作之狀態資料從READY狀態變更為RUN狀態,藉此切換成為執行對象的工作;於該執行控制電路,當執行中之工作執行輔助處理指令作為用以執行該既定輔助處理的系統呼叫指令時,該工作切換電路,指示該輔助處理電路執行該輔助處理。A work processing apparatus includes: a processing register that temporarily stores data for performing work; and an execution control circuit that loads instructions and operands from a memory to the processing register, according to the processing The instruction and the operation unit of the memory perform the work; the state register is used to store the state data indicating the execution state of the work; the work switching circuit is used to control the execution state of the work; and the work selection circuit is based on the state data. Selecting the work by the predetermined selection condition; and assisting the processing circuit to perform the predetermined auxiliary processing as part of the work; the execution control circuit transmitting the predetermined system call signal to the work switching circuit when executing the predetermined system call instruction; Selecting a circuit to select a job to be the next execution target from among the operations indicating that the standby state is the READY state of the executable state; the work switching circuit selects the output of the work selection circuit when receiving the system call signal to become the next Execute the work of the object, and retain the data of the processing register in the established memory. a domain, and changing the status data of the work in execution from the RUN state setting indicating the execution of the job to another state, and loading the data retained in the memory area into the processing register for the selected work, and The status data of the operation is changed from the READY state to the RUN state, thereby switching to the operation of the execution target; and the execution control circuit executes the auxiliary processing instruction as the system call instruction for executing the predetermined auxiliary processing when the execution is performed. The work switching circuit instructs the auxiliary processing circuit to perform the auxiliary processing. 如申請專利範圍第1項之工作處理裝置,其中,該工作切換電路,當指示執行該輔助處理時,設定執行該輔助處理指令之第1工作對該輔助處理電路的佔有權,且將與該第1工作不同之第2工作設定成RUN狀態,以從該輔助處理電路接收到表示該輔助處理結束之輔助結束訊號為條件,解除該第1工作的佔有權。The work processing apparatus of claim 1, wherein the work switching circuit sets, when instructing execution of the auxiliary processing, a possession of a first operation of the auxiliary processing command to the auxiliary processing circuit, and The second operation different from the first operation is set to the RUN state, and the possession of the first operation is canceled on the condition that the auxiliary processing circuit receives the auxiliary end signal indicating the completion of the auxiliary processing. 如申請專利範圍第2項之工作處理裝置,其中,於該執行控制電路,執行佔有要求指令作為該第1工作要求佔有該輔助處理電路的系統呼叫指令;該工作切換電路,以對該輔助處理電路未設定其他工作之佔有權為條件,設定該第1工作對該輔助處理電路的佔有權;於該執行控制電路,該第1工作,以成功取得該輔助處理電路的佔有權為條件,執行該輔助處理指令。The work processing apparatus of claim 2, wherein the execution control circuit executes a system call instruction that occupies the occupation request circuit as the first operation request; the work switching circuit performs the auxiliary processing The circuit does not set the possession of other work as a condition, and the possession of the first operation to the auxiliary processing circuit is set; and in the execution control circuit, the first operation is performed on the condition that the possession of the auxiliary processing circuit is successfully obtained. This auxiliary processing instruction. 如申請專利範圍第1項之工作處理裝置,其中,該工作切換電路,將既定資料記錄於執行該輔助處理指令之第1工作的狀態暫存器,以設定該第1工作正在等待該輔助處理電路的處理結束;該工作選擇電路,將該狀態暫存器記錄有該既定資料的工作通知該工作切換電路;該工作切換電路,從該輔助處理電路接收到表示該輔助處理結束之輔助結束訊號時,將從該工作選擇電路通知之該第1工作再次設定成RUN狀態。The work processing device according to claim 1, wherein the work switching circuit records the predetermined data in a state register that executes the first operation of the auxiliary processing command to set the first job to wait for the auxiliary processing. End of the processing of the circuit; the work selection circuit notifying the work switching circuit of the operation of recording the predetermined data in the state register; the work switching circuit receiving an auxiliary end signal indicating the end of the auxiliary processing from the auxiliary processing circuit At this time, the first operation notified from the operation selection circuit is set to the RUN state again. 如申請專利範圍第1項之工作處理裝置,其中,該輔助處理電路,係分別對應複數種輔助處理設置複數個;於該執行控制電路,當執行中之工作以輔助處理的種類為參數執行該輔助處理指令時,該工作切換電路,從複數個輔助處理電路之中選擇與指定為參數之輔助處理對應的輔助處理電路,對該選擇之輔助處理電路指示執行該輔助處理。The work processing device of claim 1, wherein the auxiliary processing circuit respectively sets a plurality of auxiliary processing, wherein the execution control circuit performs the work in the execution with the type of the auxiliary processing as a parameter. When the processing command is assisted, the operation switching circuit selects an auxiliary processing circuit corresponding to the auxiliary processing designated as the parameter from among the plurality of auxiliary processing circuits, and instructs the selected auxiliary processing circuit to execute the auxiliary processing. 如申請專利範圍第5項之工作處理裝置,其中,該工作切換電路,選擇該輔助處理電路時,對執行該輔助處理指令之工作的狀態暫存器記錄一意辨識該選擇之輔助處理電路的輔助處理ID,以設定執行該輔助處理指令之工作正在等待該選擇之輔助處理電路的處理結束,從該選擇之輔助處理電路接收到表示該輔助處理結束之輔助結束訊號時,將該選擇之輔助處理電路的輔助處理ID通知該工作選擇電路;該工作選擇電路,選擇記錄有該通知之輔助處理ID的工作;該工作切換電路,接收該輔助結束訊號時,將該選擇之工作再次設定成RUN狀態。The work processing apparatus of claim 5, wherein the work switching circuit selects the auxiliary processing circuit to record an auxiliary processing circuit for identifying the selected auxiliary processing circuit for the state register that performs the operation of the auxiliary processing instruction Processing the ID to set the execution of the auxiliary processing instruction to wait for the processing of the selected auxiliary processing circuit to end, and receiving the auxiliary processing of the selection when receiving the auxiliary end signal indicating the completion of the auxiliary processing from the selected auxiliary processing circuit The auxiliary processing ID of the circuit notifies the work selection circuit; the work selection circuit selects an operation of recording the auxiliary processing ID of the notification; and the work switching circuit sets the selected operation to the RUN state again when receiving the auxiliary end signal . 如申請專利範圍第1項之工作處理裝置,其進一步具備用以保留該處理暫存器之資料,分別與複數個工作相對應的複數個保留暫存器;該工作切換電路,接收該既定系統呼叫訊號時,將該處理暫存器之資料保留於與執行中之工作相對應之該保留暫存器,將與成為下一個執行對象之工作相對應之該保留暫存器的資料載入至該處理暫存器。The working processing device of claim 1, further comprising: a plurality of reserved registers corresponding to the plurality of jobs for retaining the data of the processing register; the working switching circuit receiving the predetermined system When the signal is called, the data of the processing register is retained in the reserved register corresponding to the work in execution, and the data of the reserved register corresponding to the work of the next execution object is loaded to This handles the scratchpad. 如申請專利範圍第7項之工作處理裝置,其中,該工作切換電路,從該輔助處理電路接收到表示該輔助處理結束之輔助結束訊號時,從該輔助處理電路取得表示該輔助處理之結果的回傳值,將該回傳值寫入至執行該輔助處理指令之工作的保留暫存器,以將該輔助處理之結果通知執行該輔助處理指令之工作。The work processing device of claim 7, wherein the work switching circuit receives, from the auxiliary processing circuit, an auxiliary end signal indicating that the auxiliary processing is completed, and obtains, from the auxiliary processing circuit, a result indicating the auxiliary processing. The return value is written to the reserved register that performs the work of the auxiliary processing instruction to notify the execution of the auxiliary processing instruction of the result of the auxiliary processing. 如申請專利範圍第1項之工作處理裝置,其中,該工作切換電路,從該輔助處理電路接收到表示該輔助處理結束之輔助結束訊號時,將執行該輔助處理指令之工作再次設定成RUN狀態。The work processing device according to claim 1, wherein the work switching circuit receives the auxiliary end signal indicating that the auxiliary processing is completed from the auxiliary processing circuit, and sets the operation of executing the auxiliary processing command to the RUN state again. . 如申請專利範圍第1項之工作處理裝置,其中,該工作切換電路,以從該輔助處理電路接收到表示該輔助處理結束之輔助結束訊號為條件,選擇成為下一個執行對象之工作並設定成RUN狀態,以防止該輔助處理之執行中於該執行控制電路執行工作。The work processing device according to claim 1, wherein the work switching circuit selects the work to be the next execution target and sets the condition to be received from the auxiliary processing circuit to receive the auxiliary end signal indicating the completion of the auxiliary processing. The RUN state is to prevent the execution of the auxiliary processing from performing the operation on the execution control circuit. 如申請專利範圍第10項之工作處理裝置,其中,該工作切換電路,當執行該輔助處理指令時,對該執行控制電路傳送停止要求訊號;該執行控制電路,接收該停止要求訊號後,停止供應用以進行工作之執行程序的執行用時脈,以暫時停止執行該輔助處理指令之工作的執行程序;該工作切換電路,當接收該輔助結束訊號時,對該執行控制電路傳送停止解除訊號;該執行控制電路,接收該停止解除訊號後,解除該執行用時脈之供應停止,以再次開始執行該輔助處理指令之工作的執行程序。The work processing device of claim 10, wherein the work switching circuit transmits a stop request signal to the execution control circuit when the auxiliary processing command is executed; the execution control circuit stops after receiving the stop request signal Providing an execution clock for executing an execution program of the work to temporarily stop execution of the operation of the auxiliary processing instruction; the work switching circuit transmitting a stop release signal to the execution control circuit when receiving the auxiliary end signal After receiving the stop release signal, the execution control circuit releases the supply stop of the execution clock to restart the execution of the operation of the auxiliary processing command.
TW098101355A 2008-01-15 2009-01-15 Work processing device TWI476696B (en)

Applications Claiming Priority (1)

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

Publications (2)

Publication Number Publication Date
TW200937294A TW200937294A (en) 2009-09-01
TWI476696B true TWI476696B (en) 2015-03-11

Family

ID=40885097

Family Applications (1)

Application Number Title Priority Date Filing Date
TW098101355A TWI476696B (en) 2008-01-15 2009-01-15 Work processing device

Country Status (3)

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

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012173870A (en) 2011-02-18 2012-09-10 Toshiba Corp Semiconductor device and memory protection method
JP5809744B2 (en) 2011-05-20 2015-11-11 アップル インコーポレイテッド Apparatus and method for optimization of scheduled operation in a hybrid network environment
KR101626267B1 (en) 2011-05-20 2016-05-31 애플 인크. Apparatus and methods for priority based task scheduling in hybrid network operation
CN108920267B (en) * 2012-05-24 2022-03-15 瑞萨电子株式会社 Task processing device
JP2017037370A (en) 2015-08-06 2017-02-16 富士通株式会社 Computing device, process control method and process control program
JP2017123190A (en) * 2017-03-08 2017-07-13 ルネサスエレクトロニクス株式会社 Task processing device
JP2018180768A (en) * 2017-04-07 2018-11-15 ルネサスエレクトロニクス株式会社 Semiconductor device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1139171A (en) * 1997-07-18 1999-02-12 Masaharu Imai Multitask processor, multitask processing control method and control program storing medium
EP0942365A2 (en) * 1998-03-10 1999-09-15 Lucent Technologies Inc. Context controller having instruction-based time slice task switching capability and processor employing the same
GB2414575A (en) * 2004-05-26 2005-11-30 Advanced Risc Mach Ltd Management of polling loops in a data processing apparatus
TW200629068A (en) * 2004-09-10 2006-08-16 Ibm An integrated circuit chip for encryption and decryption having a secure mechanism for programming ON-chip hardware
TW200719276A (en) * 2005-11-10 2007-05-16 Via Tech Inc Method and device for saving and restoring a state context in a graphics processing unit

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003263329A (en) * 2002-03-08 2003-09-19 Oki Electric Ind Co Ltd Task scheduler
EP1820100B1 (en) * 2004-11-30 2008-08-27 Koninklijke Philips Electronics N.V. Efficient switching between prioritized tasks
JP2007317171A (en) * 2006-04-27 2007-12-06 Matsushita Electric Ind Co Ltd Multi-thread computer system and multi-thread execution control method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1139171A (en) * 1997-07-18 1999-02-12 Masaharu Imai Multitask processor, multitask processing control method and control program storing medium
EP0942365A2 (en) * 1998-03-10 1999-09-15 Lucent Technologies Inc. Context controller having instruction-based time slice task switching capability and processor employing the same
GB2414575A (en) * 2004-05-26 2005-11-30 Advanced Risc Mach Ltd Management of polling loops in a data processing apparatus
TW200629068A (en) * 2004-09-10 2006-08-16 Ibm An integrated circuit chip for encryption and decryption having a secure mechanism for programming ON-chip hardware
TW200719276A (en) * 2005-11-10 2007-05-16 Via Tech Inc Method and device for saving and restoring a state context in a graphics processing unit

Also Published As

Publication number Publication date
TW200937294A (en) 2009-09-01
JP5155336B2 (en) 2013-03-06
WO2009090684A1 (en) 2009-07-23
JPWO2009090684A1 (en) 2011-05-26

Similar Documents

Publication Publication Date Title
TWI520056B (en) Virtual queue processing circuit and work processing device
TWI426452B (en) Work processing device
TWI416413B (en) Work processing device
TWI426451B (en) Work processing device
JP6153925B2 (en) Task processing device
TWI476696B (en) Work processing device
TWI537831B (en) Multi-core processor,method to perform process switching,method to secure a memory block, apparatus to enable transactional processing using a multi core device and method to perform memory transactional processing
CN101310257A (en) Multi-processor system and program for causing computer to execute multi-processor system control method
JP2018180768A (en) Semiconductor device
JP2017123190A (en) Task processing device
TW200925999A (en) Task processing device
JP5204740B2 (en) Task processing device
JP2008269597A (en) Task processor
JP2019003710A (en) Task processing device