Summary of the invention
In view of the foregoing deficiencies of prior art, the purpose of the present invention is to provide a kind of storage of data access and processes
Between data-sharing systems, for solve cannot achieve between mobile phone and computer in the prior art data access storage and inter-process data
Shared problem.
In order to achieve the above objects and other related objects, the present invention provides a kind of storage of data access and inter-process data is total
System is enjoyed, applied between computer and the mobile phone of Android system, the data access storage and inter-process data shared system are wrapped
It includes: adaptation module and sharing module;The adaptation module is used for the number between the mobile phone or computer and the sharing module
According to being converted;The mobile phone or computer send shared file to the sharing module by the adaptation module, issue creation
Or the request of access shared file;The sharing module sends shared text to the mobile phone or computer by the adaptation module
Part;The sharing module includes shared library, and the shared library is for saving shared file;The sharing module is used for described total
It enjoys creation in library and stores and accesses shared file, and storage access is carried out by the way of shared drive to shared file;It is creating
Shared file is locked before building and accessing, shared file is correspondingly unlocked at the end of creation and access.
Optionally, the shared file includes the inter-process data of the mobile phone or the computer.
Optionally, the adaptation module is Glue adaptation module.
Optionally, the sharing module further includes semaphore creation module, shared file creation module, shared file access
Module plus unlocked state and control module;The semaphore creation module is used to create semaphore according to shared file;It is described total
File creation module is enjoyed for the creation storage shared file in the shared library;The shared file access modules are for accessing
Shared file in the shared library;Described plus unlocked state is used to before creating or accessing lock shared file, and
It is unlocked accordingly at the end of creation or access;The control module is for controlling the semaphore creation module, described
Shared file creation module, the shared file access modules, described plus unlocked state and the shared library.
Optionally, the shared file creation module creates storage shared file simultaneously in the shared library, described total
Enjoying library is that shared file distributes memory space for saving shared file.
Optionally, the sharing module is that creation stores shared file in accordance with the following steps: being created by the semaphore
Build module creation semaphore;Judge in the shared library with the presence or absence of the shared file: if it is present terminating;If do not deposited
Then described that unlocked state is added to lock shared file;It is created by shared file creation module and stores shared file, and
Memory space is distributed in the shared library for shared file;After the completion of shared file creation storage, described plus unlocked state is carried out
Corresponding unlock.
Optionally, the sharing module is to access shared file in accordance with the following steps: step 1 judges shared file
Whether semaphore is effective: if it is valid, jumping directly to step 3;If invalid, created by semaphore creation module
The semaphore of shared file, then go to step two;Step 2 judges in the shared library with the presence or absence of shared file: if
In the presence of then going to step three;If it does not exist, then terminating;Step 3, described plus unlocked state lock shared file;It is logical
It crosses the shared file access modules and accesses shared file in the shared library;And after access, described plus Xie Suomo
Block is unlocked accordingly.
Optionally.It there are shared file include: that shared file is assigned in the shared library and deposits in the shared library
Storage space and shared file have created completion.
Optionally, the sharing module further includes one or more expansion interfaces.
As described above, a kind of data access storage of the invention and inter-process data shared system, according to Bridge mode
It is designed as sharing module and adaptation module, the shared file of mobile phone or computer sended over is converted by adaptation module
The shared file that sharing module can identify, and store into shared library;Computer or mobile phone, which are shared, to be stored into the shared library
Shared file, thus the perfect data sharing service function of realizing the mobile phone under computer and Android platform.Also, this hair
It is bright that also there are following advantageous effects:
1 present invention rationally designs out data structure required for realizing data sharing business, while using shared drive
Mode carries out storage access to data, can greatly improve the overall performance of system in this way;Reduce software transplanting and maintenance
Degree-of-difficulty factor.
Shared file in mobile phone or computer is stored as a shared library by 2 present invention, in mobile phone or computer respectively into
Journey is to its share and access;And it is all accessed by the way of mutual exclusion lock to the shared file in shared library, enhances system
Security and stability.
3 present invention are day by the data in one bigger shared drive of maintenance, while by the way of shared library
Great benefit is come to the value-added service of system and transplanting work belt afterwards.
Embodiment
Present embodiment discloses a kind of storage of data access and inter-process data shared systems, are applied to computer and Android system
Between the mobile phone of system, to complete the shared of the storage of the data access between mobile phone and computer and inter-process data.As shown in Figure 1,
The data access of the present embodiment stores and inter-process data shared system 100 includes: adaptation module 110 and sharing module 120.
Adaptation module 110 is used to complete the data conversion between mobile phone 200 or computer 300 and sharing module.Adaptation module
110 pairs of mobile phones 200 or the UI (User Interface, interface) of computer 300 etc. issue the configuration got off and (create or access is asked
Ask, the shared file of transmission) data conversion is carried out to meet the parameter transmitting of sharing module 120.Mobile phone 200 and computer 300 are logical
Cross the shared of API (Application Programming Interface, application programming interface) function call of standard
Shared file in module 120.Either equipment still passes through common mobile network GPRS/ by WIFI by USB in this way
WCDMA/LTE uses the data sharing under the premise of data easily to be realized.Also, it can be very big by adaptation module 110
Raising system safety and stability performance, while also greatly reducing the degree-of-difficulty factor of software transplanting and maintenance.
Mobile phone 200 or computer 300 pass through adaptation module 110 and send shared file to sharing module 120, issue creation or visit
Ask the request of shared file, sharing module 120 sends shared file to mobile phone 200 or computer 300 by adaptation module 110.Hand
The file and request that machine 200 or computer 300 are issued to adaptation module 110, are converted into sharing module in adaptation module 110
120 formats identified, i.e. shared file save so as to unified.Similarly, sharing module 120 feeds back to adaptation module 110
Shared file, adaptation module 110 are converted into after the identifiable format of requesting party again according to its requesting party's (mobile phone or computer)
It is sent to requesting party.
As described above, adaptation module 110 provides unified interface API Function to mobile phone 200 or computer 300.Preferably,
Adaptation module 110 uses Glue adaptation module, identifies specific hardware plan and product chips structure, calls matched API.
Glue adaptation module may call upon corresponding SDK (Software Development Kit, Software Development Kit) API
Registered events.A function pointer is transmitted in API, in event triggering, SDK will call directly this API.
Sharing module 120 includes shared library 121, and shared library 121 is for saving shared file;Sharing module 121 is used for
Shared file is created and accessed in shared library 121, also, shared file is locked before creating and accessing, and is being created and is being accessed
At the end of shared file is correspondingly unlocked.
Further, as shown in Figure 1, sharing module 120 further includes semaphore creation module 122, shared file creation mould
Block 123, shared file access modules 124 plus unlocked state 125 and control module 126.
Wherein, semaphore creation module 122 is used to create semaphore according to shared file, and semaphore and shared file are one
One is corresponding, that is to say, that semaphore is unique.
Shared file creation module 123 is shared file for creating shared file, shared library 121 in shared library 121
Distribute corresponding memory space.Also, it after shared file creation, is stored using the access storage mode of shared drive.
Shared file access modules 124 are used to access the shared file in shared library 121.
Add unlocked state 125 create or access before shared file is locked, and at the end of creation or access into
The corresponding unlock of row, is accessed by way of adding and unlocking so that being all made of mutual exclusion lock to the shared file in shared library 121,
Enhance the security and stability of whole system.
Control module 126 is for controlling semaphore creation module 122, shared file creation module 123, shared file access
Module 124 plus unlocked state 125 and shared library 121.
Sharing module 120 is to provide each process data creation for upper layer (i.e. mobile phone or computer), storage, call and access,
Using compiling it as shared library 121.Simultaneously because multi-process accesses storage to data therein, so on this basis
By the way of shared drive combination resource calling-on signal amount.
By taking the shared file process for creating SHARE_HAL_SWITCH_T*pShareHalSwitch as an example, the present embodiment
The process of the creation storage shared file of sharing module 122 is specifically as shown in Figure 2, comprising:
Step 1 is the resource calling-on signal that shared file creates a unique identification by semaphore creation module 122
Amount:
HalSwitchSem=VOS_SemOpen (HAL_L2_SEM, 1,0);
If (VOS_SEM_INVALID==halSwitchSem)
{
Printf (" fun [%s] line [%d] r n ", _ _ FUNCTION__, _ _ LINE__);
return;
}
Step 2 judges in shared library 122 with the presence or absence of the shared file:
If it does, illustrating to have existed this document in shared library 120, then do not need to create the shared file,
Terminate;
If it does not exist, then plus unlocked state 125 to shared file lock;It is created by shared file creation module 123
Shared file, and memory space is distributed in shared library 121 for shared file;After the completion of shared file creation, add Xie Suomo
Block 125 is unlocked accordingly.
Wherein, the creation of shared file creation module 123 shared file includes:
GShareHalSwitchFd=open (SHARE_HAL_SWITCH_FILE, O_RDWR, 0666);
if(gShareHalSwitchFd<0)
{
return;
}
Distributing memory space for shared file includes:
PShareHalSwitch=(SHARE_HAL_SWITCH_T*) mmap (NULL, sizeof (SHARE_HAL_
SWITCH_T),PROT_READ|PROT_WRITE,MAP_SHARED,gShareHalSwitchFd,0);
If (pShareHalSwitch==MAP_FAILED)
{
Printf (" [%s%d] mmap error. ", _ _ FUNCTION__, _ _ LINE__);
}
It and during entire creation of the shared file creation module 123 to shared file, is protected by " lock ",
Mean can only to have the thread accesses object.
Further, there are two the judgment basis that whether there is shared file in shared library 121: shared file is in shared library
Memory space is assigned in 121, and shared file complete in shared library 121 by creation storage.
The process of the access shared file of the sharing module 122 of the present embodiment is specifically as shown in Figure 2, comprising:
Step 1 judges whether the semaphore of shared file is effective:
If effectively, due to semaphore and shared file be it is one-to-one, the semaphore is effective, and shared file is just
It is present in shared library 121, then jumping directly to the access that step 3 carries out shared file;
If invalid, the semaphore of shared file is created by semaphore creation module 122, then go to step two into
The judgement that row shared file whether there is.
Step 2 judges in shared library 121 with the presence or absence of shared file:
If it does, indicate shared file exist in shared library 121, and the visit for the three carry out shared files that go to step
It asks;
If it does not, indicate shared file be not present, access request be also it is meaningless, then terminate.
Step 3 adds unlocked state 125 to lock shared file;Shared library is accessed by shared file access modules 124
Shared file in 121;And after access, unlocked state 125 is added to be unlocked accordingly.
It in entire access process of the shared file access modules 124 to shared file, is protected by " lock ", meaning
Can only have the thread accesses object.
Further, there are two the judgment basis that whether there is shared file in shared library 121: shared file is in shared library
Memory space is assigned in 121, and shared file complete in shared library 121 by creation storage.Only there are two conditions
It meets simultaneously, just indicates that shared file is present in shared library 121.
It in the present embodiment, about the monitoring of sharing module 122 and debugging is completed by external PC machine (computer),
And PC machine uses PCOS system.
In addition, the sharing module 122 of the present embodiment further includes multiple expansion interfaces, for the data access for the present embodiment
The Function Extension of storage and inter-process data shared system provides spare interface.
In order to protrude innovative part of the invention, the technology proposed by the invention with solution is not asked in the present embodiment
The less close unit of topic relationship introduces, but this does not indicate that there is no other units in the present embodiment.
It should be noted that the basic conception that only the invention is illustrated in a schematic way is illustrated provided in the present embodiment,
Then only shown in schema with it is of the invention in related component rather than component count, shape and size when according to actual implementation draw
System, when actual implementation kenel, quantity and the ratio of each component can arbitrarily change for one kind, and its assembly layout kenel can also
It can be increasingly complex.
Also, the step of various methods above, divides, and is intended merely to describe clear, and when realization can be merged into a step
Or certain steps are split, multiple steps are decomposed into, as long as comprising identical logical relation, all in the protection of this patent
In range;To adding inessential modification in algorithm or in process or introducing inessential design, but do not change it
The core design of algorithm and process is all in the protection scope of the patent.
In conclusion a kind of data access storage of the invention and inter-process data shared system, according to Bridge mode
It is designed as sharing module and adaptation module, the shared file of mobile phone or computer sended over is converted by adaptation module
The shared file that sharing module can identify, and store into shared library;Computer or mobile phone, which are shared, to be stored into the shared library
Shared file, thus the perfect data sharing service function of realizing the mobile phone under computer and Android platform.Also, this hair
It is bright also rationally design out realize data sharing business required for data structure, while by the way of shared drive to data into
Row storage access, can greatly improve the overall performance of system in this way;Reduce the degree-of-difficulty factor of software transplanting and maintenance.This
Shared file in mobile phone or computer is stored as a shared library by invention, so that each process shares visit to it in mobile phone or computer
It asks;And it is all accessed by the way of mutual exclusion lock to the shared file in shared library, enhances system security and stability.This
Invention is in the future to system by the data in one bigger shared drive of maintenance, while by the way of shared library
Value-added service and transplanting work belt carry out great benefit.So the present invention effectively overcome various shortcoming in the prior art and
Has high industrial utilization value.
The above-described embodiments merely illustrate the principles and effects of the present invention, and is not intended to limit the present invention.It is any ripe
The personage for knowing this technology all without departing from the spirit and scope of the present invention, carries out modifications and changes to above-described embodiment.Cause
This, institute is complete without departing from the spirit and technical ideas disclosed in the present invention by those of ordinary skill in the art such as
At all equivalent modifications or change, should be covered by the claims of the present invention.