Inter-program communication method and computer device

By using program monitors and log structures to store storage addresses of shared capabilities in computer equipment, the problems of long time-consuming and insufficient security in inter-program communication in the existing technology are solved, and efficient and secure zero-copy communication is achieved.

WO2024193310A1PCT designated stage expired Publication Date: 2024-09-26HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/079211
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-21
Filing Date
2024-02-29
Publication Date
2024-09-26

AI Technical Summary

Technical Problem

Existing inter-program communication methods are time-consuming and insufficiently secure in large-scale data transmission scenarios. Especially in zero-copy communication, recycling capabilities are low, resulting in low communication efficiency.

Method used

By introducing a program monitor into computer equipment, allocating shared message buffers and creating shared capabilities, and using log structures to store storage addresses of shared capabilities, zero-copy, secure inter-program communication is achieved, and communication efficiency and recycling speed are improved.

Benefits of technology

It achieves secure, zero-copy inter-program communication, improves communication efficiency and recycling capabilities, avoids memory scanning, and improves system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024079211_26092024_PF_FP
    Figure CN2024079211_26092024_PF_FP
Patent Text Reader

Abstract

The present application provides an inter-program communication method and a computer device. The method comprises: a computer device allocates a first sharing capability to a first program running sandbox, so that the first program running sandbox writes data into a first shared message buffer area by using the first sharing capability; the computer device stores the first sharing capability into a memory according to the type of the first sharing capability, and writes a first storage address into a first data structure; the computer device recovers or encapsulates a sharing capability set corresponding to a storage address stored in the first data structure; and the computer device allocates the first sharing capability to a second program running sandbox. According to the inter-program communication method provided in the present application, mutual exclusion access to the first shared message buffer area is implemented, the purpose of safe and zero-copy communication is achieved, there is no need to scan the whole memory in a recovery or encapsulation process, so that the recovery capacity speed can be increased, and therefore the communication efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Inter-program communication method and computer device

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 21, 2023, with application number 202310306148.7 and application name “A method for communication between programs and a computer device”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of computer technology, and more particularly, to an inter-program communication method and a computer device. Background Art

[0003] Inter-program communication technology is a commonly used technical means in computer systems. It can be divided into the following three categories according to the number of memory copies: (1) Multi-copy inter-program communication: The communication process involves multiple memory copy operations, such as the commonly used TCP / PIPE communication mechanism. Usually, the kernel will copy the data from the source end to the kernel space, and then notify the destination end to copy the data from the kernel space to the destination end. Multi-copy inter-program communication can effectively ensure the security of communication. The communicating parties access their own message buffers and cannot access or tamper with each other's data. However, in large-scale data transmission scenarios, this communication mechanism requires a lot of time to copy data, resulting in excessive communication delay. (2) Single-copy inter-program communication: The communication process between programs involves only one memory copy. The source end notifies the destination end to prepare to receive data. After the destination end prepares the corresponding message buffer, the kernel is responsible for copying the data from the source end to the message buffer provided by the destination end. Compared to multi-copy inter-program communication, this communication method only requires one memory copy operation, but it requires the introduction of mechanisms such as locks or semaphores to ensure that the source end cannot arbitrarily tamper with the data during the data copy process. (3) Zero-copy inter-program communication: No memory copy is required during the communication process, but the shared memory area is directly mapped to the address space of both communicating parties. Similar to single-copy inter-program communication, programmers need to introduce other security mechanisms such as locks or semaphores to ensure the security of inter-program communication. Therefore, how to solve the long time-consuming inter-program communication and ensure the security of communication has become an urgent problem to be solved.

[0004] Summary of the Invention

[0005] The present application provides an inter-program communication method and computer device, which can achieve zero-copy, secure communication purposes and improve communication efficiency.

[0006] In a first aspect, a method for communication between programs is provided, which is applied to a computer device, wherein the computer device includes a first program execution sandbox, a second program execution sandbox and a program monitor, and is characterized in that the method includes: the computer device allocates a first sharing capability to the first program execution sandbox so that the first program execution sandbox writes data to a first shared message buffer through the first sharing capability, the first sharing capability points to the first shared message buffer, and the first sharing capability is created by the program monitor; the computer device saves the first sharing capability to a memory according to the type of the first sharing capability, writes a first storage address to a first data structure, and the first storage address is the storage address of the first sharing capability in the memory; the computer device recovers or encapsulates a sharing capability set corresponding to the storage address stored in the first data structure, the sharing capability set including the first sharing capability; the computer device allocates the first sharing capability to the second program execution sandbox so that the second program execution sandbox reads the data in the first shared message buffer through the first sharing capability.

[0007] In an embodiment of the present application, a computer device can allocate a first shared message buffer for a first program running sandbox and a second program running sandbox in communication, and first pass a first shared capability pointing to the shared message buffer to the first program running sandbox. The computer device can store the first shared capability in memory and store the storage address in a corresponding data structure. After the first program running sandbox writes data, the computer device recovers or encapsulates the first shared capability of the first program running sandbox, and then passes the first shared capability to the second program running sandbox, thereby achieving mutually exclusive access to the first shared message buffer by the first program running sandbox and the second program running sandbox, thereby achieving a secure, zero-copy communication purpose. Since the storage address of the first shared capability in memory has been stored in a specific data structure, the computer device does not need to scan the entire memory in the process of recovering or encapsulating the first shared capability. It only needs to find and recover or encapsulate the first shared capability based on the storage address stored in the data structure, which can increase the speed of recovering the capability and thus improve communication efficiency.

[0008] In combination with the first aspect, in certain implementations of the first aspect, the computer device saves the first shared capability to the memory according to the type of the first shared capability, and writes the first storage address to the first data structure, including: the computer device saves the first shared capability to the memory according to the type of the first shared capability, and writes the first storage address to the first log; when the first program execution sandbox initiates a communication request, the computer device writes the storage address set stored in the first log to the first data structure, and the storage address set includes the first storage address.

[0009] In the embodiment of the present application, by introducing a log to first store the storage address of the shared capability and then uniformly writing it into the data structure, the number of times data is written into the data structure can be reduced, which can save performance overhead.

[0010] In combination with the first aspect, in certain implementations of the first aspect, before the computer device writes the first storage address into the first log, the method further includes: the computer device determines whether the first log is full; the computer device writes the first storage address into the first log, including: when the computer device determines that the first log is not full, the computer device writes the first storage address into the first log.

[0011] In the embodiment of the present application, before writing the first storage address into the first log, it can be determined whether the first log is full. If it is not full, the first storage address is written into the first log, which can effectively avoid problems such as memory overflow and memory overwrite.

[0012] In combination with the first aspect, in certain implementations of the first aspect, the computer device includes a first log length register and a first log index register, the value of the first log length register is used to indicate the length of the first log in the memory, and the value of the first log index register is used to indicate the index of the storage address of the next entry to be written to the first log. The computer device determines whether the first log is full, including: the computer device determines, based on the first log length register and the length of the storage address, the number of storage addresses that can be stored in the first log; the computer device determines, based on the value of the first log index register and the number of storage addresses that can be stored in the first log, whether the first log is full; and the computer device writes the first storage address to the first log when determining that the first log is not full, including: the computer device writes the first storage address to the first log when determining that the value of the first log index register is less than the number of storage addresses that can be stored in the first log.

[0013] In conjunction with the first aspect, in certain implementations of the first aspect, the computer device includes a first log base register, a first log end register, and a first log index register. The value of the first log base register is used to indicate the starting address of the first log in the memory, the value of the first log end register is used to indicate the ending address of the first log in the memory, and the value of the first log index register is used to indicate the index of the storage address of the next entry to be written to the first log. The computer device determines whether the first log is full, including: determining, by the computer device, the length of the first log in the memory based on the value of the first log base register and the value of the first log end register; determining, by the computer device, the number of storage addresses that can be stored in the first log based on the length of the first log in the memory and the length of the storage address; determining, by the computer device, whether the first log is full based on the value of the first log index register and the number of storage addresses that can be stored in the first log; and when the computer device determines that the first log is not full, writing the first storage address to the first log, including: when the computer device determines that the value of the first log index register is less than the number of storage addresses that can be stored in the first log, writing the first storage address to the first log.

[0014] In conjunction with the first aspect, in certain implementations of the first aspect, the computer device includes a first log base register, a first log end register, and the first log address register. The value of the first log base register is used to indicate the starting address of the first log in the memory, the value of the first log end register is used to indicate the ending address of the first log in the memory, and the value of the first log address register is used to indicate the address of the next storage address to be written to the first log. The computer device determines whether the first log is full, including: the computer device determines, based on the value of the first log base register and the value of the first log end register, an area of ​​the first log in the memory; the computer device determines, based on the value of the first log address register, whether the address of the next storage address to be written to the first log falls within the area of ​​the first log in the memory; and when the computer device determines that the first log is not full, writing the first storage address to the first log, including: when the computer device determines that the address of the next storage address to be written to the first log falls within the area of ​​the first log in the memory, writing the first storage address to the first log.

[0015] In combination with the first aspect, in certain implementations of the first aspect, the computer device includes a first log index register, the value of the first log index register is used to indicate the index of the next storage address to be written to the first log, the first log already stores N storage addresses, N ≥ 1 and is an integer, and when the computer device determines that the first log is full, the method further includes: the computer device loads N sharing capabilities corresponding to the N storage addresses according to the N storage addresses; the computer device determines M data structures according to the N sharing capabilities, the N sharing capabilities are associated with the M data structures, M ≥ 1 and is an integer; the computer device traverses the M data structures to detect whether each data structure in the M data structures stores the first storage address; if P data structures among the M data structures do not store the first storage address, the computer device writes the first storage address into the P data structures, P ≥ 0 and is an integer.

[0016] In combination with the first aspect, in certain implementations of the first aspect, after the computer device writes the first storage address into the P data structures, the method further includes: setting the value of the first log index register to 0.

[0017] In combination with the first aspect, in certain implementations of the first aspect, the first sharing capability includes a type field, upper and lower boundary fields, and an access permission field, wherein the type field is used to indicate the type of the first sharing capability, the upper and lower boundary fields are used to indicate the upper and lower boundaries of the first shared message buffer, and the access permission field is used to indicate the permission to access the first shared message buffer.

