WO2010146328A1 - Data processing apparatus and method - Google Patents
Data processing apparatus and method Download PDFInfo
- Publication number
- WO2010146328A1 WO2010146328A1 PCT/GB2010/000879 GB2010000879W WO2010146328A1 WO 2010146328 A1 WO2010146328 A1 WO 2010146328A1 GB 2010000879 W GB2010000879 W GB 2010000879W WO 2010146328 A1 WO2010146328 A1 WO 2010146328A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- floating point
- data processing
- integer
- registers
- stack
- Prior art date
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/38—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
- G06F7/48—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
- G06F7/483—Computations with numbers represented by a non-linear combination of denominational numbers, e.g. rational numbers, logarithmic number system or floating-point numbers
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/461—Saving or restoring of program or task context
- G06F9/462—Saving or restoring of program or task context with multiple register sets
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30098—Register arrangements
- G06F9/3012—Organisation of register space, e.g. banked or distributed register file
- G06F9/3013—Organisation of register space, e.g. banked or distributed register file according to data content, e.g. floating-point registers, address registers
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/14—Handling requests for interconnection or transfer
- G06F13/20—Handling requests for interconnection or transfer for access to input/output bus
- G06F13/24—Handling requests for interconnection or transfer for access to input/output bus using interrupt
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/461—Saving or restoring of program or task context
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4812—Task transfer initiation or dispatching by interrupt, e.g. masked
Definitions
- a data processing apparatus For many applications, it is desirable for a data processing apparatus to be able to interrupt a current process in which data processing instructions are being executed in order to service another process. While the interrupted process could be terminated entirely and restarted from the beginning once the interrupting process has been serviced, it is desirable to be able to restart the interrupted process from the point at which it was interrupted. In order to achieve this, it is known to copy the contents of a register file storing the current parameters and the current state of the existing process to a stack memory prior to switching to the new process.
- a process runs in a context, which is the system state required for the process to run correctly.
- this state includes the values of certain integer processor registers, including the program counter, stack pointer and link register, and the values of the floating point registers if these are required by the process. Switching between processes therefore requires a switch in the context, including register values, and so a return from an interrupting process to the previous interrupted process therefore requires the preservation and restoration of the context corresponding to the interrupted process.
- a data processing apparatus comprising: processing circuitry responsive to data processing instructions to execute integer data processing operations and floating point data processing operations; a first set of integer registers useable by said processing circuitry in executing said integer data processing operations, and a second set of floating point registers useable by said processing circuitry in executing said floating point data processing operations; wherein said processing circuitry is responsive to an interrupt request to perform one of an integer state preservation function in which at least a subset of only said integer registers are copied to a stack memory, and a floating point state preservation function in which at least a subset of both said integer registers and said floating point registers are copied to said stack memory, said one of said integer state preservation function and said floating point state preservation function being selected by said processing circuitry in dependence on state information.
- the more time and space intensive floating point state preservation function (which backs up at least some of both the integer registers and the floating point registers) is conducted only when the state information indicates that the floating point registers need to be backed up. Otherwise, if the state information indicates that only the integer registers need to be backed up, the less time and space intensive integer state preservation function is conducted to back up only the integer registers.
- backwards compatibility is preserved, by maintaining interrupt latency and private stack size requirements for integer-only code. Accordingly, undesirable requirements to increase stack-frame sizes on legacy (integer-only) code and to adjust legacy interrupt handlers to accommodate increased latency may be avoided, or at least mitigated.
- embodiments of the present invention reduce the memory size requirement through reduced stack sizes, and reduce the number of memory accesses compared with the basic solution of always preserving floating point registers. As a result, power usage and interrupt latency can be reduced.
- the state information may comprise first state information which is indicative of whether a current data processing context being executed by said processing circuitry when the interrupt request is received is a floating point data processing context which includes one or more floating point data processing operations or an integer data processing context which does, not include any floating point data processing operations.
- This first state information may be set in response to a data processing instruction which causes the processing circuitry to execute floating point data processing operations.
- the processing circuitry may be responsive to the interrupt request to perform said integer state preservation function if the first state information indicates that the current data processing context is an integer data processing context, and to perform the floating point state preservation function if the first state information indicates that the current data processing context is a floating point data processing context. This configuration enables floating point state preservation to be conducted only when an interrupted process is using the floating point registers.
- the integer state recovery function is selected by the processing circuitry if the second state information indicates that the floating point registers have not been stored into the stack memory, and the floating point state recovery function is selected by the processing circuitry if the second state information indicates that the floating point registers have been stored into the stack memory.
- the processing circuitry may be responsive to the interrupt request to perform the integer state preservation function if the first state information indicates that the current data processing context is an integer data processing context, and to perform, if the first state information indicates that the current data processing context is a floating point data processing context, a first part of the floating point state preservation function in which only the subset of integer registers are copied to the stack memory and a second part of the floating point state preservation function in which space is allocated on the stack memory for the subset of floating point registers.
- the processing circuitry sets second state information to indicate that space for the floating point registers has not been allocated to the stack memory, and when the second part of the floating point state preservation function is performed, the processing circuitry sets the second state information to indicate that space for the floating point registers has been allocated in the stack memory.
- the processing circuitry may then be responsive to a data processing instruction following the allocation of space on the stack memory which causes the processing circuitry to execute floating point data processing operations to perform a third part of the floating point state preservation function in which the subset of floating point registers are copied to the allocated portion of the stack memory.
- a stack allocation address register may be provided for storing the memory address of the portion of the stack memory allocated in the second part of said floating point state preservation function, wherein the processing circuitry copies the floating point registers to an address within the stack memory indicated by the stack allocation address register in the third part of the floating point state preservation function.
- the integer state recovery function is selected by the processing circuitry if the second state information indicates that the floating point registers have not been stored into the stack memory or if the second state information indicates that space has been allocated in the stack memory for the floating point registers and the third state information indicates that the copying of the subset of floating point registers to the allocated portion of the stack memory has not yet occurred, and the floating point state recovery function is selected by said processing circuitry if the second state information indicates that space has been allocated in the stack memory for the floating point registers and the third state information indicates that the subset of floating point registers have been copied to the allocated portion of the stack memory. In this way, if space on the stack has been allocated to the floating point registers but the content of the floating point registers has not actually been copied into the allocated space, only the integer registers are recovered from the stack.
- the first state information is set to indicate that the current data processing context is an integer data processing context
- the first state information is set to indicate that the current data processing context is a floating point data processing context
- the state information may comprise first state information which is indicative of whether a current data processing context being executed by the processing circuitry when the interrupt request is received is a floating point data processing context which includes one or more floating point data processing operations or an integer data processing context which does not include any floating point data processing operations.
- the state information may also include second state information which is indicative of whether a target data processing context to be executed by the processing circuitry as a result of said interrupt request is a floating point data processing context which includes one or more floating point data processing operations or an integer data processing context which does not include any floating point data processing operations.
- the state information may also comprise third state information which is indicative of whether a current data processing context is a thread data processing context which has not been triggered by an interrupt request, or a handler data processing context which has been triggered by an interrupt request.
- third state information is indicative of whether a current data processing context is a thread data processing context which has not been triggered by an interrupt request, or a handler data processing context which has been triggered by an interrupt request.
- a thread mode is a baseline process, that is, a process which is not triggered by an interrupt or exception.
- a handler mode is an interrupting mode which interrupts either a thread mode process or another handler process, hi other words, the destination of an exception or interrupt is always a handler, but the origin may be either a thread or a handler.
- Embodiments of the present invention provide additional machine state that annotates each handler as either using the floating point hardware (a float-handler), or not (an integer-handler). Similarly, additional machine state can be provided indicating that the current thread uses the floating point hardware (a float-thread) or not (an integer-thread).
- the additional machine state is used to limit floating point state preservation to the case where the destination process is a "float-handler" and the origin process is not an "integer-thread” (i.e. where the origin is either a float-thread, a float handler or an integer handler).
- floating point state preservation does not take place if the interrupting handler is an integer handler, because the interrupting process will not overwrite the floating point registers.
- interrupting handler is a floating point handler
- floating point preservation does not take place if the interrupted (origin) process is an integer thread, because in this case the floating point registers which may be overwritten by the floating point handler are not required by the interrupted process, and the interrupted process does not itself interrupt any other process which might require the floating point registers (because it is a thread rather than a handler).
- the processing circuitry may be responsive to state information indicating that the target data processing context is a floating point data processing context, and that the current data processing context is either a floating point data processing context, or an integer data processing context triggered by an interrupt request, to select the floating point state preservation function.
- state information indicating that the target data processing context is a floating point data processing context, and that the current data processing context is either a floating point data processing context, or an integer data processing context triggered by an interrupt request.
- the processing circuitry may be responsive to state information indicating that the current data processing context is an integer data processing context and that the target data processing context is an integer data processing context to select the integer state preservation function. In this way, the latency of a state preservation function in the case of an integer exception remains constant with legacy code.
- the processing circuitry may be responsive to state information indicating that the current data processing context is a floating point data processing context and that the target data processing context is a floating point data processing context to select the floating point state preservation function. In this way, floating point state preservation can be provided for potentially active floating-point state.
- the processing circuitry may be responsive to state information indicating that the current data processing context is an integer data processing context not triggered by an interrupt request, and that the target data processing context is a floating point data processing context, to select the integer state preservation function. In this way, it becomes unnecessary to provide for float-frame storage when backing up integer threads.
- the data processing apparatus may include an interrupt controller for generating the interrupt requests.
- the interrupt controller may be arranged to store state information regarding a target process in association with one or more possible interrupt requests for triggering target processes, and to communicate the state information associated with a selected one of the possible interrupt requests to the processing circuitry along with the selected interrupt request.
- a conventional interrupt controller could be used, and a state information store for storing the state information in association with one or more possible interrupt requests could be provided separately, for instance within the processor itself, or within main memory.
- the processing circuitry would in this case be configured to read the state information from the state information store in response to a received interrupt request.
- the state of the system needs to be set up for the target data processing context, while setting register information to enable the processing circuitry to return to the current data processing context once the target data processing context has completed or terminated.
- a first configuration register into which the second state information is stored prior to commencement of the target data processing context, and a second configuration register into which the first and third state information is stored prior to commencement of the target data processing context may be provided.
- the first configuration register may be a dedicated configuration register indicating a current floating point state of the system (that is, whether a currently executing context is an integer or floating point context), and the second configuration register may be a link register for indicating the stack pointer of the previous data processing context, and an indication of whether the previous data processing context is an integer data processing context or a floating point data processing context, hi this case, when a target data processing context is to be started, the processing circuitry sets the link register to indicate the stack pointer of the current data processing context, and to indicate whether the current data processing context is an integer data processing context or a floating point data processing context.
- the processing circuitry will have access to the information required (stack identification and the amount of data backed up to the stack) to enable a return to the current data processing context once the target data processing context has completed.
- the link register is the mechanism traditionally used in function calls and for servicing interrupts, hi the case of a function call, a branch instruction writes the address of its following instruction in the link register and branches to the specified location. To return after the branch has completed, the processor uses the value which was stored into the link register to determine exactly where to go back to. The same applies on entering an exception, whereby an exception return value would traditionally be stored in the link register. However, it is possible, and may in some cases be useful, to use a register other than the link register to store a return value for a function call or interrupt.
- the first set of integer registers may comprise a register for storing a stack pointer, the stack pointer pointing to the top of a process stack when the current data processing context is a thread, and pointing to the top of a main stack when the current data processing context is a handler.
- the stack pointer can be used to determine whether a current context is a thread or a handler, and thus the active stack pointer may be used as the third state information.
- the processing circuitry may be responsive to the interrupt request to set the link register to indicate the stack pointer of the current data processing context, and the indication of whether the current data processing context is an integer data processing context or a floating point data processing context.
- the processing circuitry will then be responsive to the termination of the target data processing context to perform one of the integer state recovery function and the floating point state recovery function using the information stored in the link register.
- the state information may be hard wired, or may alternatively be configurable by the processing circuitry under the control of an operating system or other program code.
- an embodiment of the invention provides that, if the target data processing operation triggered by the interrupt request attempts to use the floating point registers when the state information indicates that the target data processing context is an integer data processing context, the processing circuitry generates an exception before the floating point registers are overwritten. The processor can then handle this exception in an appropriate manner.
- the floating point state preservation function may be conducted by first copying the first set of integer registers to the stack, and then copying the second set of floating point registers to the top of the stack.
- the process of copying the register values to the stack takes a certain period of time.
- the processing circuitry is responsive to a higher priority interrupt requiring an integer state preservation function received while the floating point state preservation function is being conducted to inhibit the copying of the second set of floating point registers to the stack, and to set a stack pointer to indicate the first set of integer registers to be at the top of the stack.
- the floating point state preservation function may be conducted by first copying the second set of floating point registers to the stack, and then copying the first set of integer registers to the stack.
- the processing circuitry is responsive to a higher priority interrupt requiring an integer state preservation function received while the floating point state preservation function is being conducted to complete storage of both the floating point registers and integer registers to the stack, and to generate further state information indicating that the interrupting floating point process was interrupted before the floating point state preservation process had completed and that the floating point register values stored to the stack are no longer required.
- the processing circuitry may be responsive to an override signal to perform the integer state preservation function in response to an interrupt request irrespective of the state information.
- a data processing method of executing integer data processing operations and floating point data processing operations in response to data processing instructions said integer data processing operations using a first set of integer registers, and said floating point data processing operations using a second set of floating point registers, the method comprising the steps of: performing, in response to an interrupt request, one of an integer state preservation function in which at least a subset of only said integer registers are copied to a stack memory, and a floating point state preservation function in which at least a subset of both said integer registers and said floating point registers are copied to said stack memory, said one of said integer state preservation function and said floating point state preservation function being selected in dependence on state information.
- Figure 1 schematically illustrates a data processing apparatus in which integer registers and floating point registers are preserved to a stack memory in response to an interrupt request from an interrupt controller;
- Figure 2 schematically illustrates an example set of integer registers (Figure 2A) and an example set of floating point registers ( Figure 2B);
- Figure 3 schematically illustrates the storage of register entries in the stack for an example integer state preservation operation (Figure 3A) and two example floating point state preservation operations ( Figures 3B and 3C);
- Figure 4 schematically illustrates a data processing apparatus according to a first embodiment in which integer or floating point state preservation is carried out in dependence on whether a current data processing context is an integer context or a floating point context;
- Figure 5 is a schematic flow diagram illustrating the operation of a state preservation function according to the first embodiment
- Figure 9 schematically illustrates the operation of the first embodiment in a mode in which both floating point state preservation and deferred preservation are disabled
- Figure 10 schematically illustrates a first example data processing apparatus according to a second embodiment in which integer or floating point state preservation is carried out in dependence on (a) whether a current data processing context is an integer context or a floating point context, (b) whether the current data processing context is a thread or a handler, and (c) whether an interrupting data processing context is an integer context or a floating point context, and in which state information is provided by an interrupt controller;
- Figure 11 schematically illustrates another example of the second embodiment in which state information is provided in the form of a look up table within a processor;
- Figure 12 schematically illustrates four example thread/handler progressions
- Figure 13 is a schematic flow diagram illustrating a context switch method in response to an interrupt in accordance with the second embodiment.
- Figure 14 is a schematic flow diagram illustrating a context switch method occurring when an interrupting process has completed in accordance with the second embodiment.
- a data processing apparatus 1 which comprises a data processor 10, a main memory 20, an interrupt controller 30 and a bus 40.
- the data processor 10 comprises processing circuitry 12 and a register file 14.
- the register file 14 includes a set of integer registers 14A and a set of floating point registers 14B.
- the processing circuitry 12 is operable in response to data processing instructions to execute data processing operations utilising the values stored in the integer registers 14A and floating point registers 14B of the register file 14. More particularly, integer data processing operations are executed by the processing circuitry 12 using the integer registers 14 A, while floating point data processing operations are executed by the processing circuitry 12 using both the integer registers 14A and the floating point registers 14B.
- the integer registers 14A may include general purpose registers for storing data values for use and manipulation by the processing circuitry 12, and may include registers which have a dedicated purpose (although in some cases these may also be used as general purpose registers).
- 16 integer registers are provided. These include a program counter (register 15), a link register (register 14) and a stack pointer (register 13).
- the program counter stores the memory address of a current instruction being executed by the processing circuitry 12.
- the link register stores, in the case of a branch from a first process to a second process, a memory address of a next instruction within the first process to be executed when the branch to the second process has been completed.
- the stack pointer stores an address indicating the top of a stack associated with a current process.
- the main memory 20 is operable to store data values for a variety of purposes, and is accessible by the data processor 10 via the bus 40.
- the bus 40 may itself include a data bus for carrying data values, an address bus for carrying address signals indicative of storage locations within the main memory and a control bus for exerting control signals for controlling the reading and writing of data to and from the main memory 40.
- the main memory 20 comprises a stack storage area 22 which provides a storage area for a main stack (MSP) 22A and a process stack (PSP) 22B.
- a stack is a last-in-first-out (LIFO) data structure whereby new data values are added to the stack by "pushing" them on to the top of the stack, and are subsequently accessed by "popping" them off the top of the stack.
- LIFO last-in-first-out
- the interrupt controller 30 includes prioritisation circuitry 32 for receiving interrupts 36 and selecting a highest priority interrupt from the received interrupts to be applied to the processing circuitry 12 of the data processor 10 via a signal line 38.
- the received interrupts 36 may be hardware interrupts received from peripheral devices or other hardware components of the data processing apparatus 1, or may be software interrupts issued by the processing circuitry 12 in response to data processing instructions.
- the processing circuitry 12 executes a stream of data processing instructions of a current process until an interrupt is received from the interrupt controller 30 via the signal line 38.
- the received interrupt indicates that the current process should be suspended while a new process is serviced, hi order that the current process can be resumed, information relating to the current process is to be stored so that it can be restored in due course.
- This information to be stored includes at least a portion of the contents of one or both of Hie integer registers 14A and the floating point registers 14B of the register file 14. hi particular, the integer registers 14A will be stored by both an integer state preservation function and a floating point state preservation function, whereas the floating point registers 14B will be stored only by the floating point state preservation function.
- the floating point state preservation function can therefore be initiated only when the state of the system at the time of an interrupt requires the preservation of the floating point registers.
- Figure 2A illustrates a set of 17 integer registers rO to rl5 and xpsr.
- Registers rO to rl5 are general purpose registers (although register rl3 functions as a stack pointer, register rl4 functions as a link register and register rl5 functions as a program counter).
- Register xpsr is a program status register which indicates the current state of the system.
- Figure 3A shows the top portion of a stack following an integer state preservation operation in which the content of registers rO to r3, rl2, rl4, rl5 and xpsr have been stored to the top of the stack.
- the previous (pre-interrupt request IRQ) top of stack position is shown in Figure 3A.
- the new top of stack position corresponds to the position within the memory at which the value of integer register rO is stored.
- the memory address of the top of the stack is actually decremented because the stack memory is filled from the top (highest address value) down.
- FIG 3B the top portion of a stack following a floating point state preservation operation is shown. This includes, at positions which correspond with those of Figure 3A, the backed up values of the integer registers rO to r3, rl2, rl4, rl5 and xpsr. However, stored above these (closer to the top of the stack) are the backed up values of the floating point registers sO to si 5, fpscr and fpexc.
- the previous (pre-interrupt request IRQ) top of stack position is shown in Figure 3B. The new top of stack position corresponds to the address at which the value of floating point register sO is stored.
- FIG 3C as with Figure 3B the top portion of a stack following a floating point state preservation operation is shown.
- the floating point registers are backed up first, and then the integer registers are stored on top of the floating point registers.
- the integer registers rO to r3, rl2, rl4, rl5 and xpsr are stored closer to the top of the stack than the floating point registers sO to si 5, fpscr and fpexc.
- the previous (pre-interrupt request IRQ) top of stack position is shown in Figure 3 C.
- the new top of stack position corresponds to the position within the memory at which the value of integer register rO is stored.
- the storage of data values from the integer and floating point registers onto the stack takes a finite period of time. During this time, it is possible that another, higher priority, interrupt will be received by the processing circuitry 12, and that in this case the previous interrupt (which triggered an integer and floating point state preservation function) will be cancelled and the higher priority interrupt serviced. In this case, if the higher priority interrupt relates to an integer process the floating point registers will not be used and therefore may (in some embodiments) no longer need to be preserved. The manner in which this situation may be dealt with depends on the order in which the integer registers and floating point registers are stored to the stack.
- the storage to the stack of the floating point registers as part of the floating point state preservation function could be terminated, and the top of stack pointer set to rO.
- the stack pointer, as well as an indication of whether the interrupted process is an integer or floating point process will be copied to the link register when the interrupting process starts, and can be used obtain access to the stack to restore the register values when the interrupted process is recommenced.
- the indication of whether the interrupted process is an integer or floating point process can be used to determine whether only the integer registers need to be restored, or whether both the integer and floating point registers need to be restored.
- the processing circuitry 12 will either transfer only the contents of (at least some of) the integer registers to a stack, or will transfer the contents of (at least some of) both the integer and floating point registers to a stack. Then, once the required registers have been copied to the stack, the incoming process can utilise the registers as required without destroying state information or data which will be required when returning to the earlier process.
- a first embodiment will now be described in which the selection of the integer or floating point state preservation function at the time of an interrupt request is conducted in dependence on whether the current data processing context (the context being interrupted) is an integer context which uses only the integer registers, or a floating point context using both the integer registers and the floating point registers.
- an integer state preservation function is performed if the current context is an integer context whereas a floating point state preservation function is performed if the current context is a floating point context.
- a data processor 110 has processing circuitry 112 which is response to an interrupt request 138 received from an interrupt controller to suspend a current context, preserve state information (register contents) relating to the current (suspended) context, and service a new (interrupting) context.
- a register file 114 includes a set of integer registers 114A and a set of floating point registers 114B.
- the integer registers 114A are shown in this case to include a stack pointer (SP) 115 and a link register (LR) 116 which are utilised in a state recovery process to be described later.
- a main memory 120 of the data processing apparatus 100 includes a stack memory 122 which is configured to store content relating to the integer and/or floating point processor registers into either a main stack area 122 A or a process stack area 122B in dependence on whether the interrupted data processing context is a thread or a handler.
- the registers relating to that process will be copied into the main stack by a state preservation function
- the registers relating to that process will be copied into the process stack by the state preservation function.
- the control register 141 is a 3 bit register having a first bit (bit [2]) which indicates whether a currently running context is an integer or floating point context, a second bit (Ht[I]) which indicates which of a main (MSP) stack and a process (PSP) stack is being used in the current context, and a third bit (bit [O]) which indicates the privilege state of a thread mode.
- bit [2] is the component of the control register 141 which is of particular interest, because the selection of the state preservation function to be performed is conducted based on whether the current context is an integer context or a floating point context.
- the floating-point context control register (FPCCR) 142 is a register which will typically be accessible only to software running in a privileged mode.
- the floating-point context control register 142 includes a bit [31] (ASPEN) which is settable to indicate whether a floating point state preservation function is available.
- ASPEN the integer state preservation function is assumed always to be available. More particularly, bit [31], if set to make the floating point state preservation function available, enables a bit [2] of the control register 141 described above to be set on execution of a floating point instruction, resulting in automatic hardware state preservation and restoration for a floating point context on exception entry and exit.
- the floating-point context control register 142 also includes a bit [30] (LSPEN) which enables and disables automatic lazy floating point state preservation (described later).
- the floating-point context control register 142 also includes a bit [0] (LSP ACT) indicating that lazy floating point state preservation is active, and in particular indicating that a floating point stack frame has been allocated on the stack, but that saving state (content of processor registers) to it has been deferred.
- LSP ACT lazy floating point state preservation
- the floating-point context control register 142 includes a number of other bits (bits [29:1]) which are either reserved for other uses or provide state information for preserving priority and privilege information relating to an interrupted process pending a return to the interrupted process.
- the floating-point context address register (FPCAR) 143 is provided, which as with the floating-point context control register 142 is accessible only in a privileged mode.
- the floating-point context address register 143 stores an address (in bits [31:3]) indicating a position in the stack to which the floating point registers are to be subsequently copied in the case of a deferred floating point state preservation function. Bits [2:0] are reserved.
- instruction (1) serves to increment the value in integer register r0 by 1
- instruction (2) serves to compare a value stored in integer register rO with the number 3. In both cases these instructions operate only on integer registers.
- VLDR was the first VFP instruction encountered in the current context, then it would cause the context to become a VFP context, whereupon bit [2] of the control register 141 would be set.
- bit [2] of the control register 141 is set, then bit [31] of the floating point context control register
- a further bit of the floating point context control register 142 indicates whether to populate the floating point frame in the stack at the time of allocation or to defer populating the floating point frame until a later time. If deferred, a further bit in the floating point context control register 142 (bit [O]) is set, and the address of the empty floating point frame in the stack memory is recorded into the floating point context address register (FPCAR) 143.
- FPCAR floating point context address register
- bit [2] of the control register 141 is inverted, and the inverted value is set as a frame size indicating bit in the link register 116. This bit is used to indicate the size of the frame (integer frame or floating point frame) allocated or copied into the stack memory 122. Once this bit is set in the link register 116, bit [2] of the control register 141 is cleared to a value of zero.
- bit [2] of the control register 141 is clear and bit [0] of the floating point context control register 142 is set to a value of one (indicating floating point frame allocated but not yet stored)
- bit [0] of the floating point context control register 142 is set to a value of one (indicating floating point frame allocated but not yet stored)
- bit [0] of the floating point context control register 142 is set to a value of one to indicate that the floating point frame has been allocated in the stack but not populated, then the floating point frame in the stack is simply skipped over, because bit [0] is in this case indicating that copying of the floating point registers to the allocated space in the stack never occurred.
- bit [0] of the floating point context control register 142 is clear (zero), as will be the case once the content of the floating point registers 114B has been copied into the stack 122, then the stacked floating point frame is loaded back into the floating point registers 114B.
- Bit [2] of the control signal is then updated in dependence on whether the apparatus is returning to an integer context or a floating point context. Bit [2] is updated independently of whether or not state was restored. This fundamentally implements a hardware based lazy context switching system.
- Return from an interrupt is implemented using the link register 116, which is set at the time of the interrupt to specify a return value which indicates to the processor to which stack (main or process) state information of the interrupted context was stored, how much information was stored (integer frame or floating point frame), and whether the process being returned to is a thread or a handler.
- a return value which indicates to the processor to which stack (main or process) state information of the interrupted context was stored, how much information was stored (integer frame or floating point frame), and whether the process being returned to is a thread or a handler.
- the penultimate hexadecimal value in the exception return value is either E or F, with a value of E indicating (column 4) that the destination (return) context is a floating point context, and a value of F indicating that the destination context is an integer context. This value therefore implements the frame size indicating bit described above.
- the final hexadecimal value in the exception return value is either 1, 9 or D, with a value of 1 indicating (columns 2 and 3) a return to the main (MSP) stack into a handler mode, a value of 9 indicating a return to the main stack into a thread mode, and a value of D indicating a return to the process (PSP) stack into a thread mode.
- FIG. 5 schematically illustrates a state preservation process according to the first embodiment.
- a current process is proceeding.
- a step S2 it is determined whether an interrupt has been received which has a higher priority than the process currently being executed. In the case where no interrupt is received, or an interrupt is received which has a lower priority than the currently executing process, the process reverts to the step Sl.
- it is determined that an interrupt request is received which has a higher priority than the currently executing process it is determined at a step S3 whether floating point state preservation is enabled based on bit [31] of the floating point context control register 142.
- an integer state preservation function is conducted at a step S4.
- the integer state preservation function causes predetermined ones of the integer registers to be copied to the stack.
- the stack pointer indicating the top of the stack is updated to reflect the new top of stack position at a step S5. This will involve modifying the stack pointer by an amount equal to an integer frame of preserved register content.
- the link register 116 is then updated with an exception return address at a step S6 to include a bit to indicate that an integer frame has been stored to the stack and to indicate to which stack the registers have been stored (MSP or PSP).
- the target (interrupting) process then commences at a step S 7, in which the integer registers (and potentially the floating point registers) may be overwritten.
- step S3 it is determined that floating point state preservation is enabled, then it is then determined at a step S 8 whether floating point register storage is required based on whether the current process is operating in an integer data processing context or a floating point data processing context, as indicated by bit [2] of the control register 141. If it is determined that the current context is an integer context, then the process is directed to the steps S4 to S 7 which are conducted as described above.
- a floating point state preservation function is conducted, hi particular, at a step S9, it is determined whether the storage of the floating point registers should be conducted immediately (at the time of stack allocation) or deferred, based on bit [30] of the floating point context control register 142. If it is determined at the step SlO that the storage of the floating point context is not to be deferred, then the process progresses to a step SlO, where both the integer and floating point registers are copied into the stack memory. The stack pointer is then updated at a step Sl 1 to reflect the new top of stack position by modifying the stack pointer by an amount equal to a floating point frame of preserved register content.
- the link register 116 is then updated with an exception return address at a step S 12 to include a bit to indicate that a floating point frame has been stored to the stack.
- the target (interrupting) process then commences at a step S 13, in which the integer registers (and potentially the floating point registers) may be overwritten.
- step S 14 If it is determined at the step S9 that copying of the floating point registers to the stack is to be deferred, then at a step S 14 only the integer registers are copied to the stack. Then, at a step S 15, the stack pointer is updated to indicate to reflect the new top of stack position by incrementing the stack pointer by an amount equal to a floating point frame of preserved register content. In this way, although only the integer registers have been copied to the stack, space is allocated in the stack for the floating point registers.
- an address register is set to store an address value indicating the location of the allocated area in the stack to which the floating point registers may be copied, and a flag is set in the floating point context control register 142 (bit [O]) to indicate that space for the floating point registers has been allocated on the stack, but that copying of the floating point registers into the allocated space has not yet been conducted.
- the link register 116 is then updated with an exception return address at a step S 17 to include a bit to indicate that a floating point frame has been stored to the stack. In this way, a return to the interrupted process using the link register 116 will obtain the floating point register content from the stack if the floating point registers have been copied. If the floating point registers have not been copied then the empty portion of the stack can be ignored during state recovery (described below).
- the target (interrupting) process then commences at a step S 18.
- step S 19 the process monitors received instructions following the commencement of the target process to determine if a floating point instruction is to be executed which would cause the floating point registers to be overwritten. If such an instruction is not received then the monitoring process of step S 19 continues. If such an instruction is received then the floating point state preservation process terminates at a step S20 by storing the floating point registers into the allocated space indicated by the address register, and resetting the flag in the floating point context control register 142 (bit [O]) to a value of zero to indicate that copying of the floating point registers has now been conducted.
- the trigger for copying the floating point registers into the allocated space on the stack may not simply be an instruction which uses the floating point registers, it will preferably be an instruction which will actually modify the content of the floating point registers.
- Figure 6 schematically illustrates a state recovery process according to the first embodiment.
- the method illustrated provides a context switch from the target (interrupting) process back to the thread or handler process which was interrupted by the target process.
- the process triggered by an interrupt proceeds until it terminates at a step T2.
- the link register 116 is read at a step T3 to determine to which stack (MSP or PSP) the state information of the interrupted process was copied, and whether an integer frame of data or a floating point frame of data was stored to that stack (the frame size indicating bit).
- a step T4 it is determined based on the frame size indicating bit, and based on the flag in the floating point context control register 142, whether (a) an integer frame was allocated and copied, (b) a floating point frame was allocated and copied (either immediately or after a subsequent floating point instruction), or (c) a floating point frame was allocated but not populated (because no floating point instruction was executed prior to the interrupting process terminating at the step T2). If it is determined at the step T4 that only an integer frame was allocated and stored to the stack, the appropriate amount of data is popped from the stack at a step T5 to obtain the data values of the integer registers, and the obtained values are stored to the corresponding registers at a step T6. Then, at a step T7, the stack pointer is updated to indicate a new top of stack position, which will differ from the previous top of stack position by an amount equal to an integer frame. The previous process is then resumed at a step T8.
- a larger amount of data (corresponding to a floating point frame) is popped off the stack at a step T9, and copied to the integer and floating point registers at a step TlO. Then, at a step T7, the stack pointer is updated to indicate a new top of stack position, which will differ from the previous top of stack position by an amount equal to a floating point frame. The previous process is then resumed at a step T8.
- a smaller amount of data (corresponding to an integer frame) is popped off the stack at a step T9, and copied to the integer registers at a step TlO.
- the stack pointer is updated to indicate a new top of stack position, which will differ from the previous top of stack position by an amount equal to a floating point frame, because the space required by the floating point frame would have been allocated, even if not ultimately used.
- the previous process is then resumed at a step T8.
- the ASPEN and LSPEN bits in the FPCCR are set such that both floating point state preservation and lazy context switching are available.
- first, second and third states of the apparatus are attainable by hardware based state preservation and recovery functions, and a fourth state is attainable only by direct software control.
- the portion of the state diagram accessible only by direct software control is indicated by the region Z.
- the data processing apparatus is reset, or switched on, whereby the apparatus enters the first state in which a first control bit (bit [2] of the control register 141) is set to zero, and a second control bit (bit [0] of the FPCCR) is set to zero, at a step A2.
- the first state is a state in which a current data processing context is an integer data processing context.
- an interrupt request (IRQ) is received at a step A3 while the apparatus is in the first state
- an integer state preservation function is initiated, and a third control bit is set in the link register to have a value which is the inverse of the first control bit
- the third control bit to be stored in the link register 116 is set to a value of one.
- the contents of (some of) the integer registers is stored to the stack, and the stack pointer is updated to reflect the new top of the stack, in this case 32 bytes (corresponding to eight 32 bit registers being copied to the stack) from the previous top of stack position.
- the modification of the stack pointer when items are added to the stack is conducted by decrementing the stack pointer.
- the modification of the stack pointer is conducted by incrementing the stack pointer.
- a return from an interrupting process occurs at a step A5 while the apparatus is in the first state, then it is determined whether the interrupted process operated in an integer context where the apparatus was in the first state or the third state (indicated by the third control bit being set to a value of one), or in a floating point context where the apparatus was in the second state or the fourth state (indicated by the third control bit being set to a value of zero). If the interrupted process operated in an integer context then the integer state recovery function is performed at the step A7 by popping the preserved integer register content from the stack and updating the stack pointer to reflect the new top of the stack, in this case 32 bytes (corresponding to eight 32 bit registers being popped off the stack) from the previous top of stack position.
- the apparatus remains in the first state once the integer state recovery function has been performed. If the interrupted process operated in a floating point context then the floating point state recovery function is performed at the step A6 by popping the preserved integer and floating point register content from the stack and updating the stack pointer to reflect the new top of the stack, in this case 104 bytes (corresponding to twenty six 32 bit registers being popped off of the stack) from the previous top of stack position. In this case, the apparatus is caused to enter the second state at a step Bl once the floating point state recovery function has been performed. This is because a floating point state recovery function is followed by the continuation of a floating point data processing context
- the apparatus If a floating point instruction is received at a step A4 while the apparatus is in the first state, the apparatus is caused to enter the second state at the step Bl, because this will mark the initiation of a floating point data processing context.
- the first control bit is set to one, but the second control bit remains at zero.
- the second state if a floating point instruction is executed at a step B2, no change of state occurs and the apparatus remains in the second state. This is because the second state always represents a floating point data processing context.
- a floating point state preservation function is initiated, and a third control bit is set in the link register to have a value which is the inverse of the first control bit As the first control bit has a value of one while the apparatus is in the second state, the third control bit to be stored in the link register is set to a value of zero.
- a return from an interrupting process occurs at a step B5 while the apparatus is in the second state, then it is determined whether the interrupted process operated in an integer context where the apparatus was in the first state or the third state (indicated by the third control bit being set to a value of one), or in a floating point context where the apparatus was in the second state or the fourth state (indicated by the third control bit being set to a value of zero). If the interrupted process operated in an integer context then the integer state recovery function is performed at the step B6 by popping the preserved integer register content from the stack and updating the stack pointer to reflect the new top of the stack, in this case 32 bytes (corresponding to eight 32 bit registers being popped off the stack) from the previous top of stack position.
- the apparatus is caused to enter the first state at a step A2 once the integer state recovery function has been performed.
- the floating point state recovery function is followed by the continuation of an integer data processing context If the interrupted process operated in a floating point context then the floating point state recovery function is performed at the step B6 by popping the preserved integer and floating point register content from the stack and updating the stack pointer to reflect the new top of the stack, in this case 104 bytes (corresponding to twenty six 32 bit registers being popped off of the stack) from the previous top of stack position.
- the apparatus remains in the second state once the floating point state recovery function has been performed.
- the third state is one in which the first control bit (bit [2] of the control register 141) is set to zero (as with the first state) to indicate that the current context is an integer data processing context, and a second control bit (bit [0] of the FPCCR) is set to a value of one, to indicate that space is currently allocated in the stack memory for the floating point registers, but that the floating point registers have not yet been copied into the allocated space.
- the apparatus If a floating point instruction is received at a step C3 while the apparatus is-in the third state, the apparatus is caused to store the floating point state (floating point registers) into the allocated space in the stack memory at a step C4, and to then enter the second state at the step Bl, because the execution of the received floating point instruction will mark the initiation of a floating point data processing context.
- the apparatus enters the second state the first control bit is set to one, and the second control bit is reset to zero.
- an interrupt request (IRQ) is received at a step C2 while the apparatus is in the third state
- an integer state preservation function is initiated, and a third control bit is set in the link register to have a value which is the inverse of the first control bit.
- the third control bit to be stored in the link register is set to a value of one.
- the contents of (some of) the integer registers is stored to the stack, and the stack pointer is updated to reflect the new top of the stack, in this case 32 bytes (corresponding to eight
- a return from an interrupting process occurs at a step C5 while the apparatus is in the third state, then it is determined whether the interrupted process operated in an integer context where the apparatus was in the first state or the third state (indicated by the third control bit being set to a value of one), or in a floating point context where the apparatus was in the second state or the fourth state (indicated by the third control bit being set to a value of zero).
- the integer state recovery function is performed at the step C7 by popping the preserved integer register content from the stack and updating the stack pointer to reflect the new top of the stack, in this case 32 bytes (corresponding to eight 32 bit registers being popped off the stack) from the previous top of stack position, m this case, the apparatus remains in the third state once the integer state recovery function has been performed.
- the fourth state is accessible only by software at a step Dl, and is a state in which the first control bit (bit [2] of the control register 141) is set to a value of one, and the second control bit (bit [0] of the FPCCR) is set to a value of one, at a step D2.
- the fourth state is a state in which a current data processing context is a floating point data processing context, and in which space is currently allocated in the stack memory for the floating point registers, but that the floating point registers have not yet been copied into the allocated space (as indicated by the fact that the second control bit is set to a value of one).
- the apparatus In the fourth state, if a floating point instruction is received at a step D4, the apparatus is caused to store the floating point state (floating point registers) into an allocated space in the stack memory at a step D5, and to then enter the second state at the step Bl.
- the first control bit remains set to a value of one, but the second control bit is reset to zero.
- a floating point state preservation function is initiated, and a third control bit is set in the link register to have a value which is the inverse of the first control bit.
- the third control bit to be stored in the link register is set to a value of zero.
- the contents of (some of) the integer registers is stored to the stack, but because Figure 7 represents a system state in which the copying of floating point registers is deferred, the floating point registers are not stored into the stack at this time.
- the stack pointer is updated to reflect the new top of the stack at a position which allocates space on the stack for the floating point registers, in this case 104 bytes (corresponding to twenty six 32 bit registers being copied to the stack) from the previous top of stack position.
- a return from an interrupting process occurs at a step D6 while the apparatus is in the fourth state, then it is determined whether the interrupted process operated in an integer context where the apparatus was in the first state or the third state (indicated by the third control bit being set to a value of one), or in a floating point context where the apparatus was in the second state or the fourth state (indicated by the third control bit being set to a value of zero).
- the integer state recovery function is performed at the step D7 by popping the preserved integer register content from the stack and updating the stack pointer to reflect the new top of the stack, in this case 32 bytes (corresponding to eight 32 bit registers being popped off the stack) from the previous top of stack position, hi this case, the apparatus is caused to enter the third state at a step A2 once the integer state recovery function has been performed.
- the floating point state recovery function is performed at the step D8 by popping the preserved integer and floating point register content from the stack and updating the stack pointer to reflect the new top of the stack, in this case 104 bytes (corresponding to twenty six 32 bit registers being popped off of the stack) from the previous top of stack position, hi this case, the apparatus enters the second state once the floating point state recovery function has been performed.
- the ASPEN bit in the FPCCR is set such that floating point state preservation is available, but the LSPEN bit in the FPCCR is set such that lazy context switching is not available. Accordingly, the third and fourth states described above with reference to Figure 7 are only available under direct software control. The portion of the state diagram accessible only by direct software control is indicated by the region Z'.
- the operation of the apparatus in the first state is identical to that described above with reference to Figure 7.
- the operation of the apparatus in the second state while similar to that described above, differs in that the content of the floating point registers is copied (along with the integer registers) into the stack memory immediately at a step B3' (which corresponds to step B3 in Figure 7), rather than the copying of the floating registers being deferred until a subsequent floating point operation is received while the apparatus is in the third state.
- the step B3 in Figure 7 transitioned into the third state
- the step B3' in Figure 8 transitions into the first state.
- the third state is only available via the fourth state (which is iteself only available via direct software control).
- the apparatus is tied to the first state, and floating point instructions received at a step A4' corresponding to step A4 in Figures 7 and 8 do not cause the apparatus to change to a different state. It is noted that when the apparatus is tied to the first state, the step A6 will not be reached (other than via direct software control from one of the second, third and fourth states) because bit 4 of the link register can only be set to one (the inverse of the control bit, which is fixed at zero in the case of the apparatus being tied to the first state).
- a second embodiment will now be described in which a determination of which of the two sets of registers to store is made on the basis of (a) whether the current process is a thread, that is a process which has not been triggered by an interrupt, or a handler, that is a process which has been triggered by an interrupt, (b) whether the current process is an integer process which does not use the floating point registers or a floating point process which does use the floating point registers, and (c) whether the interrupting process is an integer process which does not use the floating point registers or a floating point process which does use the floating point registers.
- an example data processor 210 and interrupt controller 230 are schematically illustrated in which state circuitry 234 providing an indication of whether an interrupting process is an integer process or a floating point process is provided within the interrupt controller 230.
- the data processor 210 and the interrupt controller 230 are coupled together via a bus 240.
- the data processor 210 comprises (in a similar manner to Figure 1) processing circuitry 212 and a register file 214.
- the register file 214 comprises integer registers 214A (which include a stack pointer 215 and a link register 216) and floating point registers 214B.
- the interrupt controller 230 comprises prioritisation circuitry 232 which takes the form of a multiplexer which selects between incoming interrupt requests 236-1 to 236-4 on the basis of relative priority.
- the prioritisation circuitry 232 also generates a control signal 233 which indicates to state circuitry 234 the interrupt request which has been selected.
- the state circuitry 234 takes the form of a multiplexer which selects between state indicators 235-1 to 235-4 in dependence upon the received control signal 233. Each of the state indicators 235-1 to 235-4 corresponds to one of the interrupt requests 236-1 to 236-4.
- the state circuitry 234 therefore generates a control signal which is applied to the processing circuitry 212 and which indicates the state of the received interrupt, and in particular indicates if the received interrupt relates to a process which requires access to the floating point registers 214B.
- the state indicators 235-1 to 235-4 can be set by the processing circuitry 212 as appropriate under hardware or software control by applying control signals via the bus 240.
- the state circuitry 234 of the interrupt controller 230 generates state information corresponding to a selected interrupt, and applies a signal representing the state information to the processing circuitry 212 of the data processor via a signal line 239 in association with the selected interrupt which is applied via the signal line 238.
- the processing circuitry 212 is able to utilise the state information acquired via the signal line 239 to determine whether the interrupt received on the signal line 238 relates to an integer context or a floating point context
- the data processor 210 also comprises configuration registers 240 including a control register 241 having a first bit 24 IA for indicating whether the current context is an integer context or a floating point context, a second bit 24 IB for indicating which of the main stack (MSP) and process stack (PSP) is currently in use, and a third bit 241C for indicating the privilege of a thread mode.
- the control register 241 corresponds to the control register 141 described above with reference to Figure 4.
- FIG. 11 another example data processor 310 and interrupt controller 330 are schematically illustrated in which a state store providing a look up table mapping possible interrupts to a corresponding state is provided within the data processor 310.
- the data processor 310 and the interrupt controller 330 are coupled together via a bus 340.
- the data processor 310 comprises (in a similar manner to Figure 10) processing circuitry 312 and a register file 314 comprising integer registers 314A (which include a stack pointer 315 and a link register 316) and floating point registers 314B.
- the interrupt controller 330 comprises prioritisation circuitry 332 which takes the form of a multiplexer which selects between incoming interrupt requests 336-1 to 336-4 on the basis of relative priority.
- the interrupt requests 336-1 and 336- 2 are software interrupts generated by the processing circuitry 312, while interrupt requests 336-3 and 336-4 are hardware interrupts generated by hardware devices (not shown).
- the prioritisation circuitry 332 selects between the interrupts 336-1 to 336-4 to generate an interrupt signal which is applied to the processing circuitry 312 via signal line 238 to indicate an interrupting process to be serviced by the processing circuitry 312.
- a state information store 316 which is provided within the data processor 310 takes the place of the state circuitry 334 in Figure 10, enabling a conventional interrupt controller to be used rather than the adapted interrupt controller provided in the arrangement of Figure 10.
- the state information store 316 stores state information indicating for each of one or more possible interrupt requests, whether a process corresponding to that request requires the floating point registers 314B.
- the processing circuitry 312 is configured to read the state information from the state information store in response to a received interrupt request from the interrupt controller 330. In this way, the processing circuitry 312 is able to appropriately back up either only the integer registers 314A or both the integer registers 314A and floating point registers 314B.
- the state information store can be updated as appropriate under software or hardware control by the processing circuitry 312.
- the data processor 310 also comprises configuration registers 340 including a control register 341 having a first bit 34 IA for indicating whether the current context is an integer context or a floating point context, a second bit 34 IB for indicating which of the main stack (MSP) and process stack (PSP) is currently in use, and a third bit 341C for indicating the privilege of a thread mode.
- the control register 341 corresponds to the control register 241 described above with reference to Figure 10.
- the state information from the interrupt controller or the state information store respectively provides an indication of whether the interrupting (target) data processing context is an integer context or a floating point context.
- the state information indicating whether the current process is an integer process or a floating point process is obtained from either the interrupt controller ( Figure 10) or the state information store ( Figure 11) and is used to update bit [2] of the control register 241 or 341 respectively to indicate whether the current context is an integer context or a floating point context.
- bit [2] of the control register 241 or 341 is set directly by the hardware or software.
- the state required to determine whether an integer or floating point state preservation function is to be performed can be extracted from the interrupt controller or state information store which indicates whether the target context is an integer context or a floating point context, from bit [2] of the control register 241, 341 which indicates whether the current context is an integer context or a floating point context, and from bit [1] of the control register 241, 341 which indicates (as described above) whether the current context is a thread or a handler.
- the preservation policy shown in Table 1 protects against loss of floating point register file data while only conducting floating point state preservation where there is a risk of overwrite.
- FIG 12 A a first example series of processes and interrupts is schematically illustrated.
- an integer thread process (process IA) is taking place, until interrupted at a point 604 by an interrupt triggering an integer handler process (process 2A).
- process IA an integer thread process
- process 2A an integer handler process
- a context switch from an integer thread to an integer handler requires only the integer registers to be backed up, because the floating point registers will not and have not been used.
- the context switch occurs between the point 604 and a point 606 when the state preservation operation of the integer registers has been completed and the new integer handler process (2A) can commence.
- the integer handler process (2A) continues until a point 608 when it is interrupted by an interrupt triggering a floating point handler process (process 3A).
- a context switch from an integer handler to a floating point handler requires both the integer registers and the floating point registers to be backed up, because the interrupting floating point handler process (3A) will use the floating point registers, and the integer handler process (2A) may itself have interrupted a floating point process which used the floating point registers.
- the context switch occurs between the point 608 and a point 610 when the state preservation operation of the integer and floating point registers has been completed and the new floating point handler process (3A) can commence.
- duration of the integer state preservation operation between the points 604 and 606 is shown for simplicity to be the same as the duration of the floating point state preservation operation between the points 608 and 610, the duration of the latter context switch may be greater due to the requirement to store more registers to the stack.
- the floating point process (3A) which commenced at the point 610 then continues until a point 612 at which the floating point process (3A) terminates and the interrupted process (2A) can be resumed.
- the backed up integer registers and floating point registers must be restored by reading the values stored to the stack in the integer and floating point state preservation process, and storing these values into the corresponding registers. This operation takes place between the point 612 and a point 614, after which the integer handler process (2A) can be resumed.
- the integer handler process (2A) then continues until a point 616 at which it terminates and the interrupted process (IA) can be resumed.
- the backed up integer registers must be restored by reading the values stored to the stack in the integer state preservation operation, and storing these values into the corresponding registers. This restore operation takes place between the point 616 and a point 618, after which the integer thread process (IA) can be resumed.
- the integer thread (IA) may be an application process operating in a user mode and using the process stack (described above).
- the integer handler (2A) and the floating point handler (3A) may be operating system processes running in a privileged mode and using the main stack (described above).
- the stack pointer used for a user process utilising the process stack will be a process stack pointer (PSP) stored in register 13
- the stack pointer used for a privileged process utilising the main stack will be a main stack pointer (MSP) stored in register 13.
- PPSP process stack pointer
- MSP main stack pointer
- the processing circuitry is therefore able to determine whether a process is a thread (user mode utilising the process stack) or a handler (privileged mode utilising the main stack) by exarnining the address pointed to by the stack pointer stored in register 13.
- a process is a thread (user mode utilising the process stack) or a handler (privileged mode utilising the main stack) by exarnining the address pointed to by the stack pointer stored in register 13.
- the same technique may be used with each of the following examples.
- FIG. 12B a second example series of processes and interrupts is schematically illustrated.
- an integer thread process (process IB) is taking place, until interrupted at a point 624 by an interrupt triggering a floating point handler process (process 2B).
- a context switch from an integer thread to a floating point handler requires only the integer registers to be backed up, because the floating point registers have not previously been used, and thus will not need to be preserved.
- the context switch occurs between the point 624 and a point 626 when the state preservation operation of the integer registers has been completed and the new floating point handler process (2B) can commence.
- the floating point handler process (2B) continues until a point 628 when it is interrupted by an interrupt triggering a further floating point handler process (process 3B).
- a context switch from a floating point handler to another floating point handler requires both the integer registers and the floating point registers to be backed up, because both the current floating point handler process (2B) and the interrupting floating point handler process (3B) will use the floating point registers.
- the context switch occurs between the point 628 and a point 630 when the state preservation operation of the integer and floating point registers has been completed and the new floating point handler process (3B) can commence.
- the floating point process (3B) which commenced at the point 630 then continues until a point 632 at which the floating point process (3B) terminates and the interrupted process (2B) can be resumed.
- the backed up integer registers and floating point registers must be restored by reading the values stored to the stack in the integer and floating point state preservation process, and storing these values into the corresponding registers. This operation takes place between the point 632 and a point 634, after which the floating point handler process (2B) can be resumed.
- the floating point handler process (2B) then continues until a point 636 at which it terminates and the interrupted process (IB) can be resumed.
- the backed up integer registers and floating point registers must be restored by reading the values stored to the stack in the integer state preservation operation and the floating point state preservation operation, and storing these values into the corresponding registers.
- This restore operation takes place between the point 636 and a point 638, after which the integer thread process (IB) can be resumed.
- FIG. 12C a third example series of processes and interrupts is schematically illustrated.
- a floating point thread process (process 1C) is taking place, until interrupted at a point 644 by an interrupt triggering an integer handler process
- process 2C As described above, a context switch from a floating point thread to an integer handler requires only the integer registers to be backed up, because the floating point registers will not be overwritten by the interrupting integer process.
- the context switch occurs between the point 644 and a point 646 when the state preservation operation of the integer registers has been completed and the new integer handler process
- the integer handler process (2C) continues until a point 648 when it is interrupted by an interrupt triggering a further integer handler process (process 3C).
- a context switch from an integer handler to an integer handler requires only the integer registers to be backed up, because the interrupting handler process (3C) will not use the floating point registers.
- the context switch occurs between the point 648 and a point 650 when the state preservation operation of the integer registers has been completed and the new integer handler process (3C) can commence.
- the integer handler process (3C) which commenced at the point 650 then continues until a point 652 at which the integer process (3C) terminates and the interrupted process (2C) can be resumed.
- the backed up integer registers must be restored by reading the values stored to the stack in the integer state preservation process, and storing these values into the corresponding registers. This operation takes place between the point 652 and a point 654, after which the integer handler process (2C) can be resumed.
- the integer handler process (2C) then continues until a point 656 at which it terminates and the interrupted process (1C) can be resumed.
- the backed up integer registers must be restored by reading the values stored to the stack in the integer state preservation process, and storing these values into the corresponding registers.
- the floating point registers which are used by the floating point thread process (1C) have not been used by the interrupting processes (2C and 3C) and thus will still be preserved in the floating point registers.
- the restore operation takes place between the point 656 and a point 658, after which the floating point thread process (1C) can be resumed.
- FIG 12D a fourth example series of processes and interrupts is schematically illustrated.
- a floating point thread process (process ID) is taking place, until interrupted at a point 664 by an interrupt triggering a floating point handler process (process 2D).
- process ID a floating point thread process
- process 2D an interrupt triggering a floating point handler process
- a context switch from a floating point thread to a floating point handler requires both the integer registers and the floating point registers to be backed up, because both the current floating point handler process (ID) and the interrupting floating point handler process (2D) will use the floating point registers.
- the context switch occurs between the point 664 and a point 666 when the state preservation operation of the integer registers and floating point registers has been completed and the new floating point handler process (2D) can commence.
- the floating point handler process (2D) continues until a point 668 when it is interrupted by an interrupt triggering an integer handler process (process 3D).
- a context switch from a floating point handler to an integer handler requires only the integer registers to be backed up, because the interrupting integer handler process (3D) will not use the floating point registers.
- the context switch occurs between the point 668 and a point 670 when the state preservation operation of the integer registers has been completed and the new integer handler process (3D) can commence.
- the integer process (3D) which commenced at the point 670 then continues until a point 672 at which the integer process (3D) terminates and the interrupted process (2D) can be resumed.
- the backed up integer registers must be restored by reading the values stored to the stack in the integer state preservation process, and storing these values into the corresponding registers. This operation takes place between the point 672 and a point 674, after which the floating point handler process (2D) can be resumed.
- the floating point handler process (2D) then continues until a point 676 at which it terminates and the interrupted process (ID) can be resumed.
- the backed up integer registers and floating point registers must be restored by reading the values stored to the stack in the integer and floating point state preservation processes, and storing these values into the corresponding registers. This restore operation takes place between the point 676 and a point 678, after which the floating point thread process (ID) can be resumed.
- Figure 13 is a schematic flow diagram showing an example method of providing a context switch from a current process to a target process.
- a current process proceeds until an interrupt is received by the processing circuitry at a step U2.
- the target process which is being initiated by the interrupt is an integer process or a floating point process. As described above, this determination may be made based on state information provided by an interrupt controller in association with the interrupt or obtained from a state information store provided within the data processor. Then, at a step U4, it is determined whether the current process is an integer process or a floating point process. As described above, this information may be stored into a bit [2] of the control register when the current process was initiated, either based on state information from the interrupt controller (where the current process is a handler), or set directly by the hardware or software (whether the current process is a thread). This indication can be extracted from that control register by the processing circuitry.
- a step U5 it is determined whether the current process is a thread process or a handler process. This determination may be made in dependence on whether bit [1] of the control register, which indicates whether the main stack is currently in use (indicating that the current process is a handler, or the process stack is currently in use (indicating that the current process is a thread).
- the information gathered at the steps U3 to U5 is that which is required in order to make a decision regarding whether only the integer registers should be stored to the stack, or whether both the integer registers and floating point registers should be stored to the stack.
- a step U6 the determination as to whether the floating point registers are to be stored is made. Then, in the case that the determination is made that the floating point registers are not to be stored, at a step U7 only the integer registers are stored to the stack. Then, the stack pointer is updated to reflect the new top of the stack at a step U8, and the link register is updated at a step U9 to store an indication of which of the main stack and the process stack have been used to store the preserved processor registers, and an indication that the interrupted process uses a floating point context. If at the step U6 a determination is made that the floating point registers are to be stored, then at a step U8 the integer registers and the floating point registers are stored to the stack. Then, the stack pointer is updated to reflect the new top of the stack at the step U8, and the link register is updated at the step U9 to store an indication that the interrupted process uses a floating point context.
- bit [2] of the control register may be set to indicate whether the target process (to become the current process) based on the information obtained at the step U3 indicating whether the interrupting process uses an integer or floating point data processing context.
- bit [2] of the control register may be set to indicate whether the target process (to become the current process) based on the information obtained at the step U3 indicating whether the interrupting process uses an integer or floating point data processing context.
- the target process is commenced.
- the target process triggered by the interrupt request attempts to use the floating point registers when the state information obtained at the step U3 and stored in bit [2] of the control register at the step UI l indicates that the target data processing context is an integer data processing context, an exception is generated by the processing circuitry.
- This exception will halt the target process before the floating point registers can be overwritten, thereby preventing loss of floating point register data which has not been stored to the stack.
- the exception could then be dealt with simply by conducting the floating point state preservation operation at that point, or by terminating the target process.
- Figure 14 is a schematic flow diagram showing an example method of providing a context switch from the target (interrupting) process back to the thread or handler process which was interrupted by the target process.
- the process triggered by an interrupt proceeds until it terminates at a step V2.
- the link register is read at a step V3 to determine to which of the main stack and the process stack the processor registers were copied, and to determine whether the interrupted process used a floating point context (which forms an indication of how much data (integer frame or floating point frame) is to be popped from the stack).
- a step V4 it is determined based on the value stored in the link register whether the floating point registers were stored to the stack when the process was interrupted. If it is determined at the step V4 that the floating point registers were stored to the stack, the appropriate amount of data is popped from the stack at a step V5 to obtain the data values of the integer and floating point registers, and the obtained values would be stored to the corresponding registers at a step V6. In the case of the example shown in Figures 2 and 3 this would require an amount of data corresponding to 26 registers to be popped from the stack.
- step V5 If on the other hand it is determined at the step V5 that the floating point registers were not stored to the stack, a smaller amount of data is popped off the stack at a step V7, and copied into the integer registers at a step V8. In the case of the example shown in Figures' 2 and 3 this would require an amount of data corresponding to 8 registers to be popped from the stack.
- step V9 once either the step V6 or the step V8 has been completed, the previous process is resumed.
Abstract
Description
Claims
Priority Applications (5)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
EP10717209.0A EP2443548B1 (en) | 2009-06-19 | 2010-04-30 | Data processing apparatus and method |
CN201080027396.9A CN102460377B (en) | 2009-06-19 | 2010-04-30 | Data processing apparatus and method |
JP2012515549A JP5564562B2 (en) | 2009-06-19 | 2010-04-30 | Data processing apparatus and method |
KR1020127000881A KR101762124B1 (en) | 2009-06-19 | 2010-04-30 | Data processing apparatus and method |
IL216377A IL216377A (en) | 2009-06-19 | 2011-11-15 | Data processing apparatus and method |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
GB0910661.8 | 2009-06-19 | ||
GB0910661.8A GB2471138B (en) | 2009-06-19 | 2009-06-19 | Handling integer and floating point registers during a context switch |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2010146328A1 true WO2010146328A1 (en) | 2010-12-23 |
Family
ID=40972495
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/GB2010/000879 WO2010146328A1 (en) | 2009-06-19 | 2010-04-30 | Data processing apparatus and method |
Country Status (10)
Country | Link |
---|---|
US (1) | US9201651B2 (en) |
EP (1) | EP2443548B1 (en) |
JP (1) | JP5564562B2 (en) |
KR (1) | KR101762124B1 (en) |
CN (1) | CN102460377B (en) |
GB (1) | GB2471138B (en) |
IL (1) | IL216377A (en) |
MY (1) | MY154086A (en) |
TW (1) | TWI478064B (en) |
WO (1) | WO2010146328A1 (en) |
Families Citing this family (24)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP4873423B2 (en) * | 2007-12-27 | 2012-02-08 | 東芝ソリューション株式会社 | Virtualization program, simulation apparatus, and virtualization method |
JP5590022B2 (en) * | 2011-12-28 | 2014-09-17 | 富士通株式会社 | Information processing apparatus, control method, and control program |
US9116711B2 (en) | 2012-02-08 | 2015-08-25 | Arm Limited | Exception handling in a data processing apparatus having a secure domain and a less secure domain |
US9213828B2 (en) * | 2012-02-08 | 2015-12-15 | Arm Limited | Data processing apparatus and method for protecting secure data and program code from non-secure access when switching between secure and less secure domains |
US10210349B2 (en) * | 2012-02-08 | 2019-02-19 | Arm Limited | Data processing apparatus and method using secure domain and less secure domain |
US9477834B2 (en) | 2012-02-08 | 2016-10-25 | Arm Limited | Maintaining secure data isolated from non-secure access when switching between domains |
GB2499287A (en) * | 2012-02-08 | 2013-08-14 | Advanced Risc Mach Ltd | Exception handling in data processing with different security domains |
JP6214142B2 (en) * | 2012-10-09 | 2017-10-18 | キヤノン株式会社 | Information processing apparatus, information processing method, and program |
CN104679585B (en) * | 2013-11-28 | 2017-10-24 | 中国航空工业集团公司第六三一研究所 | Floating-point context switching method |
GB2548603B (en) | 2016-03-23 | 2018-09-26 | Advanced Risc Mach Ltd | Program loop control |
GB2548604B (en) | 2016-03-23 | 2018-03-21 | Advanced Risc Mach Ltd | Branch instruction |
GB2548602B (en) * | 2016-03-23 | 2019-10-23 | Advanced Risc Mach Ltd | Program loop control |
JP2018109838A (en) * | 2016-12-28 | 2018-07-12 | 富士通株式会社 | Information processing device, information processing system, program and information processing method |
US10740067B2 (en) | 2017-06-23 | 2020-08-11 | International Business Machines Corporation | Selective updating of floating point controls |
US10684852B2 (en) | 2017-06-23 | 2020-06-16 | International Business Machines Corporation | Employing prefixes to control floating point operations |
US10481908B2 (en) | 2017-06-23 | 2019-11-19 | International Business Machines Corporation | Predicted null updated |
US10514913B2 (en) | 2017-06-23 | 2019-12-24 | International Business Machines Corporation | Compiler controls for program regions |
US10379851B2 (en) | 2017-06-23 | 2019-08-13 | International Business Machines Corporation | Fine-grained management of exception enablement of floating point controls |
US10310814B2 (en) | 2017-06-23 | 2019-06-04 | International Business Machines Corporation | Read and set floating point control register instruction |
US10725739B2 (en) | 2017-06-23 | 2020-07-28 | International Business Machines Corporation | Compiler controls for program language constructs |
GB2564144B (en) * | 2017-07-05 | 2020-01-08 | Advanced Risc Mach Ltd | Context data management |
GB2575877B (en) | 2018-07-27 | 2021-06-09 | Advanced Risc Mach Ltd | Memory protection unit using memory protection table stored in memory system |
CN111782269B (en) * | 2020-06-04 | 2023-12-12 | 珠海格力电器股份有限公司 | Interrupt processing method and interrupt processing equipment |
CN114064302A (en) * | 2020-07-30 | 2022-02-18 | 华为技术有限公司 | Method and device for interprocess communication |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5701508A (en) * | 1995-12-19 | 1997-12-23 | Intel Corporation | Executing different instructions that cause different data type operations to be performed on single logical register file |
EP0953905A2 (en) * | 1998-04-27 | 1999-11-03 | Sony Corporation | Method and apparatus for switching tasks |
US20080046701A1 (en) * | 2006-08-16 | 2008-02-21 | Arm Limited | Data processing apparatus and method for controlling access to registers |
Family Cites Families (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5481719A (en) * | 1994-09-09 | 1996-01-02 | International Business Machines Corporation | Exception handling method and apparatus for a microkernel data processing system |
DE69628326D1 (en) * | 1995-10-06 | 2003-06-26 | Patriot Scient Corp | ARCHITECTURE FOR A RISC MICROPROCESSOR |
US6792523B1 (en) * | 1995-12-19 | 2004-09-14 | Intel Corporation | Processor with instructions that operate on different data types stored in the same single logical register file |
US6119206A (en) * | 1996-02-12 | 2000-09-12 | Sun Microsystems, Inc. | Design of tags for lookup of non-volatile registers |
US5761491A (en) * | 1996-04-15 | 1998-06-02 | Motorola Inc. | Data processing system and method for storing and restoring a stack pointer |
US5928356A (en) * | 1997-10-11 | 1999-07-27 | Institute For The Development Of Emerging Architectures, L.L.C. | Method and apparatus for selectively controlling groups of registers |
JP3982353B2 (en) | 2002-07-12 | 2007-09-26 | 日本電気株式会社 | Fault tolerant computer apparatus, resynchronization method and resynchronization program |
US7934082B2 (en) * | 2004-08-27 | 2011-04-26 | Panasonic Corporation | Information processing apparatus and exception control circuit |
US20070136724A1 (en) * | 2005-12-12 | 2007-06-14 | Arun Sharma | Transferring registers in transitions between computer environments |
-
2009
- 2009-06-19 GB GB0910661.8A patent/GB2471138B/en active Active
-
2010
- 2010-04-30 WO PCT/GB2010/000879 patent/WO2010146328A1/en active Application Filing
- 2010-04-30 CN CN201080027396.9A patent/CN102460377B/en active Active
- 2010-04-30 MY MYPI2011005609A patent/MY154086A/en unknown
- 2010-04-30 EP EP10717209.0A patent/EP2443548B1/en active Active
- 2010-04-30 KR KR1020127000881A patent/KR101762124B1/en active IP Right Grant
- 2010-04-30 JP JP2012515549A patent/JP5564562B2/en active Active
- 2010-05-03 US US12/662,783 patent/US9201651B2/en active Active
- 2010-05-24 TW TW099116532A patent/TWI478064B/en active
-
2011
- 2011-11-15 IL IL216377A patent/IL216377A/en active IP Right Grant
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5701508A (en) * | 1995-12-19 | 1997-12-23 | Intel Corporation | Executing different instructions that cause different data type operations to be performed on single logical register file |
EP0953905A2 (en) * | 1998-04-27 | 1999-11-03 | Sony Corporation | Method and apparatus for switching tasks |
US20080046701A1 (en) * | 2006-08-16 | 2008-02-21 | Arm Limited | Data processing apparatus and method for controlling access to registers |
Also Published As
Publication number | Publication date |
---|---|
CN102460377B (en) | 2015-02-18 |
IL216377A (en) | 2016-05-31 |
IL216377A0 (en) | 2012-01-31 |
GB0910661D0 (en) | 2009-08-05 |
CN102460377A (en) | 2012-05-16 |
GB2471138B (en) | 2014-08-13 |
JP5564562B2 (en) | 2014-07-30 |
GB2471138A (en) | 2010-12-22 |
KR101762124B1 (en) | 2017-07-27 |
US20100325397A1 (en) | 2010-12-23 |
TW201102929A (en) | 2011-01-16 |
KR20120052934A (en) | 2012-05-24 |
MY154086A (en) | 2015-04-30 |
JP2012530315A (en) | 2012-11-29 |
TWI478064B (en) | 2015-03-21 |
EP2443548B1 (en) | 2015-07-01 |
EP2443548A1 (en) | 2012-04-25 |
US9201651B2 (en) | 2015-12-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP2443548B1 (en) | Data processing apparatus and method | |
JP5680679B2 (en) | Apparatus and method for handling exception events | |
US8195922B2 (en) | System for dynamically allocating processing time to multiple threads | |
US5197138A (en) | Reporting delayed coprocessor exceptions to code threads having caused the exceptions by saving and restoring exception state during code thread switching | |
JP2612168B2 (en) | Data processor | |
US8191085B2 (en) | Method and apparatus for loading or storing multiple registers in a data processing system | |
EP2593861B1 (en) | System and method to allocate portions of a shared stack | |
WO2013117899A1 (en) | Exception handling in a data processing apparatus having a secure domain and a less secure domain | |
JPH05197548A (en) | Psw changing system | |
US20130212700A1 (en) | Exception handling in a data processing apparatus having a secure domain and a less secure domain | |
EP2083352B1 (en) | Processing unit | |
US20120042136A1 (en) | Alignment control | |
CN1099631C (en) | Backout logic for dual execution unit processor | |
US5943494A (en) | Method and system for processing multiple branch instructions that write to count and link registers | |
US7890740B2 (en) | Processor comprising a first and a second mode of operation and method of operating the same | |
JP3701203B2 (en) | Computer system | |
JPH1040103A (en) | Information processing system having register/remapping structure and its method | |
US7203822B2 (en) | Unprivileged context management | |
US20020144091A1 (en) | Method and apparatus for dynamic register management in a processor | |
JP3603314B2 (en) | Information processing apparatus and method | |
GB2500844A (en) | Selecting either base level or further level stack when processing data in current further level exception state above base level | |
WO2001061476A2 (en) | System including cpu and code translator for translating code from a second instruction set to a first instruction set | |
JPS58215779A (en) | Data processor |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
WWE | Wipo information: entry into national phase |
Ref document number: 201080027396.9 Country of ref document: CN |
|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 10717209 Country of ref document: EP Kind code of ref document: A1 |
|
WWE | Wipo information: entry into national phase |
Ref document number: 2010717209 Country of ref document: EP |
|
WWE | Wipo information: entry into national phase |
Ref document number: 2012515549 Country of ref document: JP |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
ENP | Entry into the national phase |
Ref document number: 20127000881 Country of ref document: KR Kind code of ref document: A |