Disclosure of Invention
The invention provides a process data read-write optimization method and a system of a mobile system, wherein, each read-write process is scanned through the conversion of an inspection process, a recovery process and three processes, when a main socket receives the read-write request of each read-write process, the data of a server end is read and written according to the read-write request, a data access queue is established, each read-write process is sequentially put into the data access queue according to the sequence of the read-write request, the inspection process writes the unfinished read-write request into a process record queue, and when the number of the read-write requests in the process record queue is greater than a record threshold value, the inspection process is converted into a blocking state, thereby providing a recovery mechanism to prevent the processes of terminal equipment from deadlock.
The purpose of the present disclosure is to provide a process data read-write optimization method and system for a mobile system, which specifically includes the following steps:
creating a plurality of read-write processes, identifying each read-write process, creating at least one inspection process and one recovery process, and distributing an independent file to each read-write process;
the main socket receives the read-write requests of all the read-write processes, reads and writes data of the server side according to the read-write requests, constructs a data access queue, and sequentially puts all the read-write processes into the data access queue according to the sequence of the read-write requests;
awakening the checking process from a blocking state to a running state at regular intervals of a preset time period, starting checking whether a read-write process is performing reading and writing at the kernel, and enabling the checking process to enter a blocking state to sleep if the read-write process is not performing reading and writing;
when the checking process is awakened to be a running state, each read-write process is scanned, if the read-write process is updating data into a file, nothing is done, because the read-write request is terminated, the influence of the read-write request on the terminal is eliminated, no operation is needed, and the checking process is converted into a blocking state;
if the checking process scans that a read-write process is waiting for a file, the read-write process has an unfinished read-write request, and the checking process cancels all operations of the read-write process in the terminal and refreshes the process;
checking a process access data access queue, and canceling the read-write request of the read-write process in the data access queue;
the checking process writes the unfinished read-write requests into a process record queue, and when the number of the read-write requests in the process record queue is larger than a record threshold value, the checking process is converted into a blocking state;
when the elements in the process record queue are larger than 1, the recovery process is awakened from a blocking state to a running state, and the recovery process starts to initiate read-write requests to the server again from the tail of the process record queue in sequence;
and when the element in the process record queue is 0, the element in the process record queue is still 0 after waiting for a preset time period, and the recovery process enters a blocking state to sleep.
Furthermore, the read-write process, the check process and the recovery process are processes divided into three basic states, namely a running state, a ready state and a blocking state;
furthermore, the master socket is an interface for message transmission across a network, and the read-write process accesses a remote server through the master socket.
Furthermore, the terminal is a mobile device, an internet of things terminal, such as a mobile phone, a tablet computer, and an industrial PAD, and is connected with a remote server through a wireless network.
Further, the data access queue is a queue data structure, and is a linear table for temporarily storing the read-write request.
Further, the predetermined time period is 500 milliseconds and can be manually adjusted.
Further, the process record queue is a queue data structure, and is a linear table for temporarily storing the read-write request.
Further, the recording threshold value is default to 10, and can be set manually.
The invention also provides a process data read-write optimization system of the mobile system, which comprises the following steps: a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the computer program to run in the units of the following system:
the process creation unit is used for creating a plurality of read-write processes, identifying each read-write process, creating at least one inspection process and one recovery process, and distributing an independent file to each read-write process;
the read-write request queue unit is used for receiving the read-write requests of all the read-write processes by the main socket, reading and writing data of the server side according to the read-write requests, constructing a data access queue and sequentially putting all the read-write processes into the data access queue according to the sequence of the read-write requests;
the timing check awakening unit is used for awakening the check process from a blocking state to a running state at regular intervals of a preset time period, checking whether a read-write process is performing reading and writing at the kernel, and enabling the check process to enter the blocking state to sleep if the read-write process is not performing the reading and writing;
the checking finishing unit is used for starting to scan each read-write process when the checking process is awakened to be in a running state, and converting the checking process into a blocking state if the read-write process does not do anything when updating data into a file;
the system comprises a checking and scanning unit, a reading and writing process and a refreshing unit, wherein the checking and scanning unit is used for refreshing a process after the process cancels all operations of the reading and writing process in a terminal if the checking process scans that the reading and writing process is waiting for a file;
a read-write request canceling unit, configured to check a process access data access queue, and cancel a read-write request of the read-write process in the data access queue;
the process recording unit is used for checking the process to write the unfinished read-write request into a process recording queue, and converting the checking process into a blocking state when the number of the read-write requests in the process recording queue is greater than a recording threshold value;
the recovery process awakening unit is used for awakening the recovery process from a blocking state to a running state when the element in the process record queue is larger than 1, and the recovery process starts to send read-write requests to the server end again in sequence from the tail of the process record queue;
and the process resuming dormancy unit is used for enabling the resuming process to enter a blocking state for dormancy if the element in the process recording queue is 0 after waiting for a preset time period.
The beneficial effect of this disclosure does: the invention discloses a process data read-write optimization method of a mobile system, which can ensure the normal operation of the application of terminal equipment under the condition that the process is disconnected with an online database or other data sources; a recovery mechanism is provided to prevent deadlock of processes of the terminal device. The data reading and writing process of the process cannot be influenced in the area switching of the network communication base station; the phenomena of blocking and false death of the terminal equipment program are reduced.
Detailed Description
The conception, specific structure and technical effects of the present disclosure will be clearly and completely described below in conjunction with the embodiments and the accompanying drawings to fully understand the objects, aspects and effects of the present disclosure. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
Referring to fig. 1, a flow chart of a process data read-write optimization method of a mobile system according to the present disclosure is shown, and the method according to the embodiment of the present disclosure is described below with reference to fig. 1.
The present disclosure provides a process data read-write optimization method for a mobile system, which specifically includes the following steps:
creating a plurality of read-write processes, identifying each read-write process, creating at least one inspection process and one recovery process, and distributing an independent file to each read-write process;
the main socket receives the read-write requests of all the read-write processes, reads and writes data of the server side according to the read-write requests, constructs a data access queue, and sequentially puts all the read-write processes into the data access queue according to the sequence of the read-write requests;
awakening the checking process from a blocking state to a running state at regular intervals of a preset time period, starting checking whether a read-write process is performing reading and writing at the kernel, and enabling the checking process to enter a blocking state to sleep if the read-write process is not performing reading and writing;
when the checking process is awakened to be a running state, each read-write process is scanned, if the read-write process is updating data into a file, nothing is done, because the read-write request is terminated, the influence of the read-write request on the terminal is eliminated, no operation is needed, and the checking process is converted into a blocking state;
if the checking process scans that a read-write process is waiting for a file, the read-write process has an unfinished read-write request, and the checking process cancels all operations of the read-write process in the terminal and refreshes the process;
checking a process access data access queue, and canceling the read-write request of the read-write process in the data access queue;
the checking process writes the unfinished read-write requests into a process record queue, and when the number of the read-write requests in the process record queue is larger than a record threshold value, the checking process is converted into a blocking state;
when the elements in the process record queue are larger than 1, the recovery process is awakened from a blocking state to a running state, and the recovery process starts to initiate read-write requests to the server again from the tail of the process record queue in sequence;
and when the element in the process record queue is 0, the element in the process record queue is still 0 after waiting for a preset time period, and the recovery process enters a blocking state to sleep.
Furthermore, the read-write process, the check process and the recovery process are processes divided into three basic states, namely a running state, a ready state and a blocking state;
furthermore, the master socket is an interface for message transmission across a network, and the read-write process accesses a remote server through the master socket.
Furthermore, the terminal is a mobile device, an internet of things terminal, such as a mobile phone, a tablet computer, and an industrial PAD, and is connected with a remote server through a wireless network.
Further, the data access queue is a queue data structure, and is a linear table for temporarily storing the read-write request.
Further, the predetermined time period is 500 milliseconds and can be manually adjusted.
Further, the process record queue is a queue data structure, and is a linear table for temporarily storing the read-write request.
Further, the recording threshold value is default to 10, and can be set manually.
Fig. 2 is a diagram of a process data read-write optimization system structure of a mobile system according to an embodiment of the present disclosure, where the process data read-write optimization system of the mobile system according to the embodiment includes: the mobile system comprises a processor, a memory and a computer program which is stored in the memory and can run on the processor, wherein the processor executes the computer program to realize the steps in the embodiment of the process data read-write optimization system of the mobile system.
The system comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the computer program to run in the units of the following system:
the process creation unit is used for creating a plurality of read-write processes, identifying each read-write process, creating at least one inspection process and one recovery process, and distributing an independent file to each read-write process;
the read-write request queue unit is used for receiving the read-write requests of all the read-write processes by the main socket, reading and writing data of the server side according to the read-write requests, constructing a data access queue and sequentially putting all the read-write processes into the data access queue according to the sequence of the read-write requests;
the timing check awakening unit is used for awakening the check process from a blocking state to a running state at regular intervals of a preset time period, checking whether a read-write process is performing reading and writing at the kernel, and enabling the check process to enter the blocking state to sleep if the read-write process is not performing the reading and writing;
the checking finishing unit is used for starting to scan each read-write process when the checking process is awakened to be in a running state, and converting the checking process into a blocking state if the read-write process does not do anything when updating data into a file;
the system comprises a checking and scanning unit, a reading and writing process and a refreshing unit, wherein the checking and scanning unit is used for refreshing a process after the process cancels all operations of the reading and writing process in a terminal if the checking process scans that the reading and writing process is waiting for a file;
a read-write request canceling unit, configured to check a process access data access queue, and cancel a read-write request of the read-write process in the data access queue;
the process recording unit is used for checking the process to write the unfinished read-write request into a process recording queue, and converting the checking process into a blocking state when the number of the read-write requests in the process recording queue is greater than a recording threshold value;
the recovery process awakening unit is used for awakening the recovery process from a blocking state to a running state when the element in the process record queue is larger than 1, and the recovery process starts to send read-write requests to the server end again in sequence from the tail of the process record queue;
and the process resuming dormancy unit is used for enabling the resuming process to enter a blocking state for dormancy if the element in the process recording queue is 0 after waiting for a preset time period.
The process data read-write optimization system of the mobile system can be operated in computing equipment such as desktop computers, notebooks, palm computers and cloud servers. The system which can be operated by the process data read-write optimization system of the mobile system can comprise a processor and a memory. It will be understood by those skilled in the art that the example is only an example of the process data read-write optimization system of a mobile system, and does not constitute a limitation to the process data read-write optimization system of a mobile system, and may include more or less components than the mobile system, or some components in combination, or different components, for example, the process data read-write optimization system of a mobile system may further include an input-output device, a network access device, a bus, and the like. The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like. The general processor may be a microprocessor or the processor may be any conventional processor, and the processor is a control center of the process data read/write optimization system operating system of the mobile system, and various interfaces and lines are used to connect various parts of the process data read/write optimization system operable system of the whole mobile system.
The memory can be used for storing the computer program and/or the module, and the processor can realize various functions of the process data read-write optimization system of the mobile system by running or executing the computer program and/or the module stored in the memory and calling the data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
While the present disclosure has been described in considerable detail and with particular reference to a few illustrative embodiments thereof, it is not intended to be limited to any such details or embodiments or any particular embodiments, but it is to be construed as effectively covering the intended scope of the disclosure by providing a broad, potential interpretation of such claims in view of the prior art with reference to the appended claims. Furthermore, the foregoing describes the disclosure in terms of embodiments foreseen by the inventor for which an enabling description was available, notwithstanding that insubstantial modifications of the disclosure, not presently foreseen, may nonetheless represent equivalent modifications thereto.