[0018] In combination with the first aspect, in some implementations of the first aspect, the first sharing capability further includes an identifier field, and the identifier field is used to identify the first sharing capability.

[0019] In a second aspect, a method for communication between programs is provided, which is applied to a computer device, wherein the computer device includes a first program running sandbox, a second program running sandbox and a program monitor, and the method includes: the first program running sandbox sends a first message to the program monitor; the program monitor transmits a first sharing capability to the first program running sandbox according to the first message, and the first sharing capability points to a first shared message buffer; the first program running sandbox saves the first sharing capability to a memory according to the type of the first sharing capability, and writes a first storage address to a first log, wherein the first storage address is a storage address of the first sharing capability in the memory; the first The program execution sandbox writes data into the first shared message buffer through the first shared capability; the first program execution sandbox sends second information to the program monitor; the program monitor writes the storage address set stored in the first log into the first data structure according to the second information, and the storage address set includes the first storage address; the program monitor recovers or encapsulates the shared capability set corresponding to the storage address stored in the first data structure, and the shared capability set includes the first shared capability; the program monitor passes the first shared capability to the second program execution sandbox so that the second execution sandbox reads the data in the first shared message buffer through the first shared capability.

[0020] In an embodiment of the present application, a program monitor can allocate a first shared message buffer for a first program execution sandbox and a second program execution sandbox in communication, and first pass a first shared capability pointing to the shared message buffer to the first program execution sandbox. The first program execution sandbox can store the first shared capability in memory and store the storage address in a log. After the first program execution sandbox writes data, the program monitor writes the first storage address in the log to a first data structure, and recovers or encapsulates the first shared capability of the first program execution sandbox based on the first data structure. The program monitor then passes the first shared capability to the second program execution sandbox, thereby enabling mutually exclusive access to the first shared message buffer by the first and second program execution sandboxes, thereby achieving secure, zero-copy communication. Because the storage address of the first shared capability in memory is stored in a specific data structure, the program monitor does not need to scan the entire memory when recovering or encapsulating the first shared capability. Instead, it can find and recover or encapsulate the first shared capability based on the storage address stored in the data structure, which can increase the speed of capability recovery and thus improve communication efficiency.

[0021] In combination with the second aspect, in certain implementations of the second aspect, before the first program execution sandbox writes the first storage address to the first log, the method further includes: the first program execution sandbox determines whether the first log is full; the first program execution sandbox writes the first storage address to the first log, including: when the first program execution sandbox determines that the first log is not full, writing the first storage address to the first log.

[0022] In combination with the second aspect, in certain implementations of the second aspect, the computer device includes a first log length register and a first log index register, the first log length register is used to indicate the length of the first log in the memory, and the first log index register is used to indicate the index of the storage address of the next item to be written to the first log. The first program running sandbox determines whether the first log is full, including: the first program running sandbox determines the number of storage addresses that can be stored in the first log according to the first log length register and the length of the storage address; determines whether the first log is full according to the value of the first log index register and the number of storage addresses that can be stored in the first log; when the first program running sandbox determines that the first log is not full, writes the first storage address to the first log, including: when the first program running sandbox determines that the value of the first log index register is less than the number of storage addresses that can be stored in the first log, writes the first storage address to the first log.

[0023] In combination with the second aspect, in some implementations of the second aspect, the computer device includes a first log base address register, a first log end address register, and a first log index register, the first log base address register is used to indicate the starting address of the first log in the memory, the first log end address register is used to indicate the ending address of the first log in the memory, and the first log index register is used to indicate the index of the storage address of the next item to be written to the first log, and the first program execution sandbox determines whether the first log is full, including: the first program execution sandbox determines the first log according to the first log base address register and the first log end address register. The first program execution sandbox determines the number of storage addresses that can be stored in the first log according to the length of the first log in the memory and the length of the storage address; the first program execution sandbox determines whether the first log is full according to the value of the first log index register and the number of storage addresses that can be stored in the first log; when the first program execution sandbox determines that the first log is not full, writing the first storage address to the first log, including: when the first program execution sandbox determines that the value of the first log index register is less than the number of storage addresses that can be stored in the first log, writing the first storage address to the first log.

[0024] In combination with the second aspect, in certain implementations of the second aspect, the computer device includes a first log base register, a first log end register, and the first log address register, the first log base register being used to indicate a starting address of the first log in the memory, the first log end register being used to indicate an ending address of the first log in the memory, and the first log address register being used to indicate an address of a next storage address to be written to the first log; the first program execution sandbox determining whether the first log is full comprises: the first program execution sandbox determining an area of ​​the first log in the memory based on the first log base register and the first log end register; determining whether the address of the next storage address to be written to the first log falls within the area of ​​the first log in the memory; when the first program execution sandbox determines that the first log is not full, writing the first storage address to the first log comprises: when the first program execution sandbox determines that the address of the next storage address to be written to the first log falls within the area of ​​the first log in the memory, writing the first storage address to the first log.

[0025] In combination with the second aspect, in certain implementations of the second aspect, the computer device includes a first log index register, which is used to indicate the index of the next storage address to be written to the first log. The first log has N storage addresses stored. When the first program running sandbox determines that the first log is full, the method also includes: the first program running sandbox loads N sharing capabilities corresponding to the N storage addresses according to the N storage addresses; the first program running sandbox determines M data structures based on the N sharing capabilities, and the N sharing capabilities are associated with the M data structures; the first program running sandbox traverses the M data structures to detect whether each data structure in the M data structures stores the first storage address; if P data structures among the M data structures do not store the first storage address, the first program running sandbox writes the first storage address into the P data structures.

[0026] In combination with the second aspect, in certain implementations of the second aspect, the first sharing capability includes a type field, upper and lower boundary fields, and an access permission field, wherein the type field is used to indicate the type of the first sharing capability, the upper and lower boundary fields are used to indicate the upper and lower boundaries of the first shared message buffer, and the access permission field is used to indicate the permission to access the first shared message buffer.

[0027] In combination with the second aspect, in some implementations of the second aspect, the first sharing capability further includes an identifier field, and the identifier field is used to identify the first sharing capability.

[0028] In a third aspect, a method for inter-program communication is provided, which is applied to a computer device, the computer device including a first program execution sandbox, a second program execution sandbox and a program monitor, the method including: the first program execution sandbox sends first information to the program monitor; the program monitor transmits a first shared capability to the first program execution sandbox based on the first information, the first shared capability pointing to a first shared message buffer; the first program execution sandbox saves the first shared capability to a memory based on the type of the first shared capability, writes the first storage address to a first data structure, the first storage address being the storage address of the first shared capability in the memory; the first program execution sandbox writes data to the first shared message buffer through the first shared capability; the first program execution sandbox sends second information to the program monitor; the program monitor recovers or encapsulates the first shared capability based on the second information and the first storage address stored in the first data structure; the program monitor transmits the first shared capability to the second program execution sandbox so that the second execution sandbox reads the data in the first shared message buffer through the first shared capability.

[0029] In an embodiment of the present application, a program monitor can allocate a first shared message buffer for a first program execution sandbox and a second program execution sandbox in communication, and first pass a first shared capability pointing to the shared message buffer to the first program execution sandbox. The first program execution sandbox can store the first shared capability in memory and store the storage address in a corresponding data structure. After the first program execution sandbox writes data, the program monitor recovers or encapsulates the first shared capability of the first program execution sandbox, and then passes the first shared capability to the second program execution sandbox, thereby achieving mutually exclusive access to the first shared message buffer by the first program execution sandbox and the second program execution sandbox, thereby achieving secure, zero-copy communication. Because the storage address of the first shared capability in memory is stored in a specific data structure, the program monitor does not need to scan the entire memory when recovering or encapsulating the first shared capability. It only needs to find and recover or encapsulate the first shared capability based on the storage address stored in the data structure, which can increase the speed of capability recovery and thus improve communication efficiency.

[0030] In combination with the third aspect, in certain implementations of the third aspect, before the program monitor passes the first shared capability to the second program execution sandbox, the method also includes: the second program execution sandbox sends third information to the program monitor, and the third information is used to indicate communication with the first program execution sandbox.

[0031] In combination with the third aspect, in certain implementations of the third aspect, the first sharing capability includes a type field, upper and lower boundary fields, and an access permission field, wherein the type field is used to indicate the type of the first sharing capability, the upper and lower boundary fields are used to indicate the upper and lower boundaries of the first shared message buffer, and the access permission field is used to indicate the permission to access the first shared message buffer.

[0032] In combination with the third aspect, in some implementations of the third aspect, the first sharing capability further includes an identifier field, and the identifier field is used to identify the first sharing capability.

[0033] The fourth aspect is a computer device according to an embodiment of the present application, which includes modules / units for executing the above aspects or any possible design method of the above aspects; these modules / units can be implemented by hardware, or corresponding software can be implemented by hardware.

[0034] The fifth aspect is a chip according to an embodiment of the present application, which is coupled to a memory in a computer device and is used to call a computer program stored in the memory and execute the above-mentioned aspects of the embodiment of the present application and any possible design of the above-mentioned aspects; in the embodiment of the present application, "coupling" refers to the direct or indirect combination of two components with each other.

[0035] The sixth aspect is a computer-readable storage medium of an embodiment of the present application, which includes a computer program. When the computer program runs on an electronic device, the computer device executes the technical solution of the above aspect and any possible design of the above aspect.

[0036] The seventh aspect is a computer program according to an embodiment of the present application, which includes instructions. When the instructions are executed on a computer, the computer executes a technical solution such as the above aspect and any possible design thereof.

[0037] The eighth aspect is a computer device of an embodiment of the present application, which includes one or more processors; one or more memories; the one or more memories store one or more computer programs, and the one or more computer programs include instructions. When the instructions are executed by the one or more processors, the above aspects or any possible implementation of the above aspects are executed. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] FIG1 is a schematic diagram of an inter-program communication technology.

[0039] FIG2 is a diagram of the system architecture provided in an embodiment of the present application.

[0040] FIG3 is a schematic diagram of the format of the sharing capability provided in an embodiment of the present application.

[0041] FIG4 is a schematic flowchart of the inter-program communication method provided in an embodiment of the present application.

[0042] FIG5 is a schematic flowchart of the inter-program communication method provided in an embodiment of the present application.

[0043] FIG6 is a schematic diagram of a program running sandbox provided in an embodiment of the present application writing a storage address in a log.

[0044] FIG7 is a schematic flowchart of processing log exceptions provided in an embodiment of the present application.

[0045] FIG8 is a schematic flowchart of the inter-program communication method provided in an embodiment of the present application.

[0046] FIG9 is a schematic flowchart of the inter-program communication method provided in an embodiment of the present application.

[0047] FIG10 is a schematic structural diagram of the inter-program communication module provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] The terms used in the following embodiments are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification of this application and the appended claims, the singular expressions "a", "an", "the", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one, two or more. The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship.

[0049] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in yet other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0050] In order to more clearly introduce the inter-program communication method provided by the embodiment of the present application, several concepts that may be involved in the implementation of the present application are first introduced.

[0051] Monolithic kernel: An operating system kernel architecture characterized by the entire kernel program running in kernel space. Compared to other operating system architectures, such as microkernels and hybrid kernels, the monolithic kernel uniquely provides a unified high-level virtual interface to computer hardware. It provides a series of system calls to implement various operating system services, such as process management, program concurrency, memory management, and various drivers.

[0052] Microkernel: Another operating system kernel architecture, this one runs as few functions as possible in kernel space and provides the necessary mechanisms to implement the operating system. These mechanisms include address space management, thread management, and inter-process communication. Compared to a macrokernel, a microkernel runs many components, such as the file system and network protocol stack, in user mode, minimizing its actual kernel functionality.

[0053] It should be noted that the inter-program communication method provided in the embodiment of the present application is applicable to the above-mentioned operating system kernel architecture, and can also be applied to other operating system kernel architectures. The embodiment of the present application is not limited thereto.

[0054] Process: The running entity of a program. A program is a description of instructions, data, and their organization. A process is the running entity of a program.

[0055] User-mode processes: These are processes that run in user mode, not kernel space. Whether they are user-mode processes or kernel processes, the functions they implement are all implemented using software code, so their execution methods can be considered the same as the methods executed by the processor after reading the software code.

[0056] Operating system: System software that manages computer hardware and software resources and is the cornerstone of a computer system. An operating system handles basic tasks such as managing and allocating memory, prioritizing the supply and demand of system resources, controlling input and output devices, operating the network, and managing the file system. An operating system also provides an interface for users to interact with the system.

[0057] Kernel: A program used to manage data input and output requests from software, translating these requests into data processing instructions and handing them over to the processor and other electronic components in the computer for processing. It is an essential part of modern operating systems.

[0058] Kernel objects are abstractions of kernel-managed information, representing various kernel-maintained information, such as thread control blocks, process page tables, and process communication channels. Kernel objects, as data structures, are stored in a kernel-allocated memory block. Kernel objects are directly accessed by the kernel. The kernel provides interfaces to allow user-mode processes to access kernel objects and uses permission control mechanisms to manage user-mode process access to kernel objects. It should be noted that user-mode processes access kernel objects indirectly: they enter the kernel after calling an interface, and the kernel then directly performs access.

[0059] Capabilities: The inter-program communication methods provided in the embodiments of this application involve the concept of capabilities. Capabilities in the embodiments of this application can be understood as a pointer type, which is a pointer type modified from an integer pointer and carries metadata. Capabilities can carry metadata through multiple fields.

[0060] It is understandable that different types of capabilities can be further constructed based on the different metadata carried by the capabilities. Based on this, an embodiment of the present application provides a shared capability. Please see below for detailed description.

[0061] Inter-program communication technology is a commonly used technical means in computer systems. It can be divided into the following three categories based on the number of memory copies:

[0062] (1) Multi-copy inter-program communication: The communication process involves multiple memory copy operations, such as the commonly used TCP / PIPE communication mechanism. Usually the kernel copies data from the source end to the kernel space, and then notifies the destination end to copy the data from the kernel space to the destination end. Multi-copy inter-program communication can effectively ensure the security of communication. The communicating parties access their own message buffers and cannot access or tamper with each other's data. However, in large-scale data transmission scenarios, this communication mechanism consumes a lot of time to copy data, resulting in excessive communication delay.

[0063] (2) Single-copy inter-program communication: The communication process between programs involves only one memory copy. The source end notifies the destination end to prepare to receive data. After the destination end prepares the corresponding message buffer, the kernel is responsible for copying the data from the source end to the message buffer provided by the destination end. Compared with multi-copy inter-program communication, this communication method only requires one memory copy operation, but it is necessary to introduce mechanisms such as locks or semaphores to ensure that the source end cannot arbitrarily tamper with the data during the data copy process.

[0064] (3) Zero-copy inter-program communication: No memory copy is required during the communication process. Instead, the shared memory area is directly mapped into the address space of both communicating parties. Similar to single-copy inter-program communication, programmers need to introduce other security mechanisms such as locks or semaphores to ensure the security of inter-program communication.

[0065] FIG1 shows a schematic diagram of an inter-program communication technology.

[0066] Figure 1 shows a schematic diagram of a single-address space microkernel operating system based on a capability architecture. In this operating system, the kernel, system services, and user programs run in the same address space, which are isolated into independent security isolation domains through the capability mechanism. The communication component of the operating system is located in the microkernel, and the communicating parties communicate through the communication component. Figure 1 (a) shows the single-copy communication technology, and Figure 1 (b) shows the zero-copy communication technology.

[0067] As shown in (a) in Figure 1, when the source program needs to send data, it can communicate with the communication component. The communication component can create an auxiliary buffer, copy the data from the message buffer to the auxiliary buffer, and create a capability pointing to the auxiliary buffer. The capability is transmitted to the destination program. After receiving the capability, the destination program can access the auxiliary buffer, thereby realizing communication between the source program and the destination program.

[0068] As shown in (b) of Figure 1, when the source program needs to send data, it can communicate with the communication component. The communication component can directly create a capability pointing to the message buffer and transmit the capability to the destination program. After receiving the capability, the destination program can access the message buffer, thereby realizing communication between the source program and the destination program.

[0069] As you can understand, the method shown in Figure 1 (a) requires the kernel to copy the data, which increases communication time. While the method shown in Figure 1 (b) eliminates the need for the kernel to copy data, once the capability is transferred, the destination program can freely access the message buffer, compromising system security. Furthermore, if the kernel wishes to reclaim the transferred capability, a significant amount of time is required to perform a global memory scan.

[0070] To sum up, the currently provided zero-copy inter-program communication method is not secure enough, and the recovery capability requires a lot of time. Based on this, the embodiment of the present application provides an inter-program communication method that does not require copying data, can improve communication efficiency, and provides a field for identifying capabilities, which can provide efficiency in recovering capabilities.

[0071] FIG2 shows a system architecture diagram provided in an embodiment of the present application.

[0072] As shown in Figure 2, the system architecture includes a first program execution sandbox, a second program execution sandbox, and a program monitor. The program monitor has a global memory view, can define the corresponding memory range for each program execution environment, and use capabilities to construct a memory security isolation domain, ensuring the integrity of the control path within the program execution sandbox and the security of memory access. The program monitor can provide a communication channel for the program execution sandbox. When the program execution sandbox needs to communicate between programs, it requests a shared message buffer by communicating with the program monitor. The program monitor allocates a shared message buffer and creates a capability pointing to the shared message buffer and returns it to the program execution sandbox. The program execution sandbox can access the shared message buffer through this capability.

[0073] Optionally, in some embodiments, when the program runs the sandbox to save the capability to the memory, the target storage address of the capability can be written to the first log so that the communicating parties can transfer the capability based on the first log. Please see below for details.

[0074] Optionally, in some embodiments, the program monitor includes a shared capability management module and an inter-program communication module, wherein the shared capability management module is used to create shared capabilities, and the inter-program communication module is used to maintain communication channels between programs.

[0075] Optionally, in some embodiments, the program monitor further includes an exception handling module, which is used to handle exceptions when the log is full. Please see below for details.

[0076] It should be noted that the program in the embodiments of the present application is a description of instructions, data and their organizational form, including but not limited to threads, processes, system services, user applications, operating systems, etc.

[0077] In order to implement the inter-program communication method provided in the embodiment of the present application, a new capability type provided in the embodiment of the present application is used to point to a shared message buffer, thereby realizing inter-program communication. In the embodiment of the present application, this capability type is referred to as a shared type, and this capability is referred to as a shared capability. This shared capability is expanded based on an existing capability. To facilitate the distinction of this shared capability, there are several possible implementation methods:

[0078] In one possible implementation, the sharing capability is indicated through a type field.

[0079] As shown in (a) in Figure 3, the format of the capability includes a type field, upper and lower bound fields, and an access permission field. In an embodiment of the present application, a new value can be defined in the type field to indicate the shared capability provided by the embodiment of the present application. The upper and lower bound fields are used to indicate the upper and lower bounds of the memory pointed to by the shared capability, and the access permission field is used to indicate the permission to access the memory.

[0080] For example, the type field is 2 bytes, "00" corresponds to the existing first capability type, "01" corresponds to the existing second capability type, "10" and "11" are not used, so "10" can be used to define the shared type provided in the embodiment of this application.

[0081] One possible implementation is to indicate the sharing capability through a reserved flag bit.

[0082] As shown in (b) of Figure 3, a flag bit may be reserved in the capability format, and the shared capability provided by the embodiment of the present application may be identified by defining the reserved flag bit. For example, the existing capability format has a first flag bit reserved, and when the flag bit is "1", it indicates that the capability is a shared capability.

[0083] One possible implementation is to add an identifier field to indicate the sharing capability.

[0084] As shown in (c) of Figure 3, in this embodiment of the present application, an identifier field may be added to the capability format. That is, when the identifier field is included in the capability format, the capability may be determined to be a shared capability, and each shared capability may be identified by the identifier field. For example, the identifier "00" indicates the first shared capability, and the identifier "01" indicates the second shared capability.

[0085] It should be noted that the format of the sharing capability shown in FIG3 is merely an example and should not be construed as a specific limitation on the sharing capability provided by the present application. Sharing capabilities may also have other formats. For example, a sharing capability may include a type field, upper and lower bound fields, an access permission field, a reserved field, and an identifier field. For another example, a sharing capability may also include a field for indicating the type of software entity accessing memory.

[0086] It is understandable that in order to construct the sharing capability provided by the embodiment of the present application, new assembly instructions can be added to construct the sharing capability provided by the embodiment of the present application.

[0087] For example, a new shared capability construction instruction may be added to convert other types of capabilities into shared capabilities.

[0088] In addition to adding instructions for constructing sharing capabilities, in order to implement the inter-program communication method provided by the embodiment of the present application, the embodiment of the present application also exemplarily provides the following instructions.

[0089] For example, a shared capability destruction instruction may be added, through which the shared capability may be destroyed or converted into another type of capability.

[0090] Exemplarily, a sharing capability identifier acquisition instruction may be added. When the sharing capability includes an identifier field, the identifier of the sharing capability may be acquired through the instruction.

[0091] Exemplarily, a shared capability identifier setting instruction may be added. When the shared capability includes an identifier field, the specific value of the shared capability identifier may be set through the instruction.

[0092] In addition to adding new assembly instructions, in the embodiment of the present application, sharing capability permissions can also be set, that is, a program with the sharing capability permission can construct or destroy sharing capabilities.

[0093] FIG4 shows a schematic flow chart of an inter-program communication method 400 provided in an embodiment of the present application. The method is applied to a computer device, which includes a first program execution sandbox, a second program execution sandbox, and a program monitor. As shown in FIG4 , the method includes:

[0094] S401: A first program execution sandbox sends first information to a program monitor.

[0095] Correspondingly, the program monitor receives the first information sent by the first program execution sandbox.

[0096] In an embodiment of the present application, the first program execution sandbox may directly or indirectly request a shared message buffer from the program monitor through the first information.

[0097] In one possible implementation, the first program execution sandbox sends first information to the program monitor, where the first information is used to request a shared message buffer. After receiving the first information, the program monitor can allocate a shared message buffer for the first program execution sandbox, i.e., directly request a shared message buffer.

[0098] Optionally, in some embodiments, the first information includes information indicating the size of the shared message buffer.

[0099] In one possible implementation, the first program execution sandbox sends a first message to the program monitor, where the first message is used to request initiation of inter-program communication. After receiving the first message, the program monitor can allocate a shared message buffer for the first program execution sandbox, i.e., indirectly request a shared message buffer.

[0100] S402: The program monitor transmits a first sharing capability to the first program execution sandbox.

[0101] Specifically, the program monitor may transmit a first sharing capability to the first program execution sandbox according to the first information. The first sharing capability points to the first shared message buffer. The type of the first sharing capability is a sharing capability type.

[0102] Exemplarily, the program monitor creates the first shared capability through the shared capability management module.

[0103] There are several possible implementations for the first sharing capability and the first shared message buffer:

[0104] A possible implementation method is: the program monitor has configured one or more shared message buffers and corresponding shared capabilities in the memory space. When the program monitor receives the first information sent by the first program running sandbox, it can select one from the configured shared message buffers as assigned to the first program running sandbox, and pass the corresponding shared capabilities to the first program running sandbox.

[0105] For example, the program monitor has allocated three shared message buffers with corresponding sizes of 10MB, 20MB and 30MB respectively. After receiving the first information, the program monitor determines that the size of the shared message buffer required by the first program monitor is 15MB based on the first information. Then the program monitor can pass the sharing capability pointing to the shared message buffer with a size of 20MB to the first program running sandbox.

[0106] A possible implementation method is: after receiving the first information, the program monitor can allocate memory space according to the first information to construct a shared message buffer, construct a sharing capability pointing to the shared message buffer, and then pass the sharing capability to the first program execution sandbox.

[0107] The size of the shared message buffer constructed by the program monitor may be fixed or determined according to the first information.

[0108] For example, after the program monitor receives the first message, if the first message does not indicate the size of the shared message buffer required by the first program running sandbox, the shared buffer constructed by the program monitor may be of a fixed size.

[0109] For another example, after receiving the first message, the program monitor determines that the size of the shared message buffer required by the first program running sandbox is 10 MB based on the first message. Then the size of the shared buffer constructed by the program monitor needs to be no less than 10 MB.

[0110] S403: The first program sandbox saves the first sharing capability into the memory according to the type of the first sharing capability, and writes the first storage address into the first data structure.

[0111] Specifically, after the first program running sandbox receives the first sharing capability transmitted by the program monitor, it determines that the type of the first sharing capability is a shared type, saves the first sharing capability into the memory, and writes the first storage address into the first data structure. The first storage address is the storage address of the first sharing capability in the memory.

[0112] It should be noted that the type of the first data structure is not limited in the embodiments of the present application. For example, the first data structure can be a one-way linked list, a two-way linked list, a hash table, a queue, a tree, etc.

[0113] S404: The first program execution sandbox writes data into the first shared message buffer through the first sharing capability.

[0114] After the first program running sandbox receives the first shared capability, since the first shared capability points to the first shared message buffer, the first program running sandbox can write data into the first shared message buffer through the first shared capability. The data is the data to be sent by the first program running sandbox.

[0115] It should be noted that the execution order of S403 and S404 is not limited in the embodiment of the present application. The first program running sandbox can execute S403 first and then execute S404, or can execute S404 first and then execute S403, or can execute S403 and S404 at the same time.

[0116] S405: The first program execution sandbox sends second information to the program monitor.

[0117] Correspondingly, the program monitor receives the second information sent by the first program execution sandbox. After receiving the second information, the program monitor can determine that the first program execution sandbox has written the data into the first shared message buffer.

[0118] In different embodiments of the present application, the content of the second information may be different.

[0119] Optionally, in some embodiments of the present application, the first information is used to request a shared message buffer, and the second information is used to request communication with a second program execution sandbox.

[0120] Optionally, in some embodiments of the present application, the first information is used to request communication with the second program execution sandbox, and the second information is used to indicate that the first program execution sandbox has written data into the first shared message buffer.

[0121] In general, after receiving the second information sent by the first program execution sandbox, the program monitor can determine that the first program execution sandbox has written the data into the first shared message buffer.

[0122] S406: The program monitor reclaims or encapsulates the first shared capability according to the second information and the first storage address stored in the first data structure.

[0123] Specifically, one or more storage addresses may be stored in the first data structure, and the one or more storage addresses include the first storage address. After receiving the second information, the program monitor may find one or more shared capabilities stored in the memory based on the one or more storage addresses stored in the first data structure, and then the program monitor may recycle or encapsulate the one or more shared capabilities, and the one or more shared capabilities include the first shared capability.

[0124] It is understandable that after the program monitor reclaims or encapsulates the first shared capability, the following possibilities may occur.

[0125] One possibility is that the first program execution sandbox cannot read data in the first shared message buffer, nor can it write data to the first shared message buffer.

[0126] One possibility is that the first program running sandbox cannot write data to the first shared message buffer, but can read data from the first shared message buffer.

[0127] One possibility is that the first program running sandbox and other program running sandboxes have mutually exclusive access, that is, when the first program running sandbox writes data to the first shared message buffer, other program running sandboxes cannot write data to the first shared message buffer; when other program running sandboxes write data to the first shared message buffer, the first program running sandbox cannot write data to the first shared message buffer.

[0128] Optionally, in some embodiments, the program monitor may also retrieve whether the program register corresponding to the first program execution sandbox stores the first shared capability or the capability derived based on the first shared capability. If so, the program monitor may also recycle or encapsulate the first shared capability and the capability derived based on the first shared capability in the program register corresponding to the first program execution sandbox.

[0129] S407: The program monitor transmits the first sharing capability to the second program execution sandbox.

[0130] Correspondingly, the second program execution sandbox receives the first shared capability transmitted by the program monitor. After receiving the first shared capability, the second program execution sandbox can access the data stored in the first shared message buffer through the first shared capability, thereby enabling communication between the first program execution sandbox and the second program execution sandbox.

[0131] Optionally, in some embodiments, since communication with the second program execution sandbox is indicated in the first information or the second information, the program monitor may transfer the first shared capability to the second program execution sandbox after reclaiming or encapsulating the first shared capability.

[0132] Optionally, in some embodiments, the first information or the second information does not indicate communication with the second program execution sandbox, and before S407, the method 400 further includes:

[0133] S408: The second program execution sandbox sends third information to the program monitor.

[0134] Correspondingly, the program monitor receives third information sent by the second program execution sandbox, where the third information is used to indicate communication with the first program execution sandbox. Then, in step S407, the program monitor transmits the first sharing capability to the second program execution sandbox, including:

[0135] The program monitor transmits the first sharing capability to the second program execution sandbox according to the third information.

[0136] Specifically, after receiving the third information, the program monitor can determine that the object of communication of the second program running sandbox is the first program running sandbox, and the data stored in the first program running sandbox is located in the first shared message buffer. After recovering or encapsulating the first shared capability of the first program running sandbox, the program monitor can pass the first shared capability to the second program running sandbox, so that the second program running sandbox can obtain the data stored in the first shared message buffer through the first shared capability, thereby realizing communication between the first program running sandbox and the second program running sandbox.

[0137] In an embodiment of the present application, a program monitor can allocate a first shared message buffer for a first program execution sandbox and a second program execution sandbox in communication, and first pass a first shared capability pointing to the shared message buffer to the first program execution sandbox. The first program execution sandbox can store the first shared capability in memory and store the storage address in a corresponding data structure. After the first program execution sandbox writes data, the program monitor recovers or encapsulates the first shared capability of the first program execution sandbox, and then passes the first shared capability to the second program execution sandbox, thereby achieving mutually exclusive access to the first shared message buffer by the first program execution sandbox and the second program execution sandbox, thereby achieving secure, zero-copy communication. Because the storage address of the first shared capability in memory is stored in a specific data structure, the program monitor does not need to scan the entire memory when recovering or encapsulating the first shared capability. It only needs to find and recover or encapsulate the first shared capability based on the storage address stored in the data structure, which can increase the speed of capability recovery and thus improve communication efficiency.

[0138] FIG5 shows a schematic flow chart of another inter-program communication method provided by an embodiment of the present application, wherein the method is applied to a computer device, the computer device including a first program execution sandbox, a second program execution sandbox, and a program monitor.

[0139] S501: A first program execution sandbox sends first information to a program monitor.

[0140] S502: The program monitor transmits a first sharing capability to the first program execution sandbox.

[0141] It should be understood that for the description of S501 and S502 , reference can be made to the above description of S401 and S402 , which will not be repeated here for the sake of brevity.

[0142] S503: The first program sandbox saves the first sharing capability into a memory according to the type of the first sharing capability, and writes the first storage address into a first log.

[0143] Specifically, after receiving the first shared capability transmitted by the program monitor, the first program execution sandbox determines that the type of the first shared capability is a shared type and can save the first shared capability to memory and write a first storage address to a first log. The first storage address is the storage address of the first shared capability in memory. Unlike S303, in S503, after storing the first shared capability in memory, the first program execution sandbox can directly write the storage address of the first shared capability in memory to the data structure corresponding to the shared capability. In S503, after storing the first shared capability in memory, the first program execution sandbox can first write the storage address of the first shared capability in memory to the first log, and then the program monitor can write the storage address stored in the first log to the data structure corresponding to the shared capability. Compared to S503, since there are multiple program execution sandboxes in the computer device, the program monitor uniformly writes the storage address of the shared capability to the data structure, which can reduce the number of data writes to the data structure and save performance overhead.

[0144] S504: The first program execution sandbox writes data into the first shared message buffer through the first sharing capability.

[0145] S505: The first program execution sandbox sends second information to the program monitor.

[0146] It should be understood that for the description of S504 and S505 , reference can be made to the description of S404 and S405 above, which will not be repeated here for the sake of brevity.

[0147] S506: The program monitor writes the first storage address stored in the first log into the first data structure according to the second information.

[0148] Specifically, the first log may store one or more storage addresses, including the first storage address. After receiving the second information, the program monitor may write the one or more storage addresses stored in the first log into the first data structure. The first data structure may be a singly linked list, a doubly linked list, a hash table, a queue, a tree, or the like.

[0149] S507: The program monitor reclaims or encapsulates the first shared capability according to the first storage address stored in the first data structure.

[0150] Specifically, after writing the first storage address stored in the first log into the first data structure, the program monitor may reclaim or encapsulate the first sharing capability corresponding to the first storage address stored in the first data structure.

[0151] S508: The program monitor transmits the first sharing capability to the second program execution sandbox.

[0152] Optionally, in some embodiments, since communication with the second program execution sandbox is indicated in the first information or the second information, the program monitor may transfer the first shared capability to the second program execution sandbox after reclaiming or encapsulating the first shared capability.

[0153] Optionally, in some embodiments, the first information or the second information does not indicate communication with the second program execution sandbox, and before S508, the method 500 further includes:

[0154] S509: The second program execution sandbox sends third information to the program monitor.

[0155] Correspondingly, the program monitor receives third information sent by the second program execution sandbox, where the third information is used to indicate communication with the first program execution sandbox. Then, in S508, the program monitor transmits the first sharing capability to the second program execution sandbox, including:

[0156] The program monitor transmits the first sharing capability to the second program execution sandbox according to the third information.

[0157] Specifically, after receiving the third information, the program monitor can determine that the object of communication of the second program running sandbox is the first program running sandbox, and the data stored in the first program running sandbox is located in the first shared message buffer. After recovering or encapsulating the first shared capability of the first program running sandbox, the program monitor can pass the first shared capability to the second program running sandbox, so that the second program running sandbox can obtain the data stored in the first shared message buffer through the first shared capability, thereby realizing communication between the first program running sandbox and the second program running sandbox.

[0158] In an embodiment of the present application, a program monitor can allocate a first shared message buffer for a first program execution sandbox and a second program execution sandbox in communication, and first pass a first shared capability pointing to the shared message buffer to the first program execution sandbox. The first program execution sandbox can store the first shared capability in memory and store the storage address in a log. After the first program execution sandbox writes data, the program monitor writes the first storage address in the log to a first data structure, and recovers or encapsulates the first shared capability of the first program execution sandbox based on the first data structure. The program monitor then passes the first shared capability to the second program execution sandbox, thereby enabling mutually exclusive access to the first shared message buffer by the first and second program execution sandboxes, thereby achieving secure, zero-copy communication. Because the storage address of the first shared capability in memory is stored in a specific data structure, the program monitor does not need to scan the entire memory when recovering or encapsulating the first shared capability. Instead, it can find and recover or encapsulate the first shared capability based on the storage address stored in the data structure, which can increase the speed of capability recovery and thus improve communication efficiency.

[0159] In the introduction method 500 , the storage address of the log storage sharing capability in the memory is introduced, and the register used to describe the log will be introduced below.

[0160] 1. Log base address register, which is used to indicate the starting physical address of the log in memory.

[0161] 2. Log length register, which is used to indicate the length of the continuous physical memory interval corresponding to the log.

[0162] It can be understood that the final physical address of the log in the memory can be determined by the values ​​of the log base register and the log length register.

[0163] 3. Log index register, which is used to indicate the index of the next storage address to be written in the log.

[0164] 4. Log end address register: This register is used to indicate the end address of the log in the memory.

[0165] 5. Log address register, which is used to indicate the physical address of the next storage address to be stored in the log.

[0166] It should be noted that the computer device in the embodiments of the present application may include all or part of the above-mentioned registers. For example, the computer device may include a log base register, a log length register, and a log index register. For another example, the computer device may include a log base register and a log index register, and set the number of entries in the log to a fixed value. The number of entries in the log is the storage address of the shared capacity that the log can store. For another example, the computer device may include a log base register, a log final register, and a log index register. For another example, the computer device may include a log base register, a log length calculator, and a log address register.

[0167] FIG6 shows a schematic diagram of a program execution sandbox according to an embodiment of the present application writing a storage address into a log.

[0168] As shown in (a) and (b) in Figure 6, the first program running sandbox determines the starting physical address of the log in the memory according to the log base address register. Since there is no storage address stored in the log at this time, the value of the log index register is 0. The first program running sandbox can write the first storage address with the starting physical address as the boundary and set the value of the log index register to 1.

[0169] Optionally, in some embodiments, since the log length register has stored the length of the continuous physical memory interval corresponding to the log, the number of storage addresses stored in the log is limited. Therefore, when the program running sandbox writes the storage address of the shared capability into the log, it can first detect whether the log is full. If the log is not full, the storage address of the shared capability can be written into the log. If the log is full, continuing to write the storage address of the shared capability into the log will cause a log exception, that is, a physical memory overflow. In order to avoid the occurrence of log exceptions, an embodiment of the present application provides a method for handling log exceptions, which will be introduced below in conjunction with Figure 7.

[0170] FIG7 shows a schematic flowchart of processing log exceptions provided in an embodiment of the present application. As shown in FIG7 , the method includes:

[0171] S701: The program runs in a sandbox to determine a first storage address of a first sharing capability.

[0172] After the program execution sandbox stores the first shared capability in the memory, a first storage address of the first shared capability in the memory may be determined.

[0173] S702: The program runs in the sandbox to determine whether the first log is full.

[0174] After the program running sandbox stores the first shared capability in the memory, it is necessary to write the first storage address of the first shared capability in the memory into the first log. Before the program running sandbox writes the first storage address into the first log, it is necessary to determine whether the first log is full. When it is determined that the first log is not full, S703 can be executed. When the first log is full, S704 can be executed.

[0175] The program running in the sandbox can detect whether the first log is full in the following possible implementations:

[0176] In one possible implementation, the computer device includes a log index register and a log length register. The program execution sandbox can determine the number of storage addresses that can be stored in the first log through the value of the log length register and the length of the storage address, and can determine the number of storage addresses that have been written to the first log through the value of the log index register. Therefore, when the value of the log index register is less than the number of storage addresses that can be stored in the first log, the first log is not full.

[0177] For example, if the length of a shared storage address is 8 bytes and the log length register is 64 bytes, the first log can store 8 storage addresses. The initial value of the log index register is 0, meaning the index of the first storage address stored in the first log is 0. After the first storage log entry is written, the value of the log index register increases by 1 to 1. When the log index register is 7, the index of the next storage address in the first log is 7, meaning the first log already has 7 storage addresses stored and can still store the next storage address. The process then proceeds to S703. When the log index register is 8, the index of the next storage address in the first log is 8, meaning the first log is full and cannot store the next storage address. The process then proceeds to S704. In other words, if the log index register value is less than the number of storage addresses that can be stored in the first log, S703 is performed; if the log index register value is greater than or equal to the number of storage addresses that can be stored in the first log, S704 is performed.

[0178] In one possible implementation, a computer device includes a log base register, a log final register, and a log index register. The program execution sandbox can determine the length of the first log in the continuous physical memory space based on the values ​​of the log base register and the log final register, and thus determine the number of storage addresses that can be stored in the first log. When the value of the log index register is less than the number of storage addresses that can be stored in the first log, S703 is performed. When the value of the log index register is greater than or equal to the number of storage addresses that can be stored in the first log, S704 is performed.

[0179] In one possible implementation, a computer device includes a log address indexer, a log base address register, and a log length register. A program execution sandbox can determine the final physical address of the first log in memory based on the values ​​of the log base address register and the log length register. The log address register is used to store the physical address of the next storage address to be written. If the physical address of the next storage address to be written does not exceed the final address of the first log in memory, it indicates that the first log is not full, and the process proceeds to S703. If the physical address of the next storage address to be written exceeds the final address of the first log in memory, it indicates that the first log is full, and the process proceeds to S704.

[0180] In one possible implementation, a computer device includes a log address indexer and a log end address register. A program execution sandbox can determine the end physical address of the first log in memory based on the value of the log end address register. The log address register is used to store the physical address of the next storage address to be written. If the physical address of the next storage address to be written does not exceed the end address of the first log in memory, it indicates that the first log is not full, and the process proceeds to S703. If the physical address of the next storage address to be stored exceeds the end address of the first log in memory, it indicates that the first log is full, and the process proceeds to S704.

