Method and device for constructing operating system decoupling for RISC-V architecture
By dividing the RISC-V operating system software components into three categories, using the general compilation tool chain to build unrelated components and the specified compilation tool chain to build related components, and packaging them through compatibility guarantee methods, the general compilation tools under the RISC-V architecture are solved. The problem of insufficient chain support improves operating system development efficiency and compatibility.
Patent Information
- Application Number
- CN202411090391.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-08-09
AI Technical Summary
The number of extended instruction sets of RISC-V architectures is growing rapidly, and existing general-purpose compilation toolchains are difficult to support, which makes operating system construction time-consuming and easy to introduce bugs, resulting in developers facing huge workload and inefficiency.
Dividing operating system software components into three categories: unrelated components are built by a general compilation toolchain, and related but not supported components are built by a designated compilation toolchain, and packaged into an operating system image through a compatibility guarantee method, using universal compilation. The components built by the toolchain can be multiplexed across processor combinations of different extended instruction sets.
It saves the engineering amount of building irrelevant software components of the extended instruction set, reduces the bug fix process, improves the operating system development efficiency, and reduces the development time and workload of the processor combined with different extended instruction sets.
Smart Images

Figure CN118626097B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software technology, and in particular to a method and device for decoupling and constructing an operating system for a RISC-V architecture. Background Art
[0002] When building a modern operating system, a compiler tool chain is generally used to build all software components of the entire operating system to achieve the following goals: (1) ensure binary compatibility between all software components; (2) make operating system maintenance easier, reducing the workload of tracking and solving problems caused by different compiler options or versions; (3) standardize the build process to make the build environment more consistent and controllable. For x86 and ARM architectures, this approach is easy to accept because the instruction sets of x86 and ARM architectures are relatively fixed, the number of extended instruction sets is small and the update speed is slow. Therefore, the general compiler tool chain used to build operating systems can relatively stably and continuously support x86 and ARM architecture processors with extended instruction sets.
[0003] First, for the RISC-V architecture, the number of RISC-V standard and non-standard extended instruction sets is growing rapidly. If the existing general-purpose compilation tool chain for building operating systems is directly used to develop operating systems for RISC-V processors with different combinations of RISC-V extended instruction sets, there may be a problem that the general-purpose compilation tool chain does not support specific RISC-V extended instruction sets.
[0004] Secondly, when the entire operating system is built directly using only the specified compilation tool chain that supports the RISC-V extended instruction set, a large number of software components that are not related to the RISC-V extended instruction set also need to be built from source code, which is a very time-consuming process. In addition, new bugs may be introduced due to the difference in versions between the RISC-V extended instruction set-specific compilation tool chain and the general compilation tool chain, which will lead to continuous bug repairs and bring huge workloads to developers. Therefore, with the increasing number of RISC-V extended instruction sets, there is a combinatorial explosion problem between the combinations of extended instruction sets. The engineering workload of developing an operating system for many RISC-V processors with different RISC-V extended instruction set combinations using only the compilation tool chain specified by the RISC-V extended instruction set is huge, and it is easy to fall into a continuous bug repair process. Summary of the invention
[0005] The present invention provides a method and device for constructing a decoupled operating system for a RISC-V architecture, so as to solve the defects in the prior art.
[0006] The present invention provides a method for decoupling and constructing an operating system for a RISC-V architecture, comprising the following steps:
[0007] Obtain the extended instruction set set in the RISC-V processor and the software component set in the operating system to be built;
[0008] Based on the extended instruction set set, determining a first subset, a second subset, and a third subset from the software component set, wherein the first subset refers to a set of software components that are not related to the RISC-V extended instruction set, the second subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is supported by a general compiler tool chain, and the third subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is not supported by a general compiler tool chain;
[0009] Building the software components in the first subset and the second subset based on a general compilation tool chain, and building the software components in the third subset based on a specified compilation tool chain supporting the RISC-V extended instruction set;
[0010] All software components constructed from the first subset, the second subset, and the third subset are packaged into an operating system image.
[0011] A method for decoupling and constructing an operating system for a RISC-V architecture provided by the present invention further includes:
[0012] If the version of the universal compilation tool chain is higher than the version of the specified compilation tool chain, the universal compilation tool chain is backward compatible with the specified compilation tool chain;
[0013] If the version of the universal compilation tool chain is lower than the version of the specified compilation tool chain, the specified compilation tool chain is backward compatible with the universal compilation tool chain.
[0014] According to a decoupled construction method for an operating system for a RISC-V architecture provided by the present invention, if the version of the general compilation tool chain is lower than the version of the specified compilation tool chain, the method further includes:
[0015] When running in an operating system running environment aligned with the universal compilation tool chain, the runtime dependency corresponding to the target software component is replaced, and the target software component refers to the software component constructed by the third subset.
[0016] According to a decoupled construction method for an operating system for a RISC-V architecture provided by the present invention, the runtime dependency corresponding to the replacement target software component includes:
[0017] Constructing a directed acyclic graph of all dependencies of the target software component;
[0018] Acquire the target software component and a first library set dependent on the target software component dependency chain from the directed acyclic graph;
[0019] Acquire a second library set corresponding to the first library set in the operating system running environment;
[0020] Traversing the elements in the first library set, obtaining a first highest version number of a current element in the first library set, and a second highest version number of an element in the second library set corresponding to the current element;
[0021] If the first highest version number is higher than the second highest version number, the element in the second library set corresponding to the current element is replaced with the current element.
[0022] A method for decoupling and constructing an operating system for a RISC-V architecture provided by the present invention further includes:
[0023] If the current element in the first library set does not have a version number, the current element is added to the third library set of unsigned versions that the specified compilation tool chain depends on, and the element corresponding to the current element in the second library set is added to the fourth library set of unsigned versions that the operating system running environment depends on.
[0024] According to a RISC-V architecture-oriented operating system decoupling construction method provided by the present invention, the element corresponding to the current element in the second library set is replaced with the current element, and then further includes:
[0025] Obtaining all function names of the target software component and constructing a function name set including all function names;
[0026] If any function name in the function name set does not have a version number, obtaining a first symbol table corresponding to the target element in the third library set;
[0027] If any of the function names belongs to the first symbol table, obtaining a second symbol table of an element in the fourth library set corresponding to the target element;
[0028] If any of the function names does not belong to the second symbol table, the element corresponding to the current element in the fourth library set is replaced with the current element.
[0029] The present invention also provides an operating system decoupling construction device for RISC-V architecture, comprising the following modules:
[0030] An acquisition unit, used to acquire an extended instruction set set in the RISC-V processor and a software component set in the operating system to be built;
[0031] A classification unit, configured to determine a first subset, a second subset, and a third subset from the software component set based on the extended instruction set set, wherein the first subset refers to a set of software components that are not related to the RISC-V extended instruction set, the second subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is supported by a general compiler tool chain, and the third subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is not supported by a general compiler tool chain;
[0032] A construction unit, configured to construct the software components in the first subset and the second subset based on a general compilation tool chain, and to construct the software components in the third subset based on a specified compilation tool chain supporting the RISC-V extended instruction set;
[0033] A packaging unit is used to package all software components constructed by the first subset, the second subset and the third subset into an operating system image.
[0034] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the decoupled construction method for an operating system for a RISC-V architecture as described in any one of the above is implemented.
[0035] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for constructing an operating system decoupled for a RISC-V architecture as described in any one of the above is implemented.
[0036] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned methods for decoupling and constructing an operating system for a RISC-V architecture.
[0037] The decoupled construction method and device for an operating system for a RISC-V architecture provided by the present invention divides a set of software components into three categories, which not only saves the engineering workload that may be caused when using a compiler tool chain specific to a RISC-V extended instruction set to construct software components that are not related to the extended instruction set, but also omits the possible continuous bug repair process. In addition, the software components that are not related to the extended instruction set constructed by the present invention using a general compiler tool chain can be reused across RISC-V processors with different extended instruction set combinations. As the number of RISC-V extended instruction sets continues to increase, the number of RISC-V processors with different extended instruction set combinations also expands. By reusing software components that are not related to the extended instruction set across different RISC-V processors, the time and engineering workload of operating system development can be saved, and development efficiency can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0039] Figure 1 It is a flow chart of the decoupling construction method of an operating system for a RISC-V architecture provided by the present invention.
[0040] Figure 2 It is an overall block diagram of the operating system decoupling construction method for RISC-V architecture provided by the present invention.
[0041] Figure 3 This is a schematic diagram of a designated compilation tool chain that is backward compatible with the RISC-V extended instruction set and is a general compilation tool chain provided by the present invention.
[0042] Figure 4 It is a schematic diagram of a general compilation tool chain that is backward compatible with the specified compilation tool chain of the RISC-V extended instruction set provided by the present invention.
[0043] Figure 5 It is a structural schematic diagram of an operating system decoupling construction device for RISC-V architecture provided by the present invention.
[0044] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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 are within the scope of protection of the present invention.
[0046] First, for the RISC-V architecture, the RISC-V standard and non-standard extended instruction sets are growing rapidly. If the existing general-purpose compilation tool chain for building operating systems is directly used to develop operating systems for RISC-V processors with RISC-V extended instruction sets, there may be a problem that the general-purpose compilation tool chain does not support specific RISC-V extended instruction sets.
[0047] Secondly, when the entire operating system is built directly using the specified compilation tool chain that supports the RISC-V extended instruction set, a large number of software components that are not related to the RISC-V extended instruction set also need to be built from source code, which is a time-consuming process. In addition, new bugs may be introduced due to the difference in versions between the specified compilation tool chain for the RISC-V extended instruction set and the general compilation tool chain, which will lead to continuous bug repairs and bring huge workloads to developers.
[0048] Furthermore, when directly using a specified compilation tool chain that supports the RISC-V extended instruction set to build an operating system, some operating system software components that are not related to the extended instruction set cannot be reused like general operating systems that support x86 and ARM architectures (most Linux operating system distributions), which reduces the efficiency of operating system development. Therefore, as the number of RISC-V extended instruction sets continues to increase, there is a combinatorial explosion problem in the combination of extended instruction sets. The amount of engineering work to develop an operating system for many RISC-V processors with different RISC-V extended instruction set combinations using a specified compilation tool chain for the RISC-V extended instruction set is huge, and it is easy to fall into continuous bug fixes, and the efficiency of existing operating system development methods is low.
[0049] In order to facilitate understanding of the technical solution of the present invention, the terms involved in the present invention are explained as follows:
[0050] RISC-V: is an open source instruction set architecture (ISA) based on the reduced instruction set computing (RISC) principle.
[0051] ELF file: is a standard file format for executable files, object code, shared libraries, and core dumps.
[0052] Figure 1 It is a flowchart of the decoupling construction method of the operating system for the RISC-V architecture provided by the present invention, such as Figure 1 As shown, the method includes step 110 , step 120 , step 130 and step 140 .
[0053] Step 110: Obtain an extended instruction set set in the RISC-V processor and a software component set in the operating system to be built;
[0054] Step 120: Based on the extended instruction set set, determine a first subset, a second subset, and a third subset from the software component set, the first subset refers to a set of software components that are not related to the RISC-V extended instruction set, the second subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is supported by a general compiler tool chain, and the third subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is not supported by a general compiler tool chain;
[0055] Step 130: construct the software components in the first subset and the second subset based on a general compilation tool chain, and construct the software components in the third subset based on a specified compilation tool chain supporting the RISC-V extended instruction set;
[0056] Step 140: Package all software components constructed from the first subset, the second subset, and the third subset into an operating system image.
[0057] Figure 2 The overall block diagram of the decoupled construction method for the RISC-V architecture provided by the present invention is proposed to solve the problem that the general compilation tool chain does not support certain RISC-V extended instruction sets and reduce the engineering workload of developing operating systems for RISC-V processors with a large number of different extended instruction set combinations. Figure 2 The decoupled construction method of the operating system for the RISC-V architecture is shown.
[0058] First, the software component set of the operating system is divided into three categories: the first subset, the second subset and the third subset. The first subset refers to the software component set that is not related to the RISC-V extended instruction set, the second subset refers to the software component set that is related to the RISC-V extended instruction set and the corresponding extended instruction set is supported by the general compilation tool chain, and the third subset refers to the software component set that is related to the RISC-V extended instruction set and the corresponding extended instruction set is not supported by the general compilation tool chain.
[0059] Secondly, the set of software components that are not related to the RISC-V extended instruction set (the first subset) and the set of software components that are related to the RISC-V extended instruction set and whose corresponding extended instruction sets are supported by the general compilation tool chain (the second subset) are built using the general compilation tool chain, and the set of software components that are related to the RISC-V extended instruction set and whose corresponding extended instruction sets are not supported by the general compilation tool chain (the third subset) are built using the compilation tool chain specified by the extended instruction set.
[0060] Finally, after the three types of software component sets are built, they are packaged into the same operating system image, and the compatibility guarantee method is used to enable the software components built by two different compilation tool chains to run compatibly in the same operating system runtime environment.
[0061] In addition, a set of software components that are not related to the RISC-V extended instruction set (the first subset) built using a general-purpose compiler tool chain and a set of software components that are related to the RISC-V extended instruction set and whose corresponding extended instruction sets are already supported by the general-purpose compiler tool chain (the second subset) can be reused across RISC-V processors with different extended instruction set combinations, thereby greatly reducing the workload of developing operating systems for a large number of RISC-V processors with different extended instruction sets and improving the efficiency of operating system development.
[0062] As an optional embodiment, the steps of the decoupling construction method of the operating system for the RISC-V architecture to build an operating system for a RISC-V processor with different extended instruction set combinations are as follows:
[0063] Step 1: Get a set of base and extended instruction sets in the RISC-V processor .
[0064] Step 2: Determine the set of software components that need to be built into the operating system .
[0065] Step 3: Assemble the software components Divided into 3 subsets, the first subset Contains a set of software components not related to the RISC-V extended instruction set, the second subset Contains a set of software components related to the RISC-V extended instruction set and the related extended instruction set has been supported by the general compilation tool chain; the third subset Contains a collection of software components related to the RISC-V extended instruction set that is not supported by the general compilation tool chain.
[0066] Step 4: For and The software components in the RISC-V processor can be built using a general compilation tool chain, or the corresponding software components that have been built on other RISC-V processors can be reused.
[0067] Step 5: For The software components in the RISC-V library are built using a specified compilation tool chain provided by the manufacturer or research project that supports a specific RISC-V extended instruction set.
[0068] Step 6: Package all built software components into an operating system image.
[0069] The decoupled construction method for an operating system oriented to a RISC-V architecture provided by an embodiment of the present invention can still build a fully functional operating system that supports the RISC-V extended instruction set when a general compiler tool chain does not support the RISC-V extended instruction set. The embodiment of the present invention divides the software component set into three categories, which not only saves the engineering workload that may be caused when using the compiler tool chain specified by the RISC-V extended instruction set to build software components that are not related to the extended instruction set, but also omits the possible continuous bug repair process.
[0070] In addition, the software components unrelated to the extended instruction set constructed by the embodiment of the present invention using the general compilation tool chain can be reused across RISC-V processors with different extended instruction set combinations. As the number of RISC-V extended instruction sets continues to increase, the number of RISC-V processors with different extended instruction set combinations also expands accordingly. By reusing software components unrelated to the extended instruction set across different RISC-V processors, the time and engineering workload of operating system development can be saved, thereby improving development efficiency.
[0071] Based on the above embodiment, the method further includes:
[0072] If the version of the general compilation toolchain is higher than that of the specified compilation toolchain, the general compilation toolchain is backward compatible with the specified compilation toolchain;
[0073] If the version of the general compilation toolchain is lower than that of the specified compilation toolchain, the specified compilation toolchain is backward compatible with the general compilation toolchain.
[0074] It should be noted that when building an operating system using the decoupled operating system build method for the RISC-V architecture, generally speaking, the version of the general compilation tool chain is inconsistent with the version of the specified compilation tool chain for the RISC-V extended instruction set.
[0075] There are mainly two situations: one is that the version of the general compilation tool chain is higher than the version of the specified compilation tool chain of the RISC-V extended instruction set, that is, the general compilation tool chain is backward compatible with the specified compilation tool chain of the RISC-V extended instruction set. The other is that the version of the general compilation tool chain is lower than the version of the specified compilation tool chain of the RISC-V extended instruction set, that is, the specified compilation tool chain of the RISC-V extended instruction set is backward compatible with the general compilation tool chain.
[0076] Figure 3 : is a schematic diagram of a specified compilation tool chain for the general compilation tool chain provided by the present invention that is backward compatible with the RISC-V extended instruction set, such as Figure 3As shown, for the case where the general compilation tool chain is backward compatible with the specified compilation tool chain of the RISC-V extended instruction set, during compilation, the software component B that is not related to the extended instruction set is compiled and constructed using the general compilation tool chain, and the software component A related to the extended instruction set is compiled and constructed using the specified compilation tool chain of the RISC-V extended instruction set. This method complies with the original construction method of software component A and software component B, and there is no need to deal with new compilation problems caused by replacing the compilation tool chain to build the software components from scratch. In addition, the operating system operating environment is aligned with the general compilation tool chain, and the software component B compiled and constructed using the general compilation tool chain can be executed correctly. Although software component A is constructed using the specified compilation tool chain of the RISC-V extended instruction set, since the general compilation tool chain is backward compatible with the specified compilation tool chain of the RISC-V extended instruction set, software component A can also be executed correctly at runtime.
[0077] Based on any of the above embodiments, if the version of the general compilation tool chain is lower than the version of the specified compilation tool chain, the method further includes:
[0078] When running in an operating system running environment aligned with a general compilation tool chain, the runtime dependency corresponding to the target software component is replaced, where the target software component refers to the software component built by the third subset.
[0079] Figure 4 : is a schematic diagram of a general compilation tool chain that is backward compatible with the specified compilation tool chain of the RISC-V extended instruction set provided by the present invention, such as Figure 4 As shown, for the case where the designated compilation tool chain of the RISC-V extended instruction set is backward compatible with the general compilation tool chain, during compilation, the general compilation tool chain is still used to compile and build the software component B that is not related to the extended instruction set, and the designated compilation tool chain of the RISC-V extended instruction set is used to compile and build the software component A related to the extended instruction set. This method still follows the original construction method of the two software components, thereby reducing the continuous bug repair problem caused by changing the compilation tool chain. At runtime, although the designated compilation tool chain of the RISC-V extended instruction set is backward compatible with the general compilation tool chain, the operating system operating environment is still aligned with the general compilation tool chain at first, and the successfully built software component B can be directly run correctly in this runtime environment. However, since the version of the general compilation tool chain is lower than the version of the designated compilation tool chain, the successfully built software component A may not be able to run directly in this runtime environment. At this time, the correct execution of software component A is ensured by replacing the runtime dependency corresponding to software component A. After replacing the runtime dependency, according to backward compatibility, software component B can still run correctly.
[0080] Based on any of the above embodiments, replacing the runtime dependency corresponding to the target software component includes:
[0081] Build a directed acyclic graph of all dependencies (including dependencies of dependencies) of the target software component;
[0082] Acquire a target software component and a first library set dependent on a dependency chain of the target software component from a directed acyclic graph;
[0083] Acquire a second library set corresponding to the first library set in the operating system running environment;
[0084] Traverse the elements in the first library set, obtain the first highest version number of the current element in the first library set, and the second highest version number of the element corresponding to the current element in the second library set;
[0085] If the first highest version number is higher than the second highest version number, the element corresponding to the current element in the second library set is replaced with the current element;
[0086] If the current element in the first library set does not have a version number, the current element is added to the third library set of unsigned versions that the specified compilation tool chain depends on, and the element corresponding to the current element in the second library set is added to the fourth library set of unsigned versions that the operating system running environment depends on.
[0087] Replace the element corresponding to the current element in the second library set with the current element, and then include:
[0088] Obtain all function names of the target software component and construct a function name set containing all function names;
[0089] If any function name in the function name set does not have a version number, obtain the first symbol table corresponding to the target element in the third library set;
[0090] If any function name belongs to the first symbol table, obtaining the second symbol table of the element corresponding to the target element in the fourth library set;
[0091] If any function name does not belong to the second symbol table, the element corresponding to the current element in the fourth library set is replaced by the current element.
[0092] Optionally, to ensure Figure 4 The compatibility of software components compiled and constructed using two compilation tool chains and the operating system running environment is shown. Taking the software component A compiled and constructed by the specified compilation tool chain of the RISC-V extended instruction set as an application App as an example, how the compatibility assurance method proposed in the present invention ensures compatibility at the library level and the function level is introduced. The specific steps of the compatibility assurance method are as follows:
[0093] Step 1: Read the application ELF file.
[0094] Step 2: Model a directed acyclic graph (DAG) . It is a set of vertices. The vertices represent applications or dependent dynamic libraries. The starting vertex is the application. ; It is a set of edges. The edges represent dependencies. The starting vertex of the edge depends on the ending vertex. is the vertex If the attribute set No version number. ;otherwise, .
[0095] Step 3: Use the breadth-first algorithm to traverse the DAG graph , get the library collection that the application and its dependency chain depend on (i.e. the first library collection).
[0096] Step 4: Get the operating system running environment and library collection Corresponding library collection (i.e. the second library set), assuming that the library set The Chinese Communist Party elements, and library-level compatibility guarantees the loop control variables of the method The initial value of is 0, .
[0097] Step 5: Get the library collection that the application depends on separately Elements in and a collection of libraries in the operating system runtime environment Elements in .
[0098] Step 6: If , go to step 7; otherwise, go to step 8.
[0099] Step 7: Then the library Add unsigned versions of libraries to the dependencies collection (i.e. the third library collection), A collection of unsigned versions of the corresponding dependent libraries added to the runtime environment (i.e. the fourth library collection).
[0100] Step 8: Get the App The actual library used in The highest version number .
[0101] Step 9: Get the runtime environment library The highest version number .
[0102] Step 10: If , then library and If compatibility is satisfied at the library level, skip to step 12. Otherwise, go to step 11.
[0103] Step 11: Install the library in the operating system environment Replace with the corresponding library in the sysroot of the specified compilation toolchain of the RISC-V extended instruction set .
[0104] Step 12: Loop Control Variables Add 1.
[0105] Step 13: If , jump to step 5, otherwise, execute step 14.
[0106] Step 14: From the App Read all function names in the ELF file and get the function name set , a total of function names, Indicates function names, The initial value of is 0. ; Assuming unsigned version of the library set The Chinese Communist Party library elements, Indicates library elements, The initial value of is 0. .
[0107] Step 15: From Extract function name .
[0108] Step 16: If If there is no version number, go to step 17; otherwise, jump to step 26.
[0109] Step 17: Get the unsigned version of the library set Element library in .
[0110] Step 18: Get the Library Symbol table (i.e. the first symbol table).
[0111] Step 19: If , then execute step 20, otherwise, jump to step 24 for execution.
[0112] Step 20: Obtain the corresponding unsigned version of the dependent library set from the operating system running environment Get and Library Corresponding library .
[0113] Step 21: Get the Library Symbol table (i.e. the second symbol table).
[0114] Step 22: If , then the function name If it is compatible with the operating system running environment, jump to step 26 for execution; otherwise, execute step 23.
[0115] Step 23: Install the library in the operating system environment Replace the library in the sysroot of the specified compilation toolchain with the RISC-V extended instruction set . And jump to step 26 to execute.
[0116] Step 24: Loop Control Variables Add 1.
[0117] Step 25: If , jump to step 17, otherwise, execute step 26.
[0118] Step 26: Loop Control Variables Add 1.
[0119] Step 27: If , jump to step 15, otherwise, execute step 28.
[0120] Step 28: End.
[0121] The embodiments of the present invention can ensure that software components built using a general compilation tool chain and a specified compilation tool chain of an extended instruction set are respectively compatible with an operating system operating environment, thereby solving the problem that when the version of the specified compilation tool chain of the RISC-V extended instruction set is higher than the version of the general compilation tool chain, software components built using a mixture of two compilation tool chains are incompatible with the operating system operating environment.
[0122] The operating system decoupling construction device for the RISC-V architecture provided by the present invention is described below. The operating system decoupling construction device for the RISC-V architecture described below and the operating system decoupling construction method for the RISC-V architecture described above can be referenced to each other.
[0123] Based on any of the above embodiments, Figure 5 : is a schematic diagram of the structure of the operating system decoupling construction device for RISC-V architecture provided by the present invention, such as Figure 5 As shown, the device comprises:
[0124] An acquisition unit 510 is used to acquire an extended instruction set set in a RISC-V processor and a software component set in an operating system to be constructed;
[0125] The classification unit 520 is used to determine a first subset, a second subset, and a third subset from the software component set based on the extended instruction set set, wherein the first subset refers to a set of software components that are not related to the RISC-V extended instruction set, the second subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is supported by the general compiler tool chain, and the third subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is not supported by the general compiler tool chain;
[0126] A construction unit 530 is used to construct the software components in the first subset and the second subset based on a general compilation tool chain, and to construct the software components in the third subset based on a specified compilation tool chain supporting the RISC-V extended instruction set;
[0127] The packaging unit 540 is used to package all software components constructed from the first subset, the second subset, and the third subset into an operating system image.
[0128] Based on any of the above embodiments, the method further includes:
[0129] If the version of the general compilation toolchain is higher than that of the specified compilation toolchain, the general compilation toolchain is backward compatible with the specified compilation toolchain;
[0130] If the version of the general compilation toolchain is lower than that of the specified compilation toolchain, the specified compilation toolchain is backward compatible with the general compilation toolchain.
[0131] Based on any of the above embodiments, if the version of the general compilation tool chain is lower than the version of the specified compilation tool chain, the method further includes:
[0132] When running in an operating system running environment aligned with a general compilation tool chain, the runtime dependency corresponding to the target software component is replaced, where the target software component refers to the software component built by the third subset.
[0133] Based on any of the above embodiments, replacing the runtime dependency corresponding to the target software component includes:
[0134] Build a directed acyclic graph of all dependencies (including dependencies of dependencies) of the target software component;
[0135] Acquire a target software component and a first library set dependent on a dependency chain of the target software component from a directed acyclic graph;
[0136] Acquire a second library set corresponding to the first library set in the operating system running environment;
[0137] Traverse the elements in the first library set, obtain the first highest version number of the current element in the first library set, and the second highest version number of the element corresponding to the current element in the second library set;
[0138] If the first highest version number is higher than the second highest version number, the element corresponding to the current element in the second library set is replaced with the current element.
[0139] Based on any of the above embodiments, the method further includes:
[0140] If the current element in the first library set does not have a version number, the current element is added to the third library set of unsigned versions that the specified compilation tool chain depends on, and the element corresponding to the current element in the second library set is added to the fourth library set of unsigned versions that the operating system runtime environment depends on.
[0141] Based on any of the above embodiments, the element corresponding to the current element in the second library set is replaced with the current element, and then the method further includes:
[0142] Obtain all function names of the target software component and construct a function name set containing all function names;
[0143] If any function name in the function name set does not have a version number, obtain the first symbol table corresponding to the target element in the third library set;
[0144] If any function name belongs to the first symbol table, obtaining the second symbol table of the element corresponding to the target element in the fourth library set;
[0145] If any function name does not belong to the second symbol table, the element corresponding to the current element in the fourth library set is replaced by the current element.
[0146] Figure 6 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 6As shown, the electronic device may include: a processor (processor) 610 , a communication interface (Communications Interface) 620 , a memory (memory) 630 and a communication bus 640 , wherein the processor 610 , the communication interface 620 , and the memory 630 communicate with each other through the communication bus 640 . The processor 610 can call the logic instructions in the memory 630 to execute the decoupling construction method of the operating system for the RISC-V architecture, the method comprising: obtaining an extended instruction set set in the RISC-V processor and a software component set in the operating system to be constructed; based on the extended instruction set set, determining a first subset, a second subset and a third subset from the software component set, the first subset refers to a set of software components that are not related to the RISC-V extended instruction set, the second subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is supported by a general compilation tool chain, and the third subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is not supported by the general compilation tool chain; constructing the software components in the first subset and the second subset based on the general compilation tool chain, and constructing the software components in the third subset based on a specified compilation tool chain that supports the RISC-V extended instruction set; packaging all software components constructed by the first subset, the second subset and the third subset into an operating system image.
[0147] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0148] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the decoupled construction method for an operating system oriented to a RISC-V architecture provided by the above methods, the method comprising: obtaining an extended instruction set set in a RISC-V processor, and a software component set in an operating system to be constructed; based on the extended instruction set set, determining a first subset, a second subset, and a third subset from the software component set, the first subset referring to the software components that are not related to the RISC-V extended instruction set. The invention relates to a set of software components related to the RISC-V extended instruction set, the second subset refers to a set of software components related to the RISC-V extended instruction set and the related extended instruction set has been supported by the general compilation tool chain, and the third subset refers to a set of software components related to the RISC-V extended instruction set and the related extended instruction set is not supported by the general compilation tool chain; the software components in the first subset and the second subset are constructed based on the general compilation tool chain, and the software components in the third subset are constructed based on the specified compilation tool chain that supports the RISC-V extended instruction set; all software components constructed by the first subset, the second subset and the third subset are packaged into an operating system image.
[0149] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the decoupled construction method for an operating system oriented to a RISC-V architecture provided by the above methods, the method comprising: obtaining an extended instruction set set in a RISC-V processor, and a software component set in an operating system to be constructed; based on the extended instruction set set, determining a first subset, a second subset, and a third subset from the software component set, the first subset referring to a set of software components not related to the RISC-V extended instruction set, the second subset referring to a set of software components related to the RISC-V extended instruction set and the related extended instruction set is supported by a general compilation tool chain, and the third subset referring to a set of software components related to the RISC-V extended instruction set and the related extended instruction set is not supported by a general compilation tool chain; constructing the software components in the first subset and the second subset based on a general compilation tool chain, and constructing the software components in the third subset based on a specified compilation tool chain that supports the RISC-V extended instruction set; and packaging all software components constructed by the first subset, the second subset, and the third subset into an operating system image.
[0150] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0151] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0152] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for constructing a decoupled operating system for a RISC-V architecture, characterized in that: include: Obtain the extended instruction set set in the RISC-V processor and the software component set in the operating system to be built; Based on the extended instruction set set, determining a first subset, a second subset, and a third subset from the software component set, wherein the first subset refers to a set of software components that are not related to the RISC-V extended instruction set, the second subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is supported by a general compiler tool chain, and the third subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is not supported by a general compiler tool chain; Building the software components in the first subset and the second subset based on a general compilation tool chain, and building the software components in the third subset based on a specified compilation tool chain supporting the RISC-V extended instruction set; Packing all software components constructed from the first subset, the second subset, and the third subset into an operating system image; The method further comprises: If the version of the universal compilation tool chain is higher than the version of the specified compilation tool chain, the universal compilation tool chain is backward compatible with the specified compilation tool chain; If the version of the universal compilation tool chain is lower than the version of the specified compilation tool chain, the specified compilation tool chain is backward compatible with the universal compilation tool chain; If the version of the general compilation tool chain is lower than the version of the specified compilation tool chain, the method further includes: When running in an operating system running environment aligned with the universal compilation tool chain, replacing the runtime dependency corresponding to the target software component, the target software component being the software component constructed by the third subset; The runtime dependencies corresponding to the replacement target software component include: Constructing a directed acyclic graph of all dependencies of the target software component; Acquire the target software component and a first library set dependent on the target software component dependency chain from the directed acyclic graph; Acquire a second library set corresponding to the first library set in the operating system running environment; Traversing the elements in the first library set, obtaining a first highest version number of a current element in the first library set, and a second highest version number of an element in the second library set corresponding to the current element; If the first highest version number is higher than the second highest version number, the element in the second library set corresponding to the current element is replaced with the current element.
2. The method for constructing a RISC-V architecture-oriented operating system decoupling according to claim 1, characterized in that: The method further comprises: If the current element in the first library set does not have a version number, the current element is added to the third library set of unsigned versions that the specified compilation tool chain depends on, and the element corresponding to the current element in the second library set is added to the fourth library set of unsigned versions that the operating system running environment depends on.
3. The method for constructing a RISC-V architecture-oriented operating system decoupling according to claim 2, characterized in that: The step of replacing the element corresponding to the current element in the second library set with the current element further includes: Obtaining all function names of the target software component and constructing a function name set including all function names; If any function name in the function name set does not have a version number, obtaining a first symbol table corresponding to the target element in the third library set; If any of the function names belongs to the first symbol table, obtaining a second symbol table of an element in the fourth library set corresponding to the target element; If any of the function names does not belong to the second symbol table, the element corresponding to the current element in the fourth library set is replaced with the current element.
4. A RISC-V architecture-oriented operating system decoupling construction device, characterized in that: include: An acquisition unit, used to acquire an extended instruction set set in the RISC-V processor and a software component set in the operating system to be built; A classification unit, configured to determine a first subset, a second subset, and a third subset from the software component set based on the extended instruction set set, wherein the first subset refers to a set of software components that are not related to the RISC-V extended instruction set, the second subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is supported by a general compiler tool chain, and the third subset refers to a set of software components that are related to the RISC-V extended instruction set and the related extended instruction set is not supported by a general compiler tool chain; A construction unit, configured to construct the software components in the first subset and the second subset based on a general compilation tool chain, and to construct the software components in the third subset based on a specified compilation tool chain supporting the RISC-V extended instruction set; A packaging unit, used for packaging all software components constructed from the first subset, the second subset and the third subset into an operating system image; Also includes: If the version of the universal compilation tool chain is higher than the version of the specified compilation tool chain, the universal compilation tool chain is backward compatible with the specified compilation tool chain; If the version of the universal compilation tool chain is lower than the version of the specified compilation tool chain, the specified compilation tool chain is backward compatible with the universal compilation tool chain; If the version of the general compilation tool chain is lower than the version of the specified compilation tool chain, the method further includes: When running in an operating system running environment aligned with the universal compilation tool chain, replacing the runtime dependency corresponding to the target software component, the target software component being the software component constructed by the third subset; The runtime dependencies corresponding to the replacement target software component include: Constructing a directed acyclic graph of all dependencies of the target software component; Acquire the target software component and a first library set dependent on the target software component dependency chain from the directed acyclic graph; Acquire a second library set corresponding to the first library set in the operating system running environment; Traversing the elements in the first library set, obtaining a first highest version number of a current element in the first library set, and a second highest version number of an element in the second library set corresponding to the current element; If the first highest version number is higher than the second highest version number, the element in the second library set corresponding to the current element is replaced with the current element.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for decoupling and constructing an operating system for the RISC-V architecture as described in any one of claims 1 to 3 is implemented.
6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for decoupling and constructing an operating system for a RISC-V architecture as described in any one of claims 1 to 3 is implemented.
7. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for decoupling and constructing an operating system for a RISC-V architecture as described in any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Method for realizing RISC-V vector expansion instruction set based on clock precision simulator
CN114721718A
Optimization method for RISC-V basic C library
CN116860256A
