Process tree creating method and device, medium, equipment and computer program product
By deriveing child processes based on template process trees in the FaaS platform and updating their relationships, the problem of FaaS cold startup delay is solved, and process creation efficiency and system startup speed are improved.
Patent Information
- Application Number
- CN202510300887.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-13
- Publication Date
- 2025-06-24
AI Technical Summary
During cold startup, the FaaS platform needs to perform operations such as instance scheduling, mirror distribution, container creation and process startup, resulting in cold startup delays and affecting system efficiency.
By obtaining the template process tree of the template container, derive child processes, isolate the child processes and the resources of the template process, add the child processes to the target container, and update the child process relationship based on the template process tree to form the target process tree.
It improves the parallelism of process creation during process tree creation, effectively improves the efficiency of process creation, simplifies the time required for process tree creation and startup, and achieves the effect of process tree startup acceleration.
Smart Images

Figure CN120196401A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to a method, apparatus, medium, device, and computer program product for creating a process tree. Background Art
[0002] FaaS (Function as a Service) is a new cloud computing programming model in recent years. With FaaS, developers only need to upload business code and perform simple resource configuration to quickly build and deploy services. However, the stateless function programming of FaaS brings inevitable cold start problems while bringing high elasticity and flexibility. When a cold start occurs, the FaaS platform needs to perform a series of operations such as instance scheduling, image distribution, container creation, and process startup, resulting in cold start latency. Summary of the Invention
[0003] This Summary of the Invention section is provided to introduce concepts in a brief form, which will be described in detail in the following Detailed Description section. This Summary of the Invention section is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to be used to limit the scope of the claimed technical solution.
[0004] In a first aspect, the present disclosure provides a method for creating a process tree, the method including: Obtaining a template process tree of a template container, where the template process tree includes a plurality of template processes; Deriving child processes based on the template processes, with the template processes serving as the parent processes of the child processes; Isolating the resources of the child processes and the template processes, and adding the child processes to a target container; Updating the relationships of the child processes based on the relationships between the template processes in the template process tree, and taking the process tree composed of the child processes as a target process tree.
[0005] In a second aspect, the present disclosure provides a device for creating a process tree, the device including: An obtaining module, configured to obtain a template process tree of a template container, where the template process tree includes a plurality of template processes; A deriving module, configured to derive child processes based on the template processes, with the template processes serving as the parent processes of the child processes; A processing module, configured to isolate the resources of the child processes and the template processes, and add the child processes to a target container; A building block for updating the relationships of the respective subprocesses based on the relationships between the respective template processes in the template process tree, and forming a process tree composed of the respective subprocesses as a target process tree.
[0006] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, and when the computer program is executed by a processing device, the steps of the method described in the first aspect are implemented.
[0007] In a fourth aspect, the present disclosure provides an electronic device, including: A storage device having a computer program stored thereon; A processing device for executing the computer program in the storage device to implement the steps of the method described in the first aspect.
[0008] In a fifth aspect, the present disclosure provides a computer program product including a computer program, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0009] In the above technical solution, when creating a process tree, it can be created based on a template process tree. And during the creation based on the template process tree, subprocesses of the respective template processes can be derived, the resources of the subprocesses and the template processes can be isolated, and the subprocesses are added to a target container. Furthermore, the relationships of the respective subprocesses are updated based on the relationships between the respective template processes in the template process tree, so as to form a process tree composed of the respective subprocesses as the target process tree. Thereby, the degree of parallelism of process creation in the process tree during the process tree creation can be improved, the efficiency of process creation can be effectively improved, and by the way of deriving subprocesses and assembling the subprocesses to obtain a target process tree, it can be applicable to the creation of complex process trees, simplify the time required for starting the process tree creation, and achieve the effect of accelerating the start of the process tree.
[0010] Other features and advantages of the present disclosure will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In combination with the accompanying drawings and with reference to the following specific implementation, the above and other features, advantages and aspects of the various embodiments of the present disclosure will become more apparent. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic and the original components and elements are not necessarily drawn to scale. In the drawings: Figure 1 is a flowchart of a process tree creation method provided according to an embodiment of the present disclosure.
[0012] Figure 2 is a schematic diagram of a template process tree provided according to an embodiment of the present disclosure.
[0013] Figure 3 It is a schematic diagram of a template process tree and a target process tree provided according to an embodiment of the present disclosure.
[0014] Figure 4 It is a block diagram of a process tree creation device provided according to an embodiment of the present disclosure.
[0015] Figure 5 It shows a schematic structural diagram of an electronic device suitable for implementing the embodiments of the present disclosure. Specific Embodiments
[0016] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. On the contrary, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not used to limit the protection scope of the present disclosure.
[0017] It should be understood that the various steps recorded in the method embodiments of the present disclosure can be executed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this regard.
[0018] The term "including" and its variants used herein are open-ended, that is, "including but not limited to". The term "based on" is "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0019] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependent relationships.
[0020] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly stated in the context, it should be understood as "one or more".
[0021] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only for illustrative purposes and are not used to limit the scope of these messages or information.
[0022] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, usage scopes, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to users and the authorization of users should be obtained through appropriate means in accordance with relevant laws and regulations.
[0023] For example, when responding to an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested by the user will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, an application program, a server, or a storage medium that executes the operation of the technical solution of the present disclosure according to the prompt message.
[0024] As an optional but non-limiting implementation manner, the manner of sending a prompt message to the user in response to receiving an active request from the user may be, for example, in the form of a pop-up window, and the prompt message may be presented in text in the pop-up window. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0025] It is understandable that the above process of notifying and obtaining user authorization is only illustrative and does not constitute a limitation on the implementation manner of the present disclosure. Other manners that meet relevant laws and regulations can also be applied to the implementation manner of the present disclosure.
[0026] Meanwhile, it is understandable that the data involved in the present technical solution (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of corresponding laws, regulations and related provisions.
[0027] Figure 1 As shown, it is a flowchart of a process tree creation method provided according to an embodiment of the present disclosure. As Figure 1 shown, the method may include: In step 11, obtain the template process tree of the template container, where the template process tree contains multiple template processes.
[0028] In the related art, the FaaS platform needs to perform a series of operations such as instance scheduling, image distribution, container creation, and process startup to complete the cold start process. In the FaaS scenario, a function instance generally contains multiple processes, and the multiple processes are related to form a process tree pstree.
[0029] As an example, the template container is a container that has been started, and the processes in the container and the relationships between the processes constitute the process tree of the container. The creation and startup efficiency of the process tree have an important impact on the time required for cold startup. Therefore, in the present disclosure, the template process tree can be pre-configured based on the process tree of the container so that the corresponding process tree can be directly created and started from the template process, thereby improving the creation and startup efficiency of the process tree and further reducing the time required for cold startup. As Figure 2 shown is an example representation of the template process tree, which includes multiple template processes A to G.
[0030] In step 12, a child process is derived based on the template process, and the template process serves as the parent process of the child process.
[0031] Among them, the derivation of a process to obtain the child process of the corresponding process can be implemented based on the fork function in Linux, which creates a process by copying. Through the fork function, the parent process can return the ID of the child process, and the child process returns 0, so that the parent process can control the child process based on the ID of the child process. The child process of the derived process acts at the process granularity. Therefore, in this step, the template processes in the template process tree can be processed in parallel, thereby effectively improving the efficiency of deriving child processes.
[0032] In step 13, the resources of the child process and the template process are isolated, and the child process is added to the target container.
[0033] In the related art, the memory spaces between the child process and the parent process obtained by derivation are isolated, but the file descriptors (fd, file descriptor) are shared. In the solution of the present disclosure, the process tree is quickly created based on the template process tree. Multiple process trees can be created for the same template process tree. In this process, the template processes in the template process tree can create multiple child processes, and there are shared resources between the multiple child processes and the template process. For example, an fd of the parent process is to open the file F1, and then the child process inherits the parent process and opens the file F1 with the same fd. When the child process writes data to the file F1, write conflicts may be found among the multiple child processes. Therefore, in this embodiment, after the child process is derived based on the template process, the shared resources of the child process and the template process can be isolated, such as the fd, file, and memory resources of the template process and the child process can be isolated.
[0034] And after a child process is obtained through forking based on a template process, the child process is also within the template container. To implement resource management and control of the container, the child process can be added to a target container, which is a different container from the template container, that is, the derived child process is added to another container, which can be represented by Cgroup and namespace, enabling adaptation to the container ecosystem and further expanding the scope of use of the present disclosure solution.
[0035] The following gives an exemplary illustration in terms of the isolation of file descriptors. When adding a child process to a target container, the root file system rootfs corresponding to the child process is the rootfs of the target container, and the rootfs corresponding to the parent process is the rootfs of the template container. Specifically, the file indicated by the first file descriptor in the parent process can be copied to the rootfs corresponding to the child process, and a second file descriptor in the child process is generated for the copied file; the current read / write position in the copied file is updated based on the current read / write position of the file in the parent process. Then, the first file descriptor in the child process is disconnected and redirected to open the copied file in the process based on the first file descriptor to achieve the isolation of file descriptors. As in the parent process: fd1 = open("hello.txt"); / / hello.txt is in the rootfs of the template container read(fd1, xxx); write(fd1, xxx); In the child process: 1. Copy hello.txt in the parent process rootfs to the rootfs of the child process; 2. fd2 = open("hello.txt"), and update the current read / write position currentposition through lseek(); 3. close(fd1); 4. dup2(fd2, fd1); 5. close(fd2).
[0036] Thus, the isolation of file descriptors can be achieved in the above manner. For another example, in the template process tree, if process A and process B communicate through a pipe, then a new pipe is required for communication between child process A' of process A and child process B' of process B. The newly created pipe is different from the pipe in the template process tree. Among them, the specific implementation of the above isolation can be achieved based on the isolation technology in CRIU (checkpoint&restore in userspace). CRIU is a project for Linux to implement checkpoint / restore functions, which will not be elaborated here.
[0037] In step 14, update the relationships of each child process based on the relationships between each template process in the template process tree, and use the process tree composed of each child process as the target process tree, which is the process tree of the target container.
[0038] In this step, each template process generates a child process. Then, the relationships between each child process can be updated based on the relationships between each template process in the template process tree to ensure that the relationships between different template processes are the same as the relationships between the child processes of this template process, that is, reorganize each child process into a process tree as the target process tree.
[0039] Thus, in the above technical solution, when creating a process tree, it can be created based on the template process tree. And during the creation based on the template process tree, child processes of each template process can be derived, the resources of the child processes and the template processes can be isolated, and the child processes can be added to the target container. Furthermore, the relationships between each child process are updated based on the relationships between each template process in the template process tree, so as to use the process tree composed of each child process as the target process tree. Thus, the parallelism of process creation in the process tree during the process tree creation can be improved, the efficiency of process creation can be effectively improved, and by the way of deriving child processes and assembling the child processes to obtain the target process tree, it can be applied to the creation of complex process trees, simplify the time required for the creation and startup of the process tree, and achieve the effect of accelerating the startup of the process tree.
[0040] In some embodiments, the exemplary implementation of spawning a child process based on the template process may include: If the template process is a multi-threaded process, create a child process in a spawning manner; Control the child process to clone according to multiple template threads in the template process based on the channel of the child process, to obtain multiple child threads in the child process. Among them, when configuring the template process tree, channels are established for each template process in the template process tree, and the child process inherits the channel of the template process.
[0041] Among them, a process can contain multiple threads, that is, a multi-threaded process. The native fork function provided in Linux can only fork a single-threaded process and cannot handle a multi-threaded process. Therefore, in this embodiment, for a multi-threaded process, the linux fork() API can be first executed based on a template process to create a new process, that is, a derived child process. The child process can inherit the channels of the template process through the fork mechanism, and then the control of the child process can be implemented based on these channels. Among them, the execution of the fork function by the template process can be controlled by the control code injected into the template process tree.
[0042] Among them, it should be noted that before deriving a child process from the template process, the running states of each template thread in the template process can be obtained. The multiple template threads in the template process are the multi-threads included in the template process. If the running state of the template thread is the stopped state, no operation is required. If the running state of the template thread is not the stopped state, the running state of the template thread is updated to the stopped state to make the state of the template process immutable, and then a child process is derived based on the template process.
[0043] In this step, multiple template threads in the template process can be obtained, and each thread in the template process can be traversed in turn to clone the thread in the context of the child process in turn, so as to generate corresponding child threads in the child process based on the template threads, realizing the replication of a process containing multiple threads.
[0044] Thus, through the above technical solution, the replication of a multi-threaded process can be realized, the efficiency of deriving the template process in the template process tree can be improved. At the same time, the above technical solution realizes the control of the child process through the channel. This process is imperceptible to the user and does not modify the kernel code invasively, improving the efficiency of process derivation while ensuring the stability and security of system operation.
[0045] In some embodiments, the controlling the child process to be cloned according to multiple template threads in the template process based on the channel to obtain multiple child threads in the child process may include: For each of the template threads, controlling the child process to create a child thread based on the channel and updating the state information of the child thread according to the state information of the template thread.
[0046] As an example, a clone function can be executed through a channel operation subprocess to create a child thread. Specifically, the kernel's sys_clone() API can be called in the context of the subprocess to create a child thread. After that, the state information of the template thread can be copied as the state information of the child thread to achieve the replication of the template thread, so as to generate a child thread in the derived subprocess that is consistent with the template thread in the template process. Among them, the state information can include information such as the registers, TLS (thread local storage), and signals of the subprocess. Thus, the replication generation of threads can be achieved through the above technical solution, so as to further achieve the replication of a multi-threaded process by traversing the template thread multiple times based on the above method.
[0047] In some embodiments, the template process tree of the template container is determined in the following manner: Obtain the process tree of the template container, where the process tree of the template container can be obtained based on the configuration information of the container. In the present disclosure, the following operations can be performed on the process tree in advance to obtain the template process tree: Inject control code into the process tree, where the control code is used to implement the control logic of the process tree. Among them, code injection can be performed through the configuration interface in the client. For example, code injection can be performed through CRIU libcompel. By using dynamic code injection, relevant information of the current process can be obtained. The control code can be determined based on the actual application scenario. For example, it can be set based on the functions to be implemented by the processes in the process tree that need to be controlled, so as to control the processes in the process tree. For example, the template process in the template process tree can be controlled to execute the linux fork() API to create a new process.
[0048] Create channels between each process in the process tree. In this process, the CRIU libcompel solution can be used to create the channels, so as to control each process through the channels.
[0049] After that, collect the state information of the process tree. The state information includes the process information of each process in the process tree and the relationship between each process in the process tree. Among them, the process information of the process can be configured based on the actual application scenario and can include one or more of the context information of the process, such as file descriptors, pipes, and memory tables, or other information based on the actual scenario. The present disclosure does not limit this.
[0050] Thus, through the above technical solution, corresponding operations can be performed on the process tree of the container to achieve operation control and information collection of the process tree, provide support for the subsequent rapid creation and startup of the process tree based on the template process tree, and effectively improve the reusability of the template process tree.
[0051] In some embodiments, updating the relationships of the respective child processes based on the relationships between the respective template processes in the template process tree may include: For each of the child processes, determine the parent template process of the template process corresponding to the child process in the template process tree according to the relationships between the respective template processes.
[0052] After that, update the parent process of the child process to a child process derived from the parent template process.
[0053] Among them, the relationships between the respective processes can be determined based on the status information of the process tree. For example, Figure 2 in the process tree shown, process C is the parent process of processes E and G. Taking process E as an example, based on the relationships between the template processes, it can be determined that the parent template process of the template process E corresponding to the child process E' in the template process tree is process C. Then, the parent process of the child process E' can be updated to a child process C' derived from the parent template process C, so that the relationships between the child processes are the same as the relationships between the template processes corresponding to the child processes.
[0054] For example, Figure 3 as shown, the relationship indicated by the dashed line L1 is used to represent the dependency relationship between the child process trees before the relationship is updated. For the convenience of display, only the child process A' is taken as an example. The relationship indicated by the dashed line L2 is used to represent the relationships between the respective child processes after the relationship is updated.
[0055] Thus, through the above technical solution, by updating the parent processes of the child processes obtained by derivation, the respective child processes are assembled according to the relationships between the template processes corresponding to them to generate a target process tree, support the parallel creation of the processes in the process tree, ensure that the target process tree and the template process tree have the same tree structure, ensure the effectiveness and stability of the process tree creation while improving the efficiency of the process tree creation, and thus improve the startup efficiency of the process.
[0056] In some embodiments, the method may further include: Updating the target data objects of the processes in the target process tree based on the callback function interface.
[0057] As an example, multiple target process trees can be created through the same template process tree. The child processes generated by the fork technology inherit the parent process to share code and data. For example, if the parent process contains a globally unique variable, the value of this globally unique variable in the child process is the same as that in the parent process, which is contradictory to the definition of this variable. For similar scenarios, in this embodiment, the user-registered post fork handler can be called to refresh the personalized configuration of the target process tree. For example, the target data object can be a pre-specified variable or object, such as a variable defined as globally unique, such as the Universally Unique Identifier (UUID). Based on the callback function interface, the value of this variable in the child process can be updated to make it different from the value of this variable in the parent process, ensuring the global uniqueness of the value of this variable. Another example is that the target data object can be a random number seed, an environment variable, etc., which can be pre-specified based on the actual application scenario. Among them, the setting method of the callback function interface can be configured based on the callback implementation method in CRIU, and the present disclosure does not limit this.
[0058] Thus, through the above technical solution, the personalized configuration of the target process tree can be realized after creating the target process tree based on the template process tree, which can not only improve the quick creation and startup efficiency of the process tree, but also improve the applicability of the created process tree, and broaden the applicable scope of the method of the present disclosure.
[0059] Based on the same inventive concept, the present disclosure also provides a process tree creation device, as Figure 4 shown. The device 10 includes: An acquisition module 100, configured to acquire the template process tree of the template container, where the template process tree contains multiple template processes; A derivation module 200, configured to derive child processes based on the template process, and the template process serves as the parent process of the child processes; A processing module 300, configured to isolate the resources of the child processes and the template processes, and add the child processes to the target container; A construction module 400, configured to update the relationships of the child processes based on the relationships between the template processes in the template process tree, and use the process tree composed of the child processes as the target process tree.
[0060] Optionally, the derivation module includes: A child process creation sub-module, configured to create child processes in a derivation manner if the template process is a process containing multiple threads; The first processing sub-module is configured to control, based on the channel of the subprocess, the subprocess to be cloned according to multiple template threads in the template process, so as to obtain multiple child threads in the subprocess. Wherein, when configuring the template process tree, channels are established for each of the template processes in the template process tree, and the subprocess inherits the channel of the template process.
[0061] Optionally, the first processing sub-module includes: The second processing sub-module is configured to, for each of the template threads, control the subprocess to create a child thread based on the channel, and update the status information of the child thread according to the status information of the template thread.
[0062] Optionally, the template process tree of the template container is determined by the following method: Obtain the process tree of the template container, and perform the following operations on the process tree to obtain the template process tree: Inject control code into the process tree, where the control code is used to implement the control logic of the process tree; Create channels between each process in the process tree; Collect the status information of the process tree, where the status information includes the process information of each process in the process tree and the relationship between each process in the process tree.
[0063] Optionally, the construction module includes: The determination sub-module is configured to, for each of the subprocesses, determine the parent template process of the template process corresponding to the subprocess in the template process tree according to the relationship between the template processes; The update sub-module is configured to update the parent process of the subprocess to the child process derived from the parent template process.
[0064] Optionally, the apparatus further includes: The update module is configured to update the target data object of the process in the target process tree based on the callback function interface.
[0065] Next, refer to Figure 5 , which shows a schematic structural diagram of an electronic device (such as a terminal device or a server) 600 suitable for implementing the embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Computers), PMPs (Portable Multimedia Players), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5The electronic device shown is merely an example and should not impose any limitations on the functions and scope of use of the embodiments of the present disclosure.
[0066] As Figure 5 shown, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage device 608 into the random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. The input / output (I / O) interface 605 is also connected to the bus 604.
[0067] Generally, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 can allow the electronic device 600 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 5 the electronic device 600 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. More or fewer devices may be implemented or had alternatively.
[0068] Specifically, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are executed.
[0069] It should be noted that the computer-readable medium described above in the present disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and this computer-readable signal medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0070] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as HTTP (HyperText Transfer Protocol), and can be interconnected with digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed network.
[0071] The above computer-readable medium can be included in the above electronic device; or it can exist separately without being assembled into the electronic device.
[0072] The above computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: obtain the template process tree of the template container, where the template process tree contains multiple template processes; derive child processes based on the template processes, with the template processes serving as the parent processes of the child processes; isolate the resources of the child processes and the template processes, and add the child processes to the target container; update the relationships of the child processes based on the relationships between the template processes in the template process tree, and use the process tree composed of the child processes as the target process tree.
[0073] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or combinations thereof. The programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., by using an Internet service provider to connect through the Internet).
[0074] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0075] The modules involved in the embodiments of the present disclosure can be implemented in software or in hardware. In some cases, the name of the module does not constitute a limitation on the module itself. For example, the acquisition module can also be described as "the module for acquiring the template process tree of the template container".
[0076] The functions described above in this article can be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: Field Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Product (ASSP), System on Chip (SOC), Complex Programmable Logic Device (CPLD), and so on.
[0077] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a Random Access Memory (RAM), a Read Only Memory (ROM), an Erasable Programmable Read Only Memory (EPROM or Flash Memory), an optical fiber, a portable compact disc read only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0078] According to one or more embodiments of the present disclosure, Example 1 provides a method for creating a process tree, characterized in that the method includes: Acquire the template process tree of the template container, where the template process tree contains multiple template processes; Derive child processes based on the template process, with the template process as the parent process of the child processes; Isolate the resources of the child processes and the template process, and add the child processes to the target container; Update the relationships of the respective child processes based on the relationships between the respective template processes in the template process tree, and use the process tree composed of the respective child processes as the target process tree.
[0079] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, and the deriving of child processes based on the template process includes: If the template process is a multi-threaded process, create child processes in a derivative manner; Based on the channel of the subprocess, control the subprocess to be cloned according to multiple template threads in the template process, obtaining multiple child threads in the subprocess. Among them, when configuring the template process tree, channels are established for each of the template processes in the template process tree, and the subprocess inherits the channel of the template process.
[0080] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2. The controlling the subprocess to be cloned according to multiple template threads in the template process based on the channel, obtaining multiple child threads in the subprocess, includes: For each of the template threads, control the subprocess to create a child thread based on the channel, and update the status information of the child thread according to the status information of the template thread.
[0081] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 1. The template process tree of the template container is determined by the following method: Obtain the process tree of the template container, and perform the following operations on the process tree to obtain the template process tree: Inject control code into the process tree, where the control code is used to implement the control logic of the process tree; Create channels between each process in the process tree; Collect the status information of the process tree, where the status information includes the process information of each process in the process tree and the relationship between each process in the process tree.
[0082] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 1. The updating the relationship between each subprocess based on the relationship between each template process in the template process tree includes: For each of the subprocesses, determine the parent template process of the template process corresponding to the subprocess in the template process tree according to the relationship between each template process; Update the parent process of the subprocess to the subprocess derived from the parent template process.
[0083] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 1. The method further includes: Update the target data object of the process in the target process tree based on the callback function interface.
[0084] According to one or more embodiments of the present disclosure, Example 7 provides a process tree creation device, and the device includes: An acquisition module, configured to acquire the template process tree of the template container, where the template process tree includes multiple template processes; A derived module for spawning child processes based on the template process, where the template process serves as the parent process of the child processes; A processing module for isolating the resources of the child processes and the template process and adding the child processes to a target container; A construction module for updating the relationships of the respective child processes based on the relationships between the respective template processes in the template process tree, and taking the process tree composed of the respective child processes as the target process tree.
[0085] According to one or more embodiments of the present disclosure, Example 8 provides a computer-readable medium having a computer program stored thereon, which when executed by a processing device implements the steps of the method described in any one of Examples 1-6.
[0086] According to one or more embodiments of the present disclosure, Example 9 provides an electronic device, including: A storage device having a computer program stored thereon; A processing device for executing the computer program in the storage device to implement the steps of the method described in any one of Examples 1-6.
[0087] According to one or more embodiments of the present disclosure, Example 10 provides a computer program product including a computer program, which when executed by a processor implements the steps of the method described in any one of Examples 1-6.
[0088] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the (but not limited to) technical features having similar functions disclosed in the present disclosure.
[0089] In addition, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although a number of specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, the various features described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0090] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. On the contrary, the specific features and acts described above are merely example forms for implementing the claims. Regarding the apparatus in the above embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments related to the method, and will not be elaborated herein.
Claims
1. A process tree creation method, characterized in that: The method comprises: Obtaining a template process tree of the template container, wherein the template process tree includes a plurality of template processes; Deriving a child process based on the template process, with the template process serving as the parent process of the child process; Isolating resources of the subprocess and the template process, and adding the subprocess to a target container; The relationship between each of the sub-processes is updated based on the relationship between each of the template processes in the template process tree, and the process tree composed of each of the sub-processes is used as the target process tree.
2. The method according to claim 1, characterized in that The deriving of a child process based on the template process comprises: If the template process is a process including multiple threads, a child process is created in a derived manner; Based on the channel control of the child process, the child process is cloned according to the multiple template threads in the template process to obtain the multiple sub-threads in the child process, wherein, when configuring the template process tree, a channel is established for each of the template processes in the template process tree, and the child process inherits the channel of the template process.
3. The method according to claim 2, characterized in that The controlling the subprocess based on the channel to clone according to the multiple template threads in the template process to obtain the multiple subthreads in the subprocess includes: For each of the template threads, the sub-process is controlled based on the channel to create a sub-thread, and the state information of the sub-thread is updated according to the state information of the template thread.
4. The method according to claim 1, characterized in that: The template process tree of the template container is determined in the following manner: Obtain the process tree of the template container, and perform the following operations on the process tree to obtain the template process tree: Injecting control code into the process tree, wherein the control code is used to implement control logic for the process tree; Creating a channel with each process in the process tree; State information of the process tree is collected, where the state information includes process information of each process in the process tree and a relationship between each process in the process tree.
5. The method according to claim 1, characterized in that The updating of the relationship between each of the sub-processes based on the relationship between each of the template processes in the template process tree includes: For each of the child processes, determining the parent template process of the template process corresponding to the child process in the template process tree according to the relationship between the template processes; The parent process of the child process is updated to the child process derived from the parent template process.
6. The method according to claim 1, characterized in that The method further comprises: The target data object of the process in the target process tree is updated based on the callback function interface.
7. A process tree creation device, characterized in that: The device comprises: An acquisition module, used to acquire a template process tree of a template container, wherein the template process tree includes a plurality of template processes; A derivation module, used for deriving a child process based on the template process, wherein the template process serves as a parent process of the child process; A processing module, used for isolating resources of the subprocess and the template process, and adding the subprocess to a target container; A construction module is used to update the relationship between each sub-process based on the relationship between each template process in the template process tree, and use the process tree composed of each sub-process as the target process tree.
8. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method according to any one of claims 1 to 6 are implemented.
9. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.