[0181] In one possible implementation, the computer includes a log index register, and the number of storage addresses that can be stored in the first log is a fixed value, so that when the value of the log index register is less than the fixed value, S703 is performed, and when the value of the log index register is greater than or equal to the fixed value, S704 is performed.

[0182] S703: The program running sandbox writes the first storage address into the first log.

[0183] When the program running sandbox determines that the first log is not full, the first storage address can be written into the first log, wherein the physical memory address storing the first storage address can be determined by formula (1). addr=addr0+n*L (1)

[0184] Wherein, addr is the physical memory address storing the first storage address, addr0 is the starting physical address of the first log, n is the index of the first storage address in the first log, and L is the length of the first storage address.

[0185] S704, the program running sandbox sets the log index value to 0.

[0186] Because before performing S704, the log index value is the index value corresponding to the first storage address, in order to start scanning from the base address of the first log, the program running sandbox can set the log index value to 0, that is, when the log index value is 0, the corresponding storage address is the first storage address of the first log storage.

[0187] S705 , the program running sandbox determines whether the log index value is less than the value of the log index register.

[0188] The program running sandbox determines whether the log index value is less than the value of the log index register. If the log index value is less than the value of the log index register, proceed to S706; if the log index value is greater than the value of the log index register, proceed to S710.

[0189] S706 , the program running sandbox reads the storage address corresponding to the corresponding log index value, loads the sharing capability corresponding to the storage address according to the storage address, and increases the log index value by 1.

[0190] Optionally, in some embodiments, before performing S707 , the program execution sandbox is further used to determine whether the sharing capability is legal. If it is legal, the process proceeds to S707 ; if it is not legal, the process jumps to S705 .

[0191] S707: The program runs in the sandbox to determine the data structure corresponding to the sharing capability.

[0192] After the program runs the sandbox and loads the shared capability, the data structure corresponding to the shared capability can be determined.

[0193] The program running sandbox can determine the data structure corresponding to the sharing capability in the following ways.

[0194] A possible implementation manner is: the program running sandbox determines the data structure corresponding to the shared capability according to the identifier field of the shared capability.

[0195] When a program monitor creates a shared capability, the shared capability may include an identifier field. Simultaneously, the program monitor may establish a correspondence between the shared capability identifier field and a data structure. For example, a first shared capability identifier corresponds to a first data structure, and a second capability identifier corresponds to a second data structure. Thus, the program execution sandbox can determine the data structure corresponding to the shared capability based on the identifier field.

[0196] In a possible implementation, the program runs a sandbox that traverses the shared capability table to determine a data structure corresponding to the shared capability.

[0197] The program monitor can establish a sharing capability table that indicates the correspondence between sharing capabilities and data structures, for example, a first sharing capability corresponds to a first data structure, and a second sharing capability corresponds to a second data structure. Therefore, after the program execution sandbox determines the sharing capability, it can traverse the sharing capability table to determine the data structure corresponding to the sharing capability.

[0198] S708: The program running sandbox determines whether the first storage address is stored in the data structure.

[0199] After the program runs the sandbox and determines the data structure, it can traverse the data structure to determine whether the first storage address is stored in the data structure. If so, it proceeds to S709; if not, it jumps to S705 to execute the next loop.

[0200] S709: The program running sandbox writes the first storage address into the data structure.

[0201] S710 , the program running sandbox sets the value of the log index register to 0.

[0202] When the log index value is greater than the value of the log index register, it indicates that all storage addresses stored in the first log have been scanned, and the value of the log index register can be set to 0 to end the exception handling process.

[0203] Optionally, in some embodiments, the program running sandbox sets the value of the log index register to 0, and thus clears the storage address stored in the first log.

[0204] It should be noted that the above method for handling the first log exception is only an example, but is not limited to this. For example, in the above method 700, when the first log is full, the program execution sandbox starts from the base address of the first log to scan each storage address in the first log, and loads the sharing capability corresponding to each storage address, and then determines the data structure of each sharing capability, and then determines whether the first storage address is stored in each data structure. If a data structure does not store the first storage address, the first storage address is written to the data structure. If a data structure stores the first storage address, no processing is performed. In other embodiments of the present application, the program execution sandbox can also start from the end address of the first log to scan each storage address in the first log, and load the sharing capability corresponding to each storage address, and then determine the data structure of each sharing capability, and then determine whether the first storage address is stored in each data structure. If a data structure does not store the first storage address, the first storage address is written to the data structure. If a data structure stores the first storage address, no processing is performed.

[0205] In the above, the inter-program communication method provided in the embodiment of the present application is introduced from the perspective of each functional module in the computer device. Below, the inter-program communication method provided in the embodiment of the present application will be introduced from the perspective of the computer device.

[0206] FIG8 shows a schematic flow chart of an inter-program communication method 800 provided in an embodiment of the present application. The method 800 is applied to a computer device, which includes a first program execution sandbox, a second program execution sandbox, and a program monitor. As shown in FIG8 , the method 800 includes:

[0207] S801, a computer device allocates a first sharing capability to a first program execution sandbox so that the first program execution sandbox writes data to a first shared message buffer through the first sharing capability, wherein the first sharing capability points to the first shared message buffer and is created by a program monitor.

[0208] Specifically, the computer device may allocate a first shared capability to the first program execution sandbox through the program monitor. That is, the program monitor transfers the first shared capability to the first program execution sandbox. After the first program execution sandbox is allocated the first shared capability, the first program execution sandbox may use the first shared capability to write data to the first shared message buffer pointed to by the first shared capability. The first shared capability is created by the computer device through the program monitor.

[0209] Optionally, in some embodiments, the first shared message buffer is pre-configured.

[0210] Optionally, in some embodiments, the first shared message buffer is created by the program monitor when receiving the first information sent by the first program execution sandbox.

[0211] S802: The computer device saves the first sharing capability into a memory according to the type of the first sharing capability, and writes a first storage address into a first data structure. The first storage address is the storage address of the first sharing capability in the memory.

[0212] Specifically, after the computer device assigns the first shared capability to the first program execution sandbox, it can save the first shared capability to the memory through the first program execution sandbox, and write the first storage address of the first shared capability in the memory into the first data structure through the first program execution sandbox or the program monitor.

[0213] Optionally, in some embodiments, the first sharing capability includes a type field, and the computer device determines that the type of the first sharing capability is a sharing type through the type field.

[0214] Optionally, in some embodiments, the first sharing capability includes an identifier field, and the computer device determines that the type of the first sharing capability is a sharing type through the identifier field.

[0215] Optionally, in some embodiments, the first sharing capability includes a reserved identification bit, and when the value of the reserved identification bit is a first value, the computer device determines that the type of the first sharing capability is a sharing type.

[0216] Optionally, in some embodiments, the computer device may directly write the first storage address into the first data structure through the first program execution sandbox.

[0217] Optionally, in some embodiments, the computer device may first write the first storage address into the first log through the first program execution sandbox. When the first program execution sandbox sends the second information to the program monitor, that is, when the first program execution sandbox sends a communication request to the program monitor, the computer device then writes the first storage address stored in the first log into the first data structure through the program monitor.

[0218] S803: The computer device recovers or encapsulates the sharing capability set corresponding to the storage address stored in the first data structure, where the sharing capability set includes the first sharing capability.

[0219] Specifically, after the computer device saves the first shared capability to the memory and writes the first storage address to the first data structure, it can determine the shared capability corresponding to each storage address based on the storage address stored in the first data structure, i.e., determine a shared capability set, which includes the first shared capability, and then recycle or encapsulate the shared capability set. Because the computer device recycles and encapsulates the first shared capability, the first program execution sandbox can no longer write data to the first shared message buffer.

[0220] S804: The computer device allocates a first sharing capability to the program execution sandbox so that the second program execution sandbox reads data in the first shared message buffer through the first sharing capability.

[0221] Specifically, after the computer reclaims or encapsulates the first shared capability, it can allocate the first shared capability to the second program running sandbox, so that the second program running sandbox can read the data in the first shared message buffer through the first shared capability, and only the second program running sandbox is allocated the first shared capability, thereby ensuring the security of communication.

[0222] Optionally, in some implementations, after determining that the second program execution sandbox sends the third information to the program monitor, the computer device allocates the first shared capability to the second program execution sandbox.

[0223] In an embodiment of the present application, a computer device can allocate a first shared message buffer for a first program running sandbox and a second program running sandbox in communication, and first pass a first shared capability pointing to the shared message buffer to the first program running sandbox. The computer device can store the first shared capability in memory and store the storage address in a corresponding data structure. After the first program running sandbox writes data, the computer device recovers or encapsulates the first shared capability of the first program running sandbox, and then passes the first shared capability to the second program running sandbox, thereby achieving mutually exclusive access to the first shared message buffer by the first program running sandbox and the second program running sandbox, thereby achieving a secure, zero-copy communication purpose. Since the storage address of the first shared capability in memory is stored in a specific data structure, the program monitor does not need to scan the entire memory during the process of recovering or encapsulating the first shared capability. It only needs to find and recover or encapsulate the first shared capability based on the storage address stored in the data structure, which can increase the speed of recovering the capability and thus improve communication efficiency.

[0224] FIG9 shows another schematic flow chart of the inter-program communication method provided in an embodiment of the present application. As shown in FIG9 , S803 includes:

[0225] S8031: The computer device saves the first sharing capability into a memory according to the type of the first sharing capability.

[0226] S8032: The computer writes the first storage address into the first log.

[0227] S8033: When the first program execution sandbox initiates a communication request, the computer device writes the storage address set stored in the first log into the first data structure, where the storage address set includes the first storage address.

[0228] As described above, the computer device can first save the first sharing capability to the memory according to the type of the first sharing capability, write the first storage address to the first log, and when the first program running sandbox sends a communication request, write the stored storage address set in the first log to the first data structure.

[0229] Optionally, in some embodiments, before S8032, the method further includes:

[0230] S805: The computer device determines whether the first log is full.

[0231] Specifically, in order to prevent memory overwriting and memory overflow, the computer device needs to determine whether the first log is full before writing the first storage address into the first log.

[0232] S8032: The computer writes the first storage address into the first log, including:

[0233] When the computer device determines that the first log is not full, the computer device writes the first storage address into the first log.

