TWI891494B - Electronic device and method for managing floating point unit resources - Google Patents
Electronic device and method for managing floating point unit resourcesInfo
- Publication number
- TWI891494B TWI891494B TW113132973A TW113132973A TWI891494B TW I891494 B TWI891494 B TW I891494B TW 113132973 A TW113132973 A TW 113132973A TW 113132973 A TW113132973 A TW 113132973A TW I891494 B TWI891494 B TW I891494B
- Authority
- TW
- Taiwan
- Prior art keywords
- state
- floating
- variable
- point
- task
- Prior art date
Links
Landscapes
- Advance Control (AREA)
Abstract
Description
本發明是關於電子裝置,尤其是關於浮點計算單元的資源管理。The present invention relates to electronic devices, and more particularly to resource management of floating-point computing units.
圖1顯示習知電子裝置的硬體資源。習知的電子裝置通常包含中央處理單元(central processing unit, CPU)及記憶體(揮發性記憶體(volatile memory)及/或非揮發性記憶體(nonvolatile memory))。CPU包含浮點計算單元(floating point unit, FPU)及多個CPU暫存器(例如,控制暫存器、通用暫存器及狀態暫存器)。FPU用來進行浮點數運算,且包含多個FPU暫存器。因此,如圖1所示,該電子裝置的硬體資源100包含CPU資源110(例如,CPU暫存器的內容)、記憶體資源120(例如,記憶體指標)及FPU資源130(例如,FPU暫存器的內容)。Figure 1 illustrates the hardware resources of a conventional electronic device. Conventional electronic devices typically include a central processing unit (CPU) and memory (volatile memory and/or nonvolatile memory). The CPU includes a floating point unit (FPU) and multiple CPU registers (e.g., control registers, general registers, and status registers). The FPU is used to perform floating-point operations and includes multiple FPU registers. Therefore, as shown in Figure 1, the hardware resources 100 of the electronic device include CPU resources 110 (e.g., the contents of CPU registers), memory resources 120 (e.g., memory pointers), and FPU resources 130 (e.g., the contents of FPU registers).
現今的作業系統通常可以進行多工處理。在切換任務(task)的過程中,作業系統必須妥當地保存硬體資源100以維持電子裝置的正確操作。硬體資源100的保存對多狀態的CPU同樣重要,特別是當多狀態對應不同的多系統(multisystem)時。否則,在切換狀態的過程中可能會導致資料處理錯誤,或甚至造成系統當機。Today's operating systems typically support multitasking. During task switching, the operating system must properly preserve hardware resources 100 to maintain the correct operation of electronic devices. Preserving hardware resources 100 is also crucial for multi-state CPUs, especially when the multiple states correspond to different multisystems. Otherwise, data processing errors may occur during state switching, or even cause a system crash.
鑑於先前技術之不足,本發明之一目的在於提供一種電子裝置及其浮點計算單元資源的管理方法,以改善先前技術的不足。In view of the shortcomings of the prior art, one object of the present invention is to provide an electronic device and a floating-point computing unit resource management method thereof to improve the shortcomings of the prior art.
本發明之一實施例提供一種電子裝置,包含:一計算電路以及一記憶體。該計算電路包含一浮點計算單元。該浮點計算單元包含一浮點計算單元暫存器。該計算電路操作於一第一狀態、一第二狀態及一第三狀態的其中之一。記憶體用來儲存一第一變數及一第二變數。當該計算電路從該第一狀態切換至該第二狀態,且該第一變數為一初始狀態時,該計算電路執行以下步驟:(A)將該第一變數指向該第二變數的所在位址;以及,(B)將該第二變數的一浮點計算單元資源內容填入該浮點計算單元暫存器。One embodiment of the present invention provides an electronic device comprising: a computing circuit and a memory. The computing circuit comprises a floating-point computing unit. The floating-point computing unit comprises a floating-point computing unit register. The computing circuit operates in one of a first state, a second state, and a third state. The memory is used to store a first variable and a second variable. When the computing circuit switches from the first state to the second state, and the first variable is in an initial state, the computing circuit performs the following steps: (A) points the first variable to the address of the second variable; and (B) fills the floating-point computing unit register with a floating-point computing unit resource content of the second variable.
本發明之另一實施例提供一種浮點計算單元資源的管理方法,應用於一電子裝置。該電子裝置包含一計算電路及一記憶體。該記憶體儲存一第一變數及一第二變數。該計算電路包含一浮點計算單元。該浮點計算單元包含一浮點計算單元暫存器。該計算電路操作於一第一狀態、一第二狀態及一第三狀態的其中之一。該管理方法包含:(A)當該計算電路從該第一狀態切換至該第二狀態,且該第一變數為一初始狀態時,將該第一變數指向該第二變數的所在位址;(B)將該第二變數的一浮點計算單元資源內容填入該浮點計算單元暫存器;以及,(C)控制該計算電路切換至該第二狀態。Another embodiment of the present invention provides a method for managing floating-point computing unit resources, which is applied to an electronic device. The electronic device includes a computing circuit and a memory. The memory stores a first variable and a second variable. The computing circuit includes a floating-point computing unit. The floating-point computing unit includes a floating-point computing unit register. The computing circuit operates in one of a first state, a second state, and a third state. The management method includes: (A) when the computing circuit switches from the first state to the second state and the first variable is an initial state, the first variable is pointed to the address of the second variable; (B) a floating-point computing unit resource content of the second variable is filled into the floating-point computing unit register; and (C) controlling the computing circuit to switch to the second state.
本發明之另一實施例提供一種浮點計算單元資源的管理方法,應用於一電子裝置。該電子裝置包含一計算電路及一記憶體。該記憶體儲存一第一變數及一第二變數。該計算電路包含一浮點計算單元。該浮點計算單元包含一浮點計算單元暫存器。該計算電路操作於一第一狀態、一第二狀態及一第三狀態的其中之一。該管理方法包含:當該第一變數非為一初始狀態,且該第一變數非指向該第二變數的位址時,將該浮點計算單元暫存器的內容保存至該第一變數所指的一任務的一任務控制塊。該任務屬於該第一狀態,且該任務控制塊儲存於該記憶體。Another embodiment of the present invention provides a method for managing floating-point calculation unit resources, which is applied to an electronic device. The electronic device includes a calculation circuit and a memory. The memory stores a first variable and a second variable. The calculation circuit includes a floating-point calculation unit. The floating-point calculation unit includes a floating-point calculation unit register. The calculation circuit operates in one of a first state, a second state, and a third state. The management method includes: when the first variable is not an initial state and the first variable does not point to the address of the second variable, saving the content of the floating-point calculation unit register to a task control block of a task pointed to by the first variable. The task belongs to the first state, and the task control block is stored in the memory.
本發明之實施例所體現的技術手段可以改善先前技術之缺點的至少其中之一,因此本發明相較於先前技術可以提升系統的安全穩定性。The technical means embodied in the embodiments of the present invention can improve at least one of the shortcomings of the prior art. Therefore, the present invention can improve the security and stability of the system compared to the prior art.
有關本發明的特徵、實作與功效,茲配合圖式作實施例詳細說明如下。The features, implementation, and effects of the present invention are described in detail below with reference to the accompanying drawings.
以下說明內容之技術用語係參照本技術領域之習慣用語,如本說明書對部分用語有加以說明或定義,該部分用語之解釋係以本說明書之說明或定義為準。The technical terms used in the following descriptions are based on customary terms in the technical field. If this manual provides explanations or definitions for certain terms, the interpretation of those terms shall be based on the explanations or definitions in this manual.
本發明之揭露內容包含電子裝置及其浮點計算單元資源的管理方法。由於本發明之電子裝置所包含之部分元件單獨而言可能為已知元件,因此在不影響該裝置發明之充分揭露及可實施性的前提下,以下說明對於已知元件的細節將予以節略。此外,本發明之浮點計算單元資源的管理方法的部分或全部流程可以是軟體及/或韌體之形式,並且可藉由本發明之電子裝置或其等效裝置來執行,在不影響該方法發明之充分揭露及可實施性的前提下,以下方法發明之說明將著重於步驟內容而非硬體。The disclosure of the present invention includes an electronic device and a method for managing floating-point computing unit resources thereof. Because some components included in the electronic device of the present invention may individually be known components, details regarding known components will be omitted in the following description without affecting the full disclosure and feasibility of the device invention. Furthermore, some or all of the processes of the floating-point computing unit resource management method of the present invention may be in the form of software and/or firmware and may be executed by the electronic device of the present invention or its equivalent. Without affecting the full disclosure and feasibility of the method invention, the following description of the method invention will focus on the steps rather than the hardware.
請參閱圖2,圖2是本發明電子裝置之一實施例的功能方塊圖。電子裝置200包含互相耦接的計算電路210及記憶體220(包含但不限於揮發性記憶體及/或非揮發性記憶體)。計算電路210包含FPU 215,而且更耦接外部記憶體230(包含但不限於揮發性記憶體及/或非揮發性記憶體)。記憶體220儲存程式碼及/或程式指令。計算電路210可以是具有程式執行能力的電路或電子元件,例如CPU、微處理器、微處理單元、數位訊號處理器、特殊應用積體電路(Application Specific Integrated Circuit, ASIC),或其等效電路。計算電路210藉由執行該些程式碼及/或程式指令來執行電子裝置200的作業系統及/或應用程式。在以下的說明中假設計算電路210是以CPU實作,但本發明不以此為限。Please refer to Figure 2, which is a functional block diagram of one embodiment of an electronic device of the present invention. Electronic device 200 includes a computing circuit 210 and a memory 220 (including but not limited to volatile memory and/or non-volatile memory) coupled to each other. Computing circuit 210 includes an FPU 215 and is further coupled to an external memory 230 (including but not limited to volatile memory and/or non-volatile memory). Memory 220 stores program code and/or program instructions. Computing circuit 210 can be a circuit or electronic component with program execution capabilities, such as a CPU, a microprocessor, a microprocessing unit, a digital signal processor, an application-specific integrated circuit (ASIC), or an equivalent circuit thereof. The computing circuit 210 executes the program codes and/or program instructions to execute the operating system and/or application programs of the electronic device 200. In the following description, it is assumed that the computing circuit 210 is implemented as a CPU, but the present invention is not limited thereto.
計算電路210可以執行至少一作業系統,並且可以處理多個任務(task)。圖3顯示一個任務的任務控制塊(task control block, TCB)。任務控制塊300是用來儲存任務運行時的相關狀態以及資訊的一塊記憶體空間(例如,可以是記憶體220的一部分)。任務控制塊300包含任務的識別碼310、優先級320、名稱330及FPU資源內容(context)340等資訊。FPU資源內容340用來儲存FPU 215的暫存器的值。Computing circuitry 210 can execute at least one operating system and process multiple tasks. Figure 3 shows a task control block (TCB) for a task. Task control block 300 is a memory space (e.g., a portion of memory 220) used to store task status and information during execution. Task control block 300 includes information such as the task's identifier 310, priority 320, name 330, and FPU resource context 340. FPU resource context 340 is used to store the values of FPU 215 registers.
計算電路210可以操作於多個狀態以執行多個系統。請參閱圖4,圖4是本發明計算電路在多個狀態之間切換的示意圖。計算電路210在第一狀態410執行第一作業系統,以及在第二狀態420執行第二作業系統。當計算電路210要從第一狀態410切換至第二狀態420,或是從第二狀態420切換至第一狀態410時,計算電路210先進入第三狀態430。第三狀態430是超高權限暫時狀態(或稱為監控(monitor)模式)。第三狀態430的權限高於第一狀態410的權限及第二狀態420的權限。在第三狀態430中,計算電路210具有切換狀態的權限,並且藉由執行監控韌體(monitor firmware)來進行作業系統間(或狀態間)的上下文交換(context switch,亦稱環境切換)(將於下方配合圖8及圖9詳述)。在一些實施例中,第一狀態410是安全狀態(security state),而第二狀態420是非安全狀態(non-security state),且第一狀態410的權限高於第二狀態420的權限。在一些實施例中,第一作業系統是簡單作業系統(simple OS),而第二作業系統是複雜作業系統(Rich OS)。The computing circuit 210 can operate in multiple states to execute multiple systems. Please refer to Figure 4, which is a schematic diagram of the computing circuit of the present invention switching between multiple states. The computing circuit 210 executes a first operating system in the first state 410 and a second operating system in the second state 420. When the computing circuit 210 switches from the first state 410 to the second state 420, or from the second state 420 to the first state 410, the computing circuit 210 first enters the third state 430. The third state 430 is a temporary state with ultra-high privileges (also known as monitor mode). The privileges of the third state 430 are higher than those of the first state 410 and the second state 420. In the third state 430, the computing circuit 210 has permission to switch states and executes monitor firmware to perform context switching (also known as environment switching) between operating systems (or states) (described in detail below with reference to Figures 8 and 9). In some embodiments, the first state 410 is a security state, while the second state 420 is a non-security state, and the permissions of the first state 410 are higher than those of the second state 420. In some embodiments, the first operating system is a simple operating system (Simple OS), while the second operating system is a rich operating system (Rich OS).
請參閱圖5,圖5是本發明上下文交換的示意圖。在圖5的例子中,計算電路210從前一個任務TAp(對應到硬體資源內容500P)切換到當前的任務TAc(對應到硬體資源內容500C)。更明確地說,在進行任務切換時,計算電路210的作業系統先將前一個任務TAp所使用的硬體資源(包含CPU暫存器510的內容、FPU暫存器520的內容,以及記憶體指標530)保存至該前一個任務TAp的硬體資源內容500P,再恢復當前的任務TAc的硬體資源內容500C(即,將硬體資源內容500C儲存至CPU暫存器510、FPU暫存器520及記憶體指標530)。接著,計算電路210便可執行當前的任務TAc。FPU暫存器520包含於FPU 215中。在一些實施例中,FPU暫存器520的內容被保存至前一個任務TAp的任務控制塊300(更明確地說,保存至FPU資源內容340)。Please refer to Figure 5, which is a schematic diagram of context switching according to the present invention. In the example of Figure 5, the computing circuit 210 switches from the previous task TAp (corresponding to the hardware resource content 500P) to the current task TAc (corresponding to the hardware resource content 500C). More specifically, during a task switch, the operating system of the computing circuit 210 first saves the hardware resources used by the previous task TAP (including the contents of the CPU registers 510, the contents of the FPU registers 520, and the memory pointers 530) to the hardware resource contents 500P of the previous task TAP. It then restores the hardware resource contents 500C of the current task TAc (i.e., stores the hardware resource contents 500C in the CPU registers 510, the FPU registers 520, and the memory pointers 530). The computing circuit 210 then executes the current task TAc. The FPU registers 520 are included in the FPU 215. In some embodiments, the contents of the FPU register 520 are saved to the task control block 300 of the previous task TAp (more specifically, to the FPU resource contents 340).
請參閱圖6,圖6是本發明狀態內任務切換之一實施例的流程圖。當計算電路210從前一個任務TAp切換到當前的任務TAc時,計算電路210(或其所執行的作業系統)執行上下文交換(步驟S610,請參閱圖5的說明)及關閉FPU 215(步驟S620),然後執行當前的任務TAc(步驟S630)。當當前的任務TAc將使用FPU 215時,因為FPU 215是關閉狀態,所以計算電路210會產生一個異常信號。作業系統捕捉到該異常信號後,作業系統執行相對應的異常處理流程。在該異常處理流程中,作業系統會開啟FPU 215並且視情況進行FPU資源的保存及/或恢復(將於下方配合圖7詳述)。當計算電路210再次執行任務切換時(即,圖6的流程),FPU 215將再次被關閉(步驟S620)。Please refer to Figure 6, which is a flowchart of one embodiment of intra-state task switching according to the present invention. When the computing circuit 210 switches from the previous task TAP to the current task TAc, the computing circuit 210 (or the operating system it executes) performs a context switch (step S610, see the description of Figure 5) and shuts down the FPU 215 (step S620), then executes the current task TAc (step S630). When the current task TAc is about to use the FPU 215, because the FPU 215 is in a shut-down state, the computing circuit 210 generates an exception signal. After the operating system detects this exception signal, it executes the corresponding exception handling process. During this exception handling process, the operating system will enable the FPU 215 and, as appropriate, save and/or restore FPU resources (described in detail below with reference to FIG. 7 ). When the computing circuit 210 performs a task switch again (i.e., the process of FIG. 6 ), the FPU 215 will be disabled again (step S620 ).
在一些實施例中,計算電路210(或其所執行的作業系統)藉由改變某個控制暫存器的暫存值來開啟或關閉FPU 215。In some embodiments, the computing circuit 210 (or the operating system it executes) turns the FPU 215 on or off by changing the value of a control register.
請參閱圖7,圖7是本發明FPU資源管理方法之一實施例的流程圖。在以下的說明中,假設計算電路210操作於第一狀態410或第二狀態420,並且由前一個任務TAp切換至當前的任務TAc。圖7的流程是作業系統的一部分,並且包含以下的步驟。Please refer to Figure 7, which is a flow chart of one embodiment of the FPU resource management method of the present invention. In the following description, it is assumed that the computing circuit 210 is operating in the first state 410 or the second state 420 and is switching from the previous task TAp to the current task TAc. The flow chart of Figure 7 is part of an operating system and includes the following steps.
步驟S710:作業系統收到異常信號,表示當前的任務TAc包含浮點指令,而該浮點指令將使用FPU 215。Step S710: The operating system receives an exception signal indicating that the current task TAc contains a floating-point instruction, and the floating-point instruction will use the FPU 215.
步驟S720:計算電路210判斷變數A是否指向當前的任務TAc(即,計算電路210所正在執行的任務)。更明確地說,變數A指向某個任務的任務控制塊300或是該任務控制塊300的FPU資源內容340。變數A可以儲存在記憶體220。步驟S720的結果為是表示當前的任務TAc在上次使用過FPU 215後經歷數次上下文交換,而過程中曾經運作的任務都未使用FPU 215。Step S720: The computing circuit 210 determines whether variable A points to the current task TAc (i.e., the task currently being executed by the computing circuit 210). More specifically, variable A points to a task control block 300 or the FPU resource contents 340 of that task control block 300. Variable A may be stored in memory 220. A yes result in step S720 indicates that the current task TAc has undergone several context switches since it last used the FPU 215, and that no previously executed tasks have used the FPU 215.
步驟S730:計算電路210不改變FPU暫存器520的內容,也不保存FPU暫存器520的內容。如前一步驟所述,因為從前一次FPU 215被使用以來,FPU暫存器520的內容沒有改變,所以計算電路210(更明確地說,FPU 215)此時可以基於當前的FPU暫存器520的內容繼續執行當前的任務TAc的浮點指令(步驟S740)。Step S730: The computing circuit 210 does not change the contents of the FPU register 520, nor does it save the contents of the FPU register 520. As described in the previous step, since the contents of the FPU register 520 have not changed since the last time the FPU 215 was used, the computing circuit 210 (more specifically, the FPU 215) can now continue to execute floating-point instructions of the current task TAc based on the current contents of the FPU register 520 (step S740).
步驟S750:計算電路210判斷變數A是否為初始狀態。初始狀態可以是變數A未賦值或是變數A為一預設值。當電子裝置200剛啟動時,變數A為該初始狀態(即,未賦值或是等於該預設值)。Step S750: The calculation circuit 210 determines whether the variable A is in an initial state. The initial state can be that the variable A is unassigned or that the variable A is a default value. When the electronic device 200 is first started, the variable A is in the initial state (i.e., unassigned or equal to the default value).
當變數A為該初始狀態時(步驟S750為是,表示電子裝置200開機後FPU 215未被使用過),作業系統恢復當前的任務TAc的FPU資源內容340,也就是將當前的任務TAc的FPU資源內容340填入FPU暫存器520(步驟S770)。需注意的是,當當前的任務TAc未使用過FPU 215時,當前的任務TAc的FPU資源內容340是初始化的FPU資源內容。When variable A is in the initial state (yes in step S750, indicating that the FPU 215 has not been used since the electronic device 200 was powered on), the operating system restores the FPU resource contents 340 of the current task TAc, that is, it fills the FPU resource contents 340 of the current task TAc into the FPU register 520 (step S770). It should be noted that when the current task TAc has not used the FPU 215, the FPU resource contents 340 of the current task TAc are initialized FPU resource contents.
當變數A不為該初始狀態時(步驟S750為否,表示電子裝置200開機後FPU 215曾被使用過),作業系統將FPU暫存器520的內容保存至前一個任務TAp的FPU資源內容340(步驟S760),然後執行步驟S770。When variable A is not in the initial state (step S750 is No, indicating that the FPU 215 has been used since the electronic device 200 was powered on), the operating system saves the contents of the FPU register 520 to the FPU resource contents 340 of the previous task TAp (step S760), and then executes step S770.
步驟S780:作業系統將變數A指向當前的任務TAc(用來指示最近一次使用FPU 215的任務是當前的任務TAc),然後執行當前的任務TAc(步驟S740)。Step S780: The operating system points variable A to the current task TAc (to indicate that the task that most recently used the FPU 215 is the current task TAc), and then executes the current task TAc (step S740).
在一些實施例中,第一狀態410與第二狀態420都基於圖7的流程進行FPU資源管理。在不同的實施例中,第一狀態410基於圖7的流程進行FPU資源管理,而第二狀態420基於其他的方法(例如,習知的積極式載入(eager loading)方式)來進行FPU資源管理。In some embodiments, both the first state 410 and the second state 420 manage FPU resources based on the process of Figure 7. In different embodiments, the first state 410 manages FPU resources based on the process of Figure 7, while the second state 420 manages FPU resources based on other methods (e.g., the known eager loading method).
請參閱圖8,圖8是本發明狀態間切換之一實施例的流程圖。當計算電路210從第二狀態420切換到第一狀態410時,第二狀態420的作業系統控制計算電路210進入第三狀態430(步驟S810),然後第三狀態430的監控韌體關閉FPU 215(步驟S820),再控制計算電路210切換至第一狀態410(步驟S830)。Please refer to Figure 8, which is a flow chart illustrating one embodiment of state switching according to the present invention. When the computing circuit 210 switches from the second state 420 to the first state 410, the operating system in the second state 420 controls the computing circuit 210 to enter the third state 430 (step S810). The monitoring firmware in the third state 430 then shuts down the FPU 215 (step S820) and then controls the computing circuit 210 to switch back to the first state 410 (step S830).
請參閱圖9,圖9是本發明FPU資源管理方法之另一實施例的流程圖。在本實施例中,變數A及變數B儲存在電子裝置200的共享記憶體(例如,記憶體220的一部分),且由第一狀態410的作業系統及第三狀態430的監控韌體共用。變數B用來儲存當計算電路210即將從第二狀態420切換至第一狀態410時FPU暫存器520的內容。變數A指向變數B所在位址,或第一狀態410的某一個任務。在以下的說明中,假設計算電路210將由第一狀態410切換至第二狀態420,而且第二狀態420的作業系統可能會使用FPU 215。圖9的流程是在第三狀態430中執行(也就是監控韌體的一部分),並且包含以下的步驟。Please refer to Figure 9, which is a flow chart of another embodiment of the FPU resource management method of the present invention. In this embodiment, variables A and B are stored in a shared memory of the electronic device 200 (for example, a portion of the memory 220) and are shared by the operating system in the first state 410 and the monitoring firmware in the third state 430. Variable B is used to store the contents of the FPU register 520 when the computing circuit 210 is about to switch from the second state 420 to the first state 410. Variable A points to the address where variable B is located, or a task in the first state 410. In the following description, it is assumed that the computing circuit 210 is about to switch from the first state 410 to the second state 420, and the operating system in the second state 420 may use the FPU 215. The process of FIG9 is executed in the third state 430 (ie, a portion of the monitoring firmware) and includes the following steps.
步驟S910:計算電路210判斷變數A是否為初始狀態。請參考步驟S750的說明。Step S910: The calculation circuit 210 determines whether the variable A is in the initial state. Please refer to the description of step S750.
當變數A為該初始狀態時(步驟S910為是,表示第一狀態410的作業系統到目前為止尚未使用過FPU 215),計算電路210將變數A指向變數B所在位址(例如,記憶體220中的某個位址)(步驟S920),再將變數B的FPU資源內容填入FPU暫存器520(步驟S930),然後控制計算電路210切換至第二狀態420(步驟S960)。需注意的是,當第二狀態420的作業系統未使用過FPU 215時,變數B的FPU資源內容是初始化的FPU資源內容。When variable A is in the initial state (yes in step S910, indicating that the operating system in the first state 410 has not yet used the FPU 215), the computing circuit 210 points variable A to the address of variable B (e.g., an address in memory 220) (step S920), then populates the FPU resource contents of variable B into the FPU register 520 (step S930), and then controls the computing circuit 210 to switch to the second state 420 (step S960). It should be noted that when the operating system in the second state 420 has not yet used the FPU 215, the FPU resource contents of variable B are initialized FPU resource contents.
當變數A不為該初始狀態時(步驟S910為否,表示FPU 215曾被使用過),計算電路210判斷變數A是否指向變數B所在位址(步驟S940)。When variable A is not in the initial state (step S910 is no, indicating that the FPU 215 has been used), the calculation circuit 210 determines whether variable A points to the address where variable B is located (step S940).
當變數A指向變數B所在位址時(步驟S940為是,表示最近一次第一狀態410的作業系統運行期間,所有的任務都未使用FPU 215),第三狀態430的監控韌體控制計算電路210切換至第二狀態420(步驟S960)。When variable A points to the address of variable B (step S940 is yes, indicating that during the most recent operation of the operating system in the first state 410, all tasks did not use the FPU 215), the monitoring firmware in the third state 430 controls the computing circuit 210 to switch to the second state 420 (step S960).
當變數A不指向變數B所在位址時(步驟S940為否,表示最近一次第一狀態410的作業系統運行期間,有任務TAx曾使用FPU 215),第三狀態430的監控韌體將FPU暫存器520的內容保存到變數A所指的任務(即,屬於該第一狀態410之任務TAx)的任務控制塊300(更明確地說,保存到FPU資源內容340)(步驟S950)。接著,監控韌體於執行步驟S920及步驟S930後,控制計算電路210切換至第二狀態420(步驟S960)。If variable A does not point to the address of variable B (step S940 is negative, indicating that task TAx used FPU 215 during the most recent operating system run in first state 410), the monitoring firmware in third state 430 saves the contents of FPU register 520 to task control block 300 (more specifically, to FPU resource content 340) of the task pointed to by variable A (i.e., task TAx in first state 410) (step S950). After executing steps S920 and S930, the monitoring firmware controls computing circuit 210 to switch to second state 420 (step S960).
綜上所述,本發明提供了一個完善的FPU資源的管理方法(即,暫存器的保存及/或恢復策略),使得計算電路210在狀態內(對應到圖6~7的流程)及狀態間(對應到圖8~9的流程)都可以妥善地管理FPU資源,大幅減少支援多系統的計算電路210於狀態間切換下的FPU資源保存及/或恢復的時間和空間開銷,並兼顧安全穩定性。此外,當計算電路210由第二狀態420切換第一狀態410時,無需花費任何保存FPU資源的成本(僅需關閉FPU 215,請參閱圖8);而當計算電路210由第一狀態410切換到第二狀態420時,保存及/或恢復FPU資源的頻率也遠小於習知的積極式載入方式。因此,本發明不僅可以顧及狀態轉換前後的安全穩定性,也可以大幅減少因程式碼使用FPU所造成的保存及/或恢復該資源的時間開銷,使得狀態之間的轉換更為快速省時。In summary, the present invention provides a comprehensive FPU resource management method (i.e., register save and/or restore strategy) that allows the computing circuit 210 to properly manage FPU resources both within a state (corresponding to the processes of Figures 6-7) and between states (corresponding to the processes of Figures 8-9). This significantly reduces the time and space overhead of saving and/or restoring FPU resources when switching between states of the computing circuit 210, supporting multiple systems, while also ensuring safety and stability. Furthermore, when the computing circuit 210 switches from the second state 420 to the first state 410, no FPU resource preservation costs are incurred (only the FPU 215 needs to be shut down, see FIG8 ). Furthermore, when the computing circuit 210 switches from the first state 410 to the second state 420, the frequency of saving and/or restoring FPU resources is significantly lower than that of conventional active loading methods. Therefore, the present invention not only ensures security and stability before and after state transitions, but also significantly reduces the time overhead of saving and/or restoring FPU resources caused by program code using the FPU, making transitions between states faster and more time-efficient.
雖然本發明之實施例如上所述,然而該些實施例並非用來限定本發明,本技術領域具有通常知識者可根據本發明之明示或隱含之內容對本發明之技術特徵施以變化,凡此種種變化均可能屬於本發明所尋求之專利保護範疇,換言之,本發明之專利保護範圍須視本說明書之申請專利範圍所界定者為準。Although the embodiments of the present invention are described above, these embodiments are not intended to limit the present invention. Those skilled in the art may modify the technical features of the present invention based on the explicit or implicit content of the present invention. All such modifications may fall within the scope of the patent protection sought by the present invention. In other words, the scope of patent protection for the present invention shall be determined by the scope of the patent application in this specification.
100:硬體資源 110:CPU資源 120:記憶體資源 130:FPU資源 200:電子裝置 210:計算電路 215:FPU(浮點計算單元) 220:記憶體 230:外部記憶體 300:任務控制塊 310:識別碼 320:優先級 330:名稱 340:FPU資源內容 410:第一狀態 420:第二狀態 430:第三狀態 500C,500P:硬體資源內容 510:CPU暫存器 520:FPU暫存器 530:記憶體指標 S610,S620,S630,S710,S720,S730,S740,S750,S760,S770,S780,S810,S820,S830,S910,S920,S930,S940,S950,S960:步驟100: Hardware Resources 110: CPU Resources 120: Memory Resources 130: FPU Resources 200: Electronic Devices 210: Computing Circuits 215: FPU (Floating Point Unit) 220: Memory 230: External Memory 300: Task Control Block 310: Identifier 320: Priority 330: Name 340: FPU Resource Details 410: First State 420: Second State 430: Third State 500C, 500P: Hardware Resource Details 510: CPU Registers 520: FPU Registers 530: Memory Pointers S610,S620,S630,S710,S720,S730,S740,S750,S760,S770,S780,S810,S820,S830,S910,S920,S930,S940,S950,S960: Step
圖1顯示習知電子裝置的硬體資源; 圖2是本發明電子裝置之一實施例的功能方塊圖; 圖3顯示一個任務的任務控制塊; 圖4是本發明計算電路在多個狀態之間切換的示意圖; 圖5是本發明上下文交換的示意圖; 圖6是本發明狀態內任務切換之一實施例的流程圖; 圖7是本發明FPU資源管理方法之一實施例的流程圖; 圖8是本發明狀態間切換之一實施例的流程圖;以及 圖9是本發明FPU資源管理方法之另一實施例的流程圖。 Figure 1 illustrates hardware resources of a known electronic device; Figure 2 is a functional block diagram of an embodiment of an electronic device according to the present invention; Figure 3 illustrates a task control block of a task; Figure 4 is a schematic diagram illustrating switching between multiple states of a computing circuit according to the present invention; Figure 5 is a schematic diagram illustrating context switching according to the present invention; Figure 6 is a flowchart of an embodiment of intra-state task switching according to the present invention; Figure 7 is a flowchart of an embodiment of an FPU resource management method according to the present invention; Figure 8 is a flowchart of an embodiment of inter-state switching according to the present invention; and Figure 9 is a flowchart of another embodiment of an FPU resource management method according to the present invention.
S910,S920,S930,S940,S950,S960:步驟 S910, S920, S930, S940, S950, S960: Steps
Claims (17)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW113132973A TWI891494B (en) | 2024-08-30 | 2024-08-30 | Electronic device and method for managing floating point unit resources |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW113132973A TWI891494B (en) | 2024-08-30 | 2024-08-30 | Electronic device and method for managing floating point unit resources |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| TWI891494B true TWI891494B (en) | 2025-07-21 |
Family
ID=97228269
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| TW113132973A TWI891494B (en) | 2024-08-30 | 2024-08-30 | Electronic device and method for managing floating point unit resources |
Country Status (1)
| Country | Link |
|---|---|
| TW (1) | TWI891494B (en) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| TW201102929A (en) * | 2009-06-19 | 2011-01-16 | Advanced Risc Mach Ltd | Data processing apparatus and method |
| TW201702890A (en) * | 2015-07-15 | 2017-01-16 | Arm股份有限公司 | Secure mode state data access tracking |
| US20210049011A1 (en) * | 2019-08-14 | 2021-02-18 | Jerry D. Harthcock | Universal floating-point instruction set architecture for computing directly with decimal character sequences and binary formats in any combination |
| US20230153265A1 (en) * | 2019-09-10 | 2023-05-18 | Cornami, Inc. | Reconfigurable Processor Circuit Architecture |
-
2024
- 2024-08-30 TW TW113132973A patent/TWI891494B/en active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| TW201102929A (en) * | 2009-06-19 | 2011-01-16 | Advanced Risc Mach Ltd | Data processing apparatus and method |
| TW201702890A (en) * | 2015-07-15 | 2017-01-16 | Arm股份有限公司 | Secure mode state data access tracking |
| US20210049011A1 (en) * | 2019-08-14 | 2021-02-18 | Jerry D. Harthcock | Universal floating-point instruction set architecture for computing directly with decimal character sequences and binary formats in any combination |
| US20230153265A1 (en) * | 2019-09-10 | 2023-05-18 | Cornami, Inc. | Reconfigurable Processor Circuit Architecture |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN102804134B (en) | Apparatus and method for handling exception events | |
| US5701493A (en) | Exception handling method and apparatus in data processing systems | |
| CN103365630B (en) | Semiconductor equipment | |
| KR20120052934A (en) | Data processing apparatus and method | |
| US20220374278A1 (en) | Methods of Hardware and Software-Coordinated Opt-In to Advanced Features on Hetero ISA Platforms | |
| KR20070080089A (en) | Interrupt Handling Method and Device in Reconstruction Array | |
| EP3944174B1 (en) | Methods and processors for performing resource deduction for execution of smart contract | |
| TWI891494B (en) | Electronic device and method for managing floating point unit resources | |
| US6820153B2 (en) | Interrupt processing and memory management method in an operation processing device and a device using the same | |
| JPH1196002A (en) | Data processor | |
| CN119166340A (en) | Electronic device and floating point computing unit resource management method thereof | |
| JP4057769B2 (en) | Interrupt management device and interrupt management method | |
| US5778207A (en) | Assisting operating-system interrupts using application-based processing | |
| JP2007164672A (en) | Programs, operating systems, and compilers | |
| CN119512820A (en) | Application restart method, device and storage medium based on dual process | |
| EP1104899A2 (en) | Data processing apparatus and method of controlling the same | |
| JPH04247523A (en) | Device and method for processing exception | |
| JPH11265284A (en) | Data processor | |
| KR20100033833A (en) | Method of reading data coherently | |
| GB2500844A (en) | Selecting either base level or further level stack when processing data in current further level exception state above base level | |
| JPH07200281A (en) | Patching execution system for program | |
| JP2001005677A (en) | Information processing device and storage medium | |
| JPS61255440A (en) | Program interruption control system | |
| JP2000020155A (en) | Temporary suspension / resumption control method for system operation | |
| JPS6212535B2 (en) |