CN110069346A - Resource share method, device, electronic equipment between multi-process - Google Patents
Resource share method, device, electronic equipment between multi-process Download PDFInfo
- Publication number
- CN110069346A CN110069346A CN201910342769.4A CN201910342769A CN110069346A CN 110069346 A CN110069346 A CN 110069346A CN 201910342769 A CN201910342769 A CN 201910342769A CN 110069346 A CN110069346 A CN 110069346A
- Authority
- CN
- China
- Prior art keywords
- resource
- shared
- target
- mentioned
- identification
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation 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/5016—Allocation 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
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/548—Queue
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The application provides resource share method, device, electronic equipment and machine readable storage medium between a kind of multi-process.In this application, first process is received to the request to create of shared resource, saves the shared resource;And distribution and the unique corresponding resource identification of the shared resource;Second process is received to the acquisition request of target shared resources;Wherein, the acquisition request includes at least the target resource identifier of target shared resources described in unique identification;In response to the acquisition request, in the resource identification that the kernel saves, search and the matched resource identification of the target resource identifier;If it exists, then shared resource corresponding with the matched resource identification of the target resource identifier is executed into duplication, so that second process obtains corresponding duplication resource, realizes the resource-sharing between multiple processes of local runtime.
Description
Technical field
This application involves resource share method, device, electronic equipments between operation system technology field more particularly to multi-process
And machine readable storage medium.
Background technique
Process is primary operation activity of the program on some data acquisition system in operating system, is that operating system is provided
The basic unit of source distribution and scheduling.Program is the static description of instruction corresponding to process, data and its organizational form, and into
Journey is the corresponding Dynamic Execution entity of program.
IPC (Interprocess communication, interprocess communication) is a kind of communication equipment that operating system provides
System.Application developer is based on IPC and writes exploitation program, may be implemented to coordinate the different processes that run in an operating system it
Between, it mutually can transmit or exchange information.
Summary of the invention
The application provides resource share method between a kind of multi-process, and the method is applied to the kernel of operating system, described
Operating system further includes the second process issued the first process of shared resource, obtain shared resource, wherein first process
The kernel is based on second process to be communicated, which comprises
First process is received to the request to create of shared resource, saves the shared resource;And distribution with it is described
The unique corresponding resource identification of shared resource;
Second process is received to the acquisition request of target shared resources;Wherein, the acquisition request includes at least only
The target resource identifier of the one mark target shared resources;
In response to the acquisition request, in the resource identification that the kernel saves, search and the target resource identifier
Matched resource identification;If it exists, then shared resource corresponding with the matched resource identification of the target resource identifier is executed
Duplication, so that second process obtains corresponding duplication resource.
Optionally, before reception second process is to the acquisition request of target shared resources, further includes:
Receive process corresponding with the target resource identifier grouping of second process adds group request;
In the resource identification that the kernel saves, search and the matched resource identification of the target resource identifier;If depositing
Second process is then being allowed to be added to the process grouping.
Optionally, when the shared resource, which exists, to be changed, further includes:
The change that first process is received for the shared resource is requested, and is requested based on the change, and institute is updated
State shared resource and corresponding duplication resource;
Based on the unique corresponding resource identification of the shared resource, the shared resource is sent to the grouping of corresponding process
Notification of Changes, so that the process in the corresponding process grouping of the shared resource, obtains updated duplication resource.
Optionally, when process corresponding with the target resource identifier grouping for receiving second process is from a group request
When, further includes:
By second process, deleted from process grouping;
Delete duplication resource corresponding with second process.
The application also provides resource shared device between a kind of multi-process, and described device is applied to the kernel of operating system, institute
State operating system further include issue shared resource the first process, obtain shared resource the second process, wherein described first into
Journey is based on the kernel with second process and is communicated, and described device includes:
Creation module receives first process to the request to create of shared resource, saves the shared resource;And point
With with the unique corresponding resource identification of the shared resource;
Module is obtained, receives second process to the acquisition request of target shared resources;Wherein, the acquisition request is extremely
It less include the target resource identifier of target shared resources described in unique identification;
Sharing module in the resource identification that the kernel saves, is searched and the target in response to the acquisition request
The matched resource identification of resource identification;It if it exists, then will be corresponding with the matched resource identification of the target resource identifier shared
Resource executes duplication, so that second process obtains corresponding duplication resource.
Optionally, before reception second process is to the acquisition request of target shared resources, the acquisition mould
Block further,
Receive process corresponding with the target resource identifier grouping of second process adds group request;
In the resource identification that the kernel saves, search and the matched resource identification of the target resource identifier;If depositing
Second process is then being allowed to be added to the process grouping.
Optionally, when the shared resource exist change when, the creation module further,
The change that first process is received for the shared resource is requested, and is requested based on the change, and institute is updated
State shared resource and corresponding duplication resource;
Based on the unique corresponding resource identification of the shared resource, the shared resource is sent to the grouping of corresponding process
Notification of Changes, so that the process in the corresponding process grouping of the shared resource, obtains updated duplication resource.
Optionally, when process corresponding with the target resource identifier grouping for receiving second process is from a group request
When, the sharing module further,
By second process, deleted from process grouping;
Delete duplication resource corresponding with second process.
The application also provides a kind of electronic equipment, including communication interface, processor, memory and bus, and the communication connects
Pass through bus between mouth, the processor and the memory to be connected with each other;
Machine readable instructions are stored in the memory, the processor is executed by calling the machine readable instructions
Above-mentioned method.
The application also provides a kind of machine readable storage medium, and the machine readable storage medium is stored with machine readable finger
It enables, the machine readable instructions realize the above method when being called and being executed by processor.
By above embodiments, the shared resource of the process based on kernel creation maintenance and its corresponding resource identification;With
And it is based on target resource identifier by managing and maintaining other processes, it obtains and the matched resource identification pair of the target resource
The duplication resource answered realizes the resource-sharing between multiple processes of local runtime.
Detailed description of the invention
Fig. 1 is the flow chart of resource share method between a kind of multi-process that an exemplary embodiment provides;
Fig. 2 is the interaction figure of communication process between a kind of multi-process that an exemplary embodiment provides;
Fig. 3 is the block diagram of resource shared device between a kind of multi-process that an exemplary embodiment provides;
Fig. 4 is the hardware structure diagram for a kind of electronic equipment that an exemplary embodiment provides.
Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to
When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with the application.On the contrary, they be only with it is such as appended
The example of the consistent device and method of some aspects be described in detail in claims, the application.
It is only to be not intended to be limiting the application merely for for the purpose of describing particular embodiments in term used in this application.
It is also intended in the application and the "an" of singular used in the attached claims, " described " and "the" including majority
Form, unless the context clearly indicates other meaning.It is also understood that term "and/or" used herein refers to and wraps
It may be combined containing one or more associated any or all of project listed.
It will be appreciated that though various information, but this may be described using term first, second, third, etc. in the application
A little information should not necessarily be limited by these terms.These terms are only used to for same type of information being distinguished from each other out.For example, not departing from
In the case where the application range, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as
One information.Depending on context, word as used in this " if " can be construed to " ... when " or " when ...
When " or " in response to determination ".
In order to make those skilled in the art more fully understand the technical solution in the embodiment of the present application, below first to this Shen
Please between the multi-process that is related to of embodiment resource-sharing the relevant technologies, be briefly described.
As program development becomes increasingly complex, the resource of a process is usually needed due to business and the needs of programming
It will be by the shared use of other processes.And existing technical solution, mainly pass through IPC mechanism based on shared drive or third party
Process, the resource-sharing between realization process;
Wherein, it based on the IPC mechanism of shared drive, is primarily present following disadvantage: needing in programming, need program
Designer causes shared resource abnormal skillfully using synchronous lock mechanism to prevent multiple processes from reading while write, once but some
The lock that process occupies shared resource for a long time does not discharge, and will lead to other processes can not obtain resource lock, so as to cause that can not obtain
Shared resource;
And the intermediary based on third party's process as multiple interprocess communications, it is main between realization process when resource-sharing
Have the following disadvantages: that third party's process needs to maintain higher stability and performance, if bottleneck occurs in third party's process performance
Or when stability difference, it will cause multiple interprocess communications abnormal, so as to cause shared resource can not be obtained.
And the application is directed to one kind, the shared resource based on process is uniquely between corresponding resource identification progress multi-process
Communication, to realize the technical solution of resource-sharing.
When realizing, operating system nucleus receives first process to the request to create of shared resource, saves described total
Enjoy resource;And distribution and the unique corresponding resource identification of the shared resource;Second process is received to the shared money of target
The acquisition request in source;Wherein, the acquisition request includes at least the target resource identifier of target shared resources described in unique identification;
In response to the acquisition request, in the resource identification that the kernel saves, search and the matched money of the target resource identifier
Source mark;If it exists, then shared resource corresponding with the matched resource identification of the target resource identifier is executed into duplication, so that
Second process obtains corresponding duplication resource.
In above scheme, the shared resource of the process based on kernel creation maintenance and its corresponding resource identification;And
It is based on target resource identifier by managing and maintaining other processes, is obtained corresponding with the matched resource identification of the target resource
Resource is replicated, the resource-sharing between multiple processes of local runtime is realized.
The application is described below by specific embodiment and in conjunction with specific application scenarios.
Referring to FIG. 1, Fig. 1 is the flow chart of resource share method between a kind of multi-process that one embodiment of the application provides,
The method is applied to the kernel of operating system, and the operating system further includes issuing the first process of shared resource, obtaining altogether
Enjoy the second process of resource, wherein first process is based on the kernel with second process and is communicated, the above method
Execute following steps:
Step 102 receives first process to the request to create of shared resource, saves the shared resource;And point
With with the unique corresponding resource identification of the shared resource.
Step 104 receives second process to the acquisition request of target shared resources;Wherein, the acquisition request is extremely
It less include the target resource identifier of target shared resources described in unique identification.
Step 106, in response to the acquisition request, in the resource identification that the kernel saves, search and the target
The matched resource identification of resource identification;It if it exists, then will be corresponding with the matched resource identification of the target resource identifier shared
Resource executes duplication, so that second process obtains corresponding duplication resource.
In the present specification, above-mentioned shared resource may include that can sharing for a process is one or more any
The data of form.Such as: above-mentioned shared resource can be a data structure of above-mentioned first process, and the data structure is specific
When realization, including and it is not limited to variable, array, queue, chained list, port status, routing state etc..Another example is: above-mentioned shared money
Source can be one section of video flowing or message flow.In this application, above-mentioned shared resource is not especially limited.In the present specification,
Above-mentioned first process, refer to the above-mentioned shared resource of offer in operating system to other processes process namely above-mentioned first into
The shared resource of oneself can be distributed to other processes by journey.
In the present specification, above-mentioned second process refers to that above-mentioned first process that needs to obtain in operating system has been issued
One or more processes of shared resource namely above-mentioned first process need to obtain the shared resource of above-mentioned first process publication.
In the present specification, above-mentioned kernel refers to that the kernel program in operating system, above-mentioned kernel are at runtime, corresponding
It is kernel process for process.Based on above-mentioned kernel, operating system can provide process for above-mentioned first process, above-mentioned second process
Between communicate, so that it is shared between multiple processes to complete above-mentioned shared resource, subsequent for convenience " kernel process " referred to as
For " kernel ".
Fig. 2 is referred to, Fig. 2 is the interaction figure of communication process between a kind of multi-process that an embodiment provides.As shown in Fig. 2,
The component communicated includes: kernel, the first process, the second process;Wherein, the first process and the second process are carried out based on kernel
Communication;First process as shown in Figure 2 can issue a shared resource, be based on kernel for the second process and obtain the shared resource.
Based on as shown in Fig. 2, below by way of specific embodiment, and combine " shared resource creation ", " shared resource acquisition
And cancel ", " shared resource update ", the technical solution of the application being related to is described in detail:
1) shared resource creates
In order to facilitate understanding, above-mentioned first process communicate relating to above-mentioned second process based on the kernel under first introducing
And detailed technology.
It is based on Socket (socket) when above-mentioned first process is communicated with above-mentioned second process based on the kernel
It is communicated;Wherein, Socket is common a kind of in IPC communication mechanism.
Such as: the corresponding client process of client-side program based on Socket exploitation can pass through call operation system
The Socket api interface of offer, server-side process corresponding with the serve end program developed based on Socket are by operation
The communication protocol stack that system provides carries out communication and data interaction.
It should be noted that under normal conditions, Socket mechanism is usually applied to C/S (client/server) or B/S
Multiple interprocess communications of (browser/server) framework group multiple devices off the net.
In the present specification, the Socket that above-mentioned first process is provided with above-mentioned second process based on above-mentioned kernel is led to
Letter;Wherein, above-mentioned first process and above-mentioned first process are all located at same equipment namely above-mentioned first process and above-mentioned second
Process is local multi-process.
In the present specification, above-mentioned kernel receives above-mentioned first process to the request to create of shared resource, saves above-mentioned total
Enjoy resource;And distribution and the unique corresponding resource identification of above-mentioned shared resource.
When realizing, above-mentioned kernel creates api interface, above-mentioned first process by providing Socket for above-mentioned first process
By using above-mentioned shared resource as ginseng is entered, being passed into above-mentioned Socket creation api interface, to be initiated on above-mentioned kernel
To above-mentioned shared resource request to create;The above-mentioned above-mentioned Socket creation api interface of kernel responds calls, and obtains above-mentioned shared resource
And it is stored in the kernel spacing of distribution;Meanwhile above-mentioned kernel is the return value that above-mentioned Socket creates api interface, distribution exists
A unique resource identification in the kernel;Wherein, the resource identification and above-mentioned shared resource are uniquely corresponding.On as a result,
It states the first process and api interface is created by above-mentioned Socket, obtain the return value of above-mentioned Socket creation api interface, Ye Jishu
First process obtain the distribution of above-mentioned kernel with the unique corresponding resource identification of above-mentioned shared resource.
It should be noted that above-mentioned first process can be sent out on direct above-mentioned kernel in another implementation shown
It rises and is directed to above-mentioned shared resource request to create.Such as: refer to P1 step and P2 step shown in Fig. 2, the first process to
The request to create of kernel initiation shared resource;Kernel receives the request to create, saves the shared resource and distributes for it unique
Resource identification;First process obtains the corresponding resource identification of the shared resource of kernel distribution.
When realizing, above-mentioned resource identification be can be as TLV (Type type, Length length, Value value) format
The character string of random length.
It should be noted that in the present specification, above-mentioned first process can initiate multiple shared resources to above-mentioned kernel
Request to create, and obtain the corresponding resource identification of above-mentioned kernel distribution.
For example, multiple shared resources and the corresponding resource mark saved in above-mentioned kernel, refers to shown in table 1:
Resource identification | Shared resource |
RES1 | SHARE1 |
RES2 | SHARE2 |
RES3 | SHARE3 |
Table 1
It should be noted that in the present specification, when above-mentioned kernel is that above-mentioned shared resource distributes corresponding resource mark, needing
In multiple shared resources and the corresponding resource mark first saved in above-mentioned kernel, search whether that there are duplicate shared moneys
Source;If it does not exist, it can just save the shared resource and distribute corresponding resource identification;If existing, it is shared directly to return to this
The corresponding allocated corresponding resource mark of resource.
Such as: if above-mentioned kernel receives the request to create that above-mentioned first process is directed to SHARE2, check as shown in Table 1
Saved in above-mentioned kernel multiple shared resources and corresponding resource mark, discovery SHARE2 it is existing, then above-mentioned kernel to
Above-mentioned first process, which connects, returns to the corresponding allocated corresponding resource mark RES2 of SHARE2.
In the present specification, above-mentioned kernel is that above-mentioned resource identification all establishes a corresponding process grouping, wherein above-mentioned
Process grouping may include the one or more processes that obtain above-mentioned resource identification and correspond to shared resource.Such as: resource identification
RES1, RES2, RES3 respectively correspond process and are grouped into Process1, Process2, Process3.
2) shared resource obtains, cancels
In the present specification, above-mentioned target resource refers to the one of the above-mentioned first process publication saved in above-mentioned kernel
A or multiple shared resources;Above-mentioned target resource identifier, refer to saved in above-mentioned kernel above-mentioned first process publication
The corresponding resource identification of shared resource.
For example, as shown in table 1, above-mentioned first process to above-mentioned kernel publication shared resource SHARE1, SHARE2,
SHARE3, above-mentioned second process need to obtain the announced shared resource SHARE3 of above-mentioned first process, then SHARE3 is upper
Target resource is stated, RES3 is above-mentioned target resource identifier.
In a kind of embodiment shown, above-mentioned second process is sent to above-mentioned kernel, with above-mentioned target resource identifier
Corresponding above-mentioned process grouping adds group request.
When realizing, above-mentioned kernel is by providing Socket connection API interface, above-mentioned first process for above-mentioned second process
By being passed into above-mentioned Socket connection API interface, thus on above-mentioned kernel using above-mentioned target resource identifier as ginseng is entered
That initiates to be grouped above-mentioned process adds group request;
Such as: above-mentioned second process is that the corresponding process of RES3 is grouped into Process3 to above-mentioned kernel target resource.
In a kind of embodiment shown, above-mentioned kernel is receiving above-mentioned second process with above-mentioned target resource identifier pair
Answer process be grouped plus group request, wherein it is above-mentioned plus group request include at least above-mentioned target resource identifier;It is saved in above-mentioned kernel
Resource identification in, search with the matched resource identification of above-mentioned target resource identifier;If it exists, then above-mentioned second process is allowed to add
Enter to above-mentioned process and is grouped.
When realizing, the above-mentioned above-mentioned Socket connection API interface of kernel responds is called, in the resource mark that above-mentioned kernel saves
In knowledge, search and the matched resource identification of above-mentioned target resource identifier;If it exists, then above-mentioned second process is allowed to be added to above-mentioned
Process grouping.
Such as: G1 step and G2 step shown in Fig. 2 are referred to, the second process initiates adding for shared resource to kernel
Group request, wherein the target resource identifier that should add group request is RES3;Kernel receives the request of this plus group, it is as shown in Table 1 on
In the resource identification for stating kernel preservation, search and the matched resource identification of RES3;Go people RES3 existing through searching, then kernel will
Second process is added in process grouping Process3 corresponding with RES3.
It should be noted that if above-mentioned target resource identifier, there is no with above-mentioned kernel, then above-mentioned kernel will be on refusal
Group request that adds of the second process is stated, and calls to return to above-mentioned second process by above-mentioned Socket connection API interface and adds a group mistake
The return value lost.
In a kind of embodiment shown, after above-mentioned second process is successfully joined the grouping of above-mentioned process, above-mentioned the
Two processes initiate the acquisition request to above-mentioned target shared resources to above-mentioned kernel;Wherein, above-mentioned acquisition request includes at least upper
State target resource identifier.
When realizing, above-mentioned kernel obtains api interface, above-mentioned first process by providing Socket for above-mentioned second process
By being passed to above-mentioned Socket and obtaining in api interface, thus on above-mentioned kernel using above-mentioned target resource identifier as ginseng is entered
Initiate the acquisition request to above-mentioned target shared resources;
In the present specification, above-mentioned kernel receives above-mentioned second process to the acquisition request of target shared resources;Wherein, on
State the target resource identifier that acquisition request includes at least the above-mentioned target shared resources of unique identification;
Above-mentioned kernel responds are in the acquisition request, in the resource identification that above-mentioned kernel saves, search and the target
The matched resource identification of resource identification;It if it exists, then will be corresponding with the matched resource identification of the target resource identifier shared
Resource executes duplication, so that second process obtains corresponding duplication resource.
When realizing, the above-mentioned above-mentioned Socket of kernel responds obtains api interface and calls, in the resource mark that above-mentioned kernel saves
In knowledge, search and the matched resource identification of above-mentioned target resource identifier;It if it exists, then will be matched with above-mentioned target resource identifier
The corresponding shared resource of resource identification executes duplication, so that second process obtains corresponding duplication resource.
For example, referring to G3 step and G4 step shown in Fig. 2, above-mentioned kernel receives above-mentioned second process, for
Target shared resources as shown in Table 1 are the acquisition request of SHARE3;Wherein, it is corresponding that SHARE3 is included at least in the acquisition request
Resource identification RES3 namely RES3 be the corresponding target resource identifier of target shared resources SHARE3;Above-mentioned kernel is above-mentioned
RES3 is searched in the resource identification that kernel saves, discovery RES3 exists, then executes the corresponding shared resource SHARE3 of RES multiple
System also replicates SHARE3 a;Wherein, the corresponding duplication resource of SHARE3 namely above-mentioned duplication resource;And it will notice
Process in the corresponding process grouping Process3 of SHARE3.
It should be noted that the number of copies of above-mentioned shared resource can be one or more parts, above-mentioned number of copies with it is upper
It is identical to state the process number that target resource identifier corresponds in process grouping.Such as: the corresponding process point of above-mentioned resource identification RES3
In group Process3, there can be 10 processes (above-mentioned second process);Then above-mentioned kernel needs to replicate SHARE3 10 parts, and will
10 parts of duplication resources are stored in respectively in the acquisition queue of corresponding 10 processes;It, can to above-mentioned second process (10 processes)
From corresponding acquisition queue, to obtain above-mentioned duplication resource respectively.
In the present specification, above-mentioned shared resource creation is completed in above-mentioned first process;And above-mentioned second process with
The corresponding resource identification of above-mentioned shared resource is above-mentioned target resource identifier, is added to matched total with above-mentioned target resource identifier
After enjoying the grouping of process corresponding to the corresponding resource identification of resource;
In a kind of embodiment shown, when above-mentioned kernel is receiving above-mentioned second process with above-mentioned target resource mark
Know corresponding process grouping from group request when, above-mentioned kernel will above-mentioned second process, from above-mentioned process be grouped in delete;Delete with
The corresponding duplication resource of above-mentioned second process.
Continue to illustrate with above-mentioned example, refer to L1 step and L2 step shown in Fig. 2, above-mentioned kernel receives
State the second process RES3 correspond to process grouping Process3 from group request when, above-mentioned kernel by above-mentioned second process, from into
Process3 is deleted in journey grouping;Delete duplication resource corresponding with Process3.
3) shared resource updates
In the present specification, above-mentioned shared resource creation is completed in above-mentioned first process;And above-mentioned second process with
The corresponding resource identification of above-mentioned shared resource is above-mentioned target resource identifier, is added to matched total with above-mentioned target resource identifier
After enjoying the grouping of process corresponding to the corresponding resource identification of resource;
In a kind of embodiment shown, when above-mentioned shared resource, which exists, to be changed, above-mentioned kernel receives above-mentioned first
Process is requested for the change of above-mentioned shared resource, wherein above-mentioned change request includes at least above-mentioned shared resource and uniquely corresponds to
Resource identification;And requested based on above-mentioned change, update above-mentioned shared resource.
When realizing, above-mentioned kernel receives above-mentioned first process and updates api interface calling for above-mentioned Socket, based on upper
Shared resource uniquely corresponding resource identification is stated, above-mentioned shared resource and corresponding duplication resource are updated.
For example, referring to C1 step and C2 step shown in Fig. 2, above-mentioned kernel receives above-mentioned second process, for
The update that target shared resources as shown in Table 1 are SHARE2 is requested;Wherein, it is corresponding that SHARE2 is included at least in the acquisition request
The corresponding more new data NewSHARE2 of resource identification RES2, SHARE2;Then above-mentioned kernel is first based on RES2 and finds such as 1 institute of table
The SHARE2 shown, and SHARE2 is updated to NewSHARE2;And updating the corresponding duplication resource of SHARE2 is NewSHARE2 pairs
The new duplication resource answered.
Wherein;Multiple shared resources and the corresponding resource mark saved in above-mentioned kernel as shown in Table 1,
After SHARE2 updates, multiple shared resources and the corresponding resource mark saved in above-mentioned kernel is referred to shown in table 2:
Resource identification | Shared resource |
RES1 | SHARE1 |
RES2 | NewSHARE2 |
RES3 | SHARE3 |
Table 2
In a kind of embodiment shown, further, above-mentioned kernel is based on above-mentioned shared resource uniquely corresponding money
Source mark sends the Notification of Changes of above-mentioned shared resource to the grouping of corresponding process, so that the corresponding process of the shared resource
Process in grouping obtains updated duplication resource.
Continue to illustrate with above-mentioned example, above-mentioned kernel is grouped Process2 to the corresponding process of RES2, and it is corresponding to send RES2
Shared resource Notification of Changes so that the process in RES2 corresponding process grouping Process2, it is corresponding to obtain NewSHARE2
New duplication resource.
In above technical scheme, the shared resource of the process based on kernel creation maintenance and its corresponding resource identification;
And it is based on target resource identifier by managing and maintaining other processes, it obtains and the matched resource identification of the target resource
Corresponding duplication resource realizes the resource-sharing between multiple processes of local runtime.Due to realizing the above technology based on kernel
Scheme can greatly improve the stability and efficiency of communication when carrying out resource-sharing between multiple processes.
Fig. 3 is the block diagram of resource shared device between a kind of multi-process that one exemplary embodiment of the application provides.With it is above-mentioned
Embodiment of the method is corresponding, and present invention also provides a kind of embodiment of resource shared device between multi-process, described device applications
In the kernel of operating system, the operating system further includes issuing the first process of shared resource, obtaining the second of shared resource
Process, wherein first process is based on the kernel with second process and is communicated, and please refers to one exemplified by Fig. 3
Resource shared device 30 between kind multi-process, described device include:
Creation module 301 receives first process to the request to create of shared resource, saves the shared resource;With
And distribution and the unique corresponding resource identification of the shared resource;
Module 302 is obtained, receives second process to the acquisition request of target shared resources;Wherein, the acquisition is asked
Seek the target resource identifier for including at least target shared resources described in unique identification;
Sharing module 303, in response to the acquisition request, in the resource identification that the kernel saves, search with it is described
The matched resource identification of target resource identifier;It if it exists, then will be corresponding with the matched resource identification of the target resource identifier
Shared resource executes duplication, so that second process obtains corresponding duplication resource.
In the present embodiment, described before reception second process is to the acquisition request of target shared resources
Obtain module 302 further,
Receive process corresponding with the target resource identifier grouping of second process adds group request;
In the resource identification that the kernel saves, search and the matched resource identification of the target resource identifier;If depositing
Second process is then being allowed to be added to the process grouping.
In the present embodiment, when the shared resource exist change when, the creation module 301 further,
The change that first process is received for the shared resource is requested, and is requested based on the change, and institute is updated
State shared resource and corresponding duplication resource;
Based on the unique corresponding resource identification of the shared resource, the shared resource is sent to the grouping of corresponding process
Notification of Changes, so that the process in the corresponding process grouping of the shared resource, obtains updated duplication resource.
In the present embodiment, when receive second process process corresponding with the target resource identifier be grouped from
Group request when, the sharing module 303 further,
By second process, deleted from process grouping;
Delete duplication resource corresponding with second process.
For device embodiment, since it corresponds essentially to embodiment of the method, so related place is referring to method reality
Apply the part explanation of example.The apparatus embodiments described above are merely exemplary, wherein described be used as separation unit
The module of explanation may or may not be physically separated, and the component shown as module can be or can also be with
It is not physical module, it can it is in one place, or may be distributed on multiple network modules.It can be according to actual
The purpose for needing to select some or all of the modules therein to realize application scheme.Those of ordinary skill in the art are not paying
Out in the case where creative work, it can understand and implement.
System, device, module or the module that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.A kind of typically to realize that equipment is computer, the concrete form of computer can
To be personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
In device, navigation equipment, E-mail receiver/send equipment, game console, tablet computer, wearable device or these equipment
The combination of any several equipment.
The embodiment of resource shared device can be using on electronic equipment shown in Fig. 4 between the multi-process of the application.Dress
Setting embodiment can also be realized by software realization by way of hardware or software and hardware combining.It is implemented in software to be
Example, as the device on a logical meaning, being will be in machine readable storage medium by the processor of electronic equipment where it
Corresponding computer program instructions run the machine-executable instruction of formation after reading.For hardware view, as shown in figure 4,
A kind of hardware structure diagram of electronic equipment where resource shared device between the multi-process of the application, in addition to processing shown in Fig. 4
Except device, communication interface, bus and machine readable storage medium, the electronic equipment in embodiment where device is generally according to this
The actual functional capability of electronic equipment can also include other hardware, repeat no more to this.
Accordingly, it the embodiment of the present application also provides the hardware configuration of a kind of electronic equipment of Fig. 3 shown device, refers to
Fig. 4, Fig. 4 are the hardware structural diagram of a kind of electronic equipment provided by the embodiments of the present application.The equipment includes: communication interface
401, processor 402, machine readable storage medium 403 and bus 404;Wherein, communication interface 401, processor 402, machine can
It reads storage medium 403 and mutual communication is completed by bus 404.Wherein, communication interface 401, for carrying out network communication.Place
Reason device 402 can be a central processing unit (CPU), and processor 402 can execute to be stored in machine readable storage medium 403
Machine readable instructions, to realize process as described above.
Machine readable storage medium 403 referred to herein can be any electronics, magnetism, optics or other physical stores
Device may include or store information, such as executable instruction, data, etc..For example, machine readable storage medium may is that easily
Lose memory, nonvolatile memory or similar storage medium.Specifically, machine readable storage medium 403 can be RAM
(Radom Access Memory, random access memory), flash memory, memory driver (such as hard disk drive), solid state hard disk,
Any kind of storage dish (such as CD, DVD) perhaps similar storage medium or their combination.
So far, hardware configuration description shown in Fig. 4 is completed.
In addition, the embodiment of the present application also provides a kind of machine readable storage medium including machine-executable instruction, example
Such as the machine-readable readable storage medium storing program for executing 403 in Fig. 4, the machine-executable instruction can be by data processing equipment
Device 402 is managed to execute to realize data processing method described above.
The function of each unit and the realization process of effect are specifically detailed in the above method and correspond to step in above-mentioned apparatus
Realization process, details are not described herein.
Those skilled in the art after considering the specification and implementing the invention disclosed here, will readily occur to its of the application
Its embodiment.This application is intended to cover any variations, uses, or adaptations of the application, these modifications, purposes or
Person's adaptive change follows the general principle of the application and including the undocumented common knowledge in the art of the application
Or conventional techniques.The description and examples are only to be considered as illustrative, and the true scope and spirit of the application are by following
Claim is pointed out.
It should be understood that the application is not limited to the precise structure that has been described above and shown in the drawings, and
And various modifications and changes may be made without departing from the scope thereof.Scope of the present application is only limited by the accompanying claims.
The foregoing is merely the preferred embodiments of the application, not to limit the application, all essences in the application
Within mind and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of the application protection.
Claims (10)
1. resource share method between a kind of multi-process, which is characterized in that the method is applied to the kernel of operating system, the behaviour
As system further include issue shared resource the first process, obtain shared resource the second process, wherein first process with
Second process is based on the kernel and is communicated, which comprises
First process is received to the request to create of shared resource, saves the shared resource;And distribution is shared with described
The unique corresponding resource identification of resource;
Second process is received to the acquisition request of target shared resources;Wherein, the acquisition request includes at least unique mark
Know the target resource identifier of the target shared resources;
In response to the acquisition request, in the resource identification that the kernel saves, lookup is matched with the target resource identifier
Resource identification;If it exists, then shared resource corresponding with the matched resource identification of the target resource identifier is executed into duplication,
So that second process obtains corresponding duplication resource.
2. the method according to claim 1, wherein receiving second process to target shared resources described
Acquisition request before, further includes:
Receive process corresponding with the target resource identifier grouping of second process adds group request;
In the resource identification that the kernel saves, search and the matched resource identification of the target resource identifier;If it exists, then
Second process is allowed to be added to the process grouping.
3. according to the method described in claim 2, it is characterized in that, when the shared resource exists and changes, further includes:
The change that first process is received for the shared resource is requested, and is requested based on the change, is updated described total
Enjoy resource and corresponding duplication resource;
Based on the unique corresponding resource identification of the shared resource, the change of the shared resource is sent to the grouping of corresponding process
Notice, so that the process in the corresponding process grouping of the shared resource, obtains updated duplication resource.
4. according to the method described in claim 2, it is characterized in that, when receiving second process with the target resource
Identify corresponding process grouping from group request when, further includes:
By second process, deleted from process grouping;
Delete duplication resource corresponding with second process.
5. resource shared device between a kind of multi-process, which is characterized in that described device is applied to the kernel of operating system, the behaviour
As system further include issue shared resource the first process, obtain shared resource the second process, wherein first process with
Second process is based on the kernel and is communicated, and described device includes:
Creation module receives first process to the request to create of shared resource, saves the shared resource;And distribution with
The unique corresponding resource identification of the shared resource;
Module is obtained, receives second process to the acquisition request of target shared resources;Wherein, the acquisition request is at least wrapped
Include the target resource identifier of target shared resources described in unique identification;
Sharing module in the resource identification that the kernel saves, is searched and the target resource in response to the acquisition request
Identify matched resource identification;It if it exists, then will shared resource corresponding with the matched resource identification of the target resource identifier
Duplication is executed, so that second process obtains corresponding duplication resource.
6. device according to claim 5, which is characterized in that receive second process to target shared resources described
Acquisition request before, the acquisition module further,
Receive process corresponding with the target resource identifier grouping of second process adds group request;
In the resource identification that the kernel saves, search and the matched resource identification of the target resource identifier;If it exists, then
Second process is allowed to be added to the process grouping.
7. device according to claim 6, which is characterized in that when the shared resource, which exists, to be changed, the creation mould
Block further,
The change that first process is received for the shared resource is requested, and is requested based on the change, is updated described total
Enjoy resource and corresponding duplication resource;
Based on the unique corresponding resource identification of the shared resource, the change of the shared resource is sent to the grouping of corresponding process
Notice, so that the process in the corresponding process grouping of the shared resource, obtains updated duplication resource.
8. device according to claim 6, which is characterized in that when receiving second process with the target resource
Identify corresponding process grouping from group request when, the sharing module further,
By second process, deleted from process grouping;
Delete duplication resource corresponding with second process.
9. a kind of electronic equipment, which is characterized in that including communication interface, processor, memory and bus, the communication interface,
It is connected with each other between the processor and the memory by bus;
Machine readable instructions are stored in the memory, the processor is executed by calling the machine readable instructions as weighed
Benefit requires 1 to 4 described in any item methods.
10. a kind of machine readable storage medium, which is characterized in that the machine readable storage medium is stored with machine readable finger
It enables, the machine readable instructions realize the described in any item methods of Claims 1-4 when being called and being executed by processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910342769.4A CN110069346B (en) | 2019-04-26 | 2019-04-26 | Method and device for sharing resources among multiple processes and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910342769.4A CN110069346B (en) | 2019-04-26 | 2019-04-26 | Method and device for sharing resources among multiple processes and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110069346A true CN110069346A (en) | 2019-07-30 |
CN110069346B CN110069346B (en) | 2021-07-23 |
Family
ID=67369104
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910342769.4A Active CN110069346B (en) | 2019-04-26 | 2019-04-26 | Method and device for sharing resources among multiple processes and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110069346B (en) |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111190748A (en) * | 2019-12-23 | 2020-05-22 | 腾讯科技(深圳)有限公司 | Data sharing method, device, equipment and storage medium |
CN112685132A (en) * | 2020-12-23 | 2021-04-20 | 北京浪潮数据技术有限公司 | Koji task execution method, device, equipment and readable storage medium |
CN113626134A (en) * | 2021-06-29 | 2021-11-09 | 广东浪潮智慧计算技术有限公司 | Resource replication method, device, equipment and computer readable storage medium |
CN113779545A (en) * | 2021-08-27 | 2021-12-10 | 深圳市优必选科技股份有限公司 | Data cross-process sharing method, terminal equipment and computer readable storage medium |
CN114201207A (en) * | 2021-11-22 | 2022-03-18 | 北京达佳互联信息技术有限公司 | Resource synchronization method and device, electronic equipment and storage medium |
CN115220911A (en) * | 2022-06-17 | 2022-10-21 | 中科驭数(北京)科技有限公司 | Resource management method, device, equipment and medium |
WO2023093588A1 (en) * | 2021-11-24 | 2023-06-01 | 中兴通讯股份有限公司 | Resource sharing method, terminal and computer readable medium |
CN117077115A (en) * | 2023-10-13 | 2023-11-17 | 沐曦集成电路(上海)有限公司 | Cross-language multi-process interaction method, electronic equipment and medium in chip verification stage |
CN117971423A (en) * | 2024-01-16 | 2024-05-03 | 北京趋动智能科技有限公司 | Multi-process application migration method and device, storage medium and electronic equipment |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102122255A (en) * | 2011-03-15 | 2011-07-13 | 合肥华云通信技术有限公司 | Method for realizing inter-process communication in Linux system by utilizing virtual character equipment and genetlink |
US20120291038A1 (en) * | 2010-11-24 | 2012-11-15 | Clevenger Brian Duane | Method for reducing inter-process communication latency |
CN104714792A (en) * | 2013-12-17 | 2015-06-17 | 腾讯科技(深圳)有限公司 | Multi-process shared data processing method and device |
CN105487933A (en) * | 2015-11-24 | 2016-04-13 | 无锡江南计算技术研究所 | Inter-kernel asynchronous message queue and shared memory based inter-domain communication method |
CN105978997A (en) * | 2016-06-24 | 2016-09-28 | 北京百度网讯科技有限公司 | Data transmission method and system |
CN105991755A (en) * | 2015-05-21 | 2016-10-05 | 杭州迪普科技有限公司 | Service message distribution method and service message distribution device |
CN106648939A (en) * | 2016-12-30 | 2017-05-10 | 上海寰视网络科技有限公司 | Method and equipment for inter-process resource sharing |
CN106874125A (en) * | 2017-01-13 | 2017-06-20 | 北京元心科技有限公司 | Method and device for sharing system resources among multi-container systems |
CN109298913A (en) * | 2018-09-26 | 2019-02-01 | 武芮 | The method and device of schedules system resources between a kind of multi-vessel system |
-
2019
- 2019-04-26 CN CN201910342769.4A patent/CN110069346B/en active Active
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120291038A1 (en) * | 2010-11-24 | 2012-11-15 | Clevenger Brian Duane | Method for reducing inter-process communication latency |
CN102122255A (en) * | 2011-03-15 | 2011-07-13 | 合肥华云通信技术有限公司 | Method for realizing inter-process communication in Linux system by utilizing virtual character equipment and genetlink |
CN104714792A (en) * | 2013-12-17 | 2015-06-17 | 腾讯科技(深圳)有限公司 | Multi-process shared data processing method and device |
CN105991755A (en) * | 2015-05-21 | 2016-10-05 | 杭州迪普科技有限公司 | Service message distribution method and service message distribution device |
CN105487933A (en) * | 2015-11-24 | 2016-04-13 | 无锡江南计算技术研究所 | Inter-kernel asynchronous message queue and shared memory based inter-domain communication method |
CN105978997A (en) * | 2016-06-24 | 2016-09-28 | 北京百度网讯科技有限公司 | Data transmission method and system |
CN106648939A (en) * | 2016-12-30 | 2017-05-10 | 上海寰视网络科技有限公司 | Method and equipment for inter-process resource sharing |
CN106874125A (en) * | 2017-01-13 | 2017-06-20 | 北京元心科技有限公司 | Method and device for sharing system resources among multi-container systems |
CN109298913A (en) * | 2018-09-26 | 2019-02-01 | 武芮 | The method and device of schedules system resources between a kind of multi-vessel system |
Non-Patent Citations (1)
Title |
---|
ZH921: "linux用户空间与内核空间通信——Netlink通信机制", 《HTTPS://BLOG.CSDN.NET/ZHAO_H/ARTICLE/DETAILS/80943226》 * |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111190748A (en) * | 2019-12-23 | 2020-05-22 | 腾讯科技(深圳)有限公司 | Data sharing method, device, equipment and storage medium |
CN112685132A (en) * | 2020-12-23 | 2021-04-20 | 北京浪潮数据技术有限公司 | Koji task execution method, device, equipment and readable storage medium |
CN112685132B (en) * | 2020-12-23 | 2024-08-02 | 北京浪潮数据技术有限公司 | Method, device and equipment for executing koji task and readable storage medium |
CN113626134A (en) * | 2021-06-29 | 2021-11-09 | 广东浪潮智慧计算技术有限公司 | Resource replication method, device, equipment and computer readable storage medium |
CN113626134B (en) * | 2021-06-29 | 2024-02-13 | 广东浪潮智慧计算技术有限公司 | Resource replication method, device, equipment and computer readable storage medium |
CN113779545A (en) * | 2021-08-27 | 2021-12-10 | 深圳市优必选科技股份有限公司 | Data cross-process sharing method, terminal equipment and computer readable storage medium |
CN114201207A (en) * | 2021-11-22 | 2022-03-18 | 北京达佳互联信息技术有限公司 | Resource synchronization method and device, electronic equipment and storage medium |
WO2023093588A1 (en) * | 2021-11-24 | 2023-06-01 | 中兴通讯股份有限公司 | Resource sharing method, terminal and computer readable medium |
CN115220911A (en) * | 2022-06-17 | 2022-10-21 | 中科驭数(北京)科技有限公司 | Resource management method, device, equipment and medium |
CN117077115A (en) * | 2023-10-13 | 2023-11-17 | 沐曦集成电路(上海)有限公司 | Cross-language multi-process interaction method, electronic equipment and medium in chip verification stage |
CN117077115B (en) * | 2023-10-13 | 2023-12-15 | 沐曦集成电路(上海)有限公司 | Cross-language multi-process interaction method, electronic equipment and medium in chip verification stage |
CN117971423A (en) * | 2024-01-16 | 2024-05-03 | 北京趋动智能科技有限公司 | Multi-process application migration method and device, storage medium and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN110069346B (en) | 2021-07-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110069346A (en) | Resource share method, device, electronic equipment between multi-process | |
US10601911B2 (en) | Partitioning of a blockchain ledger | |
TWI743458B (en) | Method, device and system for parallel execution of blockchain transactions | |
CN111400112B (en) | Writing method and device of storage system of distributed cluster and readable storage medium | |
KR20200066254A (en) | How to execute a multiparty transaction using a smart contract | |
CN111091429A (en) | Electronic bill identification distribution method and device and electronic bill generation system | |
CN106663033B (en) | System and method for supporting a wraparound domain and proxy model and updating service information for cross-domain messaging in a transactional middleware machine environment | |
CN112583931B (en) | Message processing method, message middleware, electronic device, and storage medium | |
CN113783922A (en) | Load balancing method, system and device | |
KR20060045365A (en) | System and method for sharing objects between computers over a network | |
CN111126977A (en) | Transaction processing method of block chain system | |
WO2022134797A1 (en) | Data fragmentation storage method and apparatus, a computer device, and a storage medium | |
JP6975153B2 (en) | Data storage service processing method and equipment | |
CN111932239A (en) | Service processing method, device, node equipment and storage medium | |
KR102553877B1 (en) | A method and system for efficiently processing the high transaction throughput required by DApps in the blockchain | |
CN112988377B (en) | Resource allocation method, system and medium for cloud service | |
CN114363402A (en) | Target range interconnection method, system and electronic equipment | |
CN113885797A (en) | Data storage method, device, equipment and storage medium | |
JP2023065558A (en) | Method of responding to operation, apparatus of responding to operation, electronic device, and storage medium | |
CN113949632B (en) | Dynamic node configuration method and device for block chain | |
US12058201B2 (en) | Read access for computational results of a distributed network | |
CN115361382A (en) | Data processing method, device, equipment and storage medium based on data group | |
CN110290215B (en) | Signal transmission method and device | |
CN113095824A (en) | Asset management method and device based on block chain and electronic equipment | |
CN108898448A (en) | A kind of ad data synchronous method and device |
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 |