CN103731328B - System and method based on Linux Sharing Memory Realization home gateway data communication - Google Patents
System and method based on Linux Sharing Memory Realization home gateway data communication Download PDFInfo
- Publication number
- CN103731328B CN103731328B CN201410002084.2A CN201410002084A CN103731328B CN 103731328 B CN103731328 B CN 103731328B CN 201410002084 A CN201410002084 A CN 201410002084A CN 103731328 B CN103731328 B CN 103731328B
- Authority
- CN
- China
- Prior art keywords
- linux
- signal
- critical zone
- subelement
- shared drive
- 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.)
- Active
Links
Abstract
The invention discloses a kind of system and method based on Linux Sharing Memory Realization home gateway data communication, relate to Linux data communication technology field.System includes shared drive exclusive reference unit, reading shared drive data cell, writes shared drive data cell and data synchronisation unit;The critical zone mutual exclusion that shared drive exclusive reference unit includes being sequentially connected with initializes subelement, critical zone authority acquiring subelement and deadlock and rebuilds subelement, critical zone authority acquiring subelement and reading shared drive data cell, writes shared drive data cell and is connected;Data synchronisation unit includes that signal installs subelement, signal monitors subelement and signal sends subelement, writes shared drive data cell and is connected with signal installation subelement, and signal installation subelement monitors subelement with signal, signal sends subelement and is connected.The present invention ensure that business configuration data safety between home gateway system multi-process, carries out share and access efficiently, it is simple to people use.
Description
Technical field
The present invention relates to Linux data communication technology field, be specifically related to a kind of based on Linux
The system and method for Sharing Memory Realization home gateway data communication.
Background technology
Home gateway can by existing computer networking technology, by household electrical appliances various in family and
Equipment networks, and provides various diversified service by network for people.Along with network technology
Development, home gateway is the most gradually applied to average family;Along with the progress in epoch, home gateway
To replace Modem (modem) and router, the home network becoming main flow accesses
Equipment.The uplink mode of home gateway is mainly supported: ADSL (Asymmetric Digital
Subscriber Line, Asymmetrical Digital Subscriber Line) up, LAN (Local Area Network,
LAN) up, PON (Passive Optical Network, passive optical-fiber network) is up.
Business datum specifically includes that Internet (internet), VoIP (Voice over Internet
Protocol, procotol phone) and IPTV (Internet Protocol TV, procotol
TV) etc..
At present, home gateway typically follows the definition requirement in TR069 specification to data model,
This data model has good manageability, can not only flexible adaptation in various uplink modes,
And multiple business ability, beneficially Internet service provider can be provided the user with and carry out unified portion
Administration and management.
The manageability demand of home gateway so that the service needed of home gateway is according to operator
The configuration data demand issued comes into force;Because the data of home gateway are unified to join by operator
Put management, so home gateway configuration data are between Configuration Manager and business module, need
A kind of realization is wanted to configure the communication means that data are shared between different application module, to realize house
The purpose that front yard gateway service comes into force according to the requirement of operator.
At present, home gateway system is generally basede on the Linux (class of a kind of free and open source code
Unix operating system) system develops, and inherits linux system resource, and linux system enters
Communication mode between journey is generally: configuration file shares communication mode, IPC (Inter-Process
Communication, interprocess communication) message queue communication mode and local Socket (BSD
The Interprocess Communication Mechanism socket of UNIX) communication mode, above communication mode is distinguished in use
There is following defect:
When using configuration file to share communication mode, owing to configuration file is by multiple routine accesses,
Therefore configuration file may be written and read operation by two programs simultaneously, and then makes configuration file
Reentry, cause configuration information to lose, the hidden danger that not only security presence is certain, and grasp with internal memory
Comparing, operating efficiency is relatively for the I/O (input/output, input/output port) of configuration file
Low.
When using IPC message queue communication mode, IPC message queue is only capable of supporting small data quantity
Communication, during multi-process carries out mass data communication use IPC message queue, meeting
Make data transmit-receive sequential control improper, and then cause message out of order, the data of generation error,
Cause IPC to run it may happen that deviation, can not get expected result.
When using local Socket communication mode, only support binary stream communication due to Socket,
Therefore local Socket is more complicated to the process of the packing and unpacking of data, its operating efficiency
Relatively low, it is not easy to people and uses.
Summary of the invention
For defect present in prior art, it is an object of the invention to provide a kind of based on
The system and method for Linux Sharing Memory Realization home gateway data communication, can not only ensure
Business configuration data safety between home gateway system multi-process, and can carry out efficiently altogether
Enjoy access, it is simple to people use.
For reaching object above, the present invention adopts the technical scheme that: 1, a kind of based on Linux
The system of Sharing Memory Realization home gateway data communication, it is characterised in that: include shared drive
Exclusive reference unit, read shared drive data cell, write shared drive data cell and data more
New synchronization notice unit;
Shared drive exclusive reference unit includes that the initial beggar of critical zone mutual exclusion being sequentially connected with is single
Subelement rebuild by unit, critical zone authority acquiring subelement and deadlock, and deadlock is rebuild subelement and faced
Battery limit (BL) mutual exclusion initializes subelement and connects, in critical zone authority acquiring subelement is shared with reading respectively
Deposit data unit, write shared drive data cell connect;
Data update synchronization notice unit include signal install subelement, signal monitor subelement and
Signal sends subelement, writes shared drive data cell and is connected with signal installation subelement, signal
Subelement is installed send subelement be connected with signal monitoring subelement, signal respectively;
Critical zone mutual exclusion initializes subelement, is used for: pre-set business data, obtains and business number
According to corresponding mutex amount title, send initializing signal;After receiving initializing signal, adjust
Use linux system function;According to mutex amount title, initial by linux system function
Change mutex amount, generate the return value of linux system function;Judge linux system function
Return value be 0, linux kernel by mutex amount resource store to semaphore memory block,
Signal is obtained to critical zone authority acquiring subelement sending permission;
Critical zone authority acquiring subelement, is used for: receives critical zone mutual exclusion initialization subelement and sends out
After the authority acquiring signal sent, preset the stand-by period obtaining mutex amount, preset and obtain mutually
Scold the access times of semaphore;Preset linux kernel semaphore resource access function malloc failure malloc
Error code, include in error code existence call time-out ETIMEDOUT information;
In semaphore memory block, by linux kernel semaphore resource access function, obtain
Mutex amount resource, generates the return value of linux kernel semaphore resource access function;Sentence
Whether the return value of disconnected linux kernel semaphore resource access function is 0,
If so, linux system function, operation mutual exclusion semaphore resource lock shared drive are called
Data storage critical zone, generates linux system function call return value;Judge linux system
Function call return value is 0, by shared drive date read-write cell interface, to shared drive
Data storage critical zone carries out service data manipulating;Release shared drive data storage critical zone
Operating right;
Otherwise whether decision error code is ETIMEDOUT information, it is judged that obtain mutex
Whether the acquisition number of times of amount resource, more than access times, is if so, rebuild subelement to deadlock and is sent
Access times are otherwise added 1 by deadlock reconstruction signal, reacquire semaphore resource;
Subelement rebuild by deadlock, is used for: receive the deadlock that critical zone authority acquiring subelement sends
After reconstruction signal, delete shared drive data storage critical zone original control signal amount, generate
Delete result;
Read shared drive data cell, be used for: obtain the visit of shared drive data storage critical zone
Ask authority, generate and obtain the return value sharing critical zone authority;Judge to obtain and share critical zone power
Whether the return value of limit is 0, if so, reads required from shared drive data storage critical zone
Business datum, release shared drive data storage critical zone operating right;Otherwise obtain also
The access rights of record shared drive data storage critical zone obtain failed abnormal information;
Write shared drive data cell, be used for: obtain the visit of shared drive data storage critical zone
Ask authority, generate and obtain the return value sharing critical zone authority;Judge to obtain and share critical zone power
Whether the return value of limit is 0, if so, write configuration in shared drive data storage critical zone
Business datum, the operating right of release shared drive data storage critical zone, passes through call signal
The function that sending subelement provides sends the business function module that signal notice business datum is corresponding,
It is different that the access rights otherwise obtaining and recording shared drive data storage critical zone obtain unsuccessfully
Often information;
Signal installs subelement, is used for: calls linux system function and initializes Linux signal,
Linux signal received processing program is installed, generates the return value of linux system function;Judge
Whether the return value of linux system function is 0, and if so, definition Linux signal reception processes
Program is installed successfully, otherwise obtains and record Linux signal received processing program install failure
Information;
Signal monitors subelement, is used for: preset the listening period that Linux signal receives, and presets
The time-out time that Linux signal is monitored, creates Linux signal watcher thread, generates Linux
The return value of system function;Whether the return value judging linux system function is 0, if it is not,
Obtain and record Linux signal watcher thread and create failure information, otherwise follow in listening period
Ring monitors Linux signal;
Judge that signal arrives whether overall identification is non-zero, if so, arrives signal in overall identification
Add 1, otherwise in time-out time, it is judged that signal arrives whether overall identification is non-zero, if not
It is to continue circulation in listening period and monitor Linux signal, otherwise face from internal storage data storage
Within battery limit reads business datum and sends to corresponding business module, and signal arrives overall situation mark
Know and be set to 0, continue circulation in listening period and monitor Linux signal;
Signal sends subelement, is used for: receive the linux system life that external call interface sends
After order, send target according to the target process name acquiring signal corresponding with linux system order
Process number, generates the return value of linux system function;Judge the return of linux system function
Value is 0, sends Linux signal to target process.
On the basis of technique scheme, the mutual exclusion of described critical zone initializes the institute in subelement
State business datum and include Internet business datum, procotol phone VoIP business number
According to network protocol television IPTV service data.
On the basis of technique scheme, described in the authority acquiring subelement of described critical zone
Stand-by period is 800~1200 milliseconds;Described access times are 3~5 times.
On the basis of technique scheme, described in the authority acquiring subelement of described critical zone
Service data manipulating includes: shared drive data storage critical zone in write business datum,
The storage of shared drive data reads business datum in critical zone.
On the basis of technique scheme, when described signal monitors the described monitoring in subelement
Between be 2~3 seconds, described time-out time is 2~5 seconds.
A kind of be applied to said system based on Linux Sharing Memory Realization home gateway data lead to
The method of letter, comprises the following steps:
S1: pre-set business data, obtain the mutex amount title corresponding with business datum, send out
Send initializing signal;Call linux system function;According to mutex amount title, pass through
Linux system function initializes mutex amount, generates the return value of linux system function;
Judge that mutex amount resource, as 0, is stored to semaphore by the return value of linux system function
Memory block;
S2: preset the stand-by period obtaining mutex amount, presets the visit obtaining mutex amount
Ask number of times;Preset the error code of linux kernel semaphore resource access function malloc failure malloc, wrong
ETIMEDOUT information is included in error code;
In semaphore memory block, by linux kernel semaphore resource access function, obtain
Mutex amount resource, generates the return value of linux kernel semaphore resource access function;Sentence
Whether the return value of disconnected linux kernel semaphore resource access function is 0,
If so, linux system function, operation mutual exclusion semaphore resource lock shared drive are called
Data storage critical zone, generates linux system function call return value;Judge linux system
Function call return value is 0, by shared drive date read-write cell interface, to shared drive
Data storage critical zone carries out service data manipulating;Release shared drive data storage critical zone
Operating right;
Otherwise whether decision error code is ETIMEDOUT information, it is judged that obtain mutex
Whether the acquisition number of times of amount resource, more than access times, if so, forwards step S3 to, otherwise will
Access times add 1, reacquire semaphore resource;
S3: delete shared drive data storage critical zone original control signal amount, generate and delete
Result;
S4: read business configuration operation information, if business configuration operation information is that reading business is joined
Put data message, forward step S5 to;If business configuration operation information is amendment or more new business
Data message, forwards step S6 to;
S5: obtain the access rights of shared drive data storage critical zone, generates to obtain to share and faces
The return value of battery limit (BL) authority;Judge whether the return value obtaining shared critical zone authority is 0, if
It is to read required business datum, in release is shared from shared drive data storage critical zone
The operating right of deposit data storage critical zone;Otherwise obtain and record shared drive data storage to face
The access rights of battery limit (BL) obtain failed abnormal information;
S6: obtain the access rights of shared drive data storage critical zone, generates to obtain to share and faces
The return value of battery limit (BL) authority;Judge whether the return value obtaining shared critical zone authority is 0, if
It is in shared drive data storage critical zone, to write configuration service data, discharge shared drive
The operating right of data storage critical zone, the function that sending subelement by call signal provides is sent out
The business function module that the number of delivering letters notice business datum is corresponding, otherwise obtains and records shared drive
The access rights of data storage critical zone obtain failed abnormal information;Forward step S7 to;
S7: call linux system function and initialize Linux signal, installs Linux signal and connects
Receive processing routine, generate the return value of linux system function;Judge linux system function
Whether return value is 0, and if so, definition Linux signal received processing program is installed successfully, no
Then obtain and record the information of Linux signal received processing program install failure;Read Linux
Signal operation information, if Linux signal operation information is Linux signal monitoring information, forwards to
Step S8;If Linux signal operation information is Linux signal sends information, forward step to
S9;
S8: preset the listening period that Linux signal receives, presets the super of Linux signal monitoring
Time the time, create Linux signal watcher thread, generate linux system function return value;
Whether the return value judging linux system function is 0, if it is not, obtain and record Linux
Signal watcher thread creates failure information, and otherwise in listening period, Linux signal is monitored in circulation;
Judge that signal arrives whether overall identification is non-zero, if so, arrives signal in overall identification
Add 1, otherwise in time-out time, it is judged that signal arrives whether overall identification is non-zero, if not
It is to continue circulation in listening period and monitor Linux signal, otherwise face from internal storage data storage
Within battery limit reads business datum and sends to corresponding business module, and signal arrives overall situation mark
Know and be set to 0, continue circulation in listening period and monitor Linux signal;
S9: send mesh according to the target process name acquiring signal corresponding with linux system order
Mark process number, generates the return value of linux system function;Judge returning of linux system function
Returning value is 0, sends Linux signal to target process.
On the basis of technique scheme, described in step S1, business datum includes Internet
Business datum, VoIP business datum and IPTV service data.
On the basis of technique scheme, the stand-by period described in step S2 is 800~1200
Millisecond;Described access times are 3~5 times.
On the basis of technique scheme, described in step S2, service data manipulating includes:
In shared drive data storage critical zone, write business datum, face in shared drive data storage
Battery limit (BL) reads business datum.
On the basis of technique scheme, listening period described in step S8 is 2~3 seconds,
Described time-out time is 2~5 seconds.
Compared with prior art, the beneficial effects of the present invention is:
(1) the shared drive exclusive reference unit of the present invention is a kind of based on Linux name letter
The shared drive data storage critical zone protected location of number amount, shared drive exclusive reference unit energy
Enough exclusive references controlled shared drive data storage critical zone, effectively protection shared drive number
According to storage critical zone;In can not only ensureing the same time, only individual process is able to access that altogether
Enjoy the resource of internal storage data storage critical zone, and it is critical to be prevented from the storage of shared drive data
Qu Yin reentries and causes data to be destroyed, it is ensured that between home gateway system multi-process, business is joined
Put the safety of data.
(2) the shared drive exclusive reference unit of the present invention can control shared drive data
The exclusive reference of storage critical zone, therefore, is difficult to message out of order, Jin Erneng when the present invention uses
Enough accurately obtain expected result.
(3) when the reading shared drive data cell of the present invention reads business configuration data, write altogether
When enjoying internal storage data unit write business datum, it is shared drive data storage critical zone
Chip operates.Compared with the I/O operation of configuration file in prior art, the present invention can be to industry
Business configuration data carry out batch operation, and its operation and efficiency of transmission are the highest, it is possible to enter efficiently
Row share and access, it is simple to people use.
Accompanying drawing explanation
Fig. 1 is to lead to based on Linux Sharing Memory Realization home gateway data in the embodiment of the present invention
The connection block diagram of the system of letter;
Fig. 2 is the workflow diagram that in the embodiment of the present invention, critical zone mutual exclusion initializes subelement;
Fig. 3 is the workflow diagram of critical zone authority acquiring subelement in the embodiment of the present invention;
Fig. 4 is the workflow diagram that in the embodiment of the present invention, subelement rebuild by deadlock;
Fig. 5 is the workflow diagram reading shared drive data cell in the embodiment of the present invention;
Fig. 6 is the workflow diagram writing shared drive data cell in the embodiment of the present invention;
Fig. 7 is the workflow diagram that in the embodiment of the present invention, signal installs subelement;
Fig. 8 is the workflow diagram that in the embodiment of the present invention, signal monitors subelement;
Fig. 9 is the workflow diagram that in the embodiment of the present invention, signal sends subelement.
Detailed description of the invention
Below in conjunction with drawings and Examples, the present invention is described in further detail.
Shown in Figure 1, in the embodiment of the present invention based on Linux Sharing Memory Realization family
The system of gateway data communication, including shared drive exclusive reference unit, reads shared drive data
Unit, write shared drive data cell and data and update synchronization notice unit;Shared drive mutual exclusion
Accessing unit and be connected with reading shared drive data cell, shared drive exclusive reference unit is by writing
Shared drive data cell updates synchronization notice unit with data and is connected.
Shared drive exclusive reference unit includes that the initial beggar of critical zone mutual exclusion being sequentially connected with is single
Subelement rebuild by unit, critical zone authority acquiring subelement and deadlock, and deadlock is rebuild subelement and faced
Battery limit (BL) mutual exclusion initializes subelement and connects, in critical zone authority acquiring subelement is shared with reading respectively
Deposit data unit, write shared drive data cell connect.
Data update synchronization notice unit include signal install subelement, signal monitor subelement and
Signal sends subelement, writes shared drive data cell and is connected with signal installation subelement, signal
Subelement is installed send subelement be connected with signal monitoring subelement, signal respectively.
Based on Linux Sharing Memory Realization home gateway data communication in the embodiment of the present invention
Method, comprises the following steps:
S1: initialize subelement by critical zone mutual exclusion and carry out mutex amount initialization.
S2: by critical zone authority acquiring subelement, obtains shared drive data storage critical zone
Operating right, if shared drive data storage critical zone operating right obtain successfully, then turn
To step S4, otherwise forward step S3 to.
S3: rebuild subelement by deadlock and rebuild the control letter of shared drive data storage critical zone
Number amount, re-execute step S2.
S4: read business configuration operation information, if business configuration operation information is that reading business is joined
Put data message, forward step S5 to;If business configuration operation information is amendment or more new business
Data message, forwards step S6 to.
S5: read in shared drive data storage critical zone by reading shared drive data cell
Required business configuration data.
S6: critical by writing the amendment of shared drive data cell and renewal shared drive data storage
Business datum in district, forwards step S7 to.
S7: install subelement by signal, installs Linux signal received processing program;Read
Linux signal operation information, if Linux signal operation information is Linux signal monitoring information,
Forward step S8 to;If Linux signal operation information is Linux signal sends information, forward step to
Rapid S9.
S8: monitor subelement by signal, carry out the monitoring of Linux signal.
S9: send subelement by signal, sends Linux signal to target process.
Shown in Figure 2, step S1 (when i.e. critical zone mutual exclusion initializes subelement work),
Comprise the following steps:
S101: pre-set business data, obtain the mutex amount title corresponding with business datum,
Send initializing signal.Business datum includes Internet (internet) business datum, VoIP
(Voice over Internet Protocol, procotol phone) business datum and IPTV (net
Network protocol TV) business datum etc..
S102: after receiving initializing signal, call linux system function;According to mutex
Amount title, initializes mutex amount by linux system function, generates linux system letter
The return value of number.
S103: whether the return value judging linux system function is 0, the most then mutual exclusion letter
Number amount initializes successfully, forwards step S104 to, and otherwise mutex amount initializes unsuccessfully, different
Often exit critical zone mutual exclusion and initialize subelement.
Mutex amount resource is stored to semaphore memory block by S104:Linux kernel, normally
Exit critical zone mutual exclusion and initialize subelement.
Shown in Figure 3, step S2 (i.e. during the work of critical zone authority acquiring subelement), bag
Include following steps:
S201: presetting the stand-by period obtaining mutex amount, the stand-by period is according to the need of user
Ask setting, generally 800~1200 milliseconds;Preset the access times obtaining mutex amount,
Access times according to the requirements set of user, generally 3~5 times;Preset linux kernel letter
Number amount resource access function malloc failure malloc error code, include ETIMEDOUT in error code
(exist and call time-out) information.
S202: in semaphore memory block, by linux kernel semaphore resource access function
(external call interface), obtains external interface and calls the mutex amount resource of access, generate
The return value of linux kernel semaphore resource access function.
S203: whether the return value judging linux kernel semaphore resource access function is 0,
The most then mutex amount resource acquisition success, goes to step 207, and otherwise mutex amount provides
Source obtains unsuccessfully, forwards step 204 to.
Whether S204: the error code that misdeems is ETIMEDOUT (exist and call time-out) information,
The acquisition time the most then obtaining mutex amount resource is more than the stand-by period, forwards step to
S205, otherwise obtains the storage critical section operation authority failure of shared drive data, extremely exits and face
Battery limit (BL) authority acquiring subelement.
S205: judge whether the acquisition number of times obtaining mutex amount resource is more than access times,
If so, rebuild subelement to deadlock and send deadlock reconstruction signal (i.e. forwarding step S301 to), different
Often exit critical zone authority acquiring subelement, otherwise forward step S206 to.
S206: add 1 by access times, forwards step S202 to.
S207: call linux system function, operation mutual exclusion semaphore resource lock shared drive
Data storage critical zone, generates linux system function call return value.
S208: judge whether linux system function call return value is 0, the most then share
Internal storage data storage critical zone locks successfully, forwards step S209 to, otherwise obtains shared drive
Data storage critical section operation authority failure, exits critical zone authority acquiring subelement extremely.
S209: by shared drive date read-write cell interface, shared drive data storage is faced
Battery limit (BL) carries out service data manipulating, and service data manipulating includes: face in shared drive data storage
Battery limit (BL) writes business datum, in shared drive data storage critical zone, reads business datum.
S210: the operating right of release shared drive data storage critical zone, normally exits critical
District's authority acquiring subelement.
Shown in Figure 4, step S3 (when i.e. subelement work rebuild by deadlock), including following
Step:
S301: after receiving deadlock reconstruction signal, deletes shared drive data storage critical zone original
Control signal amount, generate delete result.
S302: judge to delete whether result is 0, the most then control signal amount is deleted successfully,
Forwarding step S303 to, otherwise control signal amount is deleted unsuccessfully, extremely exits deadlock and rebuilds son list
Unit.
S303: initialize subelement to critical zone mutual exclusion and send initializing signal, (i.e. forward step to
Rapid S102), normally exit deadlock and rebuild subelement.
Shown in Figure 5, step S5 (when i.e. reading the work of shared drive data cell), including
Following steps:
S501: by the interface (external call interface) of critical zone authority acquiring subelement, obtain
Take the access rights of shared drive data storage critical zone, generate to obtain and share critical zone authority
Return value.
S502: judge whether the return value obtaining shared critical zone authority is 0, the most altogether
The access rights enjoying internal storage data storage critical zone obtain successfully, forward step S503 to, otherwise
The access rights of shared drive data storage critical zone obtain unsuccessfully, forward S505 to.
S503: read required business datum from shared drive data storage critical zone.
S504: the operating right of release shared drive data storage critical zone, normally exits reading altogether
Enjoying internal storage data unit, business datum of reading etc. is to be used.
S505: the access rights obtaining and recording shared drive data storage critical zone obtain unsuccessfully
Abnormal information, extremely exit reading shared drive data cell.
Shown in Figure 6, step S6 (when i.e. writing the work of shared drive data cell), including
Following steps:
S601: by the interface (external call interface) of critical zone authority acquiring subelement, obtain
Take the access rights of shared drive data storage critical zone, generate to obtain and share critical zone authority
Return value.
S602: judge whether the return value obtaining shared critical zone authority is 0, the most altogether
The access rights enjoying internal storage data storage critical zone obtain successfully, forward step S603 to, otherwise
The access rights of shared drive data storage critical zone obtain unsuccessfully, forward S606 to.
S603: write configuration service data in shared drive data storage critical zone.
S604: the operating right of release shared drive data storage critical zone.
S605: the function that sending subelement by call signal provides sends signal notice business number
According to corresponding business function module, normally exit and write shared drive data cell.
S606: the access rights obtaining and recording shared drive data storage critical zone obtain unsuccessfully
Abnormal information, extremely exit and write shared drive data cell.
Shown in Figure 7, step S7 (when i.e. signal installs subelement work), including following
Step:
S701: call linux system function and initialize Linux signal, install Linux signal
Received processing program, generates the return value of linux system function.
S702: whether the return value judging linux system function is 0, the most then Linux
Signal received processing program is installed successfully, normally exits signal installation unit, otherwise Linux letter
Number received processing program install failure, forwards step S703 to.
S703: obtain and record the information of Linux signal received processing program install failure, different
Often exit signal installation unit.
Shown in Figure 8, step S8 (when i.e. signal monitors subelement work), including following
Step:
S801: (listening period is according to the need of user for the listening period that default Linux signal receives
Ask setting, generally 2~3 seconds);Preset the time-out time that Linux signal is monitored, (time-out
Time is arranged according to the demand of user, generally 2~5 seconds) call linux system function (i.e.
External call interface) create Linux signal watcher thread, generate returning of linux system function
Return value.
S802: whether the return value judging linux system function is 0, the most then Linux
Signal watcher thread creates successfully, forwards step S803 to, otherwise Linux signal watcher thread
Create unsuccessfully, forward step S807 to.
S803: Linux signal is monitored in circulation in listening period, it is judged that signal arrives overall situation mark
Whether be non-zero, the most then forward step S804 to, otherwise forward step S805 to if knowing.
S804: signal is arrived overall identification and adds 1.
S805;In time-out time, it is judged that signal arrives whether overall identification is non-zero, if so,
Then determine that Linux signal arrives, forward step S806 to, otherwise determine that Linux signal does not arrives,
Re-execute step S803.
S806: process power function by signal arrival, reads in internal storage data storage critical zone
Take business datum and send to corresponding business module, signal being arrived overall identification simultaneously and put
It is 0, forwards step S803 to.
S807: obtain and record Linux signal watcher thread and create failure information, extremely exit
Signal monitors subelement.
Semiotic function function is made up of " signal " and " power function ", and " signal " is used for:
Business datum is had the information notification related service module of change;" power function " is used for: be responsible for
Data syn-chronization, reads data from internal storage data storage critical zone, completes data syn-chronization." signal "
The combination of " power function ", it is possible to realize complete data communication.
Shown in Figure 9, step S9 (when i.e. signal sends subelement work), including following
Step:
S901: receive external call interface send linux system order after, according to Linux
The target process name acquiring signal that system command is corresponding sends target process number, generates Linux
The return value of system function.
S902: whether the return value judging linux system function is 0, the most then signal is sent out
Sending target process number to obtain successfully, forward step S903 to, otherwise signal sends target process number
Obtaining unsuccessfully, extremely exit signal and send subelement, end signal transmission flow, program continues
Run other tasks.
S903: send Linux signal to target process, normally exits signal and sends subelement.
The present invention is not limited to above-mentioned embodiment, for those skilled in the art
For, under the premise without departing from the principles of the invention, it is also possible to make some improvements and modifications,
Within these improvements and modifications are also considered as protection scope of the present invention.This specification is not made in detail
The content described belongs to prior art known to professional and technical personnel in the field.
Claims (10)
1. a system based on Linux Sharing Memory Realization home gateway data communication, its
It is characterised by: include shared drive exclusive reference unit, reading shared drive data cell, write altogether
Enjoy internal storage data unit and data update synchronization notice unit;
Shared drive exclusive reference unit includes that the initial beggar of critical zone mutual exclusion being sequentially connected with is single
Subelement rebuild by unit, critical zone authority acquiring subelement and deadlock, and deadlock is rebuild subelement and faced
Battery limit (BL) mutual exclusion initializes subelement and connects, in critical zone authority acquiring subelement is shared with reading respectively
Deposit data unit, write shared drive data cell connect;
Data update synchronization notice unit include signal install subelement, signal monitor subelement and
Signal sends subelement, writes shared drive data cell and is connected with signal installation subelement, signal
Subelement is installed send subelement be connected with signal monitoring subelement, signal respectively;
Critical zone mutual exclusion initializes subelement, is used for: pre-set business data, obtains and business number
According to corresponding mutex amount title, send initializing signal;After receiving initializing signal, adjust
Use linux system function;According to mutex amount title, initial by linux system function
Change mutex amount, generate the return value of linux system function;Judge linux system function
Return value be 0, linux kernel by mutex amount resource store to semaphore memory block,
Signal is obtained to critical zone authority acquiring subelement sending permission;
Critical zone authority acquiring subelement, is used for: receives critical zone mutual exclusion initialization subelement and sends out
After the authority acquiring signal sent, preset the stand-by period obtaining mutex amount, preset and obtain mutually
Scold the access times of semaphore;Preset linux kernel semaphore resource access function malloc failure malloc
Error code, include in error code existence call time-out ETIMEDOUT information;
In semaphore memory block, by linux kernel semaphore resource access function, obtain
Mutex amount resource, generates the return value of linux kernel semaphore resource access function;Sentence
Whether the return value of disconnected linux kernel semaphore resource access function is 0,
If so, linux system function, operation mutual exclusion semaphore resource lock shared drive are called
Data storage critical zone, generates linux system function call return value;Judge linux system
Function call return value is 0, by shared drive date read-write cell interface, to shared drive
Data storage critical zone carries out service data manipulating;Release shared drive data storage critical zone
Operating right;
Otherwise whether decision error code is ETIMEDOUT information, it is judged that obtain mutex
Whether the acquisition number of times of amount resource, more than access times, is if so, rebuild subelement to deadlock and is sent
Access times are otherwise added 1 by deadlock reconstruction signal, reacquire semaphore resource;
Subelement rebuild by deadlock, is used for: receive the deadlock that critical zone authority acquiring subelement sends
After reconstruction signal, delete shared drive data storage critical zone original control signal amount, generate
Delete result;
Read shared drive data cell, be used for: obtain the visit of shared drive data storage critical zone
Ask authority, generate and obtain the return value sharing critical zone authority;Judge to obtain and share critical zone power
Whether the return value of limit is 0, if so, reads required from shared drive data storage critical zone
Business datum, release shared drive data storage critical zone operating right;Otherwise obtain also
The access rights of record shared drive data storage critical zone obtain failed abnormal information;
Write shared drive data cell, be used for: obtain the visit of shared drive data storage critical zone
Ask authority, generate and obtain the return value sharing critical zone authority;Judge to obtain and share critical zone power
Whether the return value of limit is 0, if so, write configuration in shared drive data storage critical zone
Business datum, the operating right of release shared drive data storage critical zone, passes through call signal
The function that sending subelement provides sends the business function module that signal notice business datum is corresponding,
It is different that the access rights otherwise obtaining and recording shared drive data storage critical zone obtain unsuccessfully
Often information;
Signal installs subelement, is used for: calls linux system function and initializes Linux signal,
Linux signal received processing program is installed, generates the return value of linux system function;Judge
Whether the return value of linux system function is 0, and if so, definition Linux signal reception processes
Program is installed successfully, otherwise obtains and record Linux signal received processing program install failure
Information;
Signal monitors subelement, is used for: preset the listening period that Linux signal receives, and presets
The time-out time that Linux signal is monitored, creates Linux signal watcher thread, generates Linux
The return value of system function;Whether the return value judging linux system function is 0, if it is not,
Obtain and record Linux signal watcher thread and create failure information, otherwise follow in listening period
Ring monitors Linux signal;
Judge that signal arrives whether overall identification is non-zero, if so, arrives signal in overall identification
Add 1, otherwise in time-out time, it is judged that signal arrives whether overall identification is non-zero, if not
It is to continue circulation in listening period and monitor Linux signal, otherwise face from internal storage data storage
Within battery limit reads business datum and sends to corresponding business module, and signal arrives overall situation mark
Know and be set to 0, continue circulation in listening period and monitor Linux signal;
Signal sends subelement, is used for: receive the linux system life that external call interface sends
After order, send target according to the target process name acquiring signal corresponding with linux system order
Process number, generates the return value of linux system function;Judge the return of linux system function
Value is 0, sends Linux signal to target process.
2. as claimed in claim 1 based on Linux Sharing Memory Realization home gateway data
The system of communication, it is characterised in that: the mutual exclusion of described critical zone initializes the described industry in subelement
Business data include Internet business datum, procotol phone VoIP business datum and
Network protocol television IPTV service data.
3. as claimed in claim 1 based on Linux Sharing Memory Realization home gateway data
The system of communication, it is characterised in that: the described wait in the authority acquiring subelement of described critical zone
Time is 800~1200 milliseconds;Described access times are 3~5 times.
4. as described in any one of claims 1 to 3 based on Linux Sharing Memory Realization man
The system of front yard gateway data communication, it is characterised in that: in the authority acquiring subelement of described critical zone
Described service data manipulating include: shared drive data storage critical zone in write business number
According to, shared drive data storage critical zone in read business datum.
5. as described in any one of claims 1 to 3 based on Linux Sharing Memory Realization man
The system of front yard gateway data communication, it is characterised in that: it is described that described signal is monitored in subelement
Listening period is 2~3 seconds, and described time-out time is 2~5 seconds.
6. one kind is applied to being total to based on Linux of system described in any one of claim 1 to 5
Enjoy the method that internal memory realizes home gateway data communication, it is characterised in that comprise the following steps:
S1: pre-set business data, obtain the mutex amount title corresponding with business datum, send out
Send initializing signal;Call linux system function;According to mutex amount title, pass through
Linux system function initializes mutex amount, generates the return value of linux system function;
Judge that mutex amount resource, as 0, is stored to semaphore by the return value of linux system function
Memory block;
S2: preset the stand-by period obtaining mutex amount, presets the visit obtaining mutex amount
Ask number of times;Preset the error code of linux kernel semaphore resource access function malloc failure malloc, wrong
ETIMEDOUT information is included in error code;
In semaphore memory block, by linux kernel semaphore resource access function, obtain
Mutex amount resource, generates the return value of linux kernel semaphore resource access function;Sentence
Whether the return value of disconnected linux kernel semaphore resource access function is 0,
If so, linux system function, operation mutual exclusion semaphore resource lock shared drive are called
Data storage critical zone, generates linux system function call return value;Judge linux system
Function call return value is 0, by shared drive date read-write cell interface, to shared drive
Data storage critical zone carries out service data manipulating;Release shared drive data storage critical zone
Operating right;
Otherwise whether decision error code is ETIMEDOUT information, it is judged that obtain mutex
Whether the acquisition number of times of amount resource, more than access times, if so, forwards step S3 to, otherwise will
Access times add 1, reacquire semaphore resource;
S3: delete shared drive data storage critical zone original control signal amount, generate and delete
Result;
S4: read business configuration operation information, if business configuration operation information is that reading business is joined
Put data message, forward step S5 to;If business configuration operation information is amendment or more new business
Data message, forwards step S6 to;
S5: obtain the access rights of shared drive data storage critical zone, generates to obtain to share and faces
The return value of battery limit (BL) authority;Judge whether the return value obtaining shared critical zone authority is 0, if
It is to read required business datum, in release is shared from shared drive data storage critical zone
The operating right of deposit data storage critical zone;Otherwise obtain and record shared drive data storage to face
The access rights of battery limit (BL) obtain failed abnormal information;
S6: obtain the access rights of shared drive data storage critical zone, generates to obtain to share and faces
The return value of battery limit (BL) authority;Judge whether the return value obtaining shared critical zone authority is 0, if
It is in shared drive data storage critical zone, to write configuration service data, discharge shared drive
The operating right of data storage critical zone, the function that sending subelement by call signal provides is sent out
The business function module that the number of delivering letters notice business datum is corresponding, otherwise obtains and records shared drive
The access rights of data storage critical zone obtain failed abnormal information;Forward step S7 to;
S7: call linux system function and initialize Linux signal, installs Linux signal and connects
Receive processing routine, generate the return value of linux system function;Judge linux system function
Whether return value is 0, and if so, definition Linux signal received processing program is installed successfully, no
Then obtain and record the information of Linux signal received processing program install failure;Read Linux
Signal operation information, if Linux signal operation information is Linux signal monitoring information, forwards to
Step S8;If Linux signal operation information is Linux signal sends information, forward step to
S9;
S8: preset the listening period that Linux signal receives, presets the super of Linux signal monitoring
Time the time, create Linux signal watcher thread, generate linux system function return value;
Whether the return value judging linux system function is 0, if it is not, obtain and record Linux
Signal watcher thread creates failure information, and otherwise in listening period, Linux signal is monitored in circulation;
Judge that signal arrives whether overall identification is non-zero, if so, arrives signal in overall identification
Add 1, otherwise in time-out time, it is judged that signal arrives whether overall identification is non-zero, if not
It is to continue circulation in listening period and monitor Linux signal, otherwise face from internal storage data storage
Within battery limit reads business datum and sends to corresponding business module, and signal arrives overall situation mark
Know and be set to 0, continue circulation in listening period and monitor Linux signal;
S9: send mesh according to the target process name acquiring signal corresponding with linux system order
Mark process number, generates the return value of linux system function;Judge returning of linux system function
Returning value is 0, sends Linux signal to target process.
7. as claimed in claim 6 based on Linux Sharing Memory Realization home gateway data
The method of communication, it is characterised in that: business datum described in step S1 includes Internet industry
Business data, VoIP business datum and IPTV service data.
8. as claimed in claim 6 based on Linux Sharing Memory Realization home gateway data
The method of communication, it is characterised in that: the stand-by period described in step S2 is 800~1200 millis
Second;Described access times are 3~5 times.
9. as described in any one of claim 6 to 8 based on Linux Sharing Memory Realization man
The method of front yard gateway data communication, it is characterised in that: service data manipulating described in step S2
Including: in shared drive data storage critical zone, write business datum, in shared drive data
Storage reads business datum in critical zone.
10. as described in any one of claim 6 to 8 based on Linux Sharing Memory Realization man
The method of front yard gateway data communication, it is characterised in that: listening period described in step S8 be 2~
3 seconds, described time-out time was 2~5 seconds.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410002084.2A CN103731328B (en) | 2014-01-02 | 2014-01-02 | System and method based on Linux Sharing Memory Realization home gateway data communication |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410002084.2A CN103731328B (en) | 2014-01-02 | 2014-01-02 | System and method based on Linux Sharing Memory Realization home gateway data communication |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103731328A CN103731328A (en) | 2014-04-16 |
CN103731328B true CN103731328B (en) | 2016-09-07 |
Family
ID=50455263
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410002084.2A Active CN103731328B (en) | 2014-01-02 | 2014-01-02 | System and method based on Linux Sharing Memory Realization home gateway data communication |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103731328B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104820622B (en) * | 2015-05-22 | 2019-07-12 | 上海斐讯数据通信技术有限公司 | A kind of shared drive lock management control method and system |
CN106681836B (en) * | 2016-12-28 | 2021-03-05 | 华为技术有限公司 | Semaphore creation method and semaphore creation device |
CN107689914A (en) * | 2017-08-28 | 2018-02-13 | 深圳通业科技股份有限公司 | A kind of communication means for the Multifunctional gateway for supporting TRDP agreements |
CN109508241B (en) * | 2018-11-20 | 2021-04-20 | 中国电子科技集团公司第五十四研究所 | Interprocess data exchange method |
CN112416815B (en) * | 2020-12-09 | 2023-05-23 | 中船重工(武汉)凌久电子有限责任公司 | High-speed storage playback method based on SRIO |
CN114911632B (en) * | 2022-07-11 | 2022-09-13 | 北京融为科技有限公司 | Method and system for controlling interprocess communication |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1501277A (en) * | 2002-11-19 | 2004-06-02 | 宝山钢铁股份有限公司 | Bus type inter-process communication method |
CN102141932A (en) * | 2010-12-14 | 2011-08-03 | 清华大学 | Large critical region protection method |
CN102541805A (en) * | 2010-12-09 | 2012-07-04 | 沈阳高精数控技术有限公司 | Multi-processor communication method based on shared memory and realizing device thereof |
CN103064748A (en) * | 2013-01-05 | 2013-04-24 | 浪潮电子信息产业股份有限公司 | Method for processing communication among multiple processes in Linux system |
-
2014
- 2014-01-02 CN CN201410002084.2A patent/CN103731328B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1501277A (en) * | 2002-11-19 | 2004-06-02 | 宝山钢铁股份有限公司 | Bus type inter-process communication method |
CN102541805A (en) * | 2010-12-09 | 2012-07-04 | 沈阳高精数控技术有限公司 | Multi-processor communication method based on shared memory and realizing device thereof |
CN102141932A (en) * | 2010-12-14 | 2011-08-03 | 清华大学 | Large critical region protection method |
CN103064748A (en) * | 2013-01-05 | 2013-04-24 | 浪潮电子信息产业股份有限公司 | Method for processing communication among multiple processes in Linux system |
Also Published As
Publication number | Publication date |
---|---|
CN103731328A (en) | 2014-04-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103731328B (en) | System and method based on Linux Sharing Memory Realization home gateway data communication | |
CN109451065B (en) | Soft load balancing and shunting automation system and operation method thereof | |
CN106453377B (en) | Block chain based distributed network intelligent monitoring system and method | |
US9037899B2 (en) | Automated node fencing integrated within a quorum service of a cluster infrastructure | |
KR102108595B1 (en) | Physical security system having multiple server nodes | |
CN105357266A (en) | Universal SOCKET communication and process management platform applied to multiple scenes and method | |
AU2016335997A1 (en) | Cloud-synchronized architecture for a home automation system | |
US10810863B2 (en) | Distributed security system over multiple sites | |
CN103455380A (en) | Multi-process communication system and establishment and communication method thereof | |
CN105530220B (en) | The interface method of two kinds of different agreement system communications is realized based on OPC | |
CN103944814A (en) | Data exchange method and system and gateway server | |
CN107682460B (en) | Distributed storage cluster data communication method and system | |
WO2018062913A1 (en) | Distributed platform for robust execution of smart home applications | |
US7913050B2 (en) | Fencing using a hierarchical relationship | |
CN108123826B (en) | Cross-region data interaction system and method | |
CN107357800A (en) | A kind of database High Availabitity zero loses solution method | |
CN108093077B (en) | Abnormality eliminating method, device and server | |
CN103984616A (en) | Server monitoring method and server | |
CN104935817A (en) | Remote video monitoring method based on XMPP protocol and system | |
JP6900891B2 (en) | Network systems, mobile devices, and connection programs | |
US10742480B2 (en) | Network management as a service (MaaS) using reverse session-origination (RSO) tunnel | |
EP2739010B1 (en) | Method for improving reliability of distributed computer systems based on service-oriented architecture | |
US9152513B2 (en) | In-band recovery mechanism for I/O modules in a data storage system | |
US11757722B2 (en) | Automatic switching fabric role determination system | |
KR20180073003A (en) | Apparatus and method for syncronizing of object |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |