A context processing method, device, medium and chip
By adopting a context processing method based on register linked list in the operating system, the problem of inconvenient and low efficiency of context storage in the prior art is solved, and more efficient context management and query are achieved.
Patent Information
- Application Number
- CN202411973813.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-04
AI Technical Summary
In the prior art, the form of saving the context into the stack is not convenient to obtain, query and trace the context in complex scenarios, and it occupies a large memory space and is less efficient.
The context processing method based on the register linked list is adopted, and the context is saved and restored through the linked list structure of the first register, the second register and N ordinary registers.
It improves the efficiency of context acquisition, query and traceability in complex scenarios, reduces memory space usage, and improves the operating efficiency of the operating system.
Smart Images

Figure CN119759506A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a context processing method, device, medium and chip. Background Art
[0002] During the operation of the chip used for vehicle control, the chip's operating system (OS) will execute different objects. Different objects can be programs used to implement different vehicle control functions. If the operating system needs to switch to executing a new object during the execution of the current object, the operating system will stop executing the current object, save the context of the current object, and then execute the new object. After the new object is executed, the operating system will obtain the saved context and restore the context based on the saved context.
[0003] In the related art, the commonly used context processing scheme is: the operating system saves the context to the stack, and obtains the saved context from the stack after the new object is executed. The context saving form of saving the context to the stack in the related art is not convenient for obtaining, querying and tracing the context in complex scenarios, occupies a large memory space, and has low efficiency. The context saving form of saving the context to the stack will require the operating system to make separate records for the context part during use. In the scenario where multiple objects are nested and the application (APP) is closed due to error handling, the operating system needs to look forward for the nested context, and the existing contexts need to be connected in the form of a linked list, which takes up space and has a slow query speed. Summary of the invention
[0004] The present invention provides a context processing method, device, medium and chip to solve the problem in the related art that the context saving method of saving the context in a stack is inconvenient for obtaining, querying and tracing the context in complex scenarios, occupies a large memory space and has low efficiency.
[0005] According to one aspect of the present invention, a context processing method is provided, which is based on a register linked list and is applied to an operating system, comprising:
[0006] The operating system performs context processing, saves data, and restores data based on the register list;
[0007] The register linked list includes: a first register, a second register and N ordinary registers; the first register is used to indicate the latest saved context and is the list head of the register linked list; the second register is used to indicate the address of the currently idle ordinary register; each ordinary register includes empty content and the previous context address.
[0008] The operating system performs context processing based on the register list, saves data, and restores data, including:
[0009] During the execution process, the operating system switches to the new target object for execution;
[0010] After the operating system saves the target data of the new target object into the general register, it executes the context save instruction and the context restore instruction based on the register linked list.
[0011] The execution context save instruction includes the initial save, specifically:
[0012] The operating system executes a context save instruction, obtains a currently idle first common register through an idle register, stores the initial context to be saved in the empty content of the first common register, updates the previous context address of the first common register to empty, updates the content of the first register to the address of the first common register, and updates the content of the second register to the address of the second common register.
[0013] Executing the context save instruction also includes saving again, specifically:
[0014] After the initial save, the operating system executes the context save instruction again, obtains the currently idle second ordinary register through the idle register, stores the context to be saved again in the empty content of the second ordinary register, and updates the previous context address of the second ordinary register to the address of the first ordinary register, updates the content of the first register to the address of the second ordinary register, and updates the content of the second register to the address of the third ordinary register.
[0015] Execute context recovery instructions, including:
[0016] After saving again, the operating system executes a context recovery instruction, updates the content of the second register from the address of the third general register to the address of the second general register through the idle register, takes out the context in the second general register, updates the empty content of the second general register to empty, updates the previous context address of the second general register to the address of the third general register, and updates the content of the first register to the address of the first general register.
[0017] According to another aspect of the present invention, there is provided a device for executing an operating system context processing method, which is configured in an operating system and includes:
[0018] System startup means, used to switch to a new target object and start execution during execution;
[0019] A context saving device, for executing a context saving instruction based on a register linked list after saving target data of a new target object to a general register;
[0020] A context recovery device, used for executing a context recovery instruction based on the register linked list after the context save instruction is executed;
[0021] The register linked list includes: a first register, a second register and N ordinary registers; the first register is used to indicate the latest saved context and is the list head of the register linked list; the second register is used to indicate the address of the currently idle ordinary register; each ordinary register includes empty content and the previous context address.
[0022] The execution context save instruction includes the initial save, specifically:
[0023] Execute a context save instruction, obtain the currently idle first common register through the idle register, store the initial context to be saved in the empty content of the first common register, and update the previous context address of the first common register to empty, update the content of the first register to the address of the first common register, and update the content of the second register to the address of the second common register.
[0024] Executing the context save instruction also includes saving again, specifically:
[0025] After the initial save, the context save instruction is executed again, the currently idle second ordinary register is obtained through the idle register, the context to be saved again is stored in the empty content of the second ordinary register, and the previous context address of the second ordinary register is updated to the address of the first ordinary register, the content of the first register is updated to the address of the second ordinary register, and the content of the second register is updated to the address of the third ordinary register.
[0026] Execute context recovery instructions, including:
[0027] After saving again, execute the context recovery instruction, update the content of the second register from the address of the third general register to the address of the second general register through the idle register, take out the context in the second general register, update the empty content of the second general register to empty, update the previous context address of the second general register to the address of the third general register, and update the content of the first register to the address of the first general register.
[0028] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the context processing method described in any embodiment of the present invention when executed.
[0029] According to another aspect of the present invention, a chip is provided, the chip comprising:
[0030] at least one processor;
[0031] and a memory communicatively coupled to the at least one processor;
[0032] The memory stores a computer program executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the context processing method described in any embodiment of the present invention.
[0033] In the technical solution of the embodiment of the present invention, the operating system performs context processing based on a register linked list to save and restore data; wherein the register linked list includes: a first register, a second register and N ordinary registers; the first register is used to indicate the latest saved context and is the list head of the register linked list; the second register is used to indicate the address of the currently idle ordinary register; each ordinary register includes an empty content and the previous context address, which solves the problem that the context saving form of saving the context to the stack in the related art is not convenient for context acquisition, query and tracing in complex scenarios, occupies a large memory space, and has low efficiency. The context can be processed based on the register linked list, and the context can be saved and restored by hardware, which occupies a small memory space, and the efficiency of context acquisition, query and tracing is high, which can increase the operating efficiency of the operating system and reduce the context query and saving time of the operating system.
[0034] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0036] Figure 1 A flowchart of a context processing method provided by an embodiment of the present invention.
[0037] Figure 2 A schematic diagram of a register linked list in an initial state provided by an embodiment of the present invention.
[0038] Figure 3 A schematic diagram of a register linked list after initial saving provided by an embodiment of the present invention.
[0039] Figure 4 A schematic diagram of a register linked list after being saved again provided by an embodiment of the present invention.
[0040] Figure 5 A schematic diagram of a register linked list after executing a context restore instruction provided by an embodiment of the present invention.
[0041] Figure 6 A flowchart of a context processing method provided by an embodiment of the present invention.
[0042] Figure 7 A schematic structural diagram of a device for executing an operating system context processing method provided by an embodiment of the present invention.
[0043] Figure 8 A schematic diagram of the structure of a chip for implementing the context processing method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0044] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0045] It should be noted that the terms "target", "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprise", "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0046] Figure 1A flowchart of a context processing method provided by an embodiment of the present invention. This embodiment is applicable to the case where the context of an executed object is processed. The method can be executed by the operating system of the chip. The chip can be a vehicle-grade chip for vehicle control. Figure 1 As shown, the method includes:
[0047] Step 101: The operating system performs context processing based on the register linked list to save and restore data.
[0048] The register linked list includes: a first register, a second register and N ordinary registers; the first register is used to indicate the latest saved context and is the list head of the register linked list; the second register is used to indicate the address of the currently idle ordinary register; each ordinary register includes empty content and the previous context address.
[0049] Optionally, during the operation of the chip, the operating system of the chip will execute different objects. Different objects may be programs for implementing different vehicle control functions. The identification information of each object may be a string used to uniquely identify the object. The context of an object may refer to data in the chip that characterizes the execution environment and execution state of the object when the execution of the object stops. If the operating system switches to executing a new object during the execution of the current object, the operating system needs to save the context of the current object.
[0050] Optionally, the first register may be a register set in the chip specifically for indicating the current latest saved context. The current latest saved context may refer to the last stored context among the contexts that have been stored in the common register. The second register may be an address of a common register set in the chip specifically for indicating the current idle context. The current idle common register may refer to a common register among N common registers that can be used to store the next context. The N common registers may be N registers set in the chip for storing contexts. The N common registers include a first common register, a second common register, ..., an Nth common register. N is a positive integer greater than or equal to 2. The common register includes an empty content and a previous context address. The empty content of the common register may be an area in the common register for storing contexts. The previous context address of the common register may be the address of the current latest saved context stored in the common register before the common register stores the context. The address of the context may refer to the address of the register for storing the context. The address of the register may be a string for uniquely identifying the register.
[0051] Optionally, in a specific example, Figure 2A schematic diagram of a register linked list in an initial state provided for an embodiment of the present invention. In the initial state, no context is saved. The content of the first register is empty. The content of the second register is the address of the first common register. The N common registers include the first common register, the second common register, ..., the Nth common register. The empty content of each common register is empty. The previous context address of the first common register is the address of the second common register. The previous context address of the second common register is the address of the third common register. By analogy, the previous context address of the Nth common register is the address of the N+1th common register. Since the N+1th common register does not exist, the address of the N+1th common register can be empty.
[0052] Optionally, the operating system performs context processing based on the register linked list to save and restore data, including: during the execution process, the operating system switches to a new target object for execution; after the operating system saves the target data of the new target object to a general register, it executes context save instructions and context restore instructions based on the register linked list.
[0053] Optionally, the new target object is a new object that needs to be executed by the operating system. The target data of the new target object may refer to data related to the new target object acquired by the operating system. The general register may be a general register set in the chip for storing data.
[0054] Optionally, the context save instruction may be a pre-set instruction for saving the context based on a register linked list. When the operating system executes the context save instruction, it obtains a currently idle ordinary register through the idle register, stores the context to be saved in the empty content of the obtained ordinary register, and updates the previous context address of the obtained ordinary register, the content of the first register, and the content of the second register. The idle register may be a pre-set register for performing related operations of saving the context and restoring the context.
[0055] Optionally, the context restore instruction may be a pre-set instruction for restoring the context based on the register linked list. When the operating system executes the context restore instruction, it will fetch the current latest saved context from the common register storing the current latest saved context through the free register, and update the empty content of the common register and the previous context address, the content of the first register, and the content of the second register.
[0056] Optionally, executing a context save instruction includes an initial save, specifically: the operating system executes a context save instruction, obtains a currently idle first ordinary register through an idle register, stores the initial context to be saved in the empty content of the first ordinary register, and updates the previous context address of the first ordinary register to empty, updates the content of the first register to the address of the first ordinary register, and updates the content of the second register to the address of the second ordinary register.
[0057] Optionally, the context to be saved for the first time is the first context that needs to be saved during the execution process. When a context needs to be saved for the first time, the operating system executes a context save instruction, obtains the currently idle first common register through the idle register, stores the context to be saved for the first time in the empty content of the first common register, and updates the previous context address of the first common register to empty, updates the content of the first register to the address of the first common register, and updates the content of the second register to the address of the second common register. Thus, the context save instruction is executed based on the register linked list, the context to be saved for the first time is saved in the first common register, and the relevant address information is updated in time, so that the latest saved context is indicated by the first register, and the currently idle common register is indicated by the second register.
[0058] Optionally, in a specific example, Figure 3 A schematic diagram of a register linked list after initial saving provided by an embodiment of the present invention. After the initial saving, the content of the first register is updated to the address of the first general register, the context to be saved for the first time is stored in the empty content of the first general register, the previous context address of the first general register is updated to empty (all 0), and the content of the second register is updated to the address of the second general register.
[0059] Optionally, executing the context save instruction also includes saving again, specifically: based on the initial save, the operating system executes the context save instruction again, obtains the currently idle second ordinary register through the idle register, stores the context to be saved again in the empty content of the second ordinary register, and updates the previous context address of the second ordinary register to the address of the first ordinary register, updates the content of the first register to the address of the second ordinary register, and updates the content of the second register to the address of the third ordinary register.
[0060] Optionally, the context to be saved again is the second context that needs to be saved during the execution process. When the context needs to be saved again after the initial save, the operating system executes the context save instruction, obtains the currently idle second ordinary register through the idle register, stores the context to be saved again in the empty content of the second ordinary register, and updates the previous context address of the second ordinary register to the address of the first ordinary register, updates the content of the first register to the address of the second ordinary register, and updates the content of the second register to the address of the third ordinary register. Thus, the context save instruction is executed based on the register linked list, the context to be saved again is stored in the second ordinary register, and the relevant address information is updated in time, so that the current latest saved context is indicated by the first register, and the currently idle ordinary register is indicated by the second register.
[0061] Optionally, in a specific example, Figure 4 A schematic diagram of a register linked list after re-saving provided by an embodiment of the present invention. After re-saving, the content of the first register is updated to the address of the second general register, the context to be saved again is stored in the empty content of the second general register, the previous context address of the second general register is updated to the address of the first general register, and the content of the second register is updated to the address of the third general register. When saving again, the register content pointed to by the second register is updated and given to the first register.
[0062] Optionally, executing a context recovery instruction includes: based on saving again, the operating system executes the context recovery instruction, updates the content of the second register from the address of the third general register to the address of the second general register through the idle register, takes out the context in the second general register, updates the empty content of the second general register to empty, updates the previous context address of the second general register to the address of the third general register, and updates the content of the first register to the address of the first general register.
[0063] Optionally, after saving again, the context to be saved again stored in the empty content of the second common register is the current latest saved context. In the case where the current latest saved context needs to be obtained after saving again, the operating system executes a context recovery instruction, updates the content of the second register from the address of the third common register to the address of the second common register through the idle register, takes out the context in the second common register, that is, takes out the current latest saved context, updates the empty content of the second common register to empty, updates the previous context address of the second common register to the address of the third common register, and updates the content of the first register to the address of the first common register. Thus, the context recovery instruction is executed based on the register linked list, and after saving again, the current latest saved context is taken out from the second common register storing the current latest saved context, and the empty content and the previous context address of the second common register, the content of the first register, and the content of the second register are updated.
[0064] Optionally, in a specific example, Figure 5 A schematic diagram of a register linked list after executing a context restore instruction provided by an embodiment of the present invention. After the initial save and the second save, the operating system executes the context restore instruction. The content of the second register is updated from the address of the third general register to the address of the second general register, the context stored in the second general register is taken out, the empty content of the second general register is updated to empty, the previous context address of the second general register is updated to the address of the third general register, and the content of the first register is updated to the address of the first general register.
[0065] In the technical solution of the embodiment of the present invention, the operating system performs context processing based on a register linked list to save and restore data; wherein the register linked list includes: a first register, a second register and N ordinary registers; the first register is used to indicate the latest saved context and is the list head of the register linked list; the second register is used to indicate the address of the currently idle ordinary register; each ordinary register includes an empty content and the previous context address, which solves the problem that the context saving form of saving the context to the stack in the related art is not convenient for context acquisition, query and tracing in complex scenarios, occupies a large memory space, and has low efficiency. The context can be processed based on the register linked list, and the context can be saved and restored by hardware, which occupies a small memory space, and the efficiency of context acquisition, query and tracing is high, which can increase the operating efficiency of the operating system and reduce the context query and saving time of the operating system.
[0066] Optionally, the size of the space occupied by the register list is determined according to kernel characteristics, such as the number of general registers, etc. The technical solution of the embodiment of the present invention is not only applicable to upper-layer usage scenarios such as OS, but also can perform conventional context preservation for underlying development. When the previous context needs to be queried, the technical solution of the embodiment of the present invention is more convenient and faster than the existing method.
[0067] Figure 6 A flowchart of a context processing method provided by an embodiment of the present invention. The embodiment of the present invention can be combined with each optional solution in one or more of the above embodiments. Figure 6 As shown, the method includes:
[0068] Step 201: During execution, the operating system switches to a new target object for execution.
[0069] Step 202: After the operating system saves the target data of the new target object into the general register, it executes the context save instruction and the context restore instruction based on the register linked list.
[0070] Optionally, executing a context save instruction includes an initial save, specifically: the operating system executes a context save instruction, obtains a currently idle first ordinary register through an idle register, stores the initial context to be saved in the empty content of the first ordinary register, and updates the previous context address of the first ordinary register to empty, updates the content of the first register to the address of the first ordinary register, and updates the content of the second register to the address of the second ordinary register.
[0071] Optionally, executing the context save instruction also includes saving again, specifically: based on the initial save, the operating system executes the context save instruction again, obtains the currently idle second ordinary register through the idle register, stores the context to be saved again in the empty content of the second ordinary register, and updates the previous context address of the second ordinary register to the address of the first ordinary register, updates the content of the first register to the address of the second ordinary register, and updates the content of the second register to the address of the third ordinary register.
[0072] Optionally, executing a context recovery instruction includes: based on saving again, the operating system executes the context recovery instruction, updates the content of the second register from the address of the third general register to the address of the second general register through the idle register, takes out the context in the second general register, updates the empty content of the second general register to empty, updates the previous context address of the second general register to the address of the third general register, and updates the content of the first register to the address of the first general register.
[0073] The technical solution of the embodiment of the present invention can execute context save instructions and context restore instructions based on the register linked list after the operating system switches to the new target object for execution, thereby processing the context, saving and restoring the context through hardware, occupying less memory space, and having high efficiency in context acquisition, query and tracing, which can increase the operating efficiency of the operating system and reduce the context query and saving time of the operating system.
[0074] Figure 7 The present invention provides a schematic diagram of a device for executing an operating system context processing method according to an embodiment of the present invention. The device for executing an operating system context processing method can be implemented in the form of hardware and / or software, and the device for executing an operating system context processing method can be configured in an operating system. Figure 7 As shown, the device for executing the operating system context processing method includes: a system starting device 301, a context saving device 302 and a context restoring device 303.
[0075] Among them, the system startup device 301 is used to switch to the new target object to start execution during the execution process; the context saving device 302 is used to execute the context saving instruction based on the register list after the target data of the new target object is saved to the general register; the context recovery device 303 is used to execute the context recovery instruction based on the register list after the context saving instruction is executed; wherein, the register list includes: a first register, a second register and N ordinary registers; the first register is used to indicate the current latest saved context and is the list head of the register list; the second register is used to indicate the address of the currently idle ordinary register; each of the ordinary registers includes empty content and the previous context address.
[0076] The technical solution of the embodiment of the present invention can execute context save instructions and context restore instructions based on the register linked list after the operating system switches to the new target object for execution, thereby processing the context, saving and restoring the context through hardware, occupying less memory space, and having high efficiency in context acquisition, query and tracing, which can increase the operating efficiency of the operating system and reduce the context query and saving time of the operating system.
[0077] In an optional implementation of an embodiment of the present invention, optionally, executing a context save instruction includes an initial save, specifically: executing a context save instruction, obtaining a currently idle first ordinary register through an idle register, storing the initial context to be saved in the empty content of the first ordinary register, and updating the previous context address of the first ordinary register to empty, updating the content of the first register to the address of the first ordinary register, and updating the content of the second register to the address of the second ordinary register.
[0078] In an optional implementation of an embodiment of the present invention, optionally, executing the context save instruction also includes saving again, specifically: based on the initial save, executing the context save instruction again, obtaining the currently idle second ordinary register through the idle register, storing the context to be saved again in the empty content of the second ordinary register, and updating the previous context address of the second ordinary register to the address of the first ordinary register, updating the content of the first register to the address of the second ordinary register, and updating the content of the second register to the address of the third ordinary register.
[0079] In an optional implementation of an embodiment of the present invention, optionally, executing a context recovery instruction includes: based on saving again, executing the context recovery instruction, updating the content of the second register from the address of the third general register to the address of the second general register through the idle register, taking out the context in the second general register, updating the empty content of the second general register to empty, updating the previous context address of the second general register to the address of the third general register, and updating the content of the first register to the address of the first general register.
[0080] The device for executing the operating system context processing method provided by the embodiment of the present invention can execute the context processing method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0081] Figure 8 The schematic diagram of the structure of a chip 10 that can be used to implement the context processing method of an embodiment of the present invention is shown. The chip 10 may be a vehicle-grade chip for vehicle control. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0082] like Figure 8As shown, the chip 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the chip 10 can also be stored. The processor 11, ROM 12 and RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0083] A number of components in the chip 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the chip 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0084] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the context processing method.
[0085] In some embodiments, the context handling method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit. In some embodiments, part or all of the computer program may be loaded and / or installed on a heterogeneous hardware accelerator via a ROM and / or a communication unit. When the computer program is loaded into RAM and executed by a processor, one or more steps of the context handling method described above may be performed. Alternatively, in other embodiments, the processor may be configured to perform the context handling method in any other appropriate manner (e.g., by means of firmware).
[0086] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0087] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a chip, a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or chip.
[0088] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0089] To provide interaction with a user, the systems and techniques described herein may be implemented on a heterogeneous hardware accelerator having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) through which a user can provide input to the heterogeneous hardware accelerator. Other types of devices may also be used to provide interaction with a user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0090] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data electronic device), or a computing system that includes middleware components (e.g., an application electronic device), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0091] The computing system may include a client and an electronic device. The client and the electronic device are generally remote from each other and usually interact through a communication network. The relationship between the client and the electronic device is generated by computer programs running on corresponding computers and having a client-electronic device relationship with each other. The electronic device may be a cloud electronic device, also known as a cloud computing electronic device or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0092] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0093] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A context processing method, based on a register linked list, applied to an operating system, characterized in that: include: The operating system performs context processing, saves data, and restores data based on the register list; The register linked list includes: a first register, a second register and N ordinary registers; the first register is used to indicate the latest saved context and is the list head of the register linked list; the second register is used to indicate the address of the currently idle ordinary register; each ordinary register includes empty content and the previous context address.
2. The context processing method according to claim 1, characterized in that: The operating system performs context processing based on the register list, saves data, and restores data, including: During the execution process, the operating system switches to the new target object for execution; After the operating system saves the target data of the new target object into the general register, it executes the context save instruction and the context restore instruction based on the register linked list.
3. The context processing method according to claim 2, characterized in that: The execution context save instruction includes the initial save, specifically: The operating system executes a context save instruction, obtains a currently idle first common register through an idle register, stores the initial context to be saved in the empty content of the first common register, updates the previous context address of the first common register to empty, updates the content of the first register to the address of the first common register, and updates the content of the second register to the address of the second common register.
4. The context processing method according to claim 3, characterized in that: Executing the context save instruction also includes saving again, specifically: After the initial save, the operating system executes the context save instruction again, obtains the currently idle second ordinary register through the idle register, stores the context to be saved again in the empty content of the second ordinary register, and updates the previous context address of the second ordinary register to the address of the first ordinary register, updates the content of the first register to the address of the second ordinary register, and updates the content of the second register to the address of the third ordinary register.
5. The context processing method according to claim 4, characterized in that: Execute context recovery instructions, including: After saving again, the operating system executes a context recovery instruction, updates the content of the second register from the address of the third general register to the address of the second general register through the idle register, takes out the context in the second general register, updates the empty content of the second general register to empty, updates the previous context address of the second general register to the address of the third general register, and updates the content of the first register to the address of the first general register.
6. A device for executing an operating system context processing method, configured in an operating system, characterized in that: include: System startup means, used to switch to a new target object and start execution during execution; A context saving device, for executing a context saving instruction based on a register linked list after saving target data of a new target object to a general register; A context recovery device, used for executing a context recovery instruction based on the register linked list after the context save instruction is executed; The register linked list includes: a first register, a second register and N ordinary registers; the first register is used to indicate the latest saved context and is the list head of the register linked list; the second register is used to indicate the address of the currently idle ordinary register; each ordinary register includes empty content and the previous context address.
7. The device for executing the operating system context processing method according to claim 6, characterized in that: The execution context save instruction includes the initial save, specifically: Execute a context save instruction, obtain the currently idle first common register through the idle register, store the initial context to be saved in the empty content of the first common register, and update the previous context address of the first common register to empty, update the content of the first register to the address of the first common register, and update the content of the second register to the address of the second common register.
8. The device for executing the operating system context processing method according to claim 7, characterized in that: Executing the context save instruction also includes saving again, specifically: After the initial save, the context save instruction is executed again, the currently idle second ordinary register is obtained through the idle register, the context to be saved again is stored in the empty content of the second ordinary register, and the previous context address of the second ordinary register is updated to the address of the first ordinary register, the content of the first register is updated to the address of the second ordinary register, and the content of the second register is updated to the address of the third ordinary register.
9. The device for executing the operating system context processing method according to claim 8, characterized in that: Execute context recovery instructions, including: After saving again, execute the context recovery instruction, update the content of the second register from the address of the third general register to the address of the second general register through the idle register, take out the context in the second general register, update the empty content of the second general register to empty, update the previous context address of the second general register to the address of the third general register, and update the content of the first register to the address of the first general register.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the context processing method according to any one of claims 1 to 5 when executed.
11. A chip, characterized in that: The chip comprises: at least one processor; and a memory coupled to the at least one processor; The memory stores a computer program executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the context processing method according to any one of claims 1 to 5.