CN112445628A - Inter-process resource sharing method and device and electronic equipment - Google Patents

Inter-process resource sharing method and device and electronic equipment Download PDF

Info

Publication number
CN112445628A
CN112445628A CN201910829328.7A CN201910829328A CN112445628A CN 112445628 A CN112445628 A CN 112445628A CN 201910829328 A CN201910829328 A CN 201910829328A CN 112445628 A CN112445628 A CN 112445628A
Authority
CN
China
Prior art keywords
access
data
current process
handle
entry
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
Application number
CN201910829328.7A
Other languages
Chinese (zh)
Other versions
CN112445628B (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910829328.7A priority Critical patent/CN112445628B/en
Publication of CN112445628A publication Critical patent/CN112445628A/en
Application granted granted Critical
Publication of CN112445628B publication Critical patent/CN112445628B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Abstract

The disclosure mainly provides an inter-process resource sharing method and device and electronic equipment. The method comprises the following steps: the current process responds to the data access request to determine a data object to be accessed; the current process sends a first access entry sharing request based on the data object to a system service process so that the system service process distributes the first access entry sharing request to at least one prior process managed by the system service process; the current process acquires a data access handle of the data object according to a first shared access entry in at least one shared access entry returned by the at least one previous process, wherein the first shared access entry comprises the data access handle and first cooperative work information; and the current process accesses the data object by using the data access handle according to the first cooperative work information. The method for sharing the resources among the processes can improve the efficiency of the multiple dependent processes for carrying out the cooperative access on the same data object.

Description

Inter-process resource sharing method and device and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an inter-process resource sharing method and apparatus, and an electronic device.
Background
In the related Android technology, when accessing a data object, a process needs to initiate a data access request to the data object through a contentresolution and a system service AMS (dynamic management service), where the AMS runs in a system _ server service process, is a core service for managing Android components, and is responsible for starting, switching, scheduling four major components in a system and managing and scheduling application processes. The AMS returns an IContentProvider proxy interface after receiving the data access request, so that the process obtains an access entry Cursor (a Cursor is a method for processing data in the Android system) capable of accessing the data object through the proxy interface, and the Cursor can advance or browse the data in the result set one or more lines at a time in order to view or process the data in the result set.
When a plurality of processes need to access the same data object in a mutual cooperation mode, namely when a plurality of processes have mutual dependency relationship among access operations of the same data object, each process needs to access the data object through a single Cursor because the Cursor cannot transfer across the processes, and data access information sharing among the processes is realized by establishing a data synchronization protocol when the processes need to perform cooperation operations such as sharing access position information and the like. Because the operation modes of the data objects are various and cannot form a unified specification, the data synchronization protocol is different along with different requirements, and the dependence on interprocess communication cost is higher.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The embodiment of the disclosure provides a method and a device for resource sharing among processes and electronic equipment, which are used for overcoming the problems of high communication cost and low cooperation efficiency when processes are depended to access the same data object due to limitations and defects of related technologies at least to a certain extent.
According to a first aspect of the embodiments of the present disclosure, there is provided an inter-process resource sharing method, including: the current process responds to the data access request to determine a data object to be accessed; the current process sends a first access entry sharing request based on the data object to a system service process so that the system service process distributes the first access entry sharing request to at least one prior process managed by the system service process; the current process acquires a data access handle of the data object according to a first shared access entry in at least one shared access entry returned by the at least one previous process, wherein the first shared access entry comprises the data access handle and first cooperative work information; and the current process accesses the data object by using the data access handle according to the first cooperative work information.
In an exemplary embodiment of the present disclosure, further comprising:
and if the current process does not receive the at least one sharing type access entry within the preset time, acquiring the access entry of the data object, further acquiring a data access handle of the data object through the access entry, and accessing the data object by using the data access handle.
In an exemplary embodiment of the present disclosure, further comprising:
the current process responds to a second access entry sharing request from a subsequent process, and second cooperative work information sent to the subsequent process is determined; the current process encapsulates the data access handle and the second cooperative work information according to a preset mode to form a second shared access entry; the current process passes the second shared access entry to the subsequent process to facilitate the subsequent process accessing the data object through the second shared access entry using the data access handle.
In an exemplary embodiment of the present disclosure, further comprising:
the current process responds to a second access entry sharing request from a subsequent process, and second cooperative work information sent to the subsequent process is determined; the current process encapsulates the data access handle, the second cooperative work information and the communication interface of the current process according to a preset mode to form a third shared access entrance; after the current process transmits the shared access interface to the subsequent process, responding to a connection establishment request sent by the subsequent process according to the communication interface, and establishing a communication channel for connecting the subsequent process; the current process acquires third cooperative work information of the subsequent process through the communication channel; and the current process accesses the data object by using the data access handle according to the third cooperative work information.
In an exemplary embodiment of the disclosure, the determining the second cooperative work information sent to the subsequent process includes: the current process judges whether the current process is a task management process; and when the current process is a task management process, the current process acquires the cooperative work information of at least one subsequent process through the established communication channel to form second cooperative work information including the cooperative work information of the current process.
In an exemplary embodiment of the present disclosure, further comprising:
the cooperative work information comprises access position information, the subsequent process acquires the access position information of a plurality of processes accessing the data object through the second cooperative work information, and the access position of the subsequent process is confirmed according to the access position information of the plurality of processes, wherein the access position information comprises the access line number information and the access column number information of the processes in the current task.
In an exemplary embodiment of the disclosure, the accessing, by the current process according to the first co-working information, the data object using the data access handle includes:
the current process applies for the use authority of the data access handle to a system;
if the data access handle is in an occupied state, the current process waits for the system to allocate the use permission of the data access handle;
and if the data access handle is not in the occupied state, the current process obtains the use permission of the data access handle and accesses the data object through the data access handle, and the data access handle is set to the occupied state by the system.
In an exemplary embodiment of the present disclosure, encapsulating, by the current process according to a preset manner, the data access handle and the second cooperative work information to form a second shared access entry includes: and the current process encapsulates the data access handle and the second cooperative work information based on a preset class to form the second shared access entry.
According to a second aspect of the embodiments of the present disclosure, there is provided an inter-process resource sharing apparatus, including: the data object confirmation module is set for responding the data access request by the current process to determine the data object to be accessed; the request sharing module is set to send a first access entry sharing request based on the data object to a system service process by the current process so that the system service process can distribute the first access entry sharing request to at least one prior process managed by the system service process; a data access handle obtaining module configured to obtain, by the current process, a data access handle of the data object according to a first shared access entry of the at least one shared access entry returned by the at least one previous process, where the first shared access entry includes the data access handle and first cooperative work information; and the data access module is set to access the data object by the current process according to the first cooperative work information by using the data access handle.
According to a third aspect of the present disclosure, there is provided an inter-process resource sharing apparatus, including: a memory; and a processor coupled to the memory, the processor configured to perform the method of any of the above based on instructions stored in the memory.
According to a fourth aspect of the present disclosure, there is provided a computer readable storage medium, having stored thereon a program which, when executed by a processor, implements an inter-process resource sharing method as recited in any of the above.
The cooperative work information and the data access handle are sent to the dependent process at one time through the shared access entry, so that the dependent process can obtain the data access handle and the cooperative work information at the same time, the dependence on a complex data synchronization protocol on the access of a plurality of dependent processes to the same data is avoided, the data access handle is prevented from being applied by the plurality of dependent processes, the access efficiency of the plurality of dependent processes to the same data object can be effectively improved, the data access handle is not limited by the data synchronization protocol, and the data access handle is suitable for wider application scenes.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure. It is to be understood that the drawings in the following description are merely exemplary of the disclosure, and that other drawings may be derived from those drawings by one of ordinary skill in the art without the exercise of inventive faculty.
FIG. 1 is a flow chart of a method for inter-process resource sharing in an exemplary embodiment of the disclosure.
Fig. 2 is a schematic diagram illustrating a process of establishing a shared access portal according to an embodiment of the present disclosure.
Fig. 3 is a schematic diagram illustrating a process of establishing a shared access portal according to still another embodiment of the present disclosure.
Fig. 4 is a schematic diagram illustrating a process of establishing a shared access portal according to still another embodiment of the present disclosure.
FIG. 5 is a flow chart of a current process responding to a data access request in an embodiment of the disclosure.
Fig. 6 is a flowchart illustrating a current process responding to a second access entry sharing request according to an embodiment of the present disclosure.
FIG. 7 is a diagram illustrating interaction between processes in one embodiment of the disclosure.
FIG. 8 is a schematic diagram of an application scenario in accordance with an embodiment of the present disclosure.
FIG. 9 is a block diagram of an inter-process resource sharing apparatus according to an embodiment of the present disclosure.
FIG. 10 is a block diagram of an electronic device in one embodiment of the disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and the like. In other instances, well-known technical solutions have not been shown or described in detail to avoid obscuring aspects of the present disclosure.
Further, the drawings are merely schematic illustrations of the present disclosure, in which the same reference numerals denote the same or similar parts, and thus, a repetitive description thereof will be omitted. Some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in the form of software, or in one or more hardware modules or process circuits, or in different networks and/or processor devices and/or microcontroller devices.
The following detailed description of exemplary embodiments of the disclosure refers to the accompanying drawings.
Fig. 1 schematically shows a flowchart of an inter-process resource sharing method in an exemplary embodiment of the present disclosure. Referring to FIG. 1, an inter-process resource sharing method 100 may include:
step S11, the current process responds to the data access request to determine the data object to be accessed;
step S12, the current process sends a first access entry sharing request based on the data object to a system service process, so that the system service process distributes the first access entry sharing request to at least one previous process managed by the system service process;
step S13, the current process obtains the data access handle of the data object according to a first shared access entry of the at least one shared access entry returned by the at least one previous process, where the first shared access entry includes the data access handle and first cooperative work information;
step S14, the current process accesses the data object using the data access handle according to the first cooperative work information.
The cooperative work information and the data access handle are sent to the dependent process at one time through the shared access entry, so that the dependent process can obtain the data access handle and the cooperative work information at the same time, the dependence on a complex data synchronization protocol on the access of a plurality of dependent processes to the same data is avoided, the data access handle is prevented from being applied by the plurality of dependent processes, the access efficiency of the plurality of dependent processes to the same data object can be effectively improved, the data access handle is not limited by the data synchronization protocol, and the data access handle is suitable for wider application scenes.
The embodiment of the disclosure can be applied to an Android system.
The steps of the inter-process resource sharing method 100 will be described in detail below.
In step S11, the current process determines a data object to be accessed in response to the data access request.
In some embodiments of the present disclosure, the data object to be accessed may be, for example, a data set of data having multiple data types, such as an address book. For example, in a task of performing image batch processing on an avatar or skin of each contact in an address book, since processing on an image may cause great resource consumption, in order to avoid generating an out of memory (OOM) for an application, the image batch processing task may be distributed into a plurality of processes, and a data access request for the address book is generated for each process.
In step S12, the current process sends a first access entry sharing request based on the data object to a system service process, so that the system service process distributes the first access entry sharing request to at least one previous process managed by the system service process.
The system service process of the Android system is responsible for scheduling the broadcast information, so that after the current process sends the access entry sharing request to the system service process, the system service process can distribute the access entry sharing request to all processes managed by the current process in a broadcast mode.
In step S13, the current process obtains a data access handle of the data object according to a first shared access entry of the at least one shared access entry returned by the at least one previous process, where the first shared access entry includes the data access handle and first cooperative work information.
In one embodiment, at least one process accessing the data object serves as a previous process of the current process, and a sharing access entry is returned to the current process in response to the access entry sharing request (the process of establishing the sharing access entry is detailed in the related description of the embodiment shown in fig. 2).
In this embodiment of the present disclosure, the shared access entry is a data packet that can be transmitted between processes through an IPC (inter processes communication), where the content of the data packet includes a data access handle of a data object and cooperative work information between processes, and the content of the cooperative work information may include a plurality of information, such as process access location information and access sequence information of a process to data.
In some embodiments, the shared access entry may further include a communication interface of a previous process, and the current process may establish a communication channel with the previous process according to the communication interface and transmit the cooperative work information with the previous process through the communication channel in the subsequent work.
The prior process transmits the cooperative work information to the current process by using the shared access entry, so that the problems of complicated steps and limited application range caused by establishing various data cooperative protocols can be effectively avoided, and the cooperative work efficiency among dependent processes can be effectively improved; and the prior process packs the data access handle and the cooperative work information together and sends the data access handle and the cooperative work information to the current process, so that the current process can obtain the data access handle without independently applying an access entry, and the access efficiency of a plurality of dependent processes to the same data object can be greatly improved. In addition, the sharing of the data access handle can enable the dependent processes to share the access authority of certain private data, so that the problem of access limitation caused by independent application of access entries by each process is avoided, and the information sharing degree and the cooperation degree between the dependent processes are improved.
In some cases, a plurality of previous processes receiving the broadcast return a plurality of shared access entries to the current process at the same time, and at this time, the current process may determine which shared access entry to use according to a preset rule. For example, the shared access entry with the earliest arrival time may be set as the first shared access entry used by the current process, or the shared access entry sent by the previous process may be preset as the first shared access entry used by the current process. The selection scheme for the sharing type access entrance can be various, and the technical personnel in the field can set the scheme according to the actual situation.
In another embodiment of the present disclosure, if at least one sharing type access entry is not received within a preset time after the current process sends the first access entry sharing request, the access entry of the data object may be obtained according to a normal flow, and then the data access handle of the data object is obtained through the access entry, and the data object is accessed through the data access handle. In the embodiment of the present disclosure, the access entry is a Cursor (Cursor) in the Android system, and the data access handle is a Cursor Window in the Android system. In the Android system, Cursor is a package class, and is packaged with CursorWindow as a data access handle. The process may access the data object by obtaining the Cursor using a CursorWindow (data access handle) encapsulated in the Cursor.
The method for acquiring the Cursor according to the normal flow is, for example, applying for the Cursor of a data object through a query method of a ContentProvider, wherein the ContentProvider is one of four major components of an Android system and provides a uniform interface for storing and reading data. Since the specific steps of obtaining the access entry of the data object are the same as those in the related art, the detailed description of the disclosure is omitted here.
At step S14, the current process accesses the data object using the data access handle according to the first co-operation information.
The first cooperative work information is, for example, access position information of a previous process sent by the previous process to the current process, and the current process may determine an access position of the current process according to the access position information, so as to access the data object. In addition, the cooperative work information may further include various information such as a data access scheme, task setting information, and the like, which is not particularly limited by the present disclosure.
When the first shared access entry includes a communication interface of a previous process, the current process may establish a communication channel (in an embodiment, for example, IBinder in an Android system) with the previous process according to the communication interface, further communicate cooperative work information with the previous process for multiple times, and adjust an access manner to the data object in time according to the latest cooperative work information.
Because the current process and the previous process use the same data access handle to access the same data object, in the embodiment of the disclosure, the use of one data access handle by a plurality of processes can be realized through a system mutual exclusion lock mechanism.
That is, after the current process obtains the access right of the data access handle through the sharing access entry, when the data object needs to be accessed, the current process may first apply for the use right of the data access handle to the system, and if the data access handle is in an occupied state, the current process waits for the use right of the data access handle to be allocated by the system; if the data access handle is not in the occupied state, the current process can obtain the use right of the data access handle and access the data object through the data access handle, and the data access handle is set to the occupied state by the system.
The setting of the mutual exclusion lock mechanism can allow a plurality of dependent processes to jointly use one data access handle to access the same data object, so that a complex flow caused by respective application of access entries by the plurality of dependent processes is avoided, and the access efficiency of the plurality of dependent processes to the same data object is effectively improved. The scheme of the system for allocating the use permission of the data access handle to the plurality of processes may be various, for example, the use permission of the data access handle is allocated according to the sequence of the process application access time or the priority of the process, and the disclosure does not make particular limitation.
Fig. 2 is a schematic diagram illustrating a process of establishing a shared access portal according to an embodiment of the present disclosure.
Referring to fig. 2, in one embodiment, the shared access portal establishment process 200 may include:
step S21, the current process responds to a second access entry sharing request from a subsequent process, and determines second cooperative work information sent to the subsequent process;
step S22, the current process packages the data access handle and the second cooperative work information according to a preset mode to form a second shared access entry;
step S23, the current process passes the second shared access entry to the subsequent process, so that the subsequent process accesses the data object through the second shared access entry using the data access handle.
In the embodiment of the present disclosure, the data access handle and the second cooperative work information are encapsulated according to a preset manner, for example, the data access handle and the second cooperative work information are encapsulated based on a preset class, so as to generate a second shared access entry inherited from the preset class, where the preset class is, for example, a paretable class.
The pareble class is a serialized interface class used for realizing Inter-Process operation in the Android system, and serialization can be realized only by inheriting a data structure of the pareble class and is transmitted among processes in an IPC (Inter-Process Communication) mode. Therefore, in the embodiment shown in fig. 2, when receiving a second access entry sharing request sent by a subsequent process through broadcasting, a current process may package and serialize an obtained data access handle (curror Window) and second cooperative work information generated for the subsequent process (package into a paretable class), and generate a second shared access entry inherited from the paretable class, so as to simultaneously implement transmission of the data access handle and the cooperative work information between processes. The data access handle may be obtained through a request access entry (Cursor), or may be obtained through a first shared access entry provided by a previous process.
In the embodiment of the present disclosure, after the current process transmits the second shared access entry to the subsequent process, the current process and the subsequent process that receives the second shared access entry use the data access handle of the data object to access the same data object together. That is, multiple processes may access the same data object using the same data access handle at the same time.
Fig. 3 is a schematic diagram illustrating a process of establishing a shared access portal according to still another embodiment of the present disclosure.
Referring to fig. 3, when the shared access portal includes a communication interface, the establishing process 300 of the shared access portal may include:
step S31, the current process responds to a second access entry sharing request from a subsequent process, and determines second cooperative work information sent to the subsequent process;
step S32, the current process packages the data access handle, the second cooperative work information and the communication interface of the current process according to a preset mode to form a third shared access entrance;
step S33, after the current process transmits the shared access interface to the subsequent process, responding to a connection establishment request sent by the subsequent process according to the communication interface, and establishing a communication channel for connecting the subsequent process;
step S34, the current process acquires the third cooperative work information of the subsequent process through the communication channel;
step S35, the current process accesses the data object using the data access handle according to the third cooperative work information.
The communication interface of the current process, the data access handle and second cooperative work information which needs to be sent to a later process can be packaged into the third sharing type access entrance together by the current process, so that a communication channel is established with the later process, convenience is provided for subsequent information communication, and the working scheme of the current process is adjusted according to the cooperative work information which is communicated with the later process in the subsequent work. The communication channel is established, so that the complicated step of realizing the inter-process communication through various data synchronization protocols in the related technology can be avoided, and the inter-process communication efficiency and the process-dependent working efficiency are effectively improved.
It can be understood that there are various communication contents between the current process and the subsequent process which establishes the communication channel, and both the current process and the subsequent process can adjust the data access scheme in time according to the communication contents, thereby realizing complex cooperative operation.
In some embodiments, when a communication channel is established between processes, a task management process may be provided to uniformly arrange the data access schemes of all dependent processes accessing the same data object.
Fig. 4 is a schematic diagram illustrating a process of establishing a shared access portal according to still another embodiment of the present disclosure.
Referring to fig. 4, in the case where the task management process is provided, step S31 may include:
step S311, the current process judges whether the current process is a task management process;
step S312, when the current process is a task management process, the current process obtains the cooperative work information of at least one subsequent process through the established communication channel, and forms the second cooperative work information including the cooperative work information of the current process.
When the current process receives a second access entry sharing request sent by the subsequent process in a broadcasting mode, whether the current process is a task management process or not can be judged firstly, and if the current process is the task management process, cooperative work information of other dependent processes is obtained through all established communication channels.
In some cases, although the current process is a task management process, a communication channel is not established with other processes (that is, the subsequent process is a second process accessing the data object), at this time, the current process may only encapsulate the own cooperative work information, the own communication interface, and the data access handle of the data object when it is determined that the number of the communication channels is zero, so as to generate a third shared access entry sent to the subsequent process.
In other cases, the number of the communication channels is not zero, the current process may acquire the cooperative work information of the other dependent processes through the communication channels, and at this time, the current process may determine, according to the own cooperative work information and the cooperative work information of the other processes, second cooperative work information that needs to be sent to the subsequent process, so as to generate a third shared access entry that is sent to the subsequent process.
If the current process judges that the current process is not the task management process, no response can be made to the second access entry sharing request. In some embodiments, the access entry sharing request can be set by the system service process to only reach the task management process, so that the task management process can uniformly manage all the dependent processes.
In this embodiment of the present disclosure, the cooperative work information may include, for example, access position information, and when a task management process is set, when a subsequent process obtains a second shared access entry sent by a current process (at this time, the current process is a task management process) or when the current process obtains a first shared access entry sent by a previous process (at this time, the previous process is a task management process), access position information of all previous processes accessing the data object may be obtained through the cooperative work information, and an access position is determined according to the access position information. The access location information may include access row number information (row) and access column number information (column) of the process in the current task.
For example, if the current process knows that the access position of the previous process a in the current task is 0 to 999 th line, the access position of the previous process B in the current task is 1000 to 1999 th line from the first cooperative work information transmitted by the previous process a (task management process), and knows that the task itself accesses 1000 th line of data from the first cooperative work information or the initial setting of the current process, it can be determined that the access range of the process itself to the data object is 2000 to 2999 th line.
FIG. 5 is a flow chart of a current process responding to a data access request in an embodiment of the disclosure.
Referring to FIG. 5, in one embodiment, a process 500 for a current process to respond to a data access request may include:
step S501, responding to a data access request to determine a data object to be accessed;
step S502, a first access entry sharing request based on the data object is sent to a system service process;
step S503, judging whether at least one sharing type access entrance is received, if yes, entering step S504, and if not, entering step S510;
step S504, a first shared access entry is determined in at least one shared access entry;
step S505, acquiring a data access handle, first cooperative work information and a communication interface of the first shared access entry;
step S506, determining a data access scheme according to the first cooperative work information, and establishing a communication channel with a previous process according to the communication interface so as to receive the latest cooperative work information in real time;
step S507, applying for the use authority of the data access handle to the system;
step S508, judge whether to obtain the use authority of the access handle of the data, if yes, enter step S509 and use the access handle of the data to visit the data object, if no, continue waiting in this step;
step S510, judging whether the waiting time exceeds a preset value, if so, entering step S511, otherwise, returning to step S503 to continue waiting;
step S511, applies for the access entry of the data object, and further obtains a data access handle through the access entry, and accesses the data object through the data access handle.
Fig. 6 is a flowchart illustrating a current process responding to a second access entry sharing request according to an embodiment of the present disclosure.
Referring to FIG. 6, in one embodiment, a process 600 for a current process to respond to a request to access a second portal sharing may include:
step S601, receiving a second access entry sharing request from a subsequent process;
step S602, judging whether the task management process is the task management process, if so, entering step S603, and if not, ending the response;
step S603, judging whether the number of the currently established communication channels is zero, if not, entering step S604, and if so, entering step S605;
step S604, acquiring cooperative work information of a plurality of dependent processes through the established communication channel, and summarizing the cooperative work information with the cooperative work information to generate second cooperative work information;
step S605, taking the cooperative work information of the current process as second cooperative work information;
step S606, packaging the second cooperative work information, the communication interface of the current process and the data access handle based on the preset class to form a third shared access entrance;
step S607, the third shared access entry is sent to the subsequent process.
FIG. 7 is a diagram illustrating interaction between processes in one embodiment of the disclosure.
Referring to fig. 7, in an interaction process 700 between processes, assuming that there is no other process accessing a data object when process a accesses the data object (i.e., no response is received after broadcasting), in step S701, process a obtains an access entry (Cursor) of the data object by obtaining a ContentProvider, invoking a query method, and the like;
in step S702, the process a obtains a data access handle (curror Window) through the access entry (curror);
after the process B is started, in step S703, an access entry sharing request is sent in a broadcast manner, and the access entry sharing request reaches the process a;
in step S704, the process a encapsulates the data access handle (curror Window), the cooperative access information, and the communication interface, and generates a shared access entry (particlebectable curror) inherited from a particlebable class;
in step S705, the process a transfers the shared access entry (pareblecurrsor) to the process B;
in step S706, the process B obtains a data access handle (curror Window) according to the shared access entry (parsablecursor);
in step S707, process a and process B use this data access handle (curror Window) in common to access the same data object.
FIG. 8 is a schematic diagram of an application scenario in accordance with an embodiment of the present disclosure.
Referring to fig. 8, in an application scenario 800, the embodiment of the present disclosure may be applied to a task of performing image batch processing on an avatar or skin of each contact in an address book.
The process a is used as a first process for accessing the address book 81, is set as a task management process, obtains a data access handle (Cursor Window) of the address book 81 by directly obtaining a ContentProvider and calling a query method to obtain an access entry (Cursor), accesses the first area 811 of the address book 81 through the data access handle (Cursor Window), and processes an image in the first area 811.
The process B, as a second process for accessing the address book 81, sends an access entry sharing request in a broadcast manner.
After receiving the access entry sharing request, the process a packages and serializes the work area information, the communication interface and the data access handle (curror Window) of the process a to generate a shared access entry 82 (parsablecursor) inherited from a parsabl class.
After receiving the shared access entry 82, the process B determines that the work area of the process B is the second area 812 of the address book 81 according to the work area information of the process a and the initial setting of the process B, accesses the second area 812 by using a data access handle (curror Window), and processes the image in the first area 812; meanwhile, the process B establishes a first communication channel 83 with the process a according to the communication interface of the process a.
The process C, as a third process for accessing the address book 81, sends an access entry sharing request in a broadcast manner.
After receiving the access entry sharing request, the process a acquires the work area information of the process B through the first communication channel 83, and packages and serializes the work area information of the process a and the work area information of the process B as cooperative work information together with the communication interface of the process a and the data access handle (curror Window) to generate the shared access entry 84 inherited from the partition class.
After receiving the shared access entry 84, the process C determines that its own working area is the third area 813 of the address book 81 according to the cooperative work information, accesses the third area 813 by using a data access handle (curror Window), and processes an image in the third area 813; meanwhile, the process C establishes a second communication channel 85 with the process a according to the communication interface of the process a.
It should be understood that fig. 8 is only an example, in an actual application, the number of processes accessing the address book 81 may be more, and the main body determining the access area of each process may also be the process a serving as the task management process, which is not limited by the disclosure.
In summary, in the embodiment of the present disclosure, the previous process transmits the data access handle and the cooperative work information to the dependent process at one time, so that a plurality of dependent processes accessing the same data object can avoid a cumbersome operation of applying for a data access entry respectively, and information communication between the plurality of dependent processes by establishing a data synchronization protocol is avoided, thereby effectively improving the work efficiency of the plurality of dependent processes.
Corresponding to the above method embodiment, the present disclosure further provides an inter-process resource sharing apparatus, which may be used to execute the above method embodiment.
Fig. 9 is a block diagram schematically illustrating an inter-process resource sharing apparatus according to an exemplary embodiment of the present disclosure.
Referring to fig. 9, the inter-process resource sharing apparatus 900 may include:
a data object confirmation module 91 configured to determine a data object to be accessed in response to the data access request in the current process;
a request sharing module 92, configured to send, by the current process, a first access entry sharing request based on the data object to a system service process, so that the system service process distributes the first access entry sharing request to at least one previous process managed by the system service process;
a data access handle obtaining module 93, configured to obtain, by the current process, a data access handle of the data object according to a first shared access entry in the at least one shared access entry returned by the at least one previous process, where the first shared access entry includes the data access handle and first cooperative work information;
a data access module 94 configured to access the data object by the current process using the data access handle according to the first cooperative work information.
In an exemplary embodiment of the disclosure, the data access handle obtaining module 93 is further configured to:
and if the current process does not receive the at least one sharing type access entry within the preset time, acquiring the access entry of the data object, further acquiring a data access handle of the data object through the access entry, and accessing the data object by using the data access handle.
In an exemplary embodiment of the present disclosure, the system further includes a shared access entry generating module 95 configured to:
the current process responds to a second access entry sharing request from a subsequent process, and second cooperative work information sent to the subsequent process is determined; the current process encapsulates the data access handle and the second cooperative work information according to a preset mode to form a second shared access entry; the current process passes the second shared access entry to the subsequent process to facilitate the subsequent process accessing the data object through the second shared access entry using the data access handle.
In an exemplary embodiment of the present disclosure, the system further includes a shared access entry generating module 95 configured to:
the current process responds to a second access entry sharing request from a subsequent process, and second cooperative work information sent to the subsequent process is determined; the current process encapsulates the data access handle, the second cooperative work information and the communication interface of the current process according to a preset mode to form a third shared access entrance; after the current process transmits the shared access interface to the subsequent process, responding to a connection establishment request sent by the subsequent process according to the communication interface, and establishing a communication channel for connecting the subsequent process; the current process acquires third cooperative work information of the subsequent process through the communication channel; and the current process accesses the data object by using the data access handle according to the third cooperative work information.
In an exemplary embodiment of the disclosure, the shared access entry generating module 95 is further configured to: the current process judges whether the current process is a task management process; and when the current process is a task management process, the current process acquires the cooperative work information of at least one subsequent process through the established communication channel to form second cooperative work information including the cooperative work information of the current process.
In an exemplary embodiment of the present disclosure, the cooperative work information includes access position information, the subsequent process obtains, through the second cooperative work information, access position information of a plurality of processes accessing the data object, and confirms an access position of the subsequent process according to the access position information of the plurality of processes, where the access position information includes access line number information and access column number information of the process in the current task.
In an exemplary embodiment of the present disclosure, the data access module 94 is configured to:
the current process applies for the use authority of the data access handle to a system;
if the data access handle is in an occupied state, the current process waits for the system to allocate the use permission of the data access handle;
and if the data access handle is not in the occupied state, the current process obtains the use permission of the data access handle and accesses the data object through the data access handle, and the data access handle is set to the occupied state by the system.
In an exemplary embodiment of the present disclosure, the shared access entry generating module 95 is configured to: and the current process encapsulates the data access handle and the second cooperative work information based on a preset class to form the second shared access entry.
Since the functions of the apparatus 900 have been described in detail in the corresponding method embodiments, the disclosure is not repeated herein.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
As will be appreciated by one skilled in the art, aspects of the present invention may be embodied as a system, method or program product. Thus, various aspects of the invention may be embodied in the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.) or an embodiment combining hardware and software aspects that may all generally be referred to herein as a "circuit," module "or" system.
An electronic device 1000 according to this embodiment of the invention is described below with reference to fig. 10. The electronic device 1000 shown in fig. 10 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 10, the electronic device 1000 is embodied in the form of a general purpose computing device. The components of the electronic device 1000 may include, but are not limited to: the at least one processing unit 1010, the at least one memory unit 1020, and a bus 1030 that couples various system components including the memory unit 1020 and the processing unit 1010.
Wherein the storage unit stores program code that is executable by the processing unit 1010 to cause the processing unit 1010 to perform steps according to various exemplary embodiments of the present invention as described in the "exemplary methods" section above in this specification. For example, the processing unit 1010 may execute step S10 shown in fig. 1: the current process responds to the data access request to determine a data object to be accessed; step S12: the current process sends a first access entry sharing request based on the data object to a system service process so that the system service process distributes the first access entry sharing request to at least one prior process managed by the system service process; step S13: the current process acquires a data access handle of the data object according to a first shared access entry in at least one shared access entry returned by the at least one previous process, wherein the first shared access entry comprises the data access handle and first cooperative work information; step S14: and the current process accesses the data object by using the data access handle according to the first cooperative work information.
The storage unit 1020 may include readable media in the form of volatile memory units, such as a random access memory unit (RAM)10201 and/or a cache memory unit 10202, and may further include a read-only memory unit (ROM) 10203.
The memory unit 1020 may also include a program/utility 10204 having a set (at least one) of program modules 10205, such program modules 10205 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 1030 may be any one or more of several types of bus structures including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, and a local bus using any of a variety of bus architectures.
The electronic device 1000 may also communicate with one or more external devices 1100 (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 1000, and/or with any devices (e.g., router, modem, etc.) that enable the electronic device 1000 to communicate with one or more other computing devices. Such communication may occur through input/output (I/O) interfaces 1050. Also, the electronic device 1000 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the internet) via the network adapter 1060. As shown, the network adapter 1060 communicates with the other modules of the electronic device 1000 over the bus 1030. It should be appreciated that although not shown, other hardware and/or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
In an exemplary embodiment of the present disclosure, there is also provided a computer-readable storage medium having stored thereon a program product capable of implementing the above-described method of the present specification. In some possible embodiments, aspects of the invention may also be implemented in the form of a program product comprising program code means for causing a terminal device to carry out the steps according to various exemplary embodiments of the invention described in the above section "exemplary methods" of the present description, when said program product is run on the terminal device.
The program product may employ a portable compact disc read only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited in this regard and, in the present document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A computer readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
Furthermore, the above-described figures are merely schematic illustrations of processes involved in methods according to exemplary embodiments of the invention, and are not intended to be limiting. It will be readily understood that the processes shown in the above figures are not intended to indicate or limit the chronological order of the processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, e.g., in multiple modules.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

