Ring elimination method and system for component relation directed graph of operating system and medium

Through the loop detection method of step-by-step gradual and specified step-by-step leap, the depth-first algorithm is used to find the loop and record dummy nodes, which solves the problem of low efficiency of loop elimination of directed graphs of component relationships of large-scale operating system, and achieves efficient loop elimination and resource conservation.

CN120295629APending Publication Date: 2025-07-11NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510197494.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

When the prior art deals with directed graphs of component relationships in large-scale operating system, the loop detection calculation is large and the resource requirements are high, making it difficult to efficiently eliminate loops.

Method used

The loop detection and elimination is performed using step-by-step gradual and specified step-by-step leap. The loop is found and dumb nodes are recorded through the depth-first algorithm, and the loop is gradually eliminated until the ring-free graph is not allowed.

Benefits of technology

It improves the loop elimination efficiency of the directed graph of the operating system component relationship, reduces the computing and storage resource requirements, and is suitable for resource-constrained environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120295629A_ABST
    Figure CN120295629A_ABST
Patent Text Reader

Abstract

The invention discloses a ring elimination method and system of an operating system component relation directed graph and a medium, and the ring elimination method of the operating system component relation directed graph comprises the following steps: S1, obtaining an input operating system component relation directed graph G, the operating system component relation directed graph G comprises a dependency relation between operating system components; and S2, carrying out ring detection and ring elimination on the operating system component relation directed graph G by adopting a leapfrogging progressive mode, and carrying out ring detection and ring elimination on the operating system component relation directed graph G by adopting a specified leapfrogging mode. The invention aims to realize the ring elimination of the operating system component relation digraph, improve the ring elimination efficiency of the operating system component relation digraph and reduce the requirements of the ring elimination of the operating system component relation digraph on computing resources and storage resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of operating system compilation, and particularly relates to a method, a system and a medium for eliminating loops in a directed graph of operating system component relationships. Background Art

[0002] An operating system contains a large number of operating system components. Therefore, when it is necessary to perform operating system compilation, it is necessary to transform the directed graph composed of operating system components into a directed acyclic graph and eliminate the loops in the directed graph. However, due to the large number of operating system components in the operating system, the scale of the operating system components is large and there are nested loops. For a complex giant graph with a large scale and nested loops, the detection calculation of loops is large, and the requirements for computing resources and storage resources are relatively high. Therefore, how to achieve loop elimination in the directed graph of operating system component relationships, improve the efficiency of loop elimination in the directed graph of operating system component relationships, and reduce the requirements for computing resources and storage resources for loop elimination in the directed graph of operating system component relationships have become a key technical problem to be solved urgently. Summary of the Invention

[0003] The technical problem to be solved by the present invention: Aiming at the above problems of the prior art, the present invention provides a method, a system and a medium for eliminating loops in a directed graph of operating system component relationships. The present invention aims to achieve loop elimination in the directed graph of operating system component relationships, improve the efficiency of loop elimination in the directed graph of operating system component relationships, and reduce the requirements for computing resources and storage resources for loop elimination in the directed graph of operating system component relationships.

[0004] To solve the above technical problems, the technical solution adopted by the present invention is as follows:

[0005] A method for eliminating loops in a directed graph of operating system component relationships includes the following steps:

[0006] S1, obtain the input directed graph G of operating system component relationships, and the directed graph G of operating system component relationships includes the dependency relationships between operating system components;

[0007] S2, perform loop detection and loop elimination on the directed graph G of operating system component relationships in a step-jumping progressive manner, and perform loop detection and loop elimination on the directed graph G of operating system component relationships in a specified step-jumping manner.

[0008] Optionally, the loop detection and loop elimination on the directed graph G of operating system component relationships in a step-jumping progressive manner in step S2 includes:

[0009] S2.1A, calculate the diameter D of the directed graph G of operating system component relationships G ; initialize the step to 2;

[0010] S2.2A. For any node A in the directed graph G of the operating system component relationships, starting from node A, use the depth-first algorithm to find a cycle. If a cycle is found, record the dummy node A# of node A, delete all incoming edges of node A to eliminate the cycle containing node A, and finally record the hop count as the set of dummy nodes {A#} at hop step step ;

[0011] S2.3A. Increment the hop step by one;

[0012] S2.4A. Determine whether the hop step is greater than the diameter D of the directed graph G of the operating system component relationships G If not, jump back to step S2.2A for continued iteration; otherwise, jump to step S2.5A;

[0013] S2.5A. The set of dummy nodes {{A#} step} formed by all the dummy nodes {A#} at hop step step} and the acyclic directed graph G of the operating system components obtained from the directed graph G of the operating system component relationships after eliminating the cycles M .

[0014] Optionally, in step S2.1A, calculating the diameter D of the directed graph G of the operating system component relationships G refers to calculating the hop count between any two software packages in the directed graph G of the operating system component relationships, and taking the maximum hop count as the diameter D of the directed graph G of the software repository G .

[0015] Optionally, in step S2, the method of detecting and eliminating cycles for the directed graph G of the operating system component relationships using a specified hop count includes:

[0016] S2.1B. Obtain the specified hop step;

[0017] S2.2B. Traverse and obtain the current node N in the node list of the directed graph G of the operating system component relationships;

[0018] S2.3B. Determine whether the current node N is empty. If the current node N is empty, jump to step S2.5B; otherwise, jump to step S2.4B;

[0019] S2.4B. For the current node N, starting from the current node N, use the depth-first algorithm to find a cycle. If a cycle is found, record the dummy node N# of the current node N, delete all incoming edges of the current node N to eliminate the cycle containing the current node N, and finally record the dummy node N# under the current node N; jump to S2.2B;

[0020] S2.5B, obtain the acyclic directed graph G of the operating system components from the set of dummy nodes {N#} composed of all the dummy nodes N# under the current node N and the directed graph G of the operating system component relationship after ring elimination M 。

[0021] Optionally, the node linked list of the directed graph G of the operating system component relationship is a linked list generated by arranging the nodes of the directed graph G of the operating system component relationship according to the dependency relationship between the operating system components

[0022] Optionally, before step S1, it further includes, for the software repository of the operating system, obtaining the running dependency relationship between software packages according to the software packages on which the operating system components depend for running, obtaining the installation dependency relationship between software packages according to the software packages on which the operating system components depend for installation, parsing the source code of the software packages to obtain the software packages on which the software packages depend for compilation to obtain the compilation dependency relationship between software packages, taking the obtained running dependency relationship, installation dependency relationship, and compilation dependency relationship between software packages as the edges of the operating system component relationship graph G, and combining the nodes and edges to obtain the operating system component relationship graph G

[0023] Optionally, the compilation dependency relationship between the software packages of the operating system components is based on the dependency relationship information declared in the dependency field in the software package control file of the software packages of the operating system components. The keywords in the dependency field include depends, Recommends, Suggests, Pre-Depends, Build-depends, Build-Depends-Indep, and Build-Depends-Arch

[0024] In addition, the present invention also provides a ring elimination system for a directed graph of operating system component relationships, including a microprocessor and a memory connected to each other, and the microprocessor is programmed or configured to execute the ring elimination method for the directed graph of operating system component relationships

[0025] In addition, the present invention also provides a computer-readable storage medium, in which a computer program or instruction is stored, and the computer program or instruction is programmed or configured to execute the ring elimination method for the directed graph of operating system component relationships through a processor

[0026] In addition, the present invention also provides a computer program product, including a computer program or instruction, and the computer program or instruction is programmed or configured to execute the ring elimination method for the directed graph of operating system component relationships through a processor

[0027] Compared with the prior art, the present invention mainly has the following advantages: In order to achieve the loop elimination of the directed graph of the operating system component relationship, improve the efficiency of the loop elimination of the directed graph of the operating system component relationship, and reduce the requirements of the loop elimination of the directed graph of the operating system component relationship for computing resources and storage resources, the present invention adopts a progressive method to detect loops for the characteristics that the directed graph contains loops with different hop counts and the elimination of a single loop has a direct impact on other nested loops, and uses the establishment of dummy nodes to eliminate loops. Starting from two-hop steps, it extends consistently to the maximum-hop loop, and gradually eliminates the loops in the directed graph through the progressive hop method, so as to be able to efficiently and quickly convert the directed graph of the operating system component relationship into a directed acyclic graph, effectively improving the efficiency of the loop elimination of the directed graph of the operating system component relationship and reducing the requirements of the loop elimination of the directed graph of the operating system component relationship for computing resources and storage resources. The present invention adopts a progressive method, and the loop detection and loop elimination in each step can be carried out independently, and the single calculation amount is controllable, and it can be applied to a computing environment with limited resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 It is a schematic diagram of the basic process of the method of the embodiment of the present invention.

[0029] Figure 2 It is a schematic diagram of the process of loop detection and loop elimination in a progressive hop manner in the embodiment of the present invention.

[0030] Figure 3 It is a schematic diagram of the process of loop detection and loop elimination in a specified hop manner in the embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0031] In order to enable those skilled in the art to better understand the technical solution of the present invention, the technical solution of the present invention will be further described in detail below with reference to the accompanying drawings in the embodiments of the present invention.

[0032] As Figure 1 shown, the method for loop elimination of the directed graph of the operating system component relationship in this embodiment includes the following steps:

[0033] S1. Obtain the input directed graph G of the operating system component relationship, where the directed graph G of the operating system component relationship includes the dependency relationship between operating system components;

[0034] S2. Perform loop detection and loop elimination on the directed graph G of the operating system component relationship in a progressive hop manner, and perform loop detection and loop elimination on the directed graph G of the operating system component relationship in a specified hop manner.

[0035] As Figure 2 shown, in step S2 of this embodiment, performing loop detection and loop elimination on the directed graph G of the operating system component relationship in a progressive hop manner includes:

[0036] S2.1A, Calculate the diameter D of the directed graph G of the operating system component relationships G ; Initialize the step to 2;

[0037] S2.2A, For any node A in the directed graph G of the operating system component relationships, use the depth-first algorithm to find a cycle starting from node A. If a cycle is found, record the dummy node A# of node A, delete all incoming edges of node A to eliminate the cycle containing node A, and finally record the number of steps as the set of dummy nodes {A#} at step step ;

[0038] S2.3A, Increment the step by one;

[0039] S2.4A, Determine whether the step is greater than the diameter D of the directed graph G of the operating system component relationships G If not, jump to step S2.2A to continue the iteration; otherwise, jump to step S2.5A;

[0040] S2.5A, The set of dummy nodes {{A#} step} formed by all the dummy nodes {A#} step} and the directed acyclic graph G of the operating system components obtained from the directed graph G of the operating system component relationships after eliminating the cycles M .

[0041] In step S2.1A of this embodiment, calculating the diameter D of the directed graph G of the operating system component relationships G refers to calculating the number of steps between any two software packages in the directed graph G of the operating system component relationships, and taking the maximum number of steps as the diameter D of the directed graph G of the software repository G .

[0042] As Figure 3 shown, in step S2 of this embodiment, the method for cycle detection and cycle elimination for the directed graph G of the operating system component relationships using a specified step includes:

[0043] S2.1B, Obtain the specified step;

[0044] S2.2B, Traverse to obtain the current node N in the node list of the directed graph G of the operating system component relationships;

[0045] S2.3B, Determine whether the current node N is null. If the current node N is null, jump to step S2.5B; otherwise, jump to step S2.4B;

[0046] S2.4B. For the current node N, use the depth - first algorithm to find a cycle with the current node N as the starting node. If a cycle is found, record the dummy node N# of the current node N, delete all incoming edges of the current node N to eliminate the cycle containing the current node N, and finally record the dummy node N# under the current node N; jump to S2.2B;

[0047] S2.5B. Obtain the acyclic directed graph G of the operating system components from the set of dummy nodes {N#} composed of all dummy nodes N# under the current node N and the directed graph G of the operating system component relationship after eliminating the cycle M 。

[0048] In this embodiment, the node list of the directed graph G of the operating system component relationship is a list generated by arranging the nodes of the directed graph G of the operating system component relationship according to the dependency relationship between the operating system components.

[0049] Before step S1 of this embodiment, it also includes: for the software repository of the operating system, obtaining the running dependency relationship between software packages according to the software packages required for the operation of the operating system components, obtaining the installation dependency relationship between software packages according to the software packages required for the installation of the operating system components, parsing the source code of the software packages to obtain the software packages required for the compilation of the software packages to obtain the compilation dependency relationship between software packages, using the obtained running dependency relationship, installation dependency relationship and compilation dependency relationship between software packages as the edges of the operating system component relationship graph G, and combining nodes and edges to obtain the operating system component relationship graph G. It should be noted that both the running dependency relationship and the installation dependency relationship can be extracted from the call and installation information of the software packages. In addition, in this embodiment, the compilation dependency relationship between the software packages of the operating system components is based on the dependency relationship information declared in the dependency field of the control file of the software packages of the operating system components. The keywords in the dependency field include depends, Recommends, Suggests, Pre-Depends, Build-depends, Build-Depends-Indep, and Build-Depends-Arch. Among them: Depends (dependency) means the dependencies necessary for the normal operation of the software package. Without these dependencies, the software package cannot be installed or run properly. For example, a software package with a graphical interface may depend on a certain graphics library software package because without this graphics library, the software cannot render the graphical interface. Recommends (recommended) means the software packages recommended for installation. Although the software package itself can run without depending on these recommended software packages, installing these recommended software packages can provide a better user experience or enhanced functions. For example, a text editor software package may recommend installing a spell-checking plugin software package. Suggests (suggested) means the software packages suggested for installation. These software packages are related to the main software package, but are not essential and not strongly recommended. Usually, they are for providing additional, non-core functions or content. For example, a game software package may suggest installing a game guide software package. Pre-Depends (pre-dependency) means the dependencies that must be installed before the software package is installed. These dependencies are crucial for the installation process of the software package itself. For example, some software packages require specific tools or libraries to complete operations such as generating configuration files during the installation process. Build-Depends (build dependency) means the software packages that the software package depends on during the compilation and build stage. These dependencies usually include tools such as compilers and development libraries, which are used to compile the source code into an executable file. For example, a software package written in C language requires the gcc compiler to compile. Build-Depends-Indep (architecture-independent build dependency) means the dependencies that are architecture-independent during the build process of the software package. These dependencies are required when building software packages on systems with different architectures.For example, some document generation tools, script language interpreters, etc. Build-Depends-Arch (architecture-related build dependencies) indicates the architecture-related dependencies of a software package during the build process. These dependencies vary according to different system architectures. For example, certain specific development libraries have different versions on systems with different architectures. It should be noted that the dependencies required to build the operating system component relationship diagram G are not limited to the running dependencies, installation dependencies, and compilation dependencies of the software packages mentioned earlier in this embodiment. Other dependencies can also be adopted according to needs, and it is also possible to build the operating system component relationship diagram G based on the dependencies.

[0050] In summary, the method for eliminating loops in the directed graph of the operating system component relationships in this embodiment is targeted at the characteristics that the directed graph contains loops with different hop counts and the elimination of a single loop has a direct impact on other nested loops. It uses a progressive approach to detect loops and uses the establishment of dummy nodes to eliminate loops. Starting from two-hop loops, it consistently extends to the maximum-hop loop, and gradually eliminates the loops in the directed graph through the progressive hop-by-hop method, so as to be able to efficiently and quickly convert the directed graph of the operating system component relationships into a directed acyclic graph, effectively improving the efficiency of loop elimination in the directed graph of the operating system component relationships and reducing the requirements for computing resources and storage resources for loop elimination in the directed graph of the operating system component relationships. The present invention adopts a progressive approach, and the loop detection and loop elimination in each step can be carried out independently, and the amount of calculation per single time is controllable, and it can be applied to a computing environment with limited resources.

[0051] In addition, this embodiment also provides a system for eliminating loops in the directed graph of the operating system component relationships, including a microprocessor and a memory connected to each other, and the microprocessor is programmed or configured to execute the method for eliminating loops in the directed graph of the operating system component relationships.

[0052] In addition, this embodiment also provides a computer-readable storage medium, in which a computer program or instruction is stored, and the computer program or instruction is programmed or configured to execute the method for eliminating loops in the directed graph of the operating system component relationships through a processor.

[0053] In addition, this embodiment also provides a computer program product, including a computer program or instruction, and the computer program or instruction is programmed or configured to execute the method for eliminating loops in the directed graph of the operating system component relationships through a processor.

[0054] Those skilled in the art should understand that the technical solutions provided by the embodiments of the present invention can be in the form of methods, systems, or computer program products. Therefore, the present invention can be implemented in the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can be in the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) that contain computer-usable program code. The present invention is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in the flow Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks. These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device that implements the functions specified in the flow Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks. These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in the flow Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0055] The above is only the preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions within the idea of the present invention belong to the protection scope of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements should also be regarded as within the protection scope of the present invention.

Claims

1. A method for eliminating loops in a directed graph of operating system component relationships, characterized in that, including the following steps: S1. Obtain the input directed graph G of the operating system component relationships, where the directed graph G of the operating system component relationships includes the dependency relationships between the operating system components; S2. Perform loop detection and loop elimination on the directed graph G of the operating system component relationships in a step-by-step progressive manner and perform loop detection and loop elimination on the directed graph G of the operating system component relationships in a specified step-by-step manner.

2. The method for eliminating loops in the directed graph of the operating system component relationship according to claim 1, wherein The loop detection and loop elimination on the directed graph G of the operating system component relationships in step S2 in a step-by-step progressive manner includes: S2.1A, calculate the diameter D of the directed graph G of the operating system component relationship G ; Initialize the skip step to 2; S2.2A. For any node A in the directed graph G of the operating system component relationships, use the depth-first algorithm to find a cycle starting from node A. If a cycle is found, record the dummy node A# of node A, delete all incoming edges of node A to eliminate the cycle containing node A, and finally record the number of skipped steps as the set of dummy nodes {A#} at the skipped step step step ; S2.3A. Increment the step by one; S2.4A, determine whether the skip step is greater than the diameter D of the directed graph G of the operating system component relationship. If not, jump to step S2.2A to continue iteration; otherwise, jump to step S2.5A; G If it holds, jump to step S2.5A; if not, jump to step S2.2A to continue iteration; S2.5A, the dummy node {A#} under all skip steps step The set of dummy nodes {{A#} step} and the directed acyclic graph G of the operating system components obtained from the directed graph G of the operating system component relationships after removing the loops M .

3. The method for eliminating loops in the directed graph of the operating system component relationship according to claim 2, characterized in that, Calculate the diameter D of the directed graph G of the operating system component relationships in step S2.1A G It refers to calculating the number of hops between any two software packages in the directed graph G of the operating system component relationships, and taking the largest number of hops as the diameter D of the software repository directed graph G G .

4. The method for eliminating loops in the directed graph of the operating system component relationship according to claim 1, wherein, The loop detection and loop elimination on the directed graph G of the operating system component relationships in step S2 in a specified step-by-step manner includes: S2.1B. Obtain the specified step step; S2.2B. Traverse to obtain the current node N in the node linked list of the directed graph G of the operating system component relationships; S2.3B. Determine whether the current node N is empty. If the current node N is empty, jump to step S2.5B; otherwise, jump to step S2.4B; S2.4B. For the current node N, use the depth-first algorithm to find a loop with the current node N as the starting node. If a loop is found, record the dummy node N# of the current node N, delete all incoming edges of the current node N to eliminate the loop containing the current node N, and finally record the dummy node N# under the current node N; jump to S2.2B; S2.5B, obtain the acyclic directed graph G of the operating system components from the set of dummy nodes {N#} composed of all the dummy nodes N# under the current node N and the directed graph G of the operating system component relationships after eliminating the loops M .

5. The method for eliminating loops in the directed graph of the operating system component relationship according to claim 4, wherein The node linked list of the directed graph G of the operating system component relationships is a linked list generated by arranging the nodes of the directed graph G of the operating system component relationships according to the dependency relationships between the operating system components.

6. The method for eliminating loops in the directed graph of the operating system component relationship according to claim 1, wherein Before step S1, it also includes, for the software repository of the operating system, obtaining the running dependency relationships between software packages based on the software packages required for the operation of the operating system components, obtaining the installation dependency relationships between software packages based on the software packages required for the installation of the operating system components, parsing the source code of the software packages to obtain the software packages required for the compilation of the software packages to obtain the compilation dependency relationships between software packages, using the obtained running dependency relationships, installation dependency relationships, and compilation dependency relationships between software packages as the edges of the directed graph G of the operating system component relationships, and combining the nodes and edges to obtain the directed graph G of the operating system component relationships.

7. The method for eliminating loops in the directed graph of the operating system component relationship according to claim 6, characterized in that, The compilation dependency relationships between the software packages of the operating system components are based on the dependency relationship information declared in the dependency relationship field in the software package control files of the software packages of the operating system components. The keywords in the dependency relationship field include depends, Recommends, Suggests, Pre-Depends, Build-depends, Build-Depends-Indep, and Build-Depends-Arch.

8. A loop elimination system for a directed graph of operating system component relationships, including a microprocessor and a memory connected to each other, characterized in that, The microprocessor is programmed or configured to execute the loop elimination method of the directed graph of the operating system component relationships according to any one of claims 1 to 7.

9. A computer-readable storage medium storing a computer program or instructions, characterized in that, The computer program or instruction is programmed or configured to execute the loop elimination method of the directed graph of the operating system component relationships according to any one of claims 1 to 7 through a processor.

10. A computer program product comprising a computer program or instructions, characterized in that, The computer program or instruction is programmed or configured to execute the loop elimination method of the directed graph of the operating system component relationship described in any one of claims 1 to 7 through a processor.