CN107491355A - Funcall method and device between a kind of process based on shared drive - Google Patents

Funcall method and device between a kind of process based on shared drive Download PDF

Info

Publication number
CN107491355A
CN107491355A CN201710708007.2A CN201710708007A CN107491355A CN 107491355 A CN107491355 A CN 107491355A CN 201710708007 A CN201710708007 A CN 201710708007A CN 107491355 A CN107491355 A CN 107491355A
Authority
CN
China
Prior art keywords
data
memory
processed
write
shared memory
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.)
Pending
Application number
CN201710708007.2A
Other languages
Chinese (zh)
Inventor
解双福
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Inspur Business System Co Ltd
Original Assignee
Shandong Inspur Business System Co Ltd
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 Shandong Inspur Business System Co Ltd filed Critical Shandong Inspur Business System Co Ltd
Priority to CN201710708007.2A priority Critical patent/CN107491355A/en
Publication of CN107491355A publication Critical patent/CN107491355A/en
Pending legal-status Critical Current

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/542Event management; Broadcasting; Multicasting; Notifications
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • 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

Landscapes

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

Abstract

The invention provides funcall method and device, this method between a kind of process based on shared drive to include:Pre-set service processes and client process;Start the service processes, and using the service processes started, create shared drive;The shared drive is monitored using the monitoring thread in the service processes;Data processing request is received, the identification information of pending data and processing function to be called is carried in the data processing request;The pending data is stored in the shared drive using the client process;When the monitoring thread, which monitors, has data deposit in the shared drive, the object function corresponding with the identification information is called;Using the object function of calling, the pending data stored in the shared drive is handled, and exports the data after processing.This programme can reduce the performance consumption of system, be especially suitable for the embedded device of limited capacity.

Description

