Resource sharing method, terminal and computer-readable medium
By associating kernel interfaces across containers through virtual interfaces, the method facilitates efficient inter-container communication and service access, addressing the challenges of low practicality and complexity in multi-container systems.
Patent Information
- Application Number
- JP2024525685
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2021-11-24
- Filing Date
- 2022-11-16
- Publication Date
- 2024-11-06
- Estimated Expiration
- 2042-11-16
AI Technical Summary
In multi-container operating systems, particularly in Android systems, inter-container penetration is challenging due to isolated kernel components, leading to low practicality and increased development and maintenance complexity when attempting to share services across containers.
A method involving associating a first kernel interface in a first container with a virtual interface in a second container, allowing processes to communicate and access services in the first container, without altering the container structure, by creating a virtual interface in the second container and associating it with the first kernel interface.
Enables efficient inter-container penetration with improved practicality and reduced development and maintenance complexity, ensuring system compatibility and safety.
Smart Images

Figure 2024541045000001_ABST
Abstract
Description
[Technical field]
[0001] This application claims priority to Chinese patent application CN202111405213.9, entitled "RESOURCE SHARING METHOD, TERMINAL, AND COMPUTER-READABLE MEDIUM," filed on November 24, 2021, the entire contents of which are incorporated herein by reference.
[0002] The present disclosure relates to the field of computer technology, and features relate to a resource sharing method, a terminal, and a computer-readable medium. [Background technology]
[0003] An operating system is often designed to run in multiple containers, and the operating system and upper applications can run independently of each other in multiple containers. In order to save memory and power consumption of the system and improve the operating speed of the system, it is usually necessary for multiple containers to share some base services, so it is necessary to enable a container to penetrate other containers to access necessary services. However, the practicality of inter-container penetration is low at present. Summary of the Invention [Problem to be solved by the invention]
[0004] The embodiments of the present disclosure provide a resource sharing method, a terminal, and a computer-readable medium. [Means for solving the problem]
[0005] In a first aspect, an embodiment of the present disclosure provides a resource sharing method including: associating a first kernel interface in a first container with a virtual interface in a second container, wherein processes in the first container communicate with each other via the first kernel interface; and controlling a process in the second container to invoke the virtual interface such that an application in the second container accesses a target process in the first container.
[0006] In a second aspect, an embodiment of the present disclosure provides a terminal comprising one or more processors, a memory storing one or more programs that, when executed by the one or more processors, cause the one or more processors to implement a resource sharing method in an embodiment of the present disclosure, and one or more I / O interfaces connected between the processors and the memory and configured to enable information interaction between the processors and the memory.
[0007] In a third aspect, an embodiment of the present disclosure provides a computer-readable medium having stored thereon a computer program that, when executed by a processor, performs a resource sharing method in an embodiment of the present disclosure. [Brief description of the drawings]
[0008] [Figure 1] FIG. 1 is a flow chart of a resource sharing method according to the present disclosure. [Diagram 2] FIG. 2 is another flowchart of a resource sharing method according to the present disclosure. [Diagram 3] FIG. 3 is another flowchart of a resource sharing method according to the present disclosure. [Figure 4] FIG. 4 is another flowchart of a resource sharing method according to the present disclosure. [Diagram 5] FIG. 5 is a flow chart of some of the steps in a resource sharing method according to the present disclosure. [Figure 6] FIG. 6 is a flow chart of some of the steps in a resource sharing method according to the present disclosure. [Figure 7] FIG. 7 is another flowchart of a resource sharing method according to the present disclosure. [Figure 8] FIG. 8 is a configuration block diagram of a terminal according to the present disclosure. [Figure 9] FIG. 9 is a block diagram of a computer-readable medium according to the present disclosure. [Figure 10] FIG. 10 is a structural schematic diagram of an inter-container feedthrough according to an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0009] In order to make those skilled in the art better understand the technical solutions of the present disclosure, the following provides a detailed description of the resource sharing method, terminal and computer-readable medium according to the present disclosure in combination with the accompanying drawings.
[0010] Although the exemplary embodiments are described in detail below with reference to the drawings, the exemplary embodiments may be embodied in different forms and should not be construed as being limited to the embodiments described herein, but rather, these embodiments are provided to make this disclosure thorough and complete, and to allow those skilled in the art to fully understand the scope of the present disclosure.
[0011] Each embodiment and each feature in the embodiment of the present disclosure can be combined with each other unless there is a contradiction.
[0012] For example, as used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0013] The terms used herein are merely for the purpose of describing particular embodiments and are not intended to limit the disclosure. For example, the singular forms "a" and "the" as used herein are intended to include the plural unless the context clearly indicates otherwise. Furthermore, it should be understood that the use of the terms "comprising" and / or "consisting of" as used herein specifies the presence of the features, wholes, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or groups thereof.
[0014] Unless otherwise limited, all terms used herein, including technical and scientific terms, have the same meaning as commonly understood by those skilled in the art. It is also understood that terms as defined in commonly used dictionaries should be interpreted to have a meaning consistent with their meaning in the context of the relevant art and this disclosure, and should not be interpreted to have an ideal or overly formal meaning unless expressly so limited herein.
[0015] In a multi-container Android system, inter-container penetration is mainly realized by the binder mechanism of the Android system. Binder is a set of Inter-Process Communication (IPC) frameworks provided by the Android system, which is used to send messages and share and synchronize memory between multiple processes. In a multi-container Android system, the binder ServiceManager of different containers is shared, and an application process in one container can access a service process in the target container by obtaining the ServiceManager of the target container, thereby realizing inter-container penetration of binder.
[0016] The inventors of the present disclosure have found through their research that in a multi-container operating system, if the components in each container for application processes and service processes to communicate in the kernel are isolated from each other and cannot access each other, inter-container penetration cannot be realized. For example, in some versions of the kernel of the Android system, the binder is designed as a file system, and the binder file systems in different containers are isolated from each other, and the containers cannot access each other's ServiceManager, so that inter-container penetration cannot be realized based on the above binder mechanism.
[0017] In some related technologies, in order to realize inter-container penetration in the Android system, a ServiceManager is shared among multiple containers, and the above-mentioned binder mechanism is used to realize inter-container penetration by deleting the binder file system. However, deleting the binder file system affects the compatibility of subsequent functions related to the binder file system. In addition, after deleting the binder file system, it is necessary to perform maintenance on the specific request messages of various service processes, which requires a deep understanding of the specific services, and increases the difficulty of development and maintenance.
[0018] In view of this, with reference to FIG. 1, an embodiment of the present disclosure provides a resource sharing method, which may include, but is not limited to, the following operations S1-S2.
[0019] S1: Associate a first kernel interface in a first container with a virtual interface in a second container, where processes in the first container communicate with each other via the first kernel interface.
[0020] S2: Control a process in the second container to invoke the virtual interface such that an application in the second container accesses a target process in the first container.
[0021] In the embodiments of the present disclosure, the operating systems of the first container and the second container are not particularly limited. In some embodiments, the operating systems of the first container and the second container may be the Android system.
[0022] In the embodiment of the present disclosure, any container includes a file system interface and a kernel interface associated with each other, where the file system interface is used for a process to access the kernel interface, and the kernel interface is used for different processes to communicate within the kernel. By accessing the kernel interface, a process can communicate with a service process in the kernel, so that an application can invoke a corresponding service.
[0023] In addition, in the embodiments of the present disclosure, "associating a first kernel interface in a first container with a virtual interface in a second container" means performing an association operation that enables a process in the second container to access the first kernel interface in the first container by invoking the virtual interface.
[0024] In the embodiment of the present disclosure, there is no particular limitation on how to associate the first kernel interface in the first container with the virtual interface in the second container. For example, the implementation format of the virtual interface may be an object, and the implementation format of the first kernel interface may also be an object, and "associating the first kernel interface with the virtual interface" means associating an object called the virtual interface with an object called the first kernel interface, for example, assigning the object called the first kernel interface to a member variable of the object called the virtual interface.
[0025] In the embodiments of the present disclosure, the kernel interfaces of different containers may be isolated from each other or may be shared with each other. For example, in a multi-container Android system, the Android system may include a binder file system, and the binder file systems of different containers are isolated from each other. The Android system may not include a binder file system, and the ServiceManagers of different containers may be shared with each other.
[0026] The embodiments of the present disclosure are not particularly limited in this regard.
[0027] In the embodiment of the present disclosure, the process may be an application process of any application in the operating system, or may be a service process in the operating system, although the embodiment of the present disclosure is not particularly limited in this respect.
[0028] In some embodiments, in operation S2, an application process in the second container communicates with a target process, a service process, in the first container by invoking a virtual interface, whereby an application corresponding to the application process in the second container invokes a service corresponding to the service process in the first container.
[0029] In the embodiment of the present disclosure, a virtual interface in a second container is associated with a first kernel interface in a first container, and the process in the second container is allowed to call the virtual interface, thereby allowing the process in the second container to access the first kernel interface in the first container, and further allowing the process in the first container to communicate and call the corresponding service, enabling inter-container penetration regardless of whether different processes can share components for communication in the kernel. In addition, while realizing container penetration, there is no need to maintain specific request messages of various processes, reducing the difficulty of development and maintenance and improving practicality. In addition, the embodiment of the present disclosure can realize inter-container penetration without changing the structure of the operating system of each container, which is more efficient and also helps ensure the safety of the operating system of each container.
[0030] In an embodiment of the present disclosure, the virtual interface is an interface for a process in the second container to communicate with a process in the first container. The virtual interface may be an existing interface in the second container, such as a second file system interface in the second container, or may be a newly created interface in the second container. The embodiment of the present disclosure is not particularly limited in this respect.
[0031] Correspondingly, in some embodiments, referring to FIG. 2, before operation S1, the resource sharing method further includes the following operation S3.
[0032] S3: Create the virtual interface in the second container.
[0033] By creating a new virtual interface in the second container, the second file system interface can be left in the second container, thereby avoiding impacting functions based on the second file system interface and ensuring compatibility.
[0034] In some embodiments, referring to FIG. 3, operation S1 includes, but is not limited to, operation S11.
[0035] S11: The first kernel interface is assigned to the virtual interface.
[0036] For example, a first kernel interface is an object and a virtual interface is also an object, and "assigning the first kernel interface to the virtual interface" means assigning an object called the first kernel interface to a member variable of an object called the virtual interface.
[0037] In some embodiments, the resource sharing method further includes obtaining the first kernel interface.
[0038] The embodiments of the present disclosure are not particularly limited on how to obtain the first kernel interface. In some embodiments, the first kernel interface can be directly extracted in the first container. In some embodiments, the first kernel interface is obtained based on an association relationship between the first file system interface in the first container and the first kernel.
[0039] Correspondingly, in some embodiments, referring to FIG. 4, before operation S1, the resource sharing method further includes the following operation S4.
[0040] S4: Obtain the first kernel interface based on an association relationship between a first file system interface in a first container and the first kernel interface, where a process in the first container accesses the first kernel interface through the first file system interface.
[0041] The embodiments of the present disclosure do not particularly limit the representation format of the association relationship between the first file system interface and the first kernel interface. In some embodiments, the association relationship between the first file system interface and the first kernel interface is characterized using a target pointer from the first file system interface to the first kernel interface.
[0042] Correspondingly, in some embodiments, with reference to FIG. 5, operation S4 includes, but is not limited to, the following operations S41 to S42.
[0043] S41: Obtain a target pointer from the first file system interface to the first kernel interface, where the target pointer characterizes an association relationship between the first file system interface and the first kernel interface.
[0044] S42: Obtain the first kernel interface based on the target pointer.
[0045] In some embodiments, when the first container is launched, during establishment of the first file system interface and the first kernel interface, an association relationship between the first file system interface and the first kernel interface is recorded.
[0046] Correspondingly, in some embodiments, with reference to FIG. 6, before operation S4, the resource sharing method further includes the following operations S51 to S53.
[0047] S51: In response to the start-up of the first container, the first file system interface is created.
[0048] S52: The first kernel interface is created.
[0049] S53: Associating the first file system interface with the first kernel interface to determine an association relationship between the first file system interface and the first kernel interface.
[0050] In some embodiments, referring to FIG. 7, operation S2 includes the following operation S21.
[0051] S21: Modify an application in the second container that accesses a second file system interface in the second container to access the virtual interface, where a process in the second container accesses a second kernel interface in the second container through the second file system interface.
[0052] In some embodiments, the first kernel interface and the second kernel interface are isolated from each other.
[0053] In a second aspect, referring to FIG. 8, an embodiment of the present disclosure provides a terminal comprising one or more processors 101 and a memory 102 having stored therein one or more programs that, when executed by the one or more processors 101, cause the one or more processors 101 to implement any one of the resource sharing methods described above.
[0054] In addition, a terminal according to an embodiment of the present disclosure may further include one or more I / O interfaces 103 connected between the processor and the memory and configured to enable information interaction between the processor 101 and the memory 102.
[0055] The processor 101 is a device having data processing capabilities, including, but not limited to, a central processing unit (CPU). The memory 102 is a device having data storage capabilities, including, but not limited to, a random access memory (RAM, more specifically, SDRAM, DDR, etc.), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory (FLASH), etc. The I / O interface (read / write interface) 103 is connected between the processor 101 and the memory 102, enables information interaction between the processor 101 and the memory 102, and includes, but is not limited to, a data bus (Bus), etc.
[0056] In some embodiments, the processor 101, memory 102 and I / O interface 103 are coupled to each other and to other components of the computing device via a bus 104.
[0057] In a third aspect, with reference to FIG. 9, an embodiment of the present disclosure provides a computer-readable medium having stored thereon a computer program that, when executed by a processor, performs the resource sharing method of any one of the above claims.
[0058] In order to enable those skilled in the art to understand the technical solutions according to the embodiments of the present disclosure more clearly, the following provides a detailed description of the technical solutions according to the embodiments of the present disclosure.
[0059] Example 1 In this embodiment, the first container and the second container are started in sequence, and the operating systems of the first container and the second container may be any operating systems. Note that in this embodiment, "the first container and the second container are started in sequence" is merely an exemplary description, and in a specific implementation process, the start-up order of the first container and the second container is not particularly limited.
[0060] When the first container starts, it creates a first file system interface that is an interface for internal inter-process communication access of the first container.
[0061] When the first container is started, it creates a first kernel interface, and the first kernel interface is a driving member for realizing process communication within the kernel, that is, the inter-process communication function of the operating system is realized in this member.
[0062] Associating a first file system interface in a first container with a first kernel interface in the first container. "Associating a first file system interface with a first kernel interface" means associating an object called a first file system interface with an object called a first kernel interface, for example, assigning the object called a first kernel interface to a member variable in an object structure called a first file system interface. After the association, the processes in the first container can communicate with each other between processes, and for example, a camera application in the first container can access a camera service in the first container by calling the first file system interface.
[0063] When the second container starts, it generates a virtual interface, which is an external interface for enabling inter-process communication between processes in the second container and processes in the first container.
[0064] Associating the virtual interface of the second container with the first kernel interface of the first container. "Associating the virtual interface with the first kernel interface" means associating an object called a virtual interface with an object called a first kernel interface, for example, assigning the object called the first kernel interface to a member variable in the structure of the object called a virtual interface.
[0065] An application in the second container can directly access the corresponding service of the first container by invoking the virtual interface, for example, a camera application in the second container can directly access the camera service of the first container by invoking the virtual interface.
[0066] In the following examples 2 and 3, a terminal dual-container Android system is taken as an example. The working container is the first container in the embodiment of the present disclosure, and the living container is the second container in the embodiment of the present disclosure. The binder file system node is the file system interface in the embodiment of the present disclosure, the binder entity device node is the kernel interface in the embodiment of the present disclosure, and the virtual binder file system node is the virtual interface in the embodiment of the present disclosure.
[0067] In addition, the following Examples 2 and 3 are explanations of some specific application scenarios in the embodiments of the present disclosure, and are intended to explain the embodiments of the present disclosure, but are not intended to limit the embodiments of the present disclosure.
[0068] Example 2 When the working container starts, it creates a first binder file system and records a pointer to a first binder entity device node of a first binder file system node under the first binder file system.
[0069] When the life container starts, a second binder file system is created, a new virtual binder file system node named "binder_home_to_work" is created, and a pointer to the first binder entity device node of the first binder file system node under the first binder file system is assigned to the virtual binder file system node.
[0070] If an application in the live container needs to access a service in the work container, the second binder file system node "open / dev / binderfs / hwbinder" that the application process in the live container was accessing is modified to the virtual binder file system node "open / dev / binderfs / binder_home_to_work".
[0071] In this embodiment, even if a binder file system exists in the Android system and the binder is completely isolated, binder penetration can be realized. When realizing binder penetration, there is no need to understand the specific detailed flow of the service business, and it is only necessary to modify the calling interface, which improves convenience and security and ensures system compatibility.
[0072] Example 3 10 is a structural schematic diagram of the inter-container penetration in the embodiment of the present disclosure. In this embodiment, the working container 201 and the living container 202 can be started up sequentially.
[0073] When the working container 201 starts up, it creates a first binder file system node labeled " / dev / binderfs / hwbinder", which is an interface for the working container's 201 internal inter-process communication access.
[0074] The working container 201 creates a first binder entity device node, labeled "hwbinder_node", which is the driving component that realizes process communication in the kernel, i.e., all inter-process communication functions of the operating system are realized within this component.
[0075] A first binder file system node / dev / binderfs / hwbinder in the working container 201 is associated with a first binder entity device node hwbinder_node in the working container 201. Here, "associating a first binder file system node with a first binder entity device node" means associating an object called a first binder file system node with an object called a first binder entity device node, for example, assigning an object called a first binder entity device node hwbinder_node to a member variable in the structure of an object called a first binder file system node / dev / binderfs / hwbinder. After the association, the process inside the working container 201 enables inter-process communication, and for example, the camera application of the working container 201 can access the service camera provider of the working container 201 by calling the first binder file system node / dev / binderfs / hwbinder.
[0076] When the live container 202 starts up, it creates a virtual binder file system node labeled " / dev / binderfs / hwbinder_home_to_work", which is an external interface that enables inter-process communication between processes in the live container 202 and processes in the work container 201.
[0077] The virtual binder file system node / dev / binderfs / hwbinder_home_to_work of the life container 202 is associated with the first binder entity device node hwbinder_node in the work container 201. Here, "associating the virtual binder file system node with the first binder entity device node" means associating an object called the virtual binder file system node with an object called the first binder entity device node, and for example, assigning the object called the first binder entity device node hwbinder_node to a member variable in the structure of the object called the virtual binder file system node / dev / binderfs / hwbinder_home_to_work.
[0078] A camera application (or any other suitable application) in the live container 202 can directly access a corresponding service (e.g., the camera provider service) in the work container 201 by calling open / dev / binderfs / hwbinder_home_to_work.
[0079] Those skilled in the art will understand that all or some of the steps of the methods, the functional modules / units of the systems, the apparatuses disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware embodiments, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components. For example, one physical component may have multiple functions, or one function or step may be performed cooperatively by several physical components. Some or all of the physical components may be implemented as software executed by a processor, such as a central processor, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as a dedicated integrated circuit. Such software may be disposed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transitory media). As is well known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and that can be accessed by a computer. Additionally, those skilled in the art will know that communication media generally include computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism and may include any information delivery media.
[0080] Although exemplary embodiments are disclosed herein and specific terms are used, they are used in a general illustrative sense only and should be construed as such only and not for purposes of limitation. It will be apparent to those skilled in the art that in some instances, features, characteristics, and / or elements described in connection with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in connection with other embodiments, unless otherwise specified. Thus, those skilled in the art will appreciate that changes in various forms and details may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. Associating a first kernel interface in a first container with a virtual interface in a second container, wherein processes in the first container communicate with each other via the first kernel interface; and controlling a process in the second container to invoke the virtual interface such that an application in the second container accesses a target process in the first container. Resource sharing methods.
2. Prior to the step of associating a first kernel interface in a first container with a virtual interface in a second container, the resource sharing method further comprises: creating the virtual interface in the second container; The resource sharing method according to claim 1 .
3. The step of associating a first kernel interface in a first container with a virtual interface in a second container includes: assigning the first kernel interface to the virtual interface; The resource sharing method according to claim 1 or 2.
4. Prior to the step of associating a first kernel interface in a first container with a virtual interface in a second container, the resource sharing method further comprises: and obtaining the first kernel interface based on an association relationship between a first file system interface and the first kernel interface in the first container, wherein a process in the first container accesses the first kernel interface through the first file system interface. The resource sharing method according to claim 1 or 2.
5. The step of obtaining the first kernel interface based on an association relationship between a first file system interface in the first container and the first kernel interface includes: obtaining a target pointer from the first file system interface to the first kernel interface, the target pointer characterizing an association relationship between the first file system interface and the first kernel interface; obtaining the first kernel interface based on the target pointer; The resource sharing method according to claim 4 .
6. Before the step of obtaining the first kernel interface based on an association relationship between a first file system interface in the first container and the first kernel interface, the resource sharing method includes: creating the first file system interface in response to launching the first container; creating the first kernel interface; and associating the first file system interface with the first kernel interface to determine an association relationship between the first file system interface and the first kernel interface. The resource sharing method according to claim 4 .
7. The step of controlling a process in the second container to invoke the virtual interface includes: modifying an application in the second container that accesses a second file system interface in the second container to access the virtual interface, such that a process in the second container accesses a second kernel interface in the second container via the second file system interface; The resource sharing method according to claim 1 or 2.
8. the first kernel interface and the second kernel interface are isolated from each other; The resource sharing method according to claim 7.
9. one or more processors; A memory having stored therein one or more programs which, when executed by said one or more processors, cause said one or more processors to implement the resource sharing method according to any one of claims 1 to 8. Terminal.
10. A computer readable medium having stored thereon a computer program which, when executed by a processor, implements the resource sharing method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Inter-process communication between containers
US9733992B1
