WO2012171438A1 - 一种传递共享内存的方法和装置 - Google Patents

一种传递共享内存的方法和装置 Download PDF

Info

Publication number
WO2012171438A1
WO2012171438A1 PCT/CN2012/076531 CN2012076531W WO2012171438A1 WO 2012171438 A1 WO2012171438 A1 WO 2012171438A1 CN 2012076531 W CN2012076531 W CN 2012076531W WO 2012171438 A1 WO2012171438 A1 WO 2012171438A1
Authority
WO
WIPO (PCT)
Prior art keywords
shared memory
function
memory
keyword
callee
Prior art date
Application number
PCT/CN2012/076531
Other languages
English (en)
French (fr)
Inventor
闵卫
Original Assignee
天津书生投资有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 天津书生投资有限公司 filed Critical 天津书生投资有限公司
Publication of WO2012171438A1 publication Critical patent/WO2012171438A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes

Definitions

  • the present invention relates to data exchange technologies, and in particular, to a method and apparatus for transferring shared memory. Background technique
  • the local memory transfer method is usually limited to the inside of a process because the operating system provides the same virtual memory space for each process running in it, and the mapping between virtual memory and physical memory. Fully controlled by the operating system, the application process can only pass
  • the shared memory is not divided from the memory of a certain process, but a memory area that can be shared by multiple processes in the physical memory of the system, because the memory of each process is always private, establishing a share.
  • the purpose of memory is to have every process that accesses it connect to it. This connection process is called mapping.
  • mapping When the system establishes shared memory, the shared memory is allocated the local memory address of each process, and the local memory address of each process can be connected to the corresponding shared memory.
  • the shared memory is mapped to the respective local memory space of each process, thereby realizing the shared memory-based data exchange between multiple processes.
  • FIG. 1 is a schematic diagram of transferring shared memory in the prior art, as shown in FIG. 1: Two processes (process A and process B) are running in the same system, and process A expects to implement process B by accessing shared memory. Invocation of information, in this case, process A can be called a caller process, and process B can be called a callee process. Specifically, the method of process A calling process B is as follows: Step 1: Process A applies for a shared memory;
  • Step 2 The system creates a shared memory keyword (0X00) based on the application of process A. Shared memory (0X00), and tell the process and process in a certain way;
  • the system can inform the process and process B of the shared memory key by:
  • the system can also specify the same public header file in the command line parameter of the compiler.
  • the public header file contains the shared memory keyword (0X00), and simultaneously informs process A and process B, but the keyword has been associated with one.
  • any attempt to create a shared memory of the same name will fail. At this point, the system must handle this failure, delete the existing shared memory, and then try to create again, making the process more complicated and may require more Second attempt
  • process A and process B stipulate a path name and project ID (a character value between 0 and 255), and process A calls the fork function to convert the two values into a keyword. Create shared memory based on this keyword; however, this method can only be applied to UNIX-like operating systems, and only the path and project ID of the system are known;
  • Step 3 Process A connects shared memory (0X00) (ie Map) to its own local memory address (ie, process A's local memory address 0X003D2C8); process B puts shared memory (0X00) to implement data exchange based on shared memory (0X00) between process A and process B.
  • the embodiments of the present invention provide a method and device for transferring shared memory, which can realize the unification of two types of data exchange modes: inter-process shared memory and in-process local memory, and improve synchronization of shared memory data exchange between processes. .
  • the embodiment of the present invention adopts the following technical solutions.
  • a method of transferring shared memory including:
  • the calling function creates a shared memory with the local memory address of the caller process as a keyword and constructs a function call statement with the shared memory keyword as a parameter;
  • the function call statement is sent to the callee process for the callee process to resolve the function call statement to obtain shared memory.
  • the embodiment of the present invention further provides an apparatus for implementing a method for transferring shared memory, which is applied to a caller process side, and includes: a first module, configured to call a function to create a shared memory by using a local memory address of a caller process as a keyword, and
  • the shared memory keyword is a parameter construction function call statement;
  • the second module is configured to send the function call statement to the callee process for the callee process to parse the function call statement to obtain the shared memory.
  • the embodiment of the present invention further provides an apparatus for implementing a method for transferring shared memory, which is applied to a process side of a callee, and includes: a first module, configured to receive a function call statement from a caller process, where the function call statement
  • the construction method is as follows: the calling function creates a shared memory with the local memory address of the caller process as a keyword and constructs the shared memory keyword as a parameter;
  • the second module is used to parse the function call statement to obtain shared memory.
  • the embodiment of the present invention directly creates a shared memory by using a local memory address as a shared memory keyword by calling a function, thereby maintaining the consistency between the shared memory keyword and the local memory address, so that the created shared memory can directly interact with the caller process.
  • the local memory connection, the caller process does not need to map the shared memory to the local memory according to the shared memory keyword and the shared memory, so that the caller process is transparent between the local memory and the shared memory, and the local memory data content can be directly copied to Shared memory;
  • the embodiment of the present invention constructs a function call statement by calling a shared memory keyword as a parameter, and sends the function call statement to the callee process for acquiring shared memory, so that the callee process local memory access and shared memory The access is unified at the function interface level. Therefore, the technical solution provided by the embodiment of the present invention can ensure the unification of the data transfer mode between the processes and the data transfer mode of the local memory in the process, and the process of data exchange is improved. Synchronization of data exchange. DRAWINGS
  • FIG. 1 is a schematic diagram of transferring shared memory in the prior art
  • FIG. 2 is a flowchart of a method for transferring shared memory in an embodiment of the present invention
  • FIG. 3 is a schematic diagram of transferring shared memory in an embodiment of the present invention.
  • FIG. 4 is a flow chart of a method for transferring shared memory in an embodiment of the present invention. detailed description
  • the method for transferring the shared memory specifically includes: calling the function to create a shared memory by using the local memory address of the caller process as a keyword. And constructing a function call statement by using the shared memory keyword as a parameter; sending the function call statement to the callee process for being The caller process resolves the function call statement to obtain shared memory, thereby implementing data exchange between processes.
  • 2 is a flowchart of a method for transmitting shared memory according to an embodiment of the present invention; as shown in FIG. 2, the method includes:
  • Step 201 The caller process call function creates a shared memory by using a local memory address as a keyword;
  • the functions include shmat, shmdt, shmget, shmctl, etc., which can create a shared memory function;
  • the local memory address can be a localized memory address in a textual form of the caller process;
  • the shared memory is in the system physical memory. Establish a memory segment that can be shared by multiple processes;
  • the caller process uses the function to create shared memory with the local memory address as the keyword.
  • the created shared memory can be directly connected to the local memory of the caller process, and the caller process does not need to share the memory keyword and shared memory.
  • the merge will map shared memory to local memory, making the caller process transparent between local and shared memory.
  • Step 202 The caller process call function constructs a function call statement by using the shared memory keyword as a parameter, and sends the call statement to the callee process through an inter-process communication mechanism;
  • the invention aims to ensure the consistency of the shared memory and the local memory address, thereby directly calling the data in the shared memory through the function, and the in-process local memory data exchange is directly passed.
  • the function calls the data of the local memory to achieve the shared memory. Only by calling the function to create the shared memory with the local memory address of the caller process as the key, can the local memory data exchange in the process and the shared memory data exchange mode between processes be unified. If the caller process establishes shared memory in a non-function manner, although the creation of shared memory can be implemented, since the subsequent shared memory keyword cannot be directly sent to the callee process through a function form, the caller process must notify through other pipes.
  • Step 203 The callee process rendezvous according to the shared memory keyword provided by the function call statement parameter and the shared memory, obtain the shared memory information (the information includes the shared memory name and/or address), and obtain the shared memory by sharing the memory information.
  • Step 204 The callee process maps the shared memory to the local memory address of the callee process.
  • Step 205 The callee process executes a function called locally by the caller process according to the function call statement, and writes the execution result to the shared memory and the function return statement, and returns the function return statement to the caller process through the inter-process communication mechanism. .
  • Step 206 The caller process directly copies the data content in the shared memory that is updated by the callee process back to the local memory.
  • FIG. 3 is a schematic diagram of transferring shared memory according to an embodiment of the present invention.
  • the caller process is used. A part of the functions provided by the caller process, first call a local function, the shared memory 01AA0314 is created with the local memory address 01AA0314 as the key, and the local memory data content is copied to the shared memory. At the same time, the function is shared memory. Keyword 01AA0314 is a parameter construction function call statement, which is passed to the callee process through the interprocess communication mechanism.
  • the callee process parses the function call statement, obtains the shared memory name from it, and maps the shared memory to the local memory address of the callee process. After that, the memory space shared with the caller process will be accessed as if it were accessing local memory.
  • Step 401 The caller process calls the local shmat function
  • Step 402 The shmat function creates a shared memory 01AA0314 with the string 01AA0314 of the local memory address of the caller process as a key, and the caller process can directly copy the data content in the local memory to the shared memory;
  • Step 403 The shmat function takes the shared memory keyword 01AA0314 as a reference. a number constructing function call statement, which transfers the function call statement to the callee process through an interprocess communication mechanism;
  • Step 404 The callee process receives a function call statement from the caller process, parses out the shared memory keyword 01AA0314 according to the function call statement parameter 01AA0314;
  • Step 405 The callee process passes the shared memory keyword 01AA0314 and shared memory meet, get the shared memory name 01AA0314;
  • Step 406 The callee process maps the shared memory 01AA0314 to the local memory address of the callee process 0001E98;
  • Step 407 Execute a locally called function of the callee process, where the called function corresponds to a function called by the caller process, and may include a shmat function or other corresponding function;
  • Step 408 The called function writes the execution result to the shared memory 01AA0314, and constructs a function return statement, which is transmitted to the caller process through the inter-process communication mechanism;
  • Step 409 The caller process directly copies the data content in the shared memory that is updated by the callee process back to the local memory.
  • the caller process uses the function to create shared memory directly with the local memory address as the shared memory keyword.
  • the shared memory keyword can be kept consistent with the local memory address, so that the created shared memory can directly connect with the local memory of the caller process.
  • the caller process does not need to map the shared memory to the local memory according to the shared memory keyword and the shared memory, so that the caller process is transparent between the local memory and the shared memory, and the local memory data content can be directly copied to the shared memory;
  • the caller process uses the function to use the shared memory keyword as a parameter to construct a function call statement and send it to the callee process, and transfer the shared memory keyword through the function call statement.
  • Local memory access and shared memory access are unified at the functional interface level.
  • the technical solution provided by the present invention can ensure the unification of the data transfer mode between the shared memory and the data transfer mode of the local memory in the process, and the flow of data exchange is improved, and the synchronization of the data exchange is improved.
  • the embodiment of the invention further provides a device for transferring shared memory, which is applied to the caller process side, and includes:
  • a first module configured to call a function to create a shared memory by using a local memory address of the caller process as a keyword, and construct a function call statement by using the shared memory keyword as a parameter;
  • the second module is configured to send the function call statement to the callee process for the callee process to parse the function call statement to obtain the shared memory.
  • the device further includes:
  • the third module is configured to directly copy the data content in the shared memory that is updated by the callee process back to the local memory address of the caller process.
  • the embodiment of the invention further provides a device for transferring shared memory, which is applied to the process side of the callee, and includes:
  • a first module configured to receive a function call statement from a caller process, wherein the function call statement is constructed by: calling a function to create a shared memory with the local memory address of the caller process as a keyword and using the shared memory Keywords are parameter construction;
  • the second module is used to parse the function call statement to obtain shared memory.
  • the second module includes:
  • the first unit the parameters used to resolve the function call statement to obtain the shared memory keyword
  • the second unit is used to share the shared memory keyword with the shared memory, and map the shared memory to the local memory address of the callee process.
  • the device further includes:
  • the third module used to write the function execution result to the shared memory, and return the statement through the function Go back to the caller process.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multi Processors (AREA)

Abstract

本发明实施例公开了一种传递共享内存的方法和装置。其中,所述传递共享内存的方法包括:调用函数以调用者进程的本地内存地址作为关键词创建共享内存并以所述的共享内存关键词为参数构建函数调用语句;将所述的函数调用语句发送给被调用者进程,以供被调用者进程解析函数调用语句获取共享内存,实现数据交换。应用本发明实施例提供的方法和装置,可以实现进程间的共享内存和进程内的本地内存这两种数据交换方式的统一,提高数据交换的同步性。

Description

一种传递共享内存的方法和装置 技术领域
本发明涉及数据交换技术, 尤其涉及一种传递共享内存的方法和装置。 背景技术
传统意义上的本地内存传递方式通常仅局限于一个进程的内部, 是因为 操作系统为每个运行于其中的进程所提供的虚拟内存空间都是相同的, 而虚 拟内存与物理内存之间的映射完全由操作系统控制, 应用程序进程只能通过
同进程之间是无法通过本地内存传递数据的。
为了提高进程间数据交换的效率, 筒化进程间通信的流程, 大多数操作 系统都会提供共享内存的进程间通信机制。 所述的共享内存不是从某一进程 的内存中划分出来的, 而是在系统的物理内存中开辟一块可以为多个进程共 享的内存区域, 因为每个进程的内存总是私有的, 建立共享内存的目的是希 望每一个访问它的进程连接它, 这个连接过程称为映射。 系统在建立共享内 存时给共享内存分配每个进程的本地内存地址, 每个进程的本地内存地址都 可以连接到相应的共享内存。 即将共享内存分别映射到每一个进程各自的本 地内存空间, 从而实现多个进程之间基于共享内存的数据交换。
图 1为现有技术中传递共享内存的示意图, 如图 1所示: 在同一系统中 有两个进程(进程 A和进程 B )正在运行, 其中进程 A期望通过访问共享内 存来实现对进程 B信息的调用,在这种情况下,进程 A可称之为调用者进程, 进程 B可称之为被调用者进程。 具体来说, 进程 A调用进程 B的方法如下: 步骤 1 : 进程 A申请一个共享内存;
步骤 2 : 系统根据进程 A的申请指定一个共享内存关键词 (0X00 )建立 共享内存(0X00) , 并通过一定的方式告知进程 Α和进程 Β;
在本步骤中, 系统可以通过如下方式将共享内存关键词告知进程 Α和进 程 B:
A、 系统采用特殊文件以匿名方式创建共享内存时, 操作系统通过特殊 文件将共享内存关键词 (0X00 )告知进程 A和进程 B, 但是, 这种方式一般 只适用于具有亲缘关系的进程之间。 例如, 在父进程中先调用 匪 ap 函数, 再调用 fork函数, 那么在父进程调用 fork函数后, 子进程继承父进程匿名 映射后的本地内存地址;
B、 系统也可以在编译程序的命令行参数中指定同一个公共头文件, 该 公共头文件包含共享内存关键词 (0X00 ) , 并同时告知进程 A和进程 B, 但 是, 在关键字已经与一个共享内存相结合的情况下, 任何试图创建同名共享 内存的操作都会失败, 此时, 系统必须处理这种失败, 删除已有的共享内存, 然后再次尝试创建, 使得流程更加复杂, 并且可能需要多次尝试;
为了解决同名共享内存问题,进程 A和进程 B约定一个路径名和项目 ID (一个介于 0到 255之间的字符值) , 进程 A调用 fork函数, 将这两个值 变换为一个关键字, 系统根据此关键字创建共享内存; 但是, 这种方式通常 只能应用于类 UNIX操作系统, 而且仅限于系统的路径和项目 ID为公知的; 步骤 3: 进程 A把共享内存( 0X00 )连接 (即映射)到自己的本地内存 地址(即进程 A的本地内存地址 0X003D2C8 ) ; 进程 B把共享内存 ( 0X00 ) 从而实现进程 A和进程 B之间基于共享内存(0X00 ) 的数据交换。
从上述现有技术公开的技术方案中,可以看出, 系统在创建共享内存时, 不仅需要依赖特殊的文件系统,有可能存在共享内存创建失败的情形, 同时, 进程 A和进程 B都必须通过共享内存关键词与共享内存会合, 再将共享内存 映射到各自的本地内存地址, 流程比较复杂, 容易导致进程间共享内存数据 交换的不同步性。 而这种进程间数据交换的不同步性是因为进程间共享内存 数据交换和进程内本地内存数据交换方式的不统一造成的。 发明内容
有鉴于此, 本发明实施例提供了一种传递共享内存的方法和装置, 能够 实现进程间共享内存和进程内本地内存这两种数据交换方式的统一, 提高进 程间共享内存数据交换的同步性。
为实现上述目的, 本发明实施例采用如下技术方案。
一种传递共享内存的方法, 包括:
调用函数以调用者进程的本地内存地址作为关键词创建共享内存并以 所述的共享内存关键词为参数构建函数调用语句;
将所述的函数调用语句发送给被调用者进程, 以供被调用者进程解析函 数调用语句获取共享内存。
本发明实施例还提供了一种实现传递共享内存方法的装置, 应用于调用 者进程侧, 包括: 第一模块, 用于调用函数以调用者进程的本地内存地址作为关键词创建 共享内存并以所述的共享内存关键词为参数构建函数调用语句;
第二模块, 用于将所述的函数调用语句发送给被调用者进程, 以供被调 用者进程解析函数调用语句获取共享内存。
本发明实施例还提供了一种实现传递共享内存方法的装置, 应用于被调 用者进程侧, 包括: 第一模块, 用于接收来自调用者进程的函数调用语句, 其中所述函数调 用语句的构建方式为: 调用函数以调用者进程的本地内存地址作为关键词创 建共享内存并以所述的共享内存关键词为参数构建;
第二模块, 用于解析函数调用语句获取共享内存。 本发明实施例通过调用函数直接以本地内存地址为共享内存关键词创 建共享内存, 通过这种方式保持共享内存关键字与本地内存地址的一致性, 使所创建的共享内存可以直接与调用者进程的本地内存连接, 调用者进程不 需要根据共享内存关键词与共享内存会合并将共享内存映射到本地内存, 从 而使调用者进程本地内存与共享内存之间透明, 本地内存数据内容可以直接 复制到共享内存;
同时, 本发明实施例又通过调用函数将共享内存关键词作为参数构建函 数调用语句, 并将函数调用语句发送给被调用者进程供其获取共享内存, 使 得被调用者进程本地内存访问与共享内存访问在函数接口层面加以统一; 因此, 本发明实施例提供的技术方案可以保证进程间共享内存的传递数 据方式和进程内本地内存的传递数据方式的统一, 筒化了数据交换的流程, 提高了数据交换的同步性。 附图说明
图 1为现有技术中传递共享内存的示意图;
图 2为本发明实施例中传递共享内存的方法流程图;
图 3为本发明实施例中传递共享内存的示意图;
图 4为本发明实施例中传递共享内存的方法流程图。 具体实施方式
为使本发明的目的、 技术方案和优点更加清楚, 下面结合附图对本发明 做进一步的详细描述。
为了实现进程间共享内存和进程内本地内存的数据方式的统一, 本发明 实施例提供的一种传递共享内存的方法, 具体包括: 调用函数以调用者进程 的本地内存地址作为关键词创建共享内存并以所述的共享内存关键词为参 数构建函数调用语句; 将所述的函数调用语句发送给被调用者进程, 以供被 调用者进程解析函数调用语句获取共享内存, 从而实现进程间的数据交换。 图 2为本发明实施例提供的一种传递共享内存的方法流程图; 如图 2所 示, 该方法包括:
步骤 201 : 调用者进程调用函数以本地内存地址作为关键词创建共享内 存;
所述的函数包括 shmat ,shmdt, shmget, shmctl等可以创建共享内存的函 数; 所述的本地内存地址可以是调用者进程的文本化形式的本地内存地址; 所述的共享内存是在系统物理内存中建立一个可以为多个进程共享的内存 段;
在该步骤中, 调用者进程利用函数以本地内存地址为关键词创建共享内 存, 所创建的共享内存可以直接与调用者进程的本地内存连接, 调用者进程 不需要根据共享内存关键词与共享内存会合并将共享内存映射到本地内存, 从而使调用者进程本地内存与共享内存之间透明。
步骤 202: 调用者进程调用函数以所述的共享内存关键词为参数构建函 数调用语句, 并通过进程间通信机制发送给被调用者进程;
这里, 需要指出的是: 正是由于本发明的发明目的是要保证共享内存和 本地内存地址的一致性, 从而实现通过函数直接调用共享内存中的数据, 而 进程内本地内存数据交换是直接通过函数调用本地内存的数据来实现的, 那 么只有通过调用函数以调用者进程的本地内存地址作为关键词来创建共享 内存, 才能保证进程内本地内存数据交换和进程间共享内存数据交换方式的 统一。 如果调用者进程采用非函数方式建立共享内存, 虽然可以实现共享内 存的创建, 但是由于后续的共享内存关键词不能通过函数形式直接发送给被 调用者进程, 而是调用者进程必须通过其他管道告知被调用者进程, 这样导 致调用者进程在创建共享内存和传递共享内存关键词不同步, 进而导致被调 用者进程与共享内存会合的滞后。 步骤 203: 被调用者进程根据函数调用语句参数提供的共享内存关键词 与共享内存会合,得到共享内存的信息(所述信息包括共享内存名字和 /或地 址) , 通过共享内存信息获取共享内存。
步骤 204: 被调用者进程将共享内存映射到被调用者进程的本地内存地 址。
步骤 205: 被调用者进程根据函数调用语句, 执行被调用者进程本地被 调用的函数, 并将执行结果写入共享内存和函数返回语句, 通过进程间通信 机制将函数返回语句返回到调用者进程。
步骤 206: 调用者进程将共享内存中被被调用者进程更新的数据内容直 接拷贝回本地内存。
上述步骤构成一次完整的进程间共享内存数据交换过程, 下面举例进一 步说明本发明的具体实施方式, 图 3为本发明实施例中传递共享内存的示意 图, 如图 3所示, 调用者进程为了使用被调用者进程所提供的一部分功能, 先调用一个本地函数, 该函数以本地内存地址 01AA0314为关键词建立共享 内存 01AA0314, 并将本地内存数据内容复制到共享内存, 同时, 该函数又 以共享内存关键词 01AA0314为参数构建函数调用语句, 通过进程间通信机 制传递给被调用者进程, 被调用者进程解析函数调用语句, 从中得到共享内 存名字, 并将共享内存映射到被调用者进程本地内存地址, 此后将如同访问 本地内存一样访问与调用者进程共享的内存空间。
具体来说, 该方法的实现流程如图 4所示:
步骤 401 : 调用者进程调用本地的 shmat函数;
步骤 402 : 所述的 shmat 函数以调用者进程本地内存地址的字符串 01AA0314作为关键字创建共享内存 01AA0314,调用者进程可以直接将本地 内存中的数据内容复制到共享内存中;
步骤 403: 所述的 shmat函数以所述的共享内存关键词 01AA0314为参 数构建函数调用语句, 通过进程间通信机制将所述的函数调用语句传送给被 调用者进程;
步骤 404: 被调用者进程接收来自调用者进程的函数调用语句, 根据所 述的函数调用语句参数 01AA0314解析出共享内存的关键字 01AA0314; 步骤 405: 被调用者进程通过所述的共享内存关键字 01AA0314与共享 内存会合, 得到共享内存名字 01AA0314;
步骤 406: 被调用者进程将共享内存 01AA0314映射到被调用者进程的 本地内存地址 0001E98;
步骤 407: 执行被调用者进程的本地被调用的函数, 所述被调用的函数 与调用者进程调用的函数相对应, 可以包括 shmat函数或者其他相对应的函 数;
步骤 408: 所述被调用的函数将执行结果写入共享内存 01AA0314, 并 构建函数返回语句, 通过进程间通信机制传递给调用者进程;
步骤 409: 调用者进程将共享内存中被被调用者进程更新的数据内容直 接拷贝回本地内存。
本发明提供的技术方案相较于其它通过共享内存实现进程间传递数据 的方法具有显著优势:
调用者进程使用函数直接以本地内存地址为共享内存关键词创建共享 内存, 可以保持共享内存关键字与本地内存地址的一致性, 使所创建的共享 内存可以直接与调用者进程的本地内存连接, 调用者进程不需要根据共享内 存关键词与共享内存会合并将共享内存映射到本地内存, 从而使调用者进程 本地内存与共享内存之间透明, 本地内存数据内容可以直接复制到共享内 存;
同时, 调用者进程又使用函数将共享内存关键词作为参数构建函数调用 语句并发送给被调用者进程, 通过函数调用语句传输共享内存的关键词, 使 得本地内存访问与共享内存访问在函数接口层面加以统一。
由此可见, 本发明提供的技术方案可以保证进程间共享内存的传递数据 方式和进程内本地内存的传递数据方式的统一, 筒化了数据交换的流程, 提 高了数据交换的同步性。
本发明实施例还提供了一种传递共享内存的装置, 应用于调用者进程 侧, 包括:
第一模块, 用于调用函数以调用者进程的本地内存地址作为关键词创建 共享内存并以所述的共享内存关键词为参数构建函数调用语句;
第二模块, 用于将所述的函数调用语句发送给被调用者进程, 以供被调 用者进程解析函数调用语句获取共享内存。
该装置进一步包括:
第三模块, 用于将共享内存中被被调用者进程更新的数据内容直接拷贝 回调用者进程的本地内存地址。
本发明实施例还提供了一种传递共享内存的装置, 应用于被调用者进程 侧, 包括:
第一模块, 用于接收来自调用者进程的函数调用语句, 其中所述函数调 用语句的构建方式为: 调用函数以调用者进程的本地内存地址作为关键词创 建共享内存并以所述的共享内存关键词为参数构建;
第二模块, 用于解析函数调用语句获取共享内存。
所述第二模块包括:
第一单元: 用于解析函数调用语句的参数从中获取共享内存关键词; 第二单元: 用于将共享内存关键词与共享内存会合, 并将共享内存映射 到被调用者进程的本地内存地址。
该装置进一步包括:
第三模块: 用于将函数执行结果写入共享内存, 并通过函数返回语句返 回到调用者进程。
以上仅为本发明的较佳实施例, 并非用于限定本发明的保护范围。 凡在 本发明的精神和原则之内, 所做的任何修改、 等同替换、 改进等, 均应包含 在本发明的保护范围之内。

Claims

权利要求
1、 一种传递共享内存的方法, 其特征在于:
调用函数以调用者进程的本地内存地址作为关键词创建共享内存并以 所述的共享内存关键词为参数构建函数调用语句;
将所述的函数调用语句发送给被调用者进程, 以供被调用者进程解析函 数调用语句获取共享内存。
2、 根据权利要求 1 所述的方法, 其特征在于, 所述被调用者进程解析 函数调用语句获取共享内存包括:
被调用者进程解析函数调用语句的参数从中获取共享内存关键词; 将共享内存关键词与共享内存会合, 并将共享内存映射到被调用者进程 的本地内存地址。
3、 根据权利要求 1或 2所述的方法, 其特征在于, 进一步包括: 被调用者进程根据函数调用语句, 执行被调用者进程本地被调用的函 数, 并将执行结果写入共享内存, 通过函数返回语句返回给调用者进程。
4、 根据权利要求 3所述的方法, 其特征在于, 进一步包括:
调用者进程将共享内存中被被调用者进程更新的数据内容直接拷贝回 调用者进程的本地内存地址。
5、 根据权利要求 1或 2所述的方法, 其特征在于, 所述调用者进程的 本地内存地址为文本化形式的内存地址。
6、一种传递共享内存的装置, 其特征在于,应用于调用者进程侧, 包括: 第一模块, 用于调用函数以调用者进程的本地内存地址作为关键词创建 共享内存并以所述的共享内存关键词为参数构建函数调用语句;
第二模块, 用于将所述的函数调用语句发送给被调用者进程, 以供被调 用者进程解析函数调用语句获取共享内存。
7、 根据权利要求 6所述的装置, 其特征在于, 进一步包括: 第三模块, 用于将共享内存中被被调用者进程更新的数据内容直接拷贝 回调用者进程的本地内存地址。
8、 一种传递共享内存的装置, 其特征在于, 应用于被调用者进程侧, 包括:
第一模块, 用于接收来自调用者进程的函数调用语句, 其中所述函数调 用语句的构建方式为: 调用函数以调用者进程的本地内存地址作为关键词创 建共享内存并以所述的共享内存关键词为参数构建;
第二模块, 用于解析函数调用语句获取共享内存。
9、 根据权利要求 8所述的装置, 其特征在于, 所述第二模块包括: 第一单元: 用于解析函数调用语句的参数从中获取共享内存关键词; 第二单元: 用于将共享内存关键词与共享内存会合, 并将共享内存映射 到被调用者进程的本地内存地址。
10、 根据权利要求 8或 9所述的装置, 其特征在于, 进一步包括: 第三模块: 用于将函数执行结果写入共享内存, 并通过函数返回语句返 回到调用者进程。
PCT/CN2012/076531 2011-06-17 2012-06-06 一种传递共享内存的方法和装置 WO2012171438A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110164503.9 2011-06-17
CN201110164503.9A CN102253855B (zh) 2011-06-17 2011-06-17 一种传递共享内存的方法和装置

Publications (1)

Publication Number Publication Date
WO2012171438A1 true WO2012171438A1 (zh) 2012-12-20

Family

ID=44981135

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/076531 WO2012171438A1 (zh) 2011-06-17 2012-06-06 一种传递共享内存的方法和装置

Country Status (2)

Country Link
CN (1) CN102253855B (zh)
WO (1) WO2012171438A1 (zh)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102253855B (zh) * 2011-06-17 2016-04-13 天津书生软件技术有限公司 一种传递共享内存的方法和装置
CN103995736B (zh) * 2011-06-17 2017-09-22 天津书生软件技术有限公司 一种传递共享内存的方法和装置
CN103197979B (zh) * 2012-01-04 2017-05-03 阿里巴巴集团控股有限公司 一种用于实现在进程间进行数据交互访问的方法及其装置
CN104516740B (zh) * 2013-09-26 2019-07-16 腾讯科技(深圳)有限公司 一种函数调用方法、装置及移动终端
CN105975407B (zh) * 2016-03-22 2020-10-09 华为技术有限公司 一种内存地址的映射方法及设备
CN106293943A (zh) * 2016-08-11 2017-01-04 浪潮电子信息产业股份有限公司 一种虚拟资源分配方法
CN107229530A (zh) * 2017-06-29 2017-10-03 上海联影医疗科技有限公司 进程间的通信方法、存储介质以及计算机设备
CN109376022B (zh) * 2018-09-29 2021-12-14 中国科学技术大学 一种提升Halide语言在多核系统执行效率的线程模型实现方法
CN115119048B (zh) * 2019-08-10 2024-02-23 荣耀终端有限公司 一种视频流处理方法及电子设备
CN111221758B (zh) * 2019-09-30 2023-06-27 华为技术有限公司 处理远程直接内存访问请求的方法和计算机设备
CN112379952B (zh) * 2020-12-09 2023-04-07 成都傲梅科技有限公司 一种跨进程回调的实现方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080216089A1 (en) * 2004-12-16 2008-09-04 International Business Machines Corporation Checkpoint/resume/restart safe methods in a data processing system to establish, to restore and to release shared memory regions
CN101667144A (zh) * 2009-09-29 2010-03-10 北京航空航天大学 一种基于共享内存的虚拟机通信方法
CN101847105A (zh) * 2009-03-26 2010-09-29 联想(北京)有限公司 一种计算机及多操作系统共享内存的方法
CN102004675A (zh) * 2010-11-11 2011-04-06 福建星网锐捷网络有限公司 跨进程数据传输方法、装置及网络设备
CN102253855A (zh) * 2011-06-17 2011-11-23 北京书生国际信息技术有限公司 一种传递共享内存的方法和装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080216089A1 (en) * 2004-12-16 2008-09-04 International Business Machines Corporation Checkpoint/resume/restart safe methods in a data processing system to establish, to restore and to release shared memory regions
CN101847105A (zh) * 2009-03-26 2010-09-29 联想(北京)有限公司 一种计算机及多操作系统共享内存的方法
CN101667144A (zh) * 2009-09-29 2010-03-10 北京航空航天大学 一种基于共享内存的虚拟机通信方法
CN102004675A (zh) * 2010-11-11 2011-04-06 福建星网锐捷网络有限公司 跨进程数据传输方法、装置及网络设备
CN102253855A (zh) * 2011-06-17 2011-11-23 北京书生国际信息技术有限公司 一种传递共享内存的方法和装置

Also Published As

Publication number Publication date
CN102253855B (zh) 2016-04-13
CN102253855A (zh) 2011-11-23

Similar Documents

Publication Publication Date Title
WO2012171438A1 (zh) 一种传递共享内存的方法和装置
US11294699B2 (en) Dynamically scaled hyperconverged system establishing minimum supported interoperable communication protocol between clusters in a cluster group
EP3361387B1 (en) Data transmission method, equipment and system
JP6092249B2 (ja) 埋込まれたプロセス通信のための仮想チャネル
US11469964B2 (en) Extension resource groups of provider network services
KR101855541B1 (ko) 컴퓨트 클러스터에서의 디버거 런칭 및 첨부 기법
WO2019218718A1 (zh) 一种区块链网络的事务处理方法、装置、设备及存储介质
US20090064194A1 (en) Event driven sendfile
TWI782306B (zh) 訪問對接器、系統及應用該訪問對接器的方法及裝置
JP2000020490A (ja) 遠隔手続き呼出し機構またはオブジェクトリクエストブローカ機構を有する計算機、データ転送方法、および転送方法記憶媒体
JPH076091A (ja) メモリスペースの使用を管理する方法及びコンピュータシステム
WO2016155332A1 (zh) 一种服务器和数据处理方法
WO2015180513A1 (zh) 一种数据传输方法及计算机
WO2018045541A1 (zh) 一种容器分配的优化方法及处理设备
WO2023040502A1 (zh) 用户服务注册
WO2015055117A1 (zh) 一种内存访问的方法、设备和系统
WO2023246486A1 (zh) 一种创建连接器的方法及装置
CN103995736B (zh) 一种传递共享内存的方法和装置
JPH08115288A (ja) 通信管理方法
CN104102550A (zh) 一种多主机进程间通信的方法
JP2002505491A (ja) 分散形システムにおける動的情報証明のための装置及び方法
US11050583B2 (en) Device control apparatus, device control system, device control method, and recording medium
CN115622878A (zh) k8s网桥插件实现方法、装置、电子设备和可读存储介质
Beu et al. High-speed formal verification of heterogeneous coherence hierarchies
Hepner et al. Patterns of conflict among software components

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12801111

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12801111

Country of ref document: EP

Kind code of ref document: A1