Shared memory-based interprocess function calling method and device
Technical Field
The invention relates to the technical field of computers, in particular to a shared memory-based interprocess function calling method and device.
Background
The processes are basic units for resource allocation and scheduling of the system, and some functions of other processes need to be utilized during running of each process, so function calling among the processes is very important.
Currently, each process is generally registered at a different server before running. When a function is called during the process running, corresponding registration information needs to be acquired from a server corresponding to the process to be called, and then the related function of the process to be called is called according to the acquired registration information.
In the process, registration information of the process to be called needs to be acquired from different servers, that is, a large amount of inter-process information is transmitted, which results in large performance consumption of the system.
Disclosure of Invention
The embodiment of the invention provides a shared memory-based interprocess function calling method and device, which can reduce the performance consumption of a system.
In a first aspect, an embodiment of the present invention provides a shared memory-based inter-process function calling method, including:
presetting a service process and a client process;
starting the service process, and creating a shared memory by using the started service process;
monitoring the shared memory by utilizing a monitoring thread in the service process;
receiving a data processing request, wherein the data processing request carries data to be processed and identification information of a processing function to be called;
storing the data to be processed into the shared memory by using the client process;
when the monitoring thread monitors that data are stored in the shared memory, calling a target function corresponding to the identification information;
and processing the data to be processed stored in the shared memory by using the called target function, and outputting the processed data.
Preferably, the first and second electrodes are formed of a metal,
after the service process is started and a shared memory is created by using the started service process, the method further includes:
initializing a storage semaphore and a derivation semaphore in the shared memory by using the service process, and dividing the shared memory into a write-in memory and an output memory; wherein the stored semaphore corresponds to the write memory, and the derived semaphore corresponds to the output memory;
the storing the data to be processed into the shared memory by using the client process includes:
when the data processing request is received, opening the storage semaphore and storing the data to be processed into the write-in memory by using the client process;
when the monitoring thread monitors that data are stored in the shared memory, calling a target function corresponding to the identification information includes:
when the monitoring thread monitors that the write-in memory has data to be stored, reading the data to be processed in the write-in memory and calling the target function;
the processing the to-be-processed data stored in the shared memory by using the called target function, and outputting the processed data, includes:
in the write-in memory, the target function is utilized to process the data to be processed;
and opening the derived semaphore, and writing the processed data into the output memory by using the monitoring thread.
Preferably, the first and second electrodes are formed of a metal,
the storing the data to be processed into the write-in memory by using the client process includes:
serializing the data to be processed by utilizing the client process, and writing the serialized data to be processed into the write-in memory;
when the monitoring thread monitors that the write-in memory has data to be stored, reading the data to be processed in the write-in memory and calling the target function, the method includes:
deserializing the read data to be processed by using the monitoring thread and calling the target function;
the writing the processed data into the output memory by using the monitoring thread includes:
serializing the processed data by using the monitoring thread, and writing the serialized processed data into the output memory.
Preferably, the first and second electrodes are formed of a metal,
before the storing the data to be processed into the write-in memory by using the client process, further comprising:
monitoring a transmission control protocol by utilizing a network thread in the service process;
and when the network thread monitors that the data processing request is transmitted through the transmission control protocol, receiving the data processing request by using the network thread, and executing the storage of the data to be processed in the write-in memory by using the client process.
Preferably, the first and second electrodes are formed of a metal,
after the writing the processed data into the output memory by using the monitoring thread, further comprising:
and outputting the processed data in the output memory through the transmission control protocol by using the network thread, and executing the monitoring of the transmission control protocol by using the network thread.
Preferably, the first and second electrodes are formed of a metal,
further comprising: setting a message broadcasting process;
after creating a shared memory by using the started service process, the method further includes:
determining at least one message monitoring thread corresponding to the service process;
registering the at least one message monitoring thread in the shared memory, and storing registration information corresponding to the at least one message monitoring thread by using the shared memory;
when the client process determines that the data processing request further carries a broadcast message, writing the broadcast message into the shared memory;
and respectively sending the broadcast message to each message monitoring thread by using the message broadcasting process according to the registration information, and broadcasting the broadcast message by using the monitoring thread.
In a second aspect, an embodiment of the present invention provides a shared memory-based inter-process function calling apparatus, including: the device comprises a setting unit, a processing unit and a calling unit; wherein,
the setting unit is used for presetting a service process and a client process; starting the service process, and creating a shared memory by using the started service process; monitoring the shared memory by utilizing a monitoring thread in the service process;
the processing unit is used for receiving a data processing request, wherein the data processing request carries data to be processed and identification information of a processing function to be called; storing the data to be processed into the shared memory by using the client process;
the calling unit is used for calling a target function corresponding to the identification information when the monitoring thread monitors that data are stored in the shared memory; and processing the data to be processed stored in the shared memory by using the called target function, and outputting the processed data.
Preferably, the first and second electrodes are formed of a metal,
the setting unit is further configured to initialize a storage semaphore and a derivation semaphore in the shared memory by using the service process, and divide the shared memory into a write memory and an output memory; wherein the stored semaphore corresponds to the write memory, and the derived semaphore corresponds to the output memory;
the processing unit is used for opening the storing semaphore when receiving the data processing request, and storing the data to be processed into the write-in memory by using the client process;
the calling unit is used for reading the data to be processed in the write-in memory and calling the target function when the monitoring thread monitors that the write-in memory has data to store; in the write-in memory, the target function is utilized to process the data to be processed; and opening the derived semaphore, and writing the processed data into the output memory by using the monitoring thread.
Preferably, the first and second electrodes are formed of a metal,
the processing unit is used for serializing the data to be processed by utilizing the client process and writing the serialized data to be processed into the write-in memory;
the calling unit is configured to perform deserialization on the read to-be-processed data by using the monitoring thread, call the target function, serialize the processed data, and write the serialized processed data into the output memory.
Preferably, the first and second electrodes are formed of a metal,
the processing unit is used for monitoring a transmission control protocol by utilizing a network thread in the service process; and when the network thread monitors that the data processing request is transmitted through the transmission control protocol, receiving the data processing request by using the network thread, and executing the storage of the data to be processed in the write-in memory by using the client process.
The embodiment of the invention provides a shared memory-based inter-process function calling method and device, wherein a shared memory is created by using a service process, the created shared memory is monitored by using a monitoring thread, and when a data processing memory is received, to-be-processed data is written into the shared memory by using a client process. And when the monitoring thread monitors that the shared memory has data to be stored, calling a corresponding target function to process the data to be processed by using the target function and outputting the processed data. Therefore, communication support among the processes is provided based on the shared memory technology, the method is simple and efficient, and the performance consumption of the system is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flowchart of a shared-memory-based inter-process function calling method according to an embodiment of the present invention;
fig. 2 is a flowchart of a shared-memory-based inter-process function calling method according to another embodiment of the present invention;
fig. 3 is a schematic structural diagram of a shared-memory-based inter-process function call apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer and more complete, the technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention, and based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without creative efforts belong to the scope of the present invention.
As shown in fig. 1, an embodiment of the present invention provides a shared memory-based inter-process function calling method, where the method includes the following steps:
step 101: presetting a service process and a client process;
step 102: starting the service process, and creating a shared memory by using the started service process;
step 103: monitoring the shared memory by utilizing a monitoring thread in the service process;
step 104: receiving a data processing request, wherein the data processing request carries data to be processed and identification information of a processing function to be called;
step 105: storing the data to be processed into the shared memory by using the client process;
step 106: when the monitoring thread monitors that data are stored in the shared memory, calling a target function corresponding to the identification information;
step 107: and processing the data to be processed stored in the shared memory by using the called target function, and outputting the processed data.
In the above embodiment, the shared memory is created by using the service process, the created shared memory is monitored by using the monitoring thread, and when the data processing memory is received, the to-be-processed data is written into the shared memory by using the client process. And when the monitoring thread monitors that the shared memory has data to be stored, calling a corresponding target function to process the data to be processed by using the target function and outputting the processed data. Therefore, communication support among the processes is provided based on the shared memory technology, the method is simple and efficient, and the performance consumption of the system is reduced.
In an embodiment of the present invention, after step 102, the method may further include:
initializing a storage semaphore and a derivation semaphore in the shared memory by using the service process, and dividing the shared memory into a write-in memory and an output memory; wherein the stored semaphore corresponds to the write memory, and the derived semaphore corresponds to the output memory;
specific embodiments of step 105 may include:
when the data processing request is received, opening the storage semaphore and storing the data to be processed into the write-in memory by using the client process;
embodiments of step 106 may include:
when the monitoring thread monitors that the write-in memory has data to be stored, reading the data to be processed in the write-in memory and calling the target function;
specific embodiments of step 107 may include:
in the write-in memory, the target function is utilized to process the data to be processed;
and opening the derived semaphore, and writing the processed data into the output memory by using the monitoring thread.
In the embodiment, the shared memory is divided into a write memory (in part) and an output memory (out part), and a storage semaphore (sem _ in) and a derived semaphore (sem _ out) are initialized in the shared memory, wherein data write and read in part are synchronized by the sem _ in semaphore and data output in out part is synchronized by the sem _ out semaphore. After receiving a data processing request, opening a sem _ in semaphore, writing data to be processed into an in part in a shared memory by using a client process, monitoring that the written memory has data to store by using a monitoring thread at the moment, reading corresponding data to be processed from the written memory by using the monitoring thread, calling a corresponding target function to process the data to be processed, releasing the sem _ in semaphore after the reading is finished, opening a sem _ out semaphore, and writing the processed data into an out part by using the monitoring thread to output the processed data. Therefore, the shared memory is divided into an in part and an out part, and the corresponding sem _ in semaphore and the sem _ out semaphore are set, so that data writing, reading and outputting can be performed in different parts of the shared memory according to the corresponding semaphores in order, the data processing efficiency is improved, and the performance consumption of the system is further reduced.
In an embodiment of the present invention, the storing the to-be-processed data into the write-in memory by using the client process includes:
serializing the data to be processed by utilizing the client process, and writing the serialized data to be processed into the write-in memory;
when the monitoring thread monitors that the write-in memory has data to be stored, reading the data to be processed in the write-in memory and calling the target function, the method includes:
deserializing the read data to be processed by using the monitoring thread and calling the target function;
the writing the processed data into the output memory by using the monitoring thread includes:
serializing the processed data by using the monitoring thread, and writing the serialized processed data into the output memory.
Here, when the client process writes data into the in part, the data is serialized first, and then when the monitoring thread reads data from the in part, the data is deserialized in sequence. After the data to be processed is processed by the called target function, the data returned by the function is serialized, and then the out part is returned. Therefore, the data in the shared memory are the data after the serial number, which is beneficial to the transmission of the data, thereby further reducing the performance consumption of the system.
In an embodiment of the present invention, before the storing the to-be-processed data into the write memory by using the client process, the method may further include:
monitoring a transmission control protocol by utilizing a network thread in the service process;
and when the network thread monitors that the data processing request is transmitted through the transmission control protocol, receiving the data processing request by using the network thread, and executing the storage of the data to be processed in the write-in memory by using the client process.
Here, when the network thread monitors that the data processing request is transmitted through a Transmission Control Protocol (TCP), it is described that the data processing request is transmitted through a remote location, and the network thread receives the data processing request, that is, a function of receiving the remote request by the network thread is started.
In an embodiment of the present invention, after the writing the processed data into the output memory by using the monitoring thread, the method may further include:
and outputting the processed data in the output memory through the transmission control protocol by using the network thread, and executing the monitoring of the transmission control protocol by using the network thread.
When the network thread receives a remote request, the received request data is written into the in part shared memory, the monitoring thread is waited to return the processed data to the out part, then the processed data in the out part is returned through the TCP, and then the connection is closed and the TCP is continuously monitored. Therefore, the remote function of the network thread is realized in a simple and efficient mode, and the performance consumption of the system is further reduced. By the scheme, the system can realize interaction among processes through small overhead and support remote calling, and is particularly suitable for embedded devices with limited performance and remote control of the devices.
In an embodiment of the present invention, the method may further include: setting a message broadcasting process;
after step 101, it may further include:
determining at least one message monitoring thread corresponding to the service process;
registering the at least one message monitoring thread in the shared memory, and storing registration information corresponding to the at least one message monitoring thread by using the shared memory;
when the client process determines that the data processing request further carries a broadcast message, writing the broadcast message into the shared memory;
and respectively sending the broadcast message to each message monitoring thread by using the message broadcasting process according to the registration information, and broadcasting the broadcast message by using the monitoring thread.
After the shared memory is created, the registration information of each message monitoring thread corresponding to the service process is stored through the shared memory, then the shared memory can be maintained through the message broadcasting process, when the monitoring thread monitors that the data written into the shared memory contains the broadcast message, namely the data written into the client process contains the broadcast message, the client process needs to send the broadcast message, at the moment, the message broadcasting process is called, the broadcast message is respectively sent to each message monitoring thread, and the message monitoring process is utilized to broadcast the broadcast message. Therefore, the broadcasting function of the process is realized, the method is simple and efficient, and the energy absorption consumption of the system is reduced.
As shown in fig. 2, an embodiment of the present invention provides a shared memory-based inter-process function calling method, where the method includes the following steps:
step 201: setting a service process and a client process.
Step 202: and starting the service process, creating a shared memory by using the started service process, and monitoring the shared memory by using a monitoring thread in the service process.
Step 203: initializing a storage semaphore and a derivation semaphore in the shared memory by using the service process, and dividing the shared memory into a write-in memory and an output memory; the storage semaphore corresponds to the write memory, and the derivation semaphore corresponds to the output memory.
Here, the shared memory is divided into a write memory (in portion) and an output memory (out portion), and a store semaphore (sem _ in) and a derive semaphore (sem _ out) are initialized in the shared memory, wherein data write and read in the in portion are synchronized by the sem _ in semaphore and data output in the out portion is synchronized by the sem _ out semaphore.
Step 204: and monitoring the TCP by using a network thread in the service process, opening the storage semaphore when the network thread monitors that a data request is received through the TCP, serializing the data to be processed carried in the data processing request by using the client process, and storing the serialized data to be processed into the write-in memory.
When the network thread monitors that the data processing request is transmitted through the TCP, the data processing request is transmitted through the remote transmission, and the data processing request is received through the network thread, namely, a function of receiving the remote request through the network thread is started. And after receiving the data processing request, opening sem _ in semaphore and writing the data to be processed into the in part in the shared memory by using the client process.
Step 205: and monitoring the shared memory by using a monitoring thread, reading the to-be-processed data in the written-in memory when the monitoring thread monitors that the written-in memory has data to be stored, performing deserialization on the read to-be-processed data, and calling a target function corresponding to the identification information of the to-be-called processing function carried by the data processing request.
Step 206: and processing the data to be processed by using a target function in the write-in memory, and serializing the processed data.
Step 207: and opening a derived semaphore, and writing the serialized processed data into the output memory by using the monitoring thread.
And the monitoring thread monitors that the write-in memory has data to store, reads corresponding data to be processed from the write-in memory, calls a corresponding target function to process the data to be processed, releases the sem _ in semaphore after reading is finished, opens the sem _ out semaphore, and writes the processed data into the out part by using the monitoring thread so as to output the processed data. And carrying out serialization and deserialization on the data to facilitate the transmission of the data.
Step 208: and outputting the processed data in the output memory through a TCP by utilizing the network thread.
In the above embodiment, the shared memory is created by using the service process, the created shared memory is monitored by using the monitoring thread, and when the data processing memory is received, the to-be-processed data is written into the shared memory by using the client process. And when the monitoring thread monitors that the shared memory has data to be stored, calling a corresponding target function to process the data to be processed by using the target function and outputting the processed data. Therefore, communication support among the processes is provided based on the shared memory technology, the method is simple and efficient, and the performance consumption of the system is reduced.
As shown in fig. 3, an embodiment of the present invention provides a shared memory-based inter-process function calling apparatus, including: a setting unit 301, a processing unit 302 and a calling unit 303; wherein,
the setting unit 301 is configured to preset a service process and a client process; starting the service process, and creating a shared memory by using the started service process; monitoring the shared memory by utilizing a monitoring thread in the service process;
the processing unit 302 is configured to receive a data processing request, where the data processing request carries identification information of data to be processed and a processing function to be called; storing the data to be processed into the shared memory by using the client process;
the calling unit 303 is configured to call a target function corresponding to the identification information when the monitoring thread monitors that data is stored in the shared memory; and processing the data to be processed stored in the shared memory by using the called target function, and outputting the processed data.
In an embodiment of the present invention, the setting unit 301 is further configured to initialize a storage semaphore and a derivation semaphore in the shared memory by using the service process, and divide the shared memory into a write memory and an output memory; wherein the stored semaphore corresponds to the write memory, and the derived semaphore corresponds to the output memory;
the processing unit 302 is configured to open the storage semaphore when receiving the data processing request, and store the to-be-processed data in the write memory by using the client process;
the calling unit 303 is configured to read the to-be-processed data in the write-in memory and call the target function when the monitoring thread monitors that the write-in memory has data to store; in the write-in memory, the target function is utilized to process the data to be processed; and opening the derived semaphore, and writing the processed data into the output memory by using the monitoring thread.
In an embodiment of the present invention, the processing unit 302 is configured to serialize the to-be-processed data by using the client process, and write the serialized to-be-processed data into the write-in memory;
the calling unit 303 is configured to perform deserialization on the read to-be-processed data by using the monitoring thread, call the target function, serialize the processed data, and write the serialized processed data into the output memory.
In an embodiment of the present invention, the processing unit 302 is configured to monitor a transmission control protocol by using a network thread in the service process; and when the network thread monitors that the data processing request is transmitted through the transmission control protocol, receiving the data processing request by using the network thread, and executing the storage of the data to be processed in the write-in memory by using the client process.
Because the information interaction, execution process, and other contents between the units in the device are based on the same concept as the method embodiment of the present invention, specific contents may refer to the description in the method embodiment of the present invention, and are not described herein again.
The invention also provides a readable medium comprising executable instructions which, when executed by a processor of a storage controller, cause the storage controller to perform a method as provided by any of the above-described embodiments of the invention.
In addition, the present invention also provides a memory controller comprising: a processor, a memory, and a bus; the memory is used for storing execution instructions, the processor is connected with the memory through the bus, and when the storage controller runs, the processor executes the execution instructions stored in the memory, so that the storage controller executes the method provided by any one of the above embodiments of the invention.
In summary, the embodiments of the present invention have at least the following advantages:
1. in the embodiment of the invention, the shared memory is created by using the service process, the created shared memory is monitored by using the monitoring thread in the service process, and when the data processing memory is received, the data to be processed is written into the shared memory by using the client process. And when the monitoring thread monitors that the shared memory has data to be stored, calling a corresponding target function to process the data to be processed by using the target function and outputting the processed data. Therefore, communication support among the processes is provided based on the shared memory technology, the method is simple and efficient, and the performance consumption of the system is reduced.
2. In the embodiment of the invention, the shared memory is divided into a write memory and an output memory, and a storage semaphore and a derivation semaphore are initialized in the shared memory, wherein data write-in and read-out of the write memory are synchronized through the storage semaphore, and data output of the output memory is synchronized through the derivation semaphore. After receiving a data processing request, opening a storage semaphore, writing data to be processed into a write-in memory in a shared memory by using a client process, monitoring the write-in memory by a monitoring thread at the moment, reading corresponding data to be processed from the write-in memory, calling a corresponding target function to process the data to be processed, releasing the storage semaphore after reading is completed, opening a derived semaphore, and writing the processed data into an output memory by using the monitoring thread to output the processed data. Therefore, data writing, reading and outputting can be orderly carried out in different parts of the shared memory according to corresponding semaphore, and the performance consumption of the system is further reduced while the data processing efficiency is improved.
3. In the embodiment of the invention, when the client process writes data into the write-in memory, the data is serialized first, and then when the monitoring thread reads the data from the write-in memory, the data is deserialized in sequence. After the data to be processed is processed by the called target function, the data returned by the function is serialized and returned to the output memory. Therefore, the data in the shared memory are the data after the serial number, which is beneficial to the transmission of the data, thereby further reducing the performance consumption of the system.
4. In the embodiment of the present invention, when the network thread monitors that the data processing request is transmitted through the TCP, the network thread receives the data processing request, that is, the network thread is started to receive the remote request. When the network thread receives the remote request, the received request data is written into the memory, the monitoring thread is waited to return the processed data to the output memory, then the processed data in the output memory is returned through the TCP, and then the connection is closed and the TCP is continuously monitored. Therefore, the remote function of the network thread is realized in a simple and efficient mode, and the performance consumption of the system is further reduced.
5. In the embodiment of the invention, the registration information of each message monitoring thread corresponding to the service process is stored through the shared memory, then the shared memory can be maintained through the message broadcasting process, when the monitoring thread monitors that the data written into the shared memory contains the broadcast message, the message broadcasting process is called, and the broadcast message is respectively sent to each message monitoring thread so as to broadcast the broadcast message by using the message monitoring process. Therefore, the broadcasting function of the process is realized, the method is simple and efficient, and the energy absorption consumption of the system is reduced.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a" does not exclude the presence of other similar elements in a process, method, article, or apparatus that comprises the element.
Those of ordinary skill in the art will understand that: all or part of the steps for realizing the method embodiments can be completed by hardware related to program instructions, the program can be stored in a computer readable storage medium, and the program executes the steps comprising the method embodiments when executed; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it is to be noted that: the above description is only a preferred embodiment of the present invention, and is only used to illustrate the technical solutions of the present invention, and not to limit the protection scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A shared memory-based interprocess function calling method is characterized by comprising the following steps:
presetting a service process and a client process;
starting the service process, and creating a shared memory by using the started service process;
monitoring the shared memory by utilizing a monitoring thread in the service process;
receiving a data processing request, wherein the data processing request carries data to be processed and identification information of a processing function to be called;
storing the data to be processed into the shared memory by using the client process;
when the monitoring thread monitors that data are stored in the shared memory, calling a target function corresponding to the identification information;
and processing the data to be processed stored in the shared memory by using the called target function, and outputting the processed data.
2. The method of claim 1,
after the service process is started and a shared memory is created by using the started service process, the method further includes:
initializing a storage semaphore and a derivation semaphore in the shared memory by using the service process, and dividing the shared memory into a write-in memory and an output memory; wherein the stored semaphore corresponds to the write memory, and the derived semaphore corresponds to the output memory;
the storing the data to be processed into the shared memory by using the client process includes:
when the data processing request is received, opening the storage semaphore and storing the data to be processed into the write-in memory by using the client process;
when the monitoring thread monitors that data are stored in the shared memory, calling a target function corresponding to the identification information includes:
when the monitoring thread monitors that the write-in memory has data to be stored, reading the data to be processed in the write-in memory and calling the target function;
the processing the to-be-processed data stored in the shared memory by using the called target function, and outputting the processed data, includes:
in the write-in memory, the target function is utilized to process the data to be processed;
and opening the derived semaphore, and writing the processed data into the output memory by using the monitoring thread.
3. The method of claim 2,
the storing the data to be processed into the write-in memory by using the client process includes:
serializing the data to be processed by utilizing the client process, and writing the serialized data to be processed into the write-in memory;
when the monitoring thread monitors that the write-in memory has data to be stored, reading the data to be processed in the write-in memory and calling the target function, the method includes:
deserializing the read data to be processed by using the monitoring thread and calling the target function;
the writing the processed data into the output memory by using the monitoring thread includes:
serializing the processed data by using the monitoring thread, and writing the serialized processed data into the output memory.
4. The method of claim 2,
before the storing the data to be processed into the write-in memory by using the client process, further comprising:
monitoring a transmission control protocol by utilizing a network thread in the service process;
and when the network thread monitors that the data processing request is transmitted through the transmission control protocol, receiving the data processing request by using the network thread, and executing the storage of the data to be processed in the write-in memory by using the client process.
5. The method of claim 4,
after the writing the processed data into the output memory by using the monitoring thread, further comprising:
and outputting the processed data in the output memory through the transmission control protocol by using the network thread, and executing the monitoring of the transmission control protocol by using the network thread.
6. The method of claim 1,
further comprising: setting a message broadcasting process;
after creating a shared memory by using the started service process, the method further includes:
determining at least one message monitoring thread corresponding to the service process;
registering the at least one message monitoring thread in the shared memory, and storing registration information corresponding to the at least one message monitoring thread by using the shared memory;
when the client process determines that the data processing request further carries a broadcast message, writing the broadcast message into the shared memory;
and respectively sending the broadcast message to each message monitoring thread by using the message broadcasting process according to the registration information, and broadcasting the broadcast message by using the monitoring thread.
7. An interprocess function calling device based on shared memory is characterized in that the device comprises: the device comprises a setting unit, a processing unit and a calling unit; wherein,
the setting unit is used for presetting a service process and a client process; starting the service process, and creating a shared memory by using the started service process; monitoring the shared memory by utilizing a monitoring thread in the service process;
the processing unit is used for receiving a data processing request, wherein the data processing request carries data to be processed and identification information of a processing function to be called; storing the data to be processed into the shared memory by using the client process;
the calling unit is used for calling a target function corresponding to the identification information when the monitoring thread monitors that data are stored in the shared memory; and processing the data to be processed stored in the shared memory by using the called target function, and outputting the processed data.
8. The apparatus of claim 7,
the setting unit is further configured to initialize a storage semaphore and a derivation semaphore in the shared memory by using the service process, and divide the shared memory into a write memory and an output memory; wherein the stored semaphore corresponds to the write memory, and the derived semaphore corresponds to the output memory;
the processing unit is used for opening the storing semaphore when receiving the data processing request, and storing the data to be processed into the write-in memory by using the client process;
the calling unit is used for reading the data to be processed in the write-in memory and calling the target function when the monitoring thread monitors that the write-in memory has data to store; in the write-in memory, the target function is utilized to process the data to be processed; and opening the derived semaphore, and writing the processed data into the output memory by using the monitoring thread.
9. The apparatus of claim 8,
the processing unit is used for serializing the data to be processed by utilizing the client process and writing the serialized data to be processed into the write-in memory;
the calling unit is configured to perform deserialization on the read to-be-processed data by using the monitoring thread, call the target function, serialize the processed data, and write the serialized processed data into the output memory.
10. The apparatus of claim 8,
the processing unit is used for monitoring a transmission control protocol by utilizing a network thread in the service process; and when the network thread monitors that the data processing request is transmitted through the transmission control protocol, receiving the data processing request by using the network thread, and executing the storage of the data to be processed in the write-in memory by using the client process.
CN201710708007.2A 2017-08-17 2017-08-17 Funcall method and device between a kind of process based on shared drive Pending CN107491355A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710708007.2A CN107491355A (en) 2017-08-17 2017-08-17 Funcall method and device between a kind of process based on shared drive

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710708007.2A CN107491355A (en) 2017-08-17 2017-08-17 Funcall method and device between a kind of process based on shared drive

Publications (1)

Publication Number Publication Date
CN107491355A true CN107491355A (en) 2017-12-19

Family

ID=60646324

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710708007.2A Pending CN107491355A (en) 2017-08-17 2017-08-17 Funcall method and device between a kind of process based on shared drive

Country Status (1)

Country Link
CN (1) CN107491355A (en)

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108038011A (en) * 2017-12-28 2018-05-15 深圳市富途网络科技有限公司 A kind of method for realizing SNS multiprocess communications
CN108566424A (en) * 2018-04-11 2018-09-21 深圳市腾讯网络信息技术有限公司 Dispatching method, device and system based on server resource consumption forecast
CN109688225A (en) * 2019-01-08 2019-04-26 网易(杭州)网络有限公司 A kind of communication means and device
CN110059004A (en) * 2019-03-21 2019-07-26 深圳市腾讯信息技术有限公司 A kind of method, apparatus, equipment and the medium of application test
CN110377356A (en) * 2019-06-14 2019-10-25 北京奇艺世纪科技有限公司 Task processing method, device, system and computer readable storage medium
CN110633145A (en) * 2019-08-27 2019-12-31 苏宁云计算有限公司 Real-time communication method and device in distributed system and distributed system
CN110928703A (en) * 2018-09-20 2020-03-27 北京君正集成电路股份有限公司 Multi-process communication registration method and device
CN110928701A (en) * 2018-09-20 2020-03-27 北京君正集成电路股份有限公司 Communication registration method and device
CN111181999A (en) * 2020-01-09 2020-05-19 山东超越数控电子股份有限公司 Stable, efficient and easy-to-use communication method
CN111352743A (en) * 2018-12-24 2020-06-30 北京新媒传信科技有限公司 Process communication method and device
CN111597089A (en) * 2020-05-18 2020-08-28 广州锦行网络科技有限公司 Linux system call event acquisition and caching device and method
CN111699479A (en) * 2019-06-20 2020-09-22 深圳市大疆创新科技有限公司 Log processing method, log processing device and computer-readable storage medium
CN112114983A (en) * 2020-09-14 2020-12-22 深圳花儿数据技术有限公司 Communication method, device and equipment based on shared memory
CN112199205A (en) * 2019-07-08 2021-01-08 南京工程学院 Program communication method between heterogeneous platforms
CN112749023A (en) * 2019-10-30 2021-05-04 阿里巴巴集团控股有限公司 Information processing method, device, equipment and system
CN113365046A (en) * 2021-04-30 2021-09-07 厦门立林科技有限公司 High-performance audio and video data test sending method, application and storage medium thereof
CN114501376A (en) * 2021-12-24 2022-05-13 中汽创智科技有限公司 Vehicle-mounted communication method, device, equipment and storage medium
CN114691051A (en) * 2022-05-30 2022-07-01 恒生电子股份有限公司 Data processing method and device
CN116069246A (en) * 2022-11-30 2023-05-05 北京天融信网络安全技术有限公司 Data read-write method and system for virtual machine
CN116126526A (en) * 2022-12-29 2023-05-16 苏州华太电子技术股份有限公司 Method, device, electronic equipment and storage medium for calculating override function
CN116627682A (en) * 2023-07-25 2023-08-22 菲特(天津)检测技术有限公司 Remote industrial information detection method and device based on shared memory

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101039333A (en) * 2007-04-12 2007-09-19 华为技术有限公司 Method and apparatus for dynamically adjusting bandwidth of advanced data link control channel
CN102340489A (en) * 2010-07-20 2012-02-01 阿里巴巴集团控股有限公司 Data transmission method between servers and servers
CN102426536A (en) * 2011-10-26 2012-04-25 深圳市亚特尔科技有限公司 Multitask data communication implementation method and system
CN102567097A (en) * 2011-12-29 2012-07-11 Tcl王牌电器(惠州)有限公司 Method and terminal for downloading multiple tasks
CN103645863A (en) * 2013-12-12 2014-03-19 北京奇虎科技有限公司 Data reading and writing-in methods and systems of shared memory
CN104102550A (en) * 2013-04-12 2014-10-15 南京南瑞继保电气有限公司 Method for communicating among multiple host machine processes
CN104899089A (en) * 2015-05-25 2015-09-09 常州北大众志网络计算机有限公司 Task scheduling method in heterogeneous multi-core architecture
CN105721473A (en) * 2016-02-24 2016-06-29 锐达互动科技股份有限公司 WEB side remote invoking optimizing method and system

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101039333A (en) * 2007-04-12 2007-09-19 华为技术有限公司 Method and apparatus for dynamically adjusting bandwidth of advanced data link control channel
CN102340489A (en) * 2010-07-20 2012-02-01 阿里巴巴集团控股有限公司 Data transmission method between servers and servers
CN102426536A (en) * 2011-10-26 2012-04-25 深圳市亚特尔科技有限公司 Multitask data communication implementation method and system
CN102567097A (en) * 2011-12-29 2012-07-11 Tcl王牌电器(惠州)有限公司 Method and terminal for downloading multiple tasks
CN104102550A (en) * 2013-04-12 2014-10-15 南京南瑞继保电气有限公司 Method for communicating among multiple host machine processes
CN103645863A (en) * 2013-12-12 2014-03-19 北京奇虎科技有限公司 Data reading and writing-in methods and systems of shared memory
CN104899089A (en) * 2015-05-25 2015-09-09 常州北大众志网络计算机有限公司 Task scheduling method in heterogeneous multi-core architecture
CN105721473A (en) * 2016-02-24 2016-06-29 锐达互动科技股份有限公司 WEB side remote invoking optimizing method and system

Cited By (35)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108038011A (en) * 2017-12-28 2018-05-15 深圳市富途网络科技有限公司 A kind of method for realizing SNS multiprocess communications
CN108566424A (en) * 2018-04-11 2018-09-21 深圳市腾讯网络信息技术有限公司 Dispatching method, device and system based on server resource consumption forecast
CN108566424B (en) * 2018-04-11 2021-04-20 深圳市腾讯网络信息技术有限公司 Scheduling method, device and system based on server resource consumption prediction
CN110928703B (en) * 2018-09-20 2023-02-21 北京君正集成电路股份有限公司 Multi-process communication registration method and device
CN110928703A (en) * 2018-09-20 2020-03-27 北京君正集成电路股份有限公司 Multi-process communication registration method and device
CN110928701A (en) * 2018-09-20 2020-03-27 北京君正集成电路股份有限公司 Communication registration method and device
CN111352743B (en) * 2018-12-24 2023-12-01 北京新媒传信科技有限公司 Process communication method and device
CN111352743A (en) * 2018-12-24 2020-06-30 北京新媒传信科技有限公司 Process communication method and device
CN109688225A (en) * 2019-01-08 2019-04-26 网易(杭州)网络有限公司 A kind of communication means and device
CN109688225B (en) * 2019-01-08 2021-11-16 网易(杭州)网络有限公司 Communication method and device
CN110059004A (en) * 2019-03-21 2019-07-26 深圳市腾讯信息技术有限公司 A kind of method, apparatus, equipment and the medium of application test
CN110377356A (en) * 2019-06-14 2019-10-25 北京奇艺世纪科技有限公司 Task processing method, device, system and computer readable storage medium
CN111699479A (en) * 2019-06-20 2020-09-22 深圳市大疆创新科技有限公司 Log processing method, log processing device and computer-readable storage medium
CN112199205A (en) * 2019-07-08 2021-01-08 南京工程学院 Program communication method between heterogeneous platforms
CN112199205B (en) * 2019-07-08 2023-10-27 南京工程学院 Program communication method between heterogeneous platforms
CN110633145B (en) * 2019-08-27 2023-03-31 苏宁云计算有限公司 Real-time communication method and device in distributed system and distributed system
CN110633145A (en) * 2019-08-27 2019-12-31 苏宁云计算有限公司 Real-time communication method and device in distributed system and distributed system
CN112749023A (en) * 2019-10-30 2021-05-04 阿里巴巴集团控股有限公司 Information processing method, device, equipment and system
CN112749023B (en) * 2019-10-30 2024-06-11 阿里巴巴集团控股有限公司 Information processing method, device, equipment and system
CN111181999A (en) * 2020-01-09 2020-05-19 山东超越数控电子股份有限公司 Stable, efficient and easy-to-use communication method
CN111597089B (en) * 2020-05-18 2020-12-18 广州锦行网络科技有限公司 Linux system call event acquisition and caching device and method
CN111597089A (en) * 2020-05-18 2020-08-28 广州锦行网络科技有限公司 Linux system call event acquisition and caching device and method
CN112114983B (en) * 2020-09-14 2022-04-19 深圳花儿数据技术有限公司 Communication method, device and equipment based on shared memory
CN112114983A (en) * 2020-09-14 2020-12-22 深圳花儿数据技术有限公司 Communication method, device and equipment based on shared memory
CN113365046B (en) * 2021-04-30 2023-08-01 厦门立林科技有限公司 High-performance audio and video data test transmitting method, application and storage medium thereof
CN113365046A (en) * 2021-04-30 2021-09-07 厦门立林科技有限公司 High-performance audio and video data test sending method, application and storage medium thereof
CN114501376A (en) * 2021-12-24 2022-05-13 中汽创智科技有限公司 Vehicle-mounted communication method, device, equipment and storage medium
CN114691051B (en) * 2022-05-30 2022-10-04 恒生电子股份有限公司 Data processing method and device
CN114691051A (en) * 2022-05-30 2022-07-01 恒生电子股份有限公司 Data processing method and device
CN116069246A (en) * 2022-11-30 2023-05-05 北京天融信网络安全技术有限公司 Data read-write method and system for virtual machine
CN116069246B (en) * 2022-11-30 2023-08-29 北京天融信网络安全技术有限公司 Data read-write method and system for virtual machine
CN116126526A (en) * 2022-12-29 2023-05-16 苏州华太电子技术股份有限公司 Method, device, electronic equipment and storage medium for calculating override function
CN116126526B (en) * 2022-12-29 2024-04-19 苏州华太电子技术股份有限公司 Method, device, electronic equipment and storage medium for calculating override function
CN116627682B (en) * 2023-07-25 2023-09-29 菲特(天津)检测技术有限公司 Remote industrial information detection method and device based on shared memory
CN116627682A (en) * 2023-07-25 2023-08-22 菲特(天津)检测技术有限公司 Remote industrial information detection method and device based on shared memory

Similar Documents

Publication Publication Date Title
CN107491355A (en) Funcall method and device between a kind of process based on shared drive
CN113452774B (en) Message pushing method, device, equipment and storage medium
WO2021000758A1 (en) Robotic resource task cycle management and control method and apparatus
US8984530B2 (en) Queued message dispatch
US10417062B2 (en) Method and apparatus of unloading out of memory processing flow to user space
CN107818012B (en) Data processing method and device and electronic equipment
US8132171B2 (en) Method of controlling thread access to a synchronization object
CN111352350B (en) Method and device for determining execution of smart home scene
CN110740145A (en) Message consumption method, device, storage medium and electronic equipment
CN111143053A (en) Scheduling method of timing task, server and storage device
CN110888726A (en) Multitask concurrent processing method and system
CN116795647A (en) Method, device, equipment and medium for managing and scheduling heterogeneous resources of database
US10523746B2 (en) Coexistence of a synchronous architecture and an asynchronous architecture in a server
CN115794317A (en) Processing method, device, equipment and medium based on virtual machine
CN109992415B (en) Container dispatching method and dispatching system
CN111177032A (en) Cache space application method, system, device and computer readable storage medium
CN103475520A (en) Service processing control method and device in distribution network
CN110944064B (en) Remote access control system, method, device and medium for embedded network
CN117573355A (en) Task processing method, device, electronic equipment and storage medium
CN114584618A (en) Information interaction method, device, equipment, storage medium and system
CN116361031A (en) Message transmission method, system, device, processor and electronic equipment
CN116760899A (en) Concurrent consumption method, device, equipment and medium based on Kafka
US12019909B2 (en) IO request pipeline processing device, method and system, and storage medium
CN116225702A (en) Heterogeneous acceleration task processing system, heterogeneous acceleration task processing method, heterogeneous acceleration task processing equipment and storage medium
CN115412500A (en) Asynchronous communication method, system, medium and device supporting load balancing strategy

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20171219