[0234] Optionally, the computer device may detect whether the first log is full by the following possible implementation methods:

[0235] In one possible implementation, a computer device includes a first log length register and a first log index register, wherein the value of the first log length register is used to indicate the length of the first log in the memory, and the value of the first log index register is used to indicate the index of the storage address of the next entry to be written into the first log. The computer device determines whether the first log is full, including:

[0236] The computer device determines the number of storage addresses that can be stored in the first log according to the value of the first log length register and the length of the storage address;

[0237] The computer device determines whether the first log is full based on the value of the first log index register and the number of storage addresses that can be stored in the first log;

[0238] When the computer device determines that the first log is not full, writing the first storage address into the first log includes:

[0239] When the computer device determines that the value of the first log index register is less than the number of storage addresses that can be stored in the first log, the computer device writes the first storage address into the first log.

[0240] A possible implementation manner: A computer device includes a first log base address register, a first log end address register, and a first log index register. The value of the first log base address register is used to indicate a starting address of the first log in the memory. The value of the first log end address register is used to indicate an ending address of the first log in the memory. The value of the first log index register is used to indicate an index of a storage address of a next entry to be written into the first log. The computer device determines whether the first log is full, including:

[0241] The computer device determines the length of the first log in the memory according to the value of the first log base address register and the value of the first log final address register;

[0242] The computer device determines the number of storage addresses that can store the first log according to the length of the first log in the memory and the length of the storage address;

[0243] The computer device determines whether the first log is full based on the value of the first log index register and the number of storage addresses that can be stored in the first log;

[0244] When the computer device determines that the first log is not full, writing the first storage address into the first log includes:

[0245] When the computer device determines that the value of the first log index register is less than the number of storage addresses that can be stored in the first log, the computer device writes the first storage address into the first log.

[0246] A possible implementation manner: A computer device includes a first log base address register, a first log end address register, and a first log address register. The value of the first log base address register is used to indicate a starting address of the first log in the memory. The value of the first log end address register is used to indicate an ending address of the first log in the memory. The value of the first log address register is used to indicate an address of a storage address of a next entry to be written into the first log. The computer device determines whether the first log is full, including:

[0247] The computer device determines the area of ​​the first log in the memory according to the value of the first log base address register and the value of the first log final address register;

[0248] The computer device determines, based on the value of the first log address register, whether the address of the storage address of the next entry to be written into the first log falls within the area of ​​the first log in the memory;

[0249] When the computer device determines that the first log is not full, writing the first storage address to the first log includes:

[0250] When the computer device determines that the address of the next storage address to be written into the first log falls within the area of ​​the first log in the memory, the computer device writes the first storage address into the first log.

[0251] It should be understood that a detailed description of how the computer device determines whether the first log is full through the register can be found in the description of FIG7 , which will not be repeated here for the sake of brevity.

[0252] Optionally, in some embodiments, when the computer device determines that the first log is not full, the computer device includes a first log index register, the value of the first log index register is used to indicate the index of a storage address to be written next to the first log, the first log has N storage addresses stored, N ≥ 1 and is an integer, and when the computer device determines that the first log is full, the method further includes:

[0253] The computer device loads N shared capabilities corresponding to the N storage addresses according to the N storage addresses;

[0254] The computer device determines M data structures according to N sharing capabilities, the N sharing capabilities are associated with the M data structures, N ≥ M ≥ 1 and M is an integer;

[0255] The computer device traverses the M data structures to detect whether each of the M data structures stores a first storage address;

[0256] If P data structures among the M data structures do not store the first storage address, the computer device writes the first storage address into the P data structures, where P≥0 and is an integer.

[0257] Specifically, when the computer device determines that the first log is full, that is, N storage addresses are stored in the first log, the computer device may load N shared capabilities corresponding to the N storage addresses, and then determine M data structures corresponding to the N shared capabilities based on the N shared capabilities. Since some of the N shared capabilities may be stored in the same data structure, N ≥ M ≥ 1, where M is an integer. The computer device may traverse each of the M data structures to determine whether the first storage address is stored. If P of the M data structures do not store the first storage address, the computer device may write the first storage address to the P data structures. In other words, the computer device may write the first storage address to a data structure among the M data structures that does not store the first storage address.

[0258] It should be understood that this application does not limit the method by which a computer loads the sharing capabilities of the N storage addresses in the first log. For example, the computer device may scan the N storage addresses from the base address of the first log in a forward-looking manner and load the sharing capabilities corresponding to the N storage addresses. For another example, the computer device may also scan the N storage addresses from the end address of the first log in a forward-looking manner and load the sharing capabilities corresponding to the N storage addresses.

[0259] Optionally, in some embodiments, after the computer device writes the first storage address into the P data structures, the method further includes:

[0260] Set the value of the first log index register to 0.

[0261] In the above, the program monitor is used to maintain the inter-program communication information channel. In some embodiments, the inter-program communication channel can be maintained by an inter-program communication module in the program monitor.

[0262] FIG10 shows a schematic structural diagram of the inter-program communication module provided in an embodiment of the present application.

[0263] As shown in FIG10 , the inter-program communication module includes a message descriptor table, a source-side circular queue, and a destination-side circular queue.

[0264] The message descriptor table includes one or more descriptors, each corresponding to a message. The inter-program communication module can use this message descriptor table to record information related to sharing capabilities, such as the data structure corresponding to the sharing capabilities. The inter-program communication module can also use this message descriptor to record messages sent by the source end to the destination end, or messages sent by the destination end to the source end.

[0265] The source ring queue stores messages sent from the source to the destination. Each entry in the ring queue corresponds to the index of a message descriptor in the message descriptor table. The source writes the message descriptor index corresponding to the message to be sent to the tail pointer of the source ring queue and increments the tail pointer by 1. The destination reads the message from the head of the source ring queue and increments the head pointer by 1.

[0266] The destination ring queue stores messages sent from the destination to the source. Each entry in the ring queue corresponds to the index of a message descriptor in the message descriptor table. The destination writes the message descriptor index corresponding to the message to be sent to the tail pointer of the destination ring queue and increments the tail pointer by 1. The source reads the message from the head of the destination ring queue and increments the head pointer by 1.

[0267] It should be noted that the structure of the inter-program communication module described above is for illustration only and should not be construed as a specific limitation on the inter-program communication module. Any inter-program communication module having a structure different from that shown in FIG10 and used to implement the inter-program communication method provided in the embodiments of the present application shall fall within the scope of protection of the present application.

[0268] The present application also provides a computer device comprising: a processor, a memory, and a computer program. The aforementioned components may be connected via one or more communication buses. The one or more computer programs are stored in the memory and configured to be executed by the one or more processors. The one or more computer programs include instructions that can be used to cause the computer device to perform the steps of the computer device described in the aforementioned embodiments.

[0269] An embodiment of the present application also provides a chip, which includes a processor and a communication interface, wherein the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the method of inter-program communication described in any possible implementation method described above is executed.

[0270] This embodiment also provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on an electronic device, the computer device executes the above-mentioned related method steps to implement the inter-program communication method in the above-mentioned embodiment.

[0271] This embodiment further provides a computer program product. When the computer program product is run on a computer, it enables the computer to execute the above-mentioned related steps to implement the method for inter-program communication in the above-mentioned embodiment.

[0272] As used in the above embodiments, the terms “when…” or “after…” may be interpreted to mean “if…” or “after…” or “in response to determining…” or “in response to detecting…”, depending on the context. Similarly, the phrases “upon determining…” or “if (stated condition or event) is detected” may be interpreted to mean “if determining…” or “in response to determining…” or “upon detecting (stated condition or event)” or “in response to detecting (stated condition or event)”, depending on the context.

[0273] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0274] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0275] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0276] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0277] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0278] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0279] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A method for communication between programs, the method being applied to a computer device, the computer device comprising a first program running sandbox, a second program running sandbox and a program monitor, characterized in that: The method comprises: The computer device allocates a first sharing capability to the first program execution sandbox so that the first program execution sandbox writes data to a first shared message buffer through the first sharing capability, the first sharing capability points to the first shared message buffer, and the first sharing capability is created by the program monitor; The computer device saves the first sharing capability into a memory according to the type of the first sharing capability, and writes a first storage address into a first data structure, where the first storage address is a storage address of the first sharing capability in the memory; The computer device recovers or encapsulates a sharing capability set corresponding to the storage address stored in the first data structure, the sharing capability set including the first sharing capability; The computer device allocates the first sharing capability to the second program execution sandbox so that the second program execution sandbox reads the data in the first shared message buffer through the first sharing capability.

2. The method according to claim 1, characterized in that The computer device saves the first sharing capability into a memory according to the type of the first sharing capability and writes a first storage address into a first data structure, including: The computer device saves the first sharing capability into the memory according to the type of the first sharing capability, and writes the first storage address into a first log; When the first program execution sandbox initiates a communication request, the computer device writes the storage address set stored in the first log into the first data structure, where the storage address set includes the first storage address.

3. The method according to claim 2, characterized in that Before the computer device writes the first storage address into the first log, the method further includes: The computer device determines whether the first log is full; The computer device writes the first storage address into the first log, including: When the computer device determines that the first log is not full, the computer device writes the first storage address into the first log.

4. The method according to claim 3, characterized in that The computer device includes a first log length register and a first log index register, wherein a value of the first log length register is used to indicate a length of the first log in the memory, and a value of the first log index register is used to indicate an index of a storage address of a next entry to be written into the first log, and the computer device determines whether the first log is full, including: The computer device determines the number of storage addresses that can store the first log according to the first log length register and the length of the storage address; The computer device determines whether the first log is full according to the value of the first log index register and the number of storage addresses that can be stored in the first log; When determining that the first log is not full, the computer device writes the first storage address into the first log, including: When the computer device determines that the value of the first log index register is less than the number of storage addresses that can be stored in the first log, the first storage address is written to the first log.

