Resource management and control method and device based on Dbus, electronic equipment and storage medium
By sending messages when a process disconnection is detected via the Dbus bus and recording the call request identifier using a logical container, the problem of untimely resource reclamation in DBus inter-process communication is solved, and timely resource reclamation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- PRANUS BEIJING TECH CO LTD
- Filing Date
- 2025-12-19
- Publication Date
- 2026-04-24
AI Technical Summary
In DBus inter-process communication, when a client process exits abnormally, resources cannot be reclaimed in a timely manner, resulting in resource waste.
When the Dbus bus detects a disconnection from the first process, it sends a message to the second process indicating the disconnection and records the request identifier of the call request through a preset logical container. The second process then promptly reclaims resources based on this message.
This allows for timely resource reclamation when the client process exits abnormally, thus avoiding resource waste.
Smart Images

Figure CN121918992A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a resource management method, apparatus, electronic device, and storage medium based on Dubs. Background Technology
[0002] DBus is a high-level inter-process communication mechanism based on a bus architecture. During DBus communication, the service process provides methods that typically utilize system resources to implement functionalities. For example, it may use system I / O and network resources for downloading or uploading, and memory and GPU resources for dialog boxes and multimedia functions. Therefore, resource management is particularly important during DBus inter-process communication.
[0003] In existing solutions, the service process, in addition to providing resource reclamation methods for the client process, also needs to be compatible with abnormal client process exits. When the client process directly calls a method of the server process, the server process can read the DBusMessag information from the dbus context. When the client process exits abnormally, dbus will send relevant signals. The server process can determine whether the client process has exited based on the signals and reclaim system resources accordingly, such as pausing downloads, pausing media playback, or exiting dialog boxes.
[0004] However, if the client process calls the server process's methods indirectly instead of directly, then resource reclamation cannot be achieved using the dbus context and signals when the client process exits. For example, if process A calls a method of process B, and process B then calls a method of process C, process C will not be aware of process A's exit, thus failing to achieve timely resource reclamation and easily leading to resource waste. Summary of the Invention
[0005] The purpose of this application is to at least solve one of the aforementioned technical defects. The technical solution provided by the embodiments of this application is as follows: In a first aspect, embodiments of this application provide a resource management method based on Dbus, comprising: When the Dbus bus determines that it has disconnected from the first process, it sends a first message to the second process. The first message is used to indicate that the bus has disconnected from the first process. Based on the first message, the second process determines from the preset first logical container that the first process calls the second process through the third process to achieve the target function, and reclaims the process resources allocated for the first process to call the second process; The first logical container is created by the bus when it receives the first call request sent by the first process. The first logical container is used to record the request identifier of the first call request. The first call request is used to request the third process to call the process that implements the target function.
[0006] Secondly, embodiments of this application provide a resource management device based on Dbus, comprising: The message sending module is used to send a first message to the second process when the Dbus bus determines that it has disconnected from the first process. The first message is used to indicate that the bus has disconnected from the first process. The resource reclamation module is used by the second process to determine from the preset first logical container, based on the first message, that the first process calls the second process through the third process to achieve the target function, and to reclaim the process resources allocated for the first process to call the second process. The first logical container is created by the bus when it receives the first call request sent by the first process. The first logical container is used to record the request identifier of the first call request. The first call request is used to request the third process to call the process that implements the target function.
[0007] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory; The processor executes a computer program to implement the method provided in the first aspect embodiment or any alternative embodiment of the first aspect.
[0008] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method provided in the first aspect embodiment or any optional embodiment of the first aspect.
[0009] The beneficial effects of the technical solutions provided in this application are: The solution provided in this application embodiment is that, firstly, when the bus determines that the first process has been disconnected, it can send a first message indicating disconnection to the second process so that the second process can further analyze the first message; Secondly, after the second process receives the first message, it can determine that the call is an indirect call of the first process by combining the request identifier of the first call request stored in the first logical container, and promptly determine that the first process has been disconnected from the bus based on the first message and the records in the first logical container, so as to reclaim the allocated process resources in a timely manner. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0011] Figure 1 A flowchart illustrating a resource management method based on Dbus provided in this application embodiment; Figure 2 This is a schematic diagram of the overall flow of a process invocation method in one example of an embodiment of this application; Figure 3 This is a flowchart illustrating the resource reclamation logic in one example of an embodiment of this application; Figure 4 A structural block diagram of a resource management device based on Dbus provided for embodiments of this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0012] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0013] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.”
[0014] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0015] The technical solutions of this application and their effects are described below through several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.
[0016] Figure 1 This application provides a flowchart illustrating a resource management method based on Dbus. The execution subject of this method can be a terminal (e.g., a computer, mobile phone, etc.) or an intelligent agent, such as... Figure 1 As shown, the method may include: In step S101, when the Dbus bus determines that it has disconnected from the first process, it sends a first message to the second process. The first message is used to indicate that the bus has disconnected from the first process.
[0017] In the embodiments of this application, the bus (Dbus) is a high-level inter-process communication mechanism on the system, which can be used to pass messages and requests between different applications, services, or processes. The first process may be a process that needs to call methods of other processes, and the second process may be a process that provides methods to the first process. However, in the embodiments of this application, the second process cannot be directly called by the first process.
[0018] Specifically, when the bus detects that any process has disconnected from itself, it sends a first message to other processes indicating that the process has disconnected, so that all processes can know the real-time connection status of each process in a timely manner.
[0019] Optionally, in the embodiments of this application, the information transmission between the process and the bus can be carried out in a routing manner.
[0020] In step S102, the second process determines from the preset first logical container, based on the first message, that the first process calls the second process through the third process to achieve the target function, and reclaims the process resources allocated for the first process to call the second process. The first logical container is created by the bus when it receives the first call request sent by the first process. The first logical container is used to record the request identifier of the first call request. The first call request is used to request the third process to call the process that implements the target function.
[0021] In the embodiments of this application, the logical container can also be called a Dbus context, which represents a temporary environment or state for a single request processing procedure, and can be understood as the "running environment for a single request processing". The third process can directly call the methods provided by the second process, and the first process can directly call the methods provided by the third process. The request identifier, also called the link name, can be the one created by the bus for the first call request when the first process initiates the first call request. The target function can be the specific function that the first process wants to implement, such as playing video, playing music, etc.
[0022] Specifically, when the second process receives the first message sent by the bus, it can determine whether the process that caused the disconnection of the first message is the process that indirectly called itself, based on the first message and the information recorded in the first logical container. If it is determined that the first process that indirectly called itself through the third process has disconnected from the bus, then the process resources that implement the target function for the first process can be reclaimed in time, thereby avoiding the waste of process resources.
[0023] The solution provided in this application embodiment is that, firstly, when the bus determines that the first process has been disconnected, it can send a first message indicating disconnection to the second process so that the second process can further analyze the first message; Secondly, after the second process receives the first message, it can determine that the call is an indirect call of the first process by combining the request identifier of the first call request stored in the first logical container, and promptly determine that the first process has been disconnected from the bus based on the first message and the records in the first logical container, so as to reclaim the allocated process resources in a timely manner.
[0024] Based on the above embodiments, as an optional embodiment, the first logical container is created by the bus in the following manner: The bus forwards the first call request to the third process; The bus receives the second call request returned by the third process, generates a first logical container, and stores the request identifier and the process identifier of the third process into the first logical container; The second call request is created by the third process from at least one process, selecting the second process that meets the conditions for achieving the target function; The second call request is used to request the second process to perform the target function.
[0025] In embodiments of this application, the process identifier may be the name of the process in the bus system.
[0026] Specifically, when the first process needs to call the second process, it needs to send the corresponding call request to the bus, and then the bus forwards the call request to the corresponding process. In order to send the call request to the bus, the first process must first connect to the bus. Therefore, in this embodiment, the first process needs to establish a connection with the bus first, and after the connection is established, it sends the first call request to the bus. After receiving the first call request, the bus will determine whether the first process can directly call the second process with the corresponding target function. If it can, it can directly send it to the second process for calling; if not, it will first forward the first call request to a third process that the first process can call. After receiving the first call request, the third process can find a suitable second process according to the target function required by the first call request, and then send the second call request for the second process to the bus. After receiving the second call request, the bus will generate a first logical container corresponding to the second call request, and store the request identifier of the first call request and the process identifier of the third process in the first logical container. The purpose of storing the request identifier of the first call request is to record that the first process is the one that actually needs to implement the target function in this call process, while the purpose of recording the process identifier of the third process is to record that the third process plays a "relay" role in this call process.
[0027] Based on the above embodiments, as an optional embodiment, the bus stores the request identifier and the second process identifier of the third process in the first logical container, and then further includes: Forward the second call request to the second process; Receive the response result returned by the second process, and return the response result to the first process so that the first process can call the second process to implement the target function; The response result is obtained by the second process responding to the second call request.
[0028] Specifically, after the bus receives the second call request sent by the third process and generates the corresponding first logical container, it will send the second call request sent by the third process to the corresponding second process. After receiving the second call request, the second process will respond and return the response result (such as whether the call is allowed) to the bus. The bus will then return the response result to the first process. When the response result is that the call is allowed, the first process can call the second process. In this process, the second process will also allocate the corresponding process resources to the first process so that the first process can achieve the target function it needs to achieve by calling the second process.
[0029] Based on the above embodiments, as an optional embodiment, the first message includes a first parameter and a second parameter, wherein the parameter value of the first parameter is not null, and the parameter value of the second parameter is null, and the null value indicates that the first process is disconnected from the bus; Based on the first message, the second process determines from the preset first logical container whether the first process calls the second process through the third process to achieve the target function, specifically including: The second process determines whether the parameter value of the first parameter in the first message is a request identifier, and determines whether the first logical container records a request identifier. If the value of the first parameter is a request identifier and the first logical container records the request identifier, then it is determined that the first process calls the second process through the third process to achieve the target function.
[0030] In the embodiments of this application, the first parameter can be oldOwner and the second parameter can be newOwner. These two parameters can be used to represent the connection status between the first process and the bus. When the connection status between the first process and the bus changes, the type of connection status change can be represented by the above two parameters.
[0031] Specifically, when the second process receives the first message sent by the bus, it can use the first message to determine whether the process that was disconnected from the bus was indirectly calling itself. Specifically, the second process first reads the parameter value of the first parameter from the first message, and then reads the information recorded in the first logical container. Since the first logical container records relevant information from this call process, it can compare the information recorded in the first logical container with the parameter value of the first parameter in the first message. If the parameter value of the first parameter is recorded in the first logical container, it can be determined that the process that was disconnected from the bus is related to this call request, thus determining that the process that was disconnected from the bus was originally directly or indirectly calling itself to achieve the relevant target function.
[0032] It should be noted that in this embodiment, the first process can only be determined to be disconnected from the bus if the value of the first parameter is not null and the value of the second parameter is null. If neither the value of the first parameter nor the value of the second parameter is null, even if the first logical container records the value of the first parameter, the first process will still be considered to be connected to the bus. Therefore, the second process will determine that the first process is still calling itself and will not reclaim the process resources allocated to it.
[0033] Based on the above embodiments, as an optional embodiment, the bus returns the response result to the first process, specifically including: The bus will send the response to the third process; The third process determines the first format of the response result and obtains the second format that the first process can accept; If the first format is the same as the second format, the third process will return the response result to the bus, so that the bus will return the response result to the first process; If the first format is different from the second format, the third process will convert the response result into the second format and return the converted response result to the bus, so that the bus will return the converted response result to the first process.
[0034] In the embodiments of this application, the response result can be in the form of a structure (i.e., a data type), and the format can characterize the structure contained in the structure.
[0035] Specifically, when the bus receives the response from the second process, it first returns the response to the third process. The third process then evaluates the returned response to determine whether it can be directly returned to the first process. Specifically, upon receiving the response, the third process checks the structure of the structure within the response and obtains the structure that the first process can accept. The two structures are then compared. If they are identical, the third process returns the response to the bus without any processing, and the bus returns the original response to the first process. However, if the structures are different, the third process first converts the structure in the response to a structure that the first process can accept before returning the converted response to the bus, allowing the bus to return the converted response to the first process.
[0036] Based on the above embodiments, as an optional embodiment, the bus forwards the first call request to the third process. Prior to this, the method further includes: The bus generates a corresponding request identifier and a second logical container based on the first call request; the request identifier includes the process identifier of the first process, and the second logical container is used to store the request identifier.
[0037] Specifically, when the bus receives the first call request, similar to when it receives the second call request, it will also generate a second logical container with the first call request. In this second logical container, only the process identifier of the first process can be stored. The purpose of storing it is to enable the third process to read and know the process that initiated the first call request, so as to ensure that the subsequent response result can be accurately returned to the first process.
[0038] Based on the above embodiments, as an optional embodiment, the third process selects a second process that meets the conditions for achieving the target function from at least one process, specifically including: The third process reads a preset mapping table; the preset mapping table includes multiple processes and the functions that each process can perform. The process that has the target function in the preset mapping table is identified as the fourth process; One process is randomly selected from each of the fourth processes to be designated as the second process.
[0039] In the embodiments of this application, the third process may call one or more other processes, and the functions provided by each called process will be recorded through a preset mapping table. That is, the preset mapping table will record each process and the specific functions that each process can provide. Optionally, each process can provide one or more functions.
[0040] Specifically, after receiving the first call request sent by the bus, the third process will search for the process containing the target function pointed to in the first call request from the preset mapping table and identify these processes as the fourth process. If there is only one fourth process, then the fourth process can be directly identified as the second process for subsequent calls. If there are multiple fourth processes, the third process can select the second process from the multiple fourth processes. The selection method can be random selection or the most suitable one can be selected as the second process according to the actual situation (such as the process with the lowest current resource occupancy or the largest amount of remaining resources, etc.).
[0041] The following is combined Figure 2 The overall flow of the process invocation method provided in the embodiments of this application will be described, such as... Figure 2 As shown: First, when process A needs to implement a target function (such as playback): Step S1: The first process A sends a first call request to the Dbus bus. The first call request is used to request the third process B to call the process that implements the target function. Step S2: The Dbus bus will generate a request identifier for the first call request (containing the process identifier of the first process A) and a second logical container (the first logical container is used to store the request identifier of the first call request and the content of the interaction), and store the request identifier in the second logical container; Step S3: The Dbus bus will forward the first call request to the third process B; Step S4: After receiving the first call request, the third process B can determine that the first call request was initiated by the first process A by reading the request identifier in the first logical container; Step S5: The third process B will select a suitable second process C based on the target function required by the first call request; Step S6: The third process B will initiate a second call request to the Dbus bus for the second process C. The second call request is used to request the second process C to implement the target function. Step S7: The Dubs process will generate a first logical container for the second call request, add the request identifier of the first call request and the process identifier of the third process B to the first logical container, and forward the second call request to the second process C; Step S8: After receiving the second call request, the second process C will respond to the second call request and return the corresponding response result to the Dbus bus; Step S9: The Dbus bus returns the response result to the third process B. The third process B will further process the response result (the processing here depends on the actual situation. If the format of the response result that the first process A can receive is different from the format of the response result returned by the second process B, then the format needs to be converted. If they are the same, no special processing is required) before returning it to the Dbus bus. Step S10: The Dbus bus returns the further processing results of the third process B to the first process A, thereby realizing the indirect call of the first process A to the second process C.
[0042] In addition, such as Figure 3 As shown, during this process, if the connection status of the first process A with the bus changes (such as the connection with Dbus suddenly being disconnected), then Dbus can: Step S11: Send a first message to all other processes. The first message contains a first parameter and a second parameter. The parameter values of the first parameter and the second parameter can reflect the changes in the connection state. Taking the case of a disconnected connection as an example, in the case of a disconnected connection, the first parameter in the first message is the request identifier of the first call request, and the second parameter is empty (null). Step S12: After receiving the first message, the second process C can search in the second logical container. If the request identifier of the first call request can be found, it can be determined that the connection between the first process A and the bus has been broken (if the connection identifier of the first call request and the process identifier of the third process B are found in the second logical container at the same time, it can be known that the type of this call is "indirect call"). Then the resources allocated due to the call by the first process A can be reclaimed in time.
[0043] Figure 4 A structural block diagram of a Dbus-based resource management device provided in this application embodiment is shown below. Figure 4 As shown, the Dbus-based resource management device 400 may include: a message sending module 401 and a resource recycling module 402, wherein, The message sending module 401 is used to send a first message to the second process when the Dbus bus determines that it has been disconnected from the first process. The first message is used to indicate that the bus has been disconnected from the first process. The resource recycling module 402 is used by the second process to determine from the preset first logical container, based on the first message, that the first process calls the second process through the third process to achieve the target function, and to reclaim the process resources allocated for the first process to call the second process. The first logical container is created by the bus when it receives the first call request sent by the first process. The first logical container is used to record the request identifier of the first call request. The first call request is used to request the third process to call the process that implements the target function.
[0044] The solution provided in this application embodiment is that, firstly, when the bus determines that the first process has been disconnected, it can send a first message indicating disconnection to the second process so that the second process can further analyze the first message; Secondly, after the second process receives the first message, it can determine that the call is an indirect call of the first process by combining the request identifier of the first call request stored in the first logical container, and promptly determine that the first process has been disconnected from the bus based on the first message and the records in the first logical container, so as to reclaim the allocated process resources in a timely manner.
[0045] Based on the above embodiments, as an optional embodiment, the device further includes a logic container creation module, specifically used for: The bus forwards the first call request to the third process; The bus receives the second call request returned by the third process, generates a first logical container, and stores the request identifier and the process identifier of the third process into the first logical container; The second call request is created by the third process from at least one process, selecting the second process that meets the conditions for achieving the target function; The second call request is used to request the second process to perform the target function.
[0046] Based on the above embodiments, as an optional embodiment, the device further includes a request-response module, specifically used for: Forward the second call request to the second process; Receive the response result returned by the second process, and return the response result to the first process so that the first process can call the second process to implement the target function; The response result is obtained by the second process responding to the second call request.
[0047] Based on the above embodiments, as an optional embodiment, the first message includes a first parameter and a second parameter, wherein the parameter value of the first parameter is not null, and the parameter value of the second parameter is null, and the null value indicates that the first process is disconnected from the bus; The resource recycling module is specifically used for: The second process determines whether the parameter value of the first parameter in the first message is a request identifier, and determines whether the first logical container records a request identifier. If the value of the first parameter is a request identifier and the first logical container records the request identifier, then it is determined that the first process calls the second process through the third process to achieve the target function.
[0048] Based on the above embodiments, as an optional embodiment, the logic container creation module is further configured to: The bus will send the response to the third process; The third process determines the first format of the response result and obtains the second format that the first process can accept; If the first format is the same as the second format, the third process will return the response result to the bus, so that the bus will return the response result to the first process; If the first format is different from the second format, the third process will convert the response result into the second format and return the converted response result to the bus, so that the bus will return the converted response result to the first process.
[0049] Based on the above embodiments, as an optional embodiment, the logic restart creation module can also be used for: The bus generates a corresponding request identifier and a second logical container based on the first call request; the request identifier includes the process identifier of the first process, and the second logical container is used to store the request identifier.
[0050] Based on the above embodiments, as an optional embodiment, the device further includes a process filtering module, specifically used for: The third process reads a preset mapping table; the preset mapping table includes multiple processes and the functions that each process can perform. The process that has the target function in the preset mapping table is identified as the fourth process; One process is randomly selected from each of the fourth processes to be designated as the second process.
[0051] The following is for reference. Figure 5 It illustrates an electronic device suitable for implementing embodiments of this application (e.g., performing...). Figure 1The diagram shows the structure of the terminal device or server 500 of the method shown. The electronic devices in the embodiments of this application may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (e.g., vehicle navigation terminals), wearable devices, and fixed terminals such as digital TVs and desktop computers. Figure 5 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0052] The electronic device includes a memory and a processor. The memory stores a program for executing the methods described in the various method embodiments above. The processor is configured to execute the program stored in the memory. The processor may be referred to as processing device 501 as described below. The memory may include at least one of read-only memory (ROM) 502, random access memory (RAM) 503, and storage device 508 as described below, as follows: like Figure 5 As shown, the electronic device 500 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. The RAM 503 also stores various programs and data required for the operation of the electronic device 500. The processing unit 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0053] Typically, the following devices can be connected to I / O interface 505: input devices 506 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 507 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 508 including, for example, magnetic tapes, hard disks, etc.; and communication devices 509. Communication device 509 allows electronic device 500 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 5 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.
[0054] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 509, or installed from storage device 508, or installed from ROM 502. When the computer program is executed by processing device 501, it performs the functions defined in the methods of embodiments of this application.
[0055] It should be noted that the computer-readable storage medium described above in this application 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 thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0056] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0057] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0058] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: When the Dbus bus determines that it has disconnected from the first process, it sends a first message to the second process. The first message indicates that the bus has disconnected from the first process. Based on the first message, the second process determines from the preset first logical container that the first process calls the second process through the third process to achieve the target function, and reclaims the process resources allocated for the first process to call the second process. The first logical container is created by the bus when it receives the first call request sent by the first process. The first logical container is used to record the request identifier of the first call request. The first call request is used to request the third process to call the process that achieves the target function.
[0059] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0060] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0061] The modules or units described in the embodiments of this application can be implemented in software or hardware. The names of modules or units do not necessarily limit the specific unit; for example, a first constraint acquisition module can also be described as a "module for acquiring the first constraint".
[0062] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.
[0063] In the context of this application, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction 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. Machine-readable media can be, 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 include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0064] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0065] The above description is only a partial embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A resource management method based on Dbus, characterized in that, include: When the Dubs bus determines that it has disconnected from the first process, it sends a first message to the second process. The first message is used to indicate that the bus has disconnected from the first process. Based on the first message, the second process determines from the preset first logical container that the first process calls the second process through the third process to achieve the target function, and reclaims the process resources allocated for the first process to call the second process; The first logical container is created by the bus when it receives a first call request sent by the first process. The first logical container is used to record the request identifier of the first call request, which is used to request the third process to call the process that implements the target function.
2. The method according to claim 1, characterized in that, The first logical container is created by the bus in the following way: The bus forwards the first call request to the third process; The bus receives the second call request returned by the third process, generates the first logical container, and stores the request identifier and the process identifier of the third process into the first logical container; The second call request is created by the third process from at least one process that selects the second process that meets the conditions for implementing the target function; The second invocation request is used to request the second process to implement the target function.
3. The method according to claim 2, characterized in that, The bus stores the request identifier and the second process identifier of the third process in the first logical container, and then further includes: Forward the second call request to the second process; The process receives the response result returned by the second process and returns the response result to the first process, so that the first process can call the second process to implement the target function. The response result is obtained by the second process responding to the second call request.
4. The method according to claim 1, characterized in that, The first message includes a first parameter and a second parameter. The value of the first parameter is not null, and the value of the second parameter is null. The null value indicates that the first process is disconnected from the bus. The second process, based on the first message, determines from a preset first logical container whether the first process invokes the second process through a third process to implement the target function, including: The second process determines whether the parameter value of the first parameter in the first message is the request identifier, and determines whether the request identifier is recorded in the first logical container; If the parameter value of the first parameter is the request identifier and the first logical container records the request identifier, then it is determined that the first process calls the second process through the third process to implement the target function.
5. The method according to claim 3, characterized in that, The bus returns the response result to the first process, including: The bus sends the response result to the third process; The third process determines the first format to which the response result belongs, and obtains a second format that the first process can accept; If the first format is the same as the second format, the third process returns the response result to the bus, so that the bus returns the response result to the first process; If the first format is different from the second format, the third process converts the response result into the second format and returns the converted response result to the bus, so that the bus returns the converted response result to the first process.
6. The method according to claim 2, characterized in that, Before the bus forwards the first call request to the third process, the method further includes: The bus generates a corresponding request identifier and a second logical container based on the first call request; the request identifier includes the process identifier of the first process, and the second logical container is used to store the request identifier.
7. The method according to claim 2, characterized in that, The third process selects the second process from at least one process that satisfies the conditions for achieving the target function, including: The third process reads a preset mapping table; the preset mapping table includes multiple processes and the functions that each process can perform. At least one process in the preset mapping table whose function is the target function is identified as the fourth process; One process is randomly selected from each of the fourth processes to be designated as the second process.
8. A resource management and control device based on Dbus, characterized in that, include: The message sending module is used to send a first message to the second process when the Dbus bus determines that it has disconnected from the first process. The first message is used to indicate that the bus has disconnected from the first process. The resource recycling module is used by the second process to determine from the preset first logical container, based on the first message, that the first process calls the second process through the third process to achieve the target function, and to reclaim the process resources allocated for the first process to call the second process. The first logical container is created by the bus when it receives a first call request sent by the first process. The first logical container is used to record the request identifier of the first call request, which is used to request the third process to call the process that implements the target function.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the method of any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1-7.