Claims (10)

1. An inter-process resource sharing method, comprising:
the current process responds to the data access request to determine a data object to be accessed;
the current process sends a first access entry sharing request based on the data object to a system service process so that the system service process distributes the first access entry sharing request to at least one prior process managed by the system service process;
the current process acquires a data access handle of the data object according to a first shared access entry in at least one shared access entry returned by the at least one previous process, wherein the first shared access entry comprises the data access handle and first cooperative work information;
and the current process accesses the data object by using the data access handle according to the first cooperative work information.
2. The inter-process resource sharing method of claim 1, further comprising:
and if the current process does not receive the at least one sharing type access entry within the preset time, acquiring the access entry of the data object, further acquiring a data access handle of the data object through the access entry, and accessing the data object by using the data access handle.
3. The inter-process resource sharing method according to claim 1 or 2, further comprising:
the current process responds to a second access entry sharing request from a subsequent process, and second cooperative work information sent to the subsequent process is determined;
the current process encapsulates the data access handle and the second cooperative work information according to a preset mode to form a second shared access entry;
the current process passes the second shared access entry to the subsequent process to facilitate the subsequent process accessing the data object through the second shared access entry using the data access handle.
4. The inter-process resource sharing method according to claim 1 or 2, further comprising:
the current process responds to a second access entry sharing request from a subsequent process, and second cooperative work information sent to the subsequent process is determined;
the current process encapsulates the data access handle, the second cooperative work information and the communication interface of the current process according to a preset mode to form a third shared access entrance;
after the current process transmits the shared access interface to the subsequent process, responding to a connection establishment request sent by the subsequent process according to the communication interface, and establishing a communication channel for connecting the subsequent process;
the current process acquires third cooperative work information of the subsequent process through the communication channel;
and the current process accesses the data object by using the data access handle according to the third cooperative work information.
5. The method of claim 4, wherein the determining second co-working information to send to the subsequent process comprises:
the current process judges whether the current process is a task management process;
and when the current process is a task management process, the current process acquires the cooperative work information of at least one subsequent process through the established communication channel to form second cooperative work information including the cooperative work information of the current process.
6. The inter-process resource sharing method of claim 5, further comprising:
the cooperative work information comprises access position information, the subsequent process acquires the access position information of a plurality of processes accessing the data object through the second cooperative work information, and the access position of the subsequent process is confirmed according to the access position information of the plurality of processes, wherein the access position information comprises the access line number information and the access column number information of the processes in the current task.
7. The method of claim 1, wherein the current process accessing the data object using the data access handle according to the first co-work information comprises:
the current process applies for the use authority of the data access handle to a system;
if the data access handle is in an occupied state, the current process waits for the system to allocate the use permission of the data access handle;
and if the data access handle is not in the occupied state, the current process obtains the use permission of the data access handle and accesses the data object through the data access handle, and the data access handle is set to the occupied state by the system.
8. The method of claim 3, wherein encapsulating the data access handle and the second co-working information in a predetermined manner by the current process to form a second shared access entry comprises:
the current process encapsulates the data access handle and the second cooperative work information based on a preset class to form the second shared access entry, and the second shared access entry is inherited from the preset class.
9. An inter-process resource sharing apparatus, comprising:
the data object confirmation module is set for responding the data access request by the current process to determine the data object to be accessed;
the request sharing module is set to send a first access entry sharing request based on the data object to a system service process by the current process so that the system service process can distribute the first access entry sharing request to at least one prior process managed by the system service process;
a data access handle obtaining module configured to obtain, by the current process, a data access handle of the data object according to a first shared access entry of the at least one shared access entry returned by the at least one previous process, where the first shared access entry includes the data access handle and first cooperative work information;
and the data access module is set to access the data object by the current process according to the first cooperative work information by using the data access handle.
10. An electronic device, comprising:
a memory; and
a processor coupled to the memory, the processor configured to perform the inter-process resource sharing method of any of claims 1-8 based on instructions stored in the memory.
CN201910829328.7A 2019-09-03 2019-09-03 Inter-process resource sharing method and device and electronic equipment Active CN112445628B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910829328.7A CN112445628B (en) 2019-09-03 2019-09-03 Inter-process resource sharing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910829328.7A CN112445628B (en) 2019-09-03 2019-09-03 Inter-process resource sharing method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN112445628A true CN112445628A (en) 2021-03-05
CN112445628B CN112445628B (en) 2023-10-24

Family

ID=74734070

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910829328.7A Active CN112445628B (en) 2019-09-03 2019-09-03 Inter-process resource sharing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN112445628B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102147751A (en) * 2011-04-26 2011-08-10 北京新媒传信科技有限公司 Communication method among multiple processes
CN102981895A (en) * 2011-09-06 2013-03-20 中国科学院声学研究所 Virtual multi-process operation method of single-process direct frame buffer (FB)
CN103645959A (en) * 2013-12-18 2014-03-19 北京直真科技股份有限公司 Telecom real-time system multi-process SMP (shared memory pool) interaction assembly and method
CN107085542A (en) * 2017-05-05 2017-08-22 深圳慧昱教育科技有限公司 IPC communication means and server
CN107193674A (en) * 2017-06-29 2017-09-22 武汉斗鱼网络科技有限公司 The processing method and processing device of online PUSH message
CN109933443A (en) * 2019-03-07 2019-06-25 腾讯科技(深圳)有限公司 Inter-process communication methods, device, computer equipment and readable storage medium storing program for executing
CN109992397A (en) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 Process handling method and device, electronic equipment, computer readable storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102147751A (en) * 2011-04-26 2011-08-10 北京新媒传信科技有限公司 Communication method among multiple processes
CN102981895A (en) * 2011-09-06 2013-03-20 中国科学院声学研究所 Virtual multi-process operation method of single-process direct frame buffer (FB)
CN103645959A (en) * 2013-12-18 2014-03-19 北京直真科技股份有限公司 Telecom real-time system multi-process SMP (shared memory pool) interaction assembly and method
CN107085542A (en) * 2017-05-05 2017-08-22 深圳慧昱教育科技有限公司 IPC communication means and server
CN107193674A (en) * 2017-06-29 2017-09-22 武汉斗鱼网络科技有限公司 The processing method and processing device of online PUSH message
CN109992397A (en) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 Process handling method and device, electronic equipment, computer readable storage medium
CN109933443A (en) * 2019-03-07 2019-06-25 腾讯科技(深圳)有限公司 Inter-process communication methods, device, computer equipment and readable storage medium storing program for executing