5. The method according to claim 3, characterized in that: The computer device comprises a first log base address register, a first log terminal address register, and a first log index register, wherein a value of the first log base address register is used to indicate a starting address of the first log in the memory, a value of the first log terminal address register is used to indicate an ending address of the first log in the memory, and a value of the first log index register is used to indicate an index of a storage address of a next entry to be written into the first log, and the computer device determines whether the first log is full, comprising: The computer device determines the length of the first log in the memory according to the value of the first log base address register and the value of the first log final address register; The computer device determines the number of storage addresses that can store the first log according to the length of the first log in the memory and the length of the storage address; The computer device determines whether the first log is full according to the value of the first log index register and the number of storage addresses that can be stored in the first log; When determining that the first log is not full, the computer device writes the first storage address into the first log, including: When the computer device determines that the value of the first log index register is less than the number of storage addresses that can be stored in the first log, the first storage address is written to the first log.

6. The method according to claim 3, characterized in that: The computer device comprises a first log base address register, a first log final address register and the first log address register, wherein the value of the first log base address register is used to indicate the starting address of the first log in the memory, the value of the first log final address register is used to indicate the ending address of the first log in the memory, and the value of the first log address register is used to indicate the address of the storage address of the next entry to be written into the first log, and the computer device determines whether the first log is full, comprising: The computer device determines the area of ​​the first log in the memory according to the value of the first log base address register and the value of the first log final address register; The computer device determines, according to the value of the first log address register, whether the address of the storage address of the next entry to be written into the first log falls within the area of ​​the first log in the memory; When the computer device determines that the first log is not full, writing the first storage address to the first log includes: When the computer device determines that the address of the next storage address to be written into the first log falls within the area of ​​the first log in the memory, the computer device writes the first storage address into the first log.

7. The method according to any one of claims 3 to 6, characterized in that The computer device includes a first log index register, the value of the first log index register is used to indicate the index of a storage address to be written to the first log next, the first log has N storage addresses stored, N ≥ 1 and is an integer, and when the computer device determines that the first log is full, the method further includes: The computer device loads N sharing capabilities corresponding to the N storage addresses according to the N storage addresses; The computer device determines M data structures according to the N sharing capabilities, the N sharing capabilities are associated with the M data structures, and M≥1 is an integer; The computer device traverses the M data structures to detect whether each of the M data structures stores the first storage address; If P data structures among the M data structures do not store the first storage address, the computer device writes the first storage address into the P data structures, where P≥0 and is an integer.

8. The method according to claim 7, characterized in that After the computer device writes the first storage address into the P data structures, the method further includes: The value of the first log index register is set to 0.

9. The method according to any one of claims 1 to 8, characterized in that The first sharing capability includes a type field, upper and lower boundary fields, and an access permission field, wherein the type field is used to indicate the type of the first sharing capability, the upper and lower boundary fields are used to indicate the upper and lower boundaries of the first shared message buffer, and the access permission field is used to indicate the permission to access the first shared message buffer.

10. The method according to claim 9, characterized in that The first sharing capability further includes an identifier field, where the identifier field is used to identify the first sharing capability.

11. A method for communication between programs, the method being applied to a computer device, the computer device comprising a first program running sandbox, a second program running sandbox and a program monitor, characterized in that: The method comprises: The first program execution sandbox sends first information to the program monitor; The program monitor transmits a first sharing capability to the first program execution sandbox according to the first information, wherein the first sharing capability points to a first shared message buffer; The first program running sandbox saves the first sharing capability into a memory according to the type of the first sharing capability, and writes a first storage address into a first log, where the first storage address is a storage address of the first sharing capability in the memory; The first program execution sandbox writes data into the first shared message buffer through the first sharing capability; The first program execution sandbox sends second information to the program monitor; The program monitor writes the storage address set stored in the first log into a first data structure according to the second information, the storage address set including the first storage address; The program monitor recycles or encapsulates a sharing capability set corresponding to the storage address stored in the first data structure, the sharing capability set including the first sharing capability; The program monitor transmits the first sharing capability to the second program execution sandbox so that the second execution sandbox reads the data in the first shared message buffer through the first sharing capability.

12. The method according to claim 11, characterized in that Before the first program execution sandbox writes the first storage address into the first log, the method further includes: The first program running sandbox determines whether the first log is full; The first program running sandbox writes the first storage address into the first log, including: When the first program execution sandbox determines that the first log is not full, the first storage address is written to the first log.

13. The method according to claim 12, characterized in that The computer device includes a first log length register and a first log index register, wherein the first log length register is used to indicate the length of the first log in the memory, and the first log index register is used to indicate the index of the storage address of the next entry to be written into the first log, and the first program running sandbox determines whether the first log is full, including: The first program execution sandbox determines the number of storage addresses that can store the first log according to the first log length register and the length of the storage address; The first program execution sandbox determines whether the first log is full according to the value of the first log index register and the number of storage addresses that can store the first log; When the first program execution sandbox determines that the first log is not full, writing the first storage address to the first log includes: When the first program execution sandbox determines that the value of the first log index register is less than the number of storage addresses that can be stored in the first log, the first storage address is written to the first log.

14. The method according to claim 12, characterized in that The computer device includes a first log base address register, a first log terminal address register, and a first log index register, wherein the first log base address register is used to indicate a starting address of the first log in the memory, the first log terminal address register is used to indicate an ending address of the first log in the memory, and the first log index register is used to indicate an index of a storage address of a next entry to be written into the first log, and the first program running sandbox determines whether the first log is full, including: The first program execution sandbox determines the length of the first log in the memory according to the first log base address register and the first log terminal address register; The first program running sandbox determines the number of storage addresses that can store the first log according to the length of the first log in the memory and the length of the storage address; determining whether the first log is full according to the value of the first log index register and the number of storage addresses that can store the first log; When the first program execution sandbox determines that the first log is not full, writing the first storage address to the first log includes: When the first program execution sandbox determines that the value of the first log index register is less than the number of storage addresses that can be stored in the first log, the first storage address is written to the first log.

15. The method according to claim 12, characterized in that The computer device comprises a first log base address register, a first log final address register and the first log address register, the first log base address register is used to indicate the starting address of the first log in the memory, the first log final address register is used to indicate the ending address of the first log in the memory, and the first log address register is used to indicate the address of the storage address of the next entry to be written into the first log; The first program running sandbox determines whether the first log is full, including: The first program execution sandbox determines the area of ​​the first log in the memory according to the first log base address register and the first log final address register; Determine whether the storage address of the next entry to be written into the first log falls within the area of ​​the first log in the memory; When the first program execution sandbox determines that the first log is not full, writing the first storage address to the first log includes: When the first program execution sandbox determines that the address of the next storage address to be written into the first log falls within the area of ​​the first log in the memory, the first storage address is written into the first log.

16. The method according to any one of claims 12 to 15, characterized in that The computer device includes a first log index register, the first log index register is used to indicate an index of a storage address to be written to the first log next, the first log has N storage addresses stored, and when the first program execution sandbox determines that the first log is full, the method further includes: The first program running sandbox loads N sharing capabilities corresponding to the N storage addresses according to the N storage addresses; The first program execution sandbox determines M data structures according to the N sharing capabilities, and the N sharing capabilities are associated with the M data structures; The first program runs the sandbox to traverse the M data structures to detect whether each of the M data structures exists storing the first storage address; If P data structures among the M data structures do not store the first storage address, the first program execution sandbox writes the first storage address into the P data structures.

17. The method according to any one of claims 11 to 16, characterized in that The first sharing capability includes a type field, upper and lower boundary fields, and an access permission field, wherein the type field is used to indicate the type of the first sharing capability, the upper and lower boundary fields are used to indicate the upper and lower boundaries of the first shared message buffer, and the access permission field is used to indicate the permission to access the first shared message buffer.

18. The method according to claim 17, characterized in that The first sharing capability further includes an identifier field, where the identifier field is used to identify the first sharing capability.

19. A method for communication between programs, the method being applied to a computer device, the computer device comprising a first program running sandbox, a second program running sandbox and a program monitor, characterized in that: The method comprises: The first program execution sandbox sends first information to the program monitor; The program monitor transmits a first sharing capability to the first program execution sandbox according to the first information, wherein the first sharing capability points to a first shared message buffer; The first program execution sandbox saves the first sharing capability into a memory according to the type of the first sharing capability, and writes the first storage address into a first data structure, where the first storage address is a storage address of the first sharing capability in the memory; The first program execution sandbox writes data into the first shared message buffer through the first sharing capability; The first program execution sandbox sends second information to the program monitor; The program monitor reclaims or encapsulates the first sharing capability according to the second information and the first storage address stored in the first data structure; The program monitor transmits the first sharing capability to the second program execution sandbox so that the second execution sandbox reads the data in the first shared message buffer through the first sharing capability.

20. The method according to claim 19, characterized in that Before the program monitor transmits the first sharing capability to the second program execution sandbox, the method further includes: The second program execution sandbox sends third information to the program monitor, where the third information is used to indicate communication with the first program execution sandbox.

21. The method according to claim 19 or 20, characterized in that The first sharing capability includes a type field, upper and lower boundary fields, and an access permission field, wherein the type field is used to indicate the type of the first sharing capability, the upper and lower boundary fields are used to indicate the upper and lower boundaries of the first shared message buffer, and the access permission field is used to indicate the permission to access the first shared message buffer.

22. The method according to claim 21, characterized in that The first sharing capability further includes an identifier field, where the identifier field is used to identify the first sharing capability.

23. A computer device, characterized in that: The method comprises one or more processors; one or more memories; the one or more memories store one or more computer programs, the one or more computer programs include instructions, and when the instructions are executed by the one or more processors, the method according to any one of claims 1 to 10, the method according to any one of claims 11 to 18, or the method according to any one of claims 19 to 22 is executed.

24. A chip, characterized in that: The chip includes a processor and a communication interface, wherein the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the method as described in any one of claims 1 to 10, the method as described in any one of claims 11 to 18, or the method as described in any one of claims 19 to 22 is executed.

25. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on a computer device, the method according to any one of claims 1 to 10, the method according to any one of claims 11 to 18, or the method according to any one of claims 19 to 22 is executed.

Citation Information

Patent Citations

  • Method for communication between courses, storage medium and computer equipment

    CN107229530A

  • Method and system for inter-process communication

    CN113939805A

  • Execution method of memory read-write instruction and computing device

    CN115080223A

  • Data processing system and cache control method

    US20100088472A1

  • Data processing device, chain and method, and corresponding computer program

    US20130111079A1