CN103995736A - Method and device for transmitting shared memory - Google Patents
Method and device for transmitting shared memory Download PDFInfo
- Publication number
- CN103995736A CN103995736A CN201310446221.7A CN201310446221A CN103995736A CN 103995736 A CN103995736 A CN 103995736A CN 201310446221 A CN201310446221 A CN 201310446221A CN 103995736 A CN103995736 A CN 103995736A
- Authority
- CN
- China
- Prior art keywords
- shared drive
- keyword
- function
- callee
- memory address
- Prior art date
- Legal status (The legal status 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 status listed.)
- Granted
Links
Abstract
The embodiment of the invention discloses a method and device for transmitting a shared memory. The method for transmitting the shared memory comprises the steps of calling a function to take a local memory address of a caller process as a keyword for setting up the shared memory, and setting a function calling sentence by taking a shared memory keyword as a parameter; sending the function calling sentence to a callee process so as to allow the callee process to analyze the function calling sentence for obtaining the shared memory, and achieving the data exchange. According to the method and device, unification of two data exchange modes of the shared memory between the processes and local memory in the processes can be achieved, and synchronization of the data exchange is improved.
Description
This case is that application number is 201110164503.9(method and apparatus that transmits shared drive), the dividing an application of the Chinese patent application that the applying date is 2011.6.17.
Technical field
The present invention relates to Data Interchange Technology, relate in particular to a kind of method and apparatus that transmits shared drive.
Background technology
Traditional local internal memory transfer mode is only confined to the inside of a process conventionally, be because operating system for the virtual memory space that each runs on process wherein and provides be identical, and mapping between virtual memory and physical memory controlled by operating system completely, program process can only be accessed the data of actual storage in physical memory by virtual memory address.As can be seen here, even identical virtual memory address, in different processes, corresponding physical memory also can be completely different, therefore cannot transmit data by local internal memory between different process.
In order to improve the efficiency of Data Exchange, simplify the flow process of interprocess communication, most of operating system all can provide the inter-process communication mechanisms of shared drive.Described shared drive is not from the internal memory of a certain process, to divide out, but open up one in the physical memory of system, it can be the shared region of memory of a plurality of processes, because the internal memory of each process is always privately owned, the object of setting up shared drive is to wish that each process of accessing it connects it, and this connection procedure is called mapping.System is distributed the local memory address of each process when setting up shared drive to shared drive, the local memory address of each process can be connected to corresponding shared drive.Be about to shared drive and be mapped to respectively each process local memory headroom separately, thereby realize the exchanges data based on shared drive between a plurality of processes.
Fig. 1 transmits the schematic diagram of shared drive in prior art, as shown in Figure 1: in same system, have two processes (process A and process B) to move, wherein process A expectation realizes calling process B information by access shared drive, in this case, process A can be referred to as caller process, and process B can be referred to as callee process.Specifically, the method for process A calling process B is as follows:
Step 1: process A applies for a shared drive;
Step 2: system specifies a shared drive keyword (0X00) to set up shared drive (0X00) according to the application of process A, and informs process A and process B by certain mode;
In this step, system can be informed shared drive keyword process A and process B in the following way:
When A, system adopt special file to create shared drive with anonymous way, operating system is informed process A and process B by special file by shared drive keyword (0X00), and still, this mode is generally only applicable between the akin process of tool.For example, first call mmap function in parent process, then call fork function, call after fork function so in parent process, subprocess is inherited the local memory address after the anonymous mapping of parent process;
B, system also can be specified same public head file in the command line parameter of program compiler, this public head file comprises shared drive keyword (0X00), and inform process A and process B simultaneously, but, in the situation that key word combines with a shared drive, any operation of attempting to create shared drive of the same name all can be failed, now, system must be processed this failure, delete existing shared drive, and then attempt creating, make flow process more complicated, and may need repeatedly to attempt;
In order to solve shared drive problem of the same name, process A and pathname of process B agreement and item id (character value between 0 to 255), process A calls fork function, by these two value transforms, is a key word, and system creates shared drive according to this key word; But this mode can only be applied to class UNIX operating system conventionally, and the path and the item id that only limit to system are known;
Step 3: process A connects shared drive (0X00) (i.e. mapping) to the local memory address (being the local memory address 0X003D2C8 of process A) of oneself; Process B is the local memory address (being the local memory address 0X0024C28 of process B) to oneself shared drive (0X00) mapping (connecting), thus the exchanges data based on shared drive (0X00) between implementation process A and process B.
From the disclosed technical scheme of above-mentioned prior art, can find out, system is when creating shared drive, not only need to rely on special file system, likely exist shared drive to create failed situation, simultaneously, process A and process B must join by shared drive keyword and shared drive, shared drive is mapped to local memory address separately, flow process more complicated, easily causes the asynchronism of shared drive exchanges data between process again.And the asynchronism of this Data Exchange is because the disunity of shared drive exchanges data and in-process local internal storage data exchanged form causes between process.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of method and apparatus that transmits shared drive, can implementation process between the unification of shared drive and in-process these two kinds of data exchange ways of local internal memory, the synchronism of shared drive exchanges data between raising process.
For achieving the above object, the embodiment of the present invention adopts following technical scheme.
A method of transmitting shared drive, comprising:
Call function is usingd the local memory address of caller process and is created shared drive and take described shared drive keyword as parameter constructor call statement as keyword;
Described function call statement is sent to callee process, for callee process analytical function call statement, obtain shared drive.
The embodiment of the present invention also provides a kind of device that transmits shared drive method of realizing, and is applied to caller process side, comprising:
The first module, usings the local memory address of caller process for call function and creates shared drive and take described shared drive keyword as parameter constructor call statement as keyword;
The second module, for described function call statement is sent to callee process, obtains shared drive for callee process analytical function call statement.
The embodiment of the present invention also provides a kind of device that transmits shared drive method of realizing, and is applied to callee process side, comprising:
The first module, for receiving the function call statement from caller process, the building mode of wherein said function call statement is: call function is usingd the local memory address of caller process and as keyword, created shared drive and take described shared drive keyword and build as parameter;
The second module, obtains shared drive for analytical function call statement.
The embodiment of the present invention directly be take local memory address as shared drive keyword establishment shared drive by call function, the consistance that keeps in this way shared drive key word and local memory address, make the created shared drive can be directly and the local Memory linkage of caller process, caller process does not need can merge shared drive is mapped to local internal memory according to shared drive keyword and shared drive, thereby make between the local internal memory of caller process and shared drive transparently, local internal storage data content can directly copy to shared drive;
Simultaneously, the embodiment of the present invention again by call function using shared drive keyword as parameter constructor call statement, and send to callee process to obtain shared drive for it function call statement, the local internal storage access of callee process and shared internal storage access are unified in function interface aspect;
Therefore, the technical scheme that the embodiment of the present invention provides can guarantee the unification of the transmission data mode of shared drive between process and the transmission data mode of in-process local internal memory, has simplified the flow process of exchanges data, has improved the synchronism of exchanges data.
Accompanying drawing explanation
Fig. 1 transmits the schematic diagram of shared drive in prior art;
Fig. 2 transmits the method flow diagram of shared drive in the embodiment of the present invention;
Fig. 3 transmits the schematic diagram of shared drive in the embodiment of the present invention;
Fig. 4 transmits the method flow diagram of shared drive in the embodiment of the present invention.
Embodiment
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing, the present invention is described in further detail.
Unification for the data mode of shared drive between implementation process and in-process local internal memory, a kind of method of transmitting shared drive that the embodiment of the present invention provides, specifically comprises: call function is usingd the local memory address of caller process and created shared drive and take described shared drive keyword as parameter constructor call statement as keyword; Described function call statement is sent to callee process, for callee process analytical function call statement, obtain shared drive, thus the exchanges data between implementation process.
A kind of method flow diagram that transmits shared drive that Fig. 2 provides for the embodiment of the present invention; As shown in Figure 2, the method comprises:
Step 201: caller process transfer function is usingd local memory address and created shared drive as keyword;
Described function comprises shmat, shmdt, and shmget, shmctl etc. can create the function of shared drive; Described local memory address can be the local memory address of the text form of caller process; Described shared drive is that in system physical internal memory, to set up one can be the shared application heap of a plurality of processes;
In this step, caller process utilizes function to take local memory address as keyword establishment shared drive, the shared drive creating can be directly and the local Memory linkage of caller process, caller process does not need can merge shared drive is mapped to local internal memory according to shared drive keyword and shared drive, thereby makes between the local internal memory of caller process and shared drive transparent.
Step 202: caller process transfer function be take described shared drive keyword as parameter constructor call statement, and sends to callee process by inter-process communication mechanisms;
Here, it is to be noted: just because of goal of the invention of the present invention, be the consistance that will guarantee shared drive and local memory address, thereby realize and directly call the data in shared drive by function, and in-process local internal storage data exchange is that directly the data by the local internal memory of function call realize, only have so and by call function, using the local memory address of caller process and as keyword, create shared drive, the unification of shared drive data exchange ways between the in-process local internal storage data exchange of guarantee and process.If caller process adopts non-function mode to set up shared drive, although can realize the establishment of shared drive, but because follow-up shared drive keyword can not directly send to callee process by functional form, but caller process must be informed callee process by other pipelines, cause like this caller process asynchronous with transmission shared drive keyword at establishment shared drive, and then the hysteresis that causes callee process and shared drive to be joined.
Step 203: the shared drive keyword that callee process provides according to function call statement parameter and shared drive are joined, obtain the information (described information comprises shared drive name and/or address) of shared drive, by shared drive acquisition of information shared drive.
Step 204: callee process is mapped to shared drive the local memory address of callee process.
Step 205: callee process is according to function call statement, carry out the local invoked function of callee process, and execution result is write to shared drive and function return statement, by inter-process communication mechanisms, function return statement is turned back to caller process.
Step 206: caller process returns the data content direct copying being upgraded by callee process in shared drive to local internal memory.
Above-mentioned steps forms once shared drive data exchange process between complete process, further illustrate for example the specific embodiment of the present invention below, Fig. 3 transmits the schematic diagram of shared drive in the embodiment of the present invention, as shown in Figure 3, the part of functions of caller process in order to use callee process to provide, first call a local function, this function be take local memory address 01AA0314 and is set up shared drive 01AA0314 as keyword, and by local internal storage data content replication to shared drive, simultaneously, this function be take again shared drive keyword 01AA0314 as parameter constructor call statement, by inter-process communication mechanisms, pass to callee process, callee process analytical function call statement, therefrom obtain shared drive name, and shared drive is mapped to callee process local memory address, after this will as the local internal memory of access, access the memory headroom shared with caller process.
Specifically, the realization flow of the method is as shown in Figure 4:
Step 401: the shmat function of caller process transfer this locality;
Step 402: described shmat function is usingd the character string 01AA0314 of caller process local memory address and created shared drive 01AA0314 as key word, and caller process can directly copy to the data content in local internal memory in shared drive;
Step 403: described shmat function be take described shared drive keyword 01AA0314 as parameter constructor call statement, sends described function call statement to callee process by inter-process communication mechanisms;
Step 404: callee process receives the function call statement from caller process, parses the key word 01AA0314 of shared drive according to described function call statement parameter 01AA0314;
Step 405: callee process is joined by described shared drive key word 01AA0314 and shared drive, obtains shared drive name 01AA0314;
Step 406: callee process is mapped to shared drive 01AA0314 the local memory address 0001E98 of callee process;
Step 407: carry out the invoked function in this locality of callee process, described invoked function is corresponding with the function of caller process transfer, can comprise shmat function or other corresponding functions;
Step 408: described invoked function writes shared drive 01AA0314 by execution result, and constructor return statement, passes to caller process by inter-process communication mechanisms;
Step 409: caller process returns the data content direct copying being upgraded by callee process in shared drive to local internal memory.
Technical scheme provided by the invention has significant advantage compared to other by transmitting the method for data between Sharing Memory Realization process:
Caller process is used function directly to take local memory address as shared drive keyword establishment shared drive, the consistance that can keep shared drive key word and local memory address, make the created shared drive can be directly and the local Memory linkage of caller process, caller process does not need can merge shared drive is mapped to local internal memory according to shared drive keyword and shared drive, thereby make between the local internal memory of caller process and shared drive transparently, local internal storage data content can directly copy to shared drive;
Simultaneously, caller process is used again function using shared drive keyword as parameter constructor call statement and is sent to callee process, keyword by function call statement transmission shared drive, makes local internal storage access and shared internal storage access be unified in function interface aspect.
As can be seen here, technical scheme provided by the invention can guarantee the unification of the transmission data mode of shared drive between process and the transmission data mode of in-process local internal memory, has simplified the flow process of exchanges data, has improved the synchronism of exchanges data.
The embodiment of the present invention also provides a kind of device that transmits shared drive, is applied to caller process side, comprising:
The first module, usings the local memory address of caller process for call function and creates shared drive and take described shared drive keyword as parameter constructor call statement as keyword;
The second module, for described function call statement is sent to callee process, obtains shared drive for callee process analytical function call statement.
This device further comprises:
The 3rd module, for the local memory address of data content direct copying readjustment user process that shared drive is upgraded by callee process.
The embodiment of the present invention also provides a kind of device that transmits shared drive, is applied to callee process side, comprising:
The first module, for receiving the function call statement from caller process, the building mode of wherein said function call statement is: call function is usingd the local memory address of caller process and as keyword, created shared drive and take described shared drive keyword and build as parameter;
The second module, obtains shared drive for analytical function call statement.
Described the second module comprises:
First module: the parameter for analytical function call statement is therefrom obtained shared drive keyword;
Second unit: for shared drive keyword and shared drive are joined, and shared drive is mapped to the local memory address of callee process.
This device further comprises:
The 3rd module: for function execution result is write to shared drive, and turn back to caller process by function return statement.
These are only preferred embodiment of the present invention, be not intended to limit protection scope of the present invention.Within the spirit and principles in the present invention all, any modification of making, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.
Claims (10)
1. a method of transmitting shared drive, is characterized in that:
Call function is usingd the local memory address of caller process and is created shared drive and take described shared drive keyword as parameter constructor call statement as keyword;
Described function call statement is sent to callee process, for callee process analytical function call statement, obtain shared drive.
2. method according to claim 1, is characterized in that, described callee process analytical function call statement is obtained shared drive and comprised:
The parameter of callee process analytical function call statement is therefrom obtained shared drive keyword;
Shared drive keyword and shared drive are joined, and shared drive is mapped to the local memory address of callee process.
3. method according to claim 1 and 2, is characterized in that, further comprises:
Callee process, according to function call statement, is carried out the local invoked function of callee process, and execution result is write to shared drive, by function return statement, returns to caller process.
4. method according to claim 3, is characterized in that, further comprises:
Caller process is by the local memory address of the data content direct copying readjustment user process of being upgraded by callee process in shared drive.
5. method according to claim 1 and 2, is characterized in that, the local memory address of described caller process is the memory address of text form.
6. a device that transmits shared drive, is characterized in that, is applied to caller process side, comprising:
The first module, usings the local memory address of caller process for call function and creates shared drive and take described shared drive keyword as parameter constructor call statement as keyword;
The second module, for described function call statement is sent to callee process, obtains shared drive for callee process analytical function call statement.
7. device according to claim 6, is characterized in that, further comprises:
The 3rd module, for the local memory address of data content direct copying readjustment user process that shared drive is upgraded by callee process.
8. a device that transmits shared drive, is characterized in that, is applied to callee process side, comprising:
The first module, for receiving the function call statement from caller process, the building mode of wherein said function call statement is: call function is usingd the local memory address of caller process and as keyword, created shared drive and take described shared drive keyword and build as parameter;
The second module, obtains shared drive for analytical function call statement.
9. device according to claim 8, is characterized in that, described the second module comprises:
First module: the parameter for analytical function call statement is therefrom obtained shared drive keyword;
Second unit: for shared drive keyword and shared drive are joined, and shared drive is mapped to the local memory address of callee process.
10. device according to claim 8 or claim 9, is characterized in that, further comprises:
The 3rd module: for function execution result is write to shared drive, and turn back to caller process by function return statement.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310446221.7A CN103995736B (en) | 2011-06-17 | 2011-06-17 | A kind of method and apparatus for transmitting shared drive |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310446221.7A CN103995736B (en) | 2011-06-17 | 2011-06-17 | A kind of method and apparatus for transmitting shared drive |
CN201110164503.9A CN102253855B (en) | 2011-06-17 | 2011-06-17 | A kind of method and apparatus transmitting shared drive |
Related Parent Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201110164503.9A Division CN102253855B (en) | 2011-06-17 | 2011-06-17 | A kind of method and apparatus transmitting shared drive |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103995736A true CN103995736A (en) | 2014-08-20 |
CN103995736B CN103995736B (en) | 2017-09-22 |
Family
ID=51309912
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310446221.7A Active CN103995736B (en) | 2011-06-17 | 2011-06-17 | A kind of method and apparatus for transmitting shared drive |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103995736B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104318476A (en) * | 2014-11-06 | 2015-01-28 | 中国建设银行股份有限公司 | Information processing method and device |
CN109426571A (en) * | 2017-08-28 | 2019-03-05 | 阿里巴巴集团控股有限公司 | Function call and the method for data access, system, storage medium, processor and device |
CN111125070A (en) * | 2019-11-19 | 2020-05-08 | 华迪计算机集团有限公司 | Data exchange method and platform |
CN112437341A (en) * | 2019-08-10 | 2021-03-02 | 华为技术有限公司 | Video stream processing method and electronic equipment |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1811717A (en) * | 2006-01-10 | 2006-08-02 | 杭州东信灵通电子实业公司 | Universal interprocess communication achieving method |
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 |
JP2009065713A (en) * | 2008-12-08 | 2009-03-26 | Ricoh Co Ltd | Image forming apparatus, shared memory arbitrating method, program and recording medium |
CN102004675A (en) * | 2010-11-11 | 2011-04-06 | 福建星网锐捷网络有限公司 | Cross-process data transmission method, device and network equipment |
CN102253855B (en) * | 2011-06-17 | 2016-04-13 | 天津书生软件技术有限公司 | A kind of method and apparatus transmitting shared drive |
-
2011
- 2011-06-17 CN CN201310446221.7A patent/CN103995736B/en active Active
Patent Citations (5)
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 |
CN1811717A (en) * | 2006-01-10 | 2006-08-02 | 杭州东信灵通电子实业公司 | Universal interprocess communication achieving method |
JP2009065713A (en) * | 2008-12-08 | 2009-03-26 | Ricoh Co Ltd | Image forming apparatus, shared memory arbitrating method, program and recording medium |
CN102004675A (en) * | 2010-11-11 | 2011-04-06 | 福建星网锐捷网络有限公司 | Cross-process data transmission method, device and network equipment |
CN102253855B (en) * | 2011-06-17 | 2016-04-13 | 天津书生软件技术有限公司 | A kind of method and apparatus transmitting shared drive |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104318476A (en) * | 2014-11-06 | 2015-01-28 | 中国建设银行股份有限公司 | Information processing method and device |
CN104318476B (en) * | 2014-11-06 | 2019-04-26 | 中国建设银行股份有限公司 | A kind of information processing method and device |
CN109426571A (en) * | 2017-08-28 | 2019-03-05 | 阿里巴巴集团控股有限公司 | Function call and the method for data access, system, storage medium, processor and device |
CN112437341A (en) * | 2019-08-10 | 2021-03-02 | 华为技术有限公司 | Video stream processing method and electronic equipment |
CN111125070A (en) * | 2019-11-19 | 2020-05-08 | 华迪计算机集团有限公司 | Data exchange method and platform |
Also Published As
Publication number | Publication date |
---|---|
CN103995736B (en) | 2017-09-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102253855B (en) | A kind of method and apparatus transmitting shared drive | |
CN103150279B (en) | Method allowing host and baseboard management controller to share device | |
JP2001216226A (en) | Inter-application data transmission/reception system and method threfor, and computer-readable recording medium having program for making computer operate inter-application data transmission/reception method recording thereon | |
US9940224B2 (en) | Automatic remote execution of an application | |
CN100473070C (en) | Mapping method for USB apparatus with storage function on network computer | |
CN110781528B (en) | Collaborative secure operating system and electronic device | |
CN111459632B (en) | Serial port agent for calling terminal application program and implementation method | |
CN104123194A (en) | Communication structure and method for kernel mode and user mode | |
CN103995736A (en) | Method and device for transmitting shared memory | |
US20240111615A1 (en) | Dynamic application programming interface (api) contract generation and conversion through microservice sidecars | |
CN105656947A (en) | Method, device and system for interaction between transaction middleware and third-party system | |
CN108664247A (en) | A kind of method and device of Page Template data interaction | |
US11784946B2 (en) | Method for improving data flow and access for a neural network processor | |
CN102664952A (en) | Method for managing and monitoring embedded equipment cluster | |
WO2022217759A1 (en) | Esim code-number management method and apparatus | |
WO2023246486A1 (en) | Method and apparatus for creating connector | |
CN101819524B (en) | Access method of RFID (Radio Frequency Identification Device) reader and interface driving device thereof | |
US6795824B1 (en) | Independent storage architecture | |
US20230023290A1 (en) | Method for managing function based on engine, electronic device and medium | |
CN106656777B (en) | Object-based intelligent domestic gateway communication interface arrangement | |
CN110581848B (en) | Cloud desktop multi-network isolation system and method | |
CN113711570B (en) | Method and system for enabling a computing device to communicate with a cloud network | |
CN114510323A (en) | Network optimization implementation method for operating virtual machine in container | |
US10970189B2 (en) | Configuring data processing pipelines | |
JP2003345516A (en) | Storage controller and method for controlling its storage controller |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20181207 Address after: 100029 Changxin Building 408-409, 39 Anding Road, Chaoyang District, Beijing Patentee after: Beijing Sursen Electronic Technology Co., Ltd. Address before: 300308 Tianjin Binhai New Area Airport Economic Zone Patentee before: Tianjin Scholar Software Technology Co., Ltd. |