Also Published As

Publication number Publication date
CN112445628B (en) 2023-10-24

Similar Documents

Publication Publication Date Title
KR102209276B1 (en) Messaging protocol communication management
US10305823B2 (en) Network interface card configuration method and resource management center
CN109561171B (en) Configuration method and device of virtual private cloud service
CN107590001B (en) Load balancing method and device, storage medium and electronic equipment
US10394723B2 (en) Data accessing method and PCIe storage device
US20180239726A1 (en) Data transmission method, device, and system
EP3267322B1 (en) Scalable direct inter-node communication over peripheral component interconnect-express (pcie)
US11711335B2 (en) Communication method applied to edge computing scenario, storage medium, and electronic device
US9356887B2 (en) Controlling shared memory
US20140337493A1 (en) Client/server network environment setup method and system
KR20160087706A (en) Apparatus and method for resource allocation of a distributed data processing system considering virtualization platform
CN109587281A (en) Container configuration method and calculate node
US10623469B2 (en) Methods and apparatuses for information transmission
JP2016531372A (en) Memory module access method and apparatus
US20230350825A1 (en) Communications for field programmable gate array device
CN112104679B (en) Method, apparatus, device and medium for processing hypertext transfer protocol request
CN111290829B (en) Access control module, virtual machine monitor and access control method
US10523741B2 (en) System and method for avoiding proxy connection latency
CN112445628B (en) Inter-process resource sharing method and device and electronic equipment
CN112804366A (en) Method and device for resolving domain name
WO2021232860A1 (en) Communication method, apparatus and system
CN116383127B (en) Inter-node communication method, inter-node communication device, electronic equipment and storage medium
CN114338595B (en) Distributed processing method and device for message, storage medium and processor
CN112882820A (en) Method and device for configuring resources
CN115914389A (en) Cloud service control system, method and device, electronic equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant