CN108491333A - Method for writing data, device, equipment and the medium of buffer circle - Google Patents
Method for writing data, device, equipment and the medium of buffer circle Download PDFInfo
- Publication number
- CN108491333A CN108491333A CN201810238860.7A CN201810238860A CN108491333A CN 108491333 A CN108491333 A CN 108491333A CN 201810238860 A CN201810238860 A CN 201810238860A CN 108491333 A CN108491333 A CN 108491333A
- Authority
- CN
- China
- Prior art keywords
- buffer circle
- data
- pointer
- written
- write
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/0802—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
- G06F12/0893—Caches characterised by their organisation or structure
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Transfer Systems (AREA)
Abstract
The invention discloses a kind of method for writing data of buffer circle, device, terminal device and computer-readable storage, methods to include the following steps:Obtain the remaining space of current annular buffering area;When the remaining space is less than the data length of data to be written, pass through the new buffer circle of buffer pool application;The new buffer circle of acquisition is initialized;The chain table pointer that current annular buffering area is arranged is directed toward the new buffer circle, to link the new buffer circle;Wherein, the chained list is for linking buffer circle;The data to be written are written in the new buffer circle, apply for new buffer circle when buffer circle is full and writes data into new buffer circle, buffer circle is chained up by the form of chained list, it solves the problems, such as that buffer circle is non-expandable, realizes the lasting write-in of data.
Description
Technical field
The present invention relates to computer software technical field more particularly to a kind of method for writing data of buffer circle, dresses
It sets, terminal device and computer-readable storage.
Background technology
Buffer circle is common data structure in producers and consumers' model, buffer circle, as the term suggests just
It is the region of a cricoid storage data, space is constructed using array or chained list, and buffer circle feature is to read
It can be separated with writing, can not go first to read after write-in data, until needing the when of reading to go to read again, the producer
The end of array is placed data into, and consumer removes data from the other end of array, when writing the tail portion of array, the producer
Then around the head of array, that is, assume that a length is the array of 256 bytes, constructs a buffer circle, works as write operation
Proceed to the 256th of array and then write-once returns to the 0th and is written;Same read operation is to read number
Group the 256th when, be read out the first item for returning to array again,
In the prior art, the realization of buffer circle is substantially the memory of one fixed size of application, in use, business
It must assure that the size of buffering area uses enough, it, then can only pending buffer area space after because certain reason buffering areas have been expired
It releases and carries out write operation again, to influence system performance, for this problem, the prior art usually has following two places
Reason method:The first is to distribute just enough smaller cushion spaces as buffer circle;Second is that distribution is sufficiently large
Cushion space, in the implementation of the present invention, inventor has found both the above method, and there are the following problems:First method
Because the spatial cache of distribution is smaller, when system abruptly reaches write operation peak, it is easy to cause the unstable of system;Second of side
Method may not have to so greatly, be easy to cause the waste of cache resources due to the spatial cache of actual needs.
Invention content
In view of the above-mentioned problems, the purpose of the present invention is to provide a kind of method for writing data of buffer circle, device, ends
End equipment and computer-readable storage, solve the problems, such as that buffer circle is non-expandable, realize the lasting write-in of data.
In a first aspect, an embodiment of the present invention provides a kind of method for writing data of buffer circle, include the following steps:
Obtain the remaining space of current annular buffering area;
When the remaining space is less than the data length of data to be written, pass through the new buffer circle of buffer pool application;
The new buffer circle of acquisition is initialized;
The chain table pointer that current annular buffering area is arranged is directed toward the new buffer circle, to link the new loop buffer
Area;Wherein, the chained list is for linking buffer circle;
The data to be written are written in the new buffer circle.
In the first realization method of first aspect, further include:
Update the write-in pointer of the new buffer circle.
In second of realization method of first aspect, the remaining space for obtaining current annular buffering area, specially:
Obtain the write-in pointer and reading pointer of current annular buffering area;
It is described current when the serial number numerical value of said write pointer is more than or equal to the serial number numerical value of the reading pointer
The remaining space of buffer circle=[(n+1)-(the serial number numerical value of serial number numerical value-reading pointer of write-in pointer) -1] ×
Block length;Wherein, each buffer circle is divided into (n+1) a block, and the n is the end block pair of buffer circle
The serial number numerical value answered, n >=0;
When the serial number numerical value of said write pointer is less than the serial number numerical value of the reading pointer, the current annular buffering
The remaining space in area=(the serial number numerical value -1 of serial number numerical value-write-in pointer of reading pointer) × block length.
In the third realization method of first aspect, the data for being less than data to be written when the remaining space are long
When spending, by the new buffer circle of buffer pool application, specially:
Whether when the remaining space is less than the data length of data to be written, detecting in buffer pool has idle annular
Buffering area;
If so, the buffer circle to be left unused by buffer pool application is using as new buffer circle;
If it is not, creating new buffer circle.
Further include in the 4th kind of realization method of first aspect according to second of realization method of first aspect:
When the remaining space is more than or equal to the data length of data to be written, the sequence of said write pointer is judged
Whether number value is more than or equal to the serial number numerical value of the reading pointer, and the remaining tailer of the current annular buffering area
Whether block length is less than the data length of the data to be written;
If so, dividing the data to be written according to the remaining tail portion block length, stored with blockette described to be written
Enter data;Wherein, by the first part's write-in remaining tail for the data to be written that length is the remaining tail portion block length
The head block of the current annular buffer area is written in the second part of the remaining data to be written by portion's block;
If it is not, the data to be written are written in the remaining space of the current annular buffering area;
Update the write-in pointer of the current annular buffering area.
In the 5th kind of realization method of first aspect, further include:
Obtain the write-in pointer and reading pointer of all buffer circles linked by chained list;
When the serial number numerical value of the write-in pointer of buffer circle is not equal to the serial number numerical value of corresponding reading pointer, read
All data in the buffer circle, and update the reading pointer;
When judge buffer circle write-in pointer serial number numerical value be equal to the corresponding reading pointer serial number numerical value,
And the buffer circle is recovered to described slow when being not at the end of chained list by the buffer circle where the reading pointer
It rushes in pond, and updates the chain table pointer of the chained list.
It is described right in the 6th kind of realization method of first aspect according to any of the above realization method of first aspect
The new buffer circle obtained is initialized, specially:
The content of the new buffer circle of acquisition is initialized, and changes the state of the new buffer circle.
Second aspect, an embodiment of the present invention provides a kind of data transfer apparatus of buffer circle, including:
Remaining space acquiring unit, the remaining space for obtaining current annular buffering area;
Buffering area acquiring unit is used to, when the remaining space is less than the data length of data to be written, pass through buffering
Apply for new buffer circle in pond;
Initialization unit is initialized for the new buffer circle to acquisition;
Extended Hyperlink unit, the chain table pointer for current annular buffering area to be arranged are directed toward the new buffer circle, with
Link the new buffer circle;Wherein, the chained list is for linking buffer circle;
Writing unit, for the data to be written to be written in the new buffer circle.
The third aspect, an embodiment of the present invention provides a kind of data of buffer circle, and terminal device, including processing is written
Device, memory and it is stored in the memory and is configured as the computer program executed by the processor, the place
Reason device realize when executing the computer program it is any one of above-mentioned described in buffer circle method for writing data.
Fourth aspect, an embodiment of the present invention provides a kind of computer readable storage medium, the computer-readable storage
Medium includes the computer program of storage, wherein controls the computer-readable storage medium when the computer program is run
Equipment where matter execute it is any one of above-mentioned described in buffer circle method for writing data.
An embodiment of the present invention provides a kind of method for writing data of buffer circle, device, terminal device and computers
Readable storage, one embodiment have the advantages that:
When there are new data to be written, the remaining space of current annular buffering area is obtained first, when judging the residue
When space is less than the data length of data to be written, by the new buffer circle of buffer pool application, then to the new annular of acquisition
Buffering area is initialized, and the chain table pointer of setting current annular buffering area is directed toward the new buffer circle, described in link
New buffer circle, the chained list are finally slow by the data write-in new annular to be written for linking buffer circle
It rushes in area, realizes and apply for new buffer circle when buffer circle is full and write data into new buffer circle, lead to
Buffer circle is chained up by the form for crossing chained list, solves the problems, such as that buffer circle is non-expandable, realizes continuing for data
Write-in avoids waiting the time to be read because buffering area is full, improves the stability and space availability ratio of system operation.
Description of the drawings
In order to illustrate more clearly of technical scheme of the present invention, attached drawing needed in embodiment will be made below
Simply introduce, it should be apparent that, the accompanying drawings in the following description is only some embodiments of the present invention, general for this field
For logical technical staff, without creative efforts, other drawings may also be obtained based on these drawings.
Fig. 1 is the flow diagram of the method for writing data for the buffer circle that first embodiment of the invention provides.
Fig. 2 is the schematic diagram for the buffer circle that first embodiment of the invention provides.
Fig. 3 is the schematic diagram for the expansion hula buffer circle that first embodiment of the invention provides.
Fig. 4 is the structural schematic diagram of the data transfer apparatus for the buffer circle that fourth embodiment of the invention provides.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation describes, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
A kind of method for writing data of buffer circle provided by the invention is suitable for single using without lock buffer circle
The case where producer list consumer, i.e., the state of one write-in and a reading are specific real to improve the readwrite performance of system
Existing mode is as follows:
Referring to Fig. 1, an embodiment of the present invention provides a kind of method for writing data of buffer circle, there can be terminal to set
It is standby to execute, and include the following steps:
S11 obtains the remaining space of current annular buffering area.
In embodiments of the present invention, the terminal device can be desktop PC, notebook, palm PC, intelligence
The computing devices such as tablet, mobile terminal and cloud server.
In embodiments of the present invention, the terminal device obtains current annular first when having detected that data are to be written
The remaining space of buffering area, specifically, referring to Fig. 2, it should be noted that the position of pointer and reading pointer is written in Fig. 2
It is merely illustrative, the restriction to pointer and reading pointer position are written in buffer circle is not constituted, Fig. 2 is buffer circle number
Group A [0, n], this array are a buffer circle, size n+1, the buffer circle there are one chained list head pointer,
After system initialization, the chained list head pointer is directed toward the buffer circle, when deposit pointer and reading pointer are directed toward with ground
When location, then this entire buffer stopper is represented as sky, in usual scheme, when reading pointer and to be stored in pointer adjacent, and reading pointer<
When pointer is written, then this buffer area is represented to be full, special, write-in pointer is A0, the state that reading pointer is An is also to expire,
When having detected that data are to be written, the write-in pointer and reading that obtain current annular buffering area first refer to the terminal device
Needle, to carry out the calculating of current buffer remaining space, when the serial number numerical value of said write pointer is more than or equal to the reading
When the serial number numerical value of fetching needle, then the data volume being written has (the serial number numerical value of serial number numerical value-reading pointer of write-in pointer),
It is empty and full for distinguishing in one block of removal, remaining space=[(n+1)-(write-in pointer of the current annular buffering area
Serial number numerical value-reading pointer serial number numerical value) -1] × block length, each buffer circle is divided into a area (n+1)
Block, the n are the corresponding serial number numerical value of end block of buffer circle, n >=0, when the serial number numerical value of said write pointer is small
When the serial number numerical value of the reading pointer, shows that pointer, which is written, to be enclosed around one, and a number of turns evidence is written with, become pursuit and read
The situation of fetching needle, the then remaining space of the current annular buffering area=(serial number numerical value-write-in pointer of reading pointer
Serial number numerical value -1) × block length.
S12 passes through the new loop buffer of buffer pool application when the remaining space is less than the data length of data to be written
Area.
In embodiments of the present invention, the terminal device judges described surplus after the remaining space for obtaining current buffer
Whether complementary space is stored in the data to be written enough, when judge the remaining space be less than data to be written data length
When, the buffer circle in buffer pool is traversed, whether has idle buffer circle in buffer pool to detect, if there is idle ring
Shape buffering area, then the buffer circle that the terminal device is left unused by buffer pool application is using as new buffer circle, if not having
There are idle buffer circle or application failure, then the terminal device creates new buffer circle.
S13 initializes the new buffer circle of acquisition.
In embodiments of the present invention, the terminal device carries out initialization process to the new buffer circle of acquisition, specifically
Ground initializes the content of the new buffer circle of acquisition, and changes the state of the new buffer circle.
The chain table pointer of S14, setting current annular buffering area are directed toward the new buffer circle, to link the new annular
Buffering area;Wherein, the chained list is for linking buffer circle.
In embodiments of the present invention, referring to Fig. 3, the chain table pointer of current buffer circle is arranged in the terminal device
It is directed toward the new buffer circle, to link the new buffer circle, to ensure persistently being normally written for data.It needs to illustrate
, the new buffer circle obtained here is default fixed size, with buffer circle in the case of normal enough, ring
The smaller the better size of shape buffering area is principle, improves memory usage, the present invention is in the case where buffering area is full, dynamic Shen
Buffering area that please be additional, avoids performance issue caused by buffer size.
The data to be written are written in the new buffer circle S15.
In embodiments of the present invention, referring to Fig. 3, the terminal device is being applied and is being linked to new buffer circle
Afterwards, the data to be written are written in the new buffer circle, and update the write-in pointer of the new buffer circle.Then
The write-in form of buffer circle by chained list link is:When there is new data to be written, the ring where chained list meter pointer
Shape buffering area starts to detect whether buffer circle has enough spaces that new data to be written is written, if not enough skies
Between, then continue the next buffer circle for detecting chained list link, until detection has the buffer circle in enough spaces to write
Enter new data, if all not enough remaining space of all buffer circles of chained list link is written for new data, applies
Buffer circle is written, and realizes the application that memory is carried out when out of buffers is to be written new data and chained list linked operation,
He realizes the conventional write operation of conventional annular buffering area the time, keeps conventional buffer circle to realize high without lock, performance
The characteristics of.
In conclusion first embodiment of the invention provides a kind of method for writing data of buffer circle, it is new when having
When data are to be written, the remaining space of current annular buffering area is obtained first, when judging the remaining space less than number to be written
According to data length when, by the new buffer circle of buffer pool application, then the new buffer circle of acquisition is initialized,
The chain table pointer that current annular buffering area is arranged is directed toward the new buffer circle, described to link the new buffer circle
The data to be written are finally written in the new buffer circle, are realized in annular for linking buffer circle by chained list
Buffering area applies for new buffer circle and writes data into new buffer circle when full, will be annular by the form of chained list
Buffer chain gets up, and solves the problems, such as that buffer circle is non-expandable, realizes the lasting write-in of data, avoids because buffering area is full
And the time to be read is waited, improve the stability and space availability ratio of system operation.
In order to facilitate the understanding of the present invention, some currently preferred embodiments of the present invention will be done and will further be retouched below
It states.
Second embodiment of the invention:
On the basis of first embodiment of the invention, further include:
When the remaining space is more than or equal to the data length of data to be written, the sequence of said write pointer is judged
Whether number value is more than or equal to the serial number numerical value of the reading pointer, and the remaining tailer of the current annular buffering area
Whether block length is less than the data length of the data to be written.
If so, dividing the data to be written according to the remaining tail portion block length, stored with blockette described to be written
Enter data;Wherein, by the first part's write-in remaining tail for the data to be written that length is the remaining tail portion block length
The head block of the current annular buffer area is written in the second part of the remaining data to be written by portion's block.
If it is not, the data to be written are written in the remaining space of the current annular buffering area.
Update the write-in pointer of the current annular buffering area.
In embodiments of the present invention, referring to Fig. 2, the terminal device is in the write-in by obtaining current annular buffering area
After the remaining space of pointer and reading pointer to obtain current annular buffering area, judge whether the remaining space is stored in institute enough
Data to be written are stated, when the remaining space is more than or equal to the data length of data to be written, show that current annular is slow
The remaining space for rushing area is enough that data to be written are written, and then the terminal device judges the write-in pointer of current annular buffering area
Serial number numerical value whether be more than or equal to current annular buffering area reading pointer serial number numerical value, and the current annular is slow
Whether the remaining tail portion block length for rushing area is less than the data length of the data to be written, that is, calculates and (it is long that pointer+data are written
Degree) whether it is more than n, to judge whether to have been written to the end of current annular buffering area, if write-in pointer>=reading pointer, and
The end of current annular buffering area is write, data cut in half according to end remaining space, and first half length is that (n- write-ins refer to
Needle), latter half length is (data length-first half length), and first half is stored to current annular buffering area end
Then the data of latter half are stored to the sky that the address of head initial position 0 of current annular buffering area starts by remaining space
Between, then after the completion of write-in, the write-in pointer of the current annular buffering area is updated, mobile write-in pointer is long to latter half
Spend the position at end;It is in the case of other, then directly that the data write-in to be written is described current according to general process flow
In the remaining space of buffer circle, then after the completion of write-in, the write-in pointer of the current annular buffering area is updated, it is rear to move
The corresponding data length of write pointer.
Third embodiment of the invention:
On the basis of first embodiment of the invention, further include:
Obtain the write-in pointer and reading pointer of all buffer circles linked by chained list.
When the serial number numerical value of the write-in pointer of buffer circle is not equal to the serial number numerical value of corresponding reading pointer, read
All data in the buffer circle, and update the reading pointer.
When judge buffer circle write-in pointer serial number numerical value be equal to the corresponding reading pointer serial number numerical value,
And the buffer circle is recovered to described slow when being not at the end of chained list by the buffer circle where the reading pointer
It rushes in pond, and updates the chain table pointer of the chained list.
In embodiments of the present invention, consumer checks whether data buffer zone has data to need using poll or other modes
It handles, the terminal device detects whether data to be read since the buffer circle where chained list gauge outfit, described
Terminal device obtains the write-in pointer and reading pointer of all buffer circles linked by chained list, records, behaviour later
Work should all be made a decision with the data recorded, and prevented pointer from being removed by other threads, caused to handle inconsistent situation, sentence
The serial number size of corresponding write-in pointer and reading pointer on disconnected each buffer circle, if they were directed toward with a position, generation
Currently all data have read and have finished table;If unequal, show that data are not read and finish, if reading pointer<Pointer is written,
Then be data not there is a situation where recycling, directly read the data between read pointer and write pointer, then update the annular
Reading pointer on buffering area, the serial number numerical value for the write pointer that setting read pointer is recorded, if reading pointer>=write-in refers to
Needle, then data recycled, then need obtain read pointer to array end all data and array head to be written refer to
All data of needle, two parts combine, and form real data, and the reading then updated on the buffer circle refers to
Needle, the serial number numerical value for the write pointer that setting read pointer is recorded.
In embodiments of the present invention, after reading data, the reading pointer on each buffer circle is judged again
It whether is directed toward identical position with corresponding write-in pointer, i.e. whether data are empty, if data are sky, the terminal device is sentenced
When whether the buffer circle where the disconnected reading pointer is in the end of chained list, if being not at the end of chained list, by institute
It states buffer circle to be recovered in the buffer pool, and updates the chain table pointer of the chained list, mobile chained list head pointer is to currently
Next buffer circle that buffer circle is directed toward, while this buffer circle is set to sky in buffering area pond;If number
According to being not sky, then continue read operation to finally complete the read operation of all data.
Referring to Fig. 4, fourth embodiment of the invention provides a kind of data transfer apparatus of buffer circle, including:
Remaining space acquiring unit 11, the remaining space for obtaining current annular buffering area.
Buffering area acquiring unit 12 is used for when the remaining space is less than the data length of data to be written, by slow
It rushes pond and applies for new buffer circle.
Initialization unit 13 is initialized for the new buffer circle to acquisition.
Extended Hyperlink unit 14, the chain table pointer for current annular buffering area to be arranged are directed toward the new buffer circle,
To link the new buffer circle;Wherein, the chained list is for linking buffer circle.
First writing unit 15, for the data to be written to be written in the new buffer circle.
In the first realization method of fourth embodiment, further include:
First updating unit, the write-in pointer for updating the new buffer circle.
In second of realization method of fourth embodiment, the remaining space acquiring unit 11 specifically includes:
Current pointer acquisition module, write-in pointer and reading pointer for obtaining current annular buffering area.
First remaining computing module is more than or equal to the reading pointer for the serial number numerical value when said write pointer
Serial number numerical value when, the remaining space of the current annular buffering area=[(n+1)-(serial number numerical value-reading of write-in pointer
The serial number numerical value of pointer) -1] × block length;Wherein, each buffer circle is divided into (n+1) a block, and the n is
The corresponding serial number numerical value of end block of buffer circle, n >=0.
Second remaining computing module, the serial number number for being less than the reading pointer when the serial number numerical value of said write pointer
When value, remaining space=(serial number numerical value-of serial number numerical value-write-in pointer of reading pointer of the current annular buffering area
1) × block length.
In the third realization method of fourth embodiment, the buffering area acquiring unit 12 specifically includes:
Idle detection module is used to, when the remaining space is less than the data length of data to be written, detect buffer pool
In whether have idle buffer circle.
Buffering area application module is used for if so, the buffer circle to be left unused by buffer pool application as new annular to delay
Rush area;
Buffering area creation module, for if it is not, creating new buffer circle.
Further include in the 4th kind of realization method of fourth embodiment according to second of realization method of fourth embodiment:
Judging unit is written, is used to, when the remaining space is more than or equal to the data length of data to be written, sentence
Whether the serial number numerical value of disconnected said write pointer is more than or equal to the serial number numerical value of the reading pointer, and the current annular
Whether the remaining tail portion block length of buffering area is less than the data length of the data to be written.
Second writing unit is used for if so, the data to be written are divided according to the remaining tail portion block length, to divide
Block stores the data to be written;Wherein, by first of the data to be written that length is the remaining tail portion block length
Divide write-in the remaining tail portion block, the current annular buffering area is written into the second part of the remaining data to be written
The head block in domain.
Third writing unit, for if it is not, the residue that the data to be written are written to the current annular buffering area is empty
Between in;
Second updating unit, the write-in pointer for updating the current annular buffering area.
In the 5th kind of realization method of fourth embodiment, further include:
All pointer acquiring units, write-in pointer and reading for obtaining all buffer circles linked by chained list refer to
Needle.
Reading unit, the serial number numerical value for the write-in pointer when buffer circle are not equal to the sequence of corresponding reading pointer
When number value, all data in the buffer circle are read, and update the reading pointer.
Recovery unit, for referring to when the serial number numerical value for the write-in pointer for judging buffer circle is equal to the corresponding reading
The serial number numerical value of needle, and when the buffer circle where the reading pointer is not at the end of chained list, by the loop buffer
Area is recovered in the buffer pool, and updates the chain table pointer of the chained list.
According to any of the above realization method of fourth embodiment, in the 6th kind of realization method of fourth embodiment, institute
Initialization unit 13 is stated to specifically include:
The content of the new buffer circle of acquisition is initialized, and changes the state of the new buffer circle.
Fifth embodiment of the invention provides a kind of data write-in terminal device of buffer circle.The annular of the embodiment
Terminal device is written in the data of buffering area:It processor, memory and is stored in the memory and can be at the place
Manage the computer program run on device, such as the data writing program of buffer circle.The processor executes the computer
The step in the method for writing data embodiment of above-mentioned each buffer circle, such as step shown in FIG. 1 are realized when program
S11.Alternatively, the processor realizes the work(of each module/unit in above-mentioned each device embodiment when executing the computer program
Can, such as initialization unit 13.
Illustratively, the computer program can be divided into one or more module/units, one or more
A module/unit is stored in the memory, and is executed by the processor, to complete the present invention.It is one or more
A module/unit can be the series of computation machine program instruction section that can complete specific function, and the instruction segment is for describing institute
State implementation procedure of the computer program in the data write-in terminal device of the buffer circle.
The buffer circle data write-in terminal device can be desktop PC, notebook, palm PC and
The computing devices such as cloud server.The data write-in terminal device of the buffer circle may include, but be not limited only to, and handle
Device, memory.It will be understood by those skilled in the art that above-mentioned component is only the data write-in terminal device of buffer circle
Example does not constitute the restriction that the data of buffer circle are written with terminal device, may include more more or fewer than above-mentioned
Component either combines certain components or different components, such as the data write-in terminal device of the buffer circle may be used also
To include input-output equipment, network access equipment, bus etc..
Alleged processor can be central processing unit (Central Processing Unit, CPU), can also be it
His general processor, digital signal processor (Digital Signal Processor, DSP), application-specific integrated circuit
(Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-
Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic,
Discrete hardware components etc..General processor can be microprocessor or the processor can also be any conventional processor
It is the control centre of the data write-in terminal device of the buffer circle Deng, the processor, utilizes various interfaces and circuit
Connect the various pieces of the data write-in terminal device of entire buffer circle.
The memory can be used for storing the computer program and/or module, and the processor is by running or executing
Computer program in the memory and/or module are stored, and calls the data being stored in memory, described in realization
The various functions of the data write-in terminal device of buffer circle.The memory can include mainly storing program area and storage number
According to area, wherein storing program area can storage program area, (for example sound plays work(to the application program needed at least one function
Energy, image player function etc.) etc.;Storage data field can store according to mobile phone use created data (such as audio data,
Phone directory etc.) etc..In addition, memory may include high-speed random access memory, can also include nonvolatile memory, example
Such as hard disk, memory, plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure
Digital, SD) card, flash card (Flash Card), at least one disk memory, flush memory device or other volatibility are solid
State memory device.
Wherein, if the integrated module/unit of terminal device is written with software function list in the data of the buffer circle
The form of member is realized and when sold or used as an independent product, can be stored in a computer read/write memory medium
In.Based on this understanding, the present invention realizes all or part of flow in above-described embodiment method, can also pass through computer
Program is completed to instruct relevant hardware, and the computer program can be stored in a computer readable storage medium, should
Computer program is when being executed by processor, it can be achieved that the step of above-mentioned each embodiment of the method.Wherein, the computer program
Including computer program code, the computer program code can be source code form, object identification code form, executable file
Or certain intermediate forms etc..The computer-readable medium may include:Any of the computer program code can be carried
Entity or device, recording medium, USB flash disk, mobile hard disk, magnetic disc, CD, computer storage, read-only memory (ROM, Read-
Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and
Software distribution medium etc..It should be noted that the content that the computer-readable medium includes can be according in jurisdiction
Legislation and the requirement of patent practice carry out increase and decrease appropriate, such as in certain jurisdictions, according to legislation and patent practice, meter
Calculation machine readable medium does not include electric carrier signal and telecommunication signal.
It should be noted that the apparatus embodiments described above are merely exemplary, wherein described be used as separating component
The unit of explanation may or may not be physically separated, and the component shown as unit can be or can also
It is not physical unit, you can be located at a place, or may be distributed over multiple network units.It can be according to actual
It needs that some or all of module therein is selected to achieve the purpose of the solution of this embodiment.In addition, device provided by the invention
In embodiment attached drawing, the connection relation between module indicates there is communication connection between them, specifically can be implemented as one or
A plurality of communication bus or signal wire.Those of ordinary skill in the art are without creative efforts, you can to understand
And implement.
The above is the preferred embodiment of the present invention, it is noted that for those skilled in the art
For, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also considered as
Protection scope of the present invention.
Claims (10)
1. a kind of method for writing data of buffer circle, which is characterized in that include the following steps:
Obtain the remaining space of current annular buffering area;
When the remaining space is less than the data length of data to be written, pass through the new buffer circle of buffer pool application;
The new buffer circle of acquisition is initialized;
The chain table pointer that current annular buffering area is arranged is directed toward the new buffer circle, to link the new buffer circle;
Wherein, the chained list is for linking buffer circle;
The data to be written are written in the new buffer circle.
2. the method for writing data of buffer circle according to claim 1, which is characterized in that further include:
Update the write-in pointer of the new buffer circle.
3. the method for writing data of buffer circle according to claim 1, which is characterized in that the acquisition current annular
The remaining space of buffering area, specially:
Obtain the write-in pointer and reading pointer of current annular buffering area;
When the serial number numerical value of said write pointer is more than or equal to the serial number numerical value of the reading pointer, the current annular
The remaining space of buffering area=[(n+1)-(the serial number numerical value of serial number numerical value-reading pointer of write-in pointer) -1] × block
Length;Wherein, each buffer circle is divided into (n+1) a block, and the n is that the end block of buffer circle is corresponding
Serial number numerical value, n >=0;
When the serial number numerical value of said write pointer is less than the serial number numerical value of the reading pointer, the current annular buffering area
Remaining space=(the serial number numerical value -1 of serial number numerical value-write-in pointer of reading pointer) × block length.
4. the method for writing data of buffer circle according to claim 1, which is characterized in that described when described remaining empty
Between be less than data to be written data length when, by the new buffer circle of buffer pool application, specially:
Whether when the remaining space is less than the data length of data to be written, detecting in buffer pool has idle loop buffer
Area;
If so, the buffer circle to be left unused by buffer pool application is using as new buffer circle;
If it is not, creating new buffer circle.
5. the method for writing data of buffer circle according to claim 3, which is characterized in that further include:
When the remaining space is more than or equal to the data length of data to be written, the serial number number of said write pointer is judged
Whether value is more than or equal to the serial number numerical value of the reading pointer, and the remaining tailer block length of the current annular buffering area
Whether degree is less than the data length of the data to be written;
If so, dividing the data to be written according to the remaining tail portion block length, the number to be written is stored with blockette
According to;Wherein, by the first part's write-in remaining tailer for the data to be written that length is the remaining tail portion block length
The head block of the current annular buffer area is written in the second part of the remaining data to be written by block;
If it is not, the data to be written are written in the remaining space of the current annular buffering area;
Update the write-in pointer of the current annular buffering area.
6. the method for writing data of buffer circle according to claim 1, which is characterized in that further include:
Obtain the write-in pointer and reading pointer of all buffer circles linked by chained list;
When the serial number numerical value of the write-in pointer of buffer circle is not equal to the serial number numerical value of corresponding reading pointer, described in reading
All data in buffer circle, and update the reading pointer;
When judging that the serial number numerical value of the write-in pointer of buffer circle is equal to the serial number numerical value of the corresponding reading pointer, and institute
When buffer circle where stating reading pointer is not at the end of chained list, the buffer circle is recovered to the buffer pool
In, and update the chain table pointer of the chained list.
7. the method for writing data of the buffer circle according to claim 1 to 6 any one, which is characterized in that described
The new buffer circle of acquisition is initialized, specially:
The content of the new buffer circle of acquisition is initialized, and changes the state of the new buffer circle.
8. a kind of data transfer apparatus of buffer circle, which is characterized in that including:
Remaining space acquiring unit, the remaining space for obtaining current annular buffering area;
Buffering area acquiring unit is used to, when the remaining space is less than the data length of data to be written, pass through buffer pool Shen
It please new buffer circle;
Initialization unit is initialized for the new buffer circle to acquisition;
Extended Hyperlink unit, the chain table pointer for current annular buffering area to be arranged is directed toward the new buffer circle, with link
The new buffer circle;Wherein, the chained list is for linking buffer circle;
Writing unit, for the data to be written to be written in the new buffer circle.
9. terminal device is written in a kind of data of buffer circle, which is characterized in that including processor, memory and be stored in
In the memory and it is configured as the computer program executed by the processor, the processor executes the computer journey
The method for writing data of buffer circle as claimed in any of claims 1 to 7 in one of claims is realized when sequence.
10. a kind of computer readable storage medium, which is characterized in that the computer readable storage medium includes the calculating of storage
Machine program, wherein equipment where controlling the computer readable storage medium when the computer program is run is executed as weighed
Profit requires the method for writing data of the buffer circle described in any one of 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810238860.7A CN108491333A (en) | 2018-03-21 | 2018-03-21 | Method for writing data, device, equipment and the medium of buffer circle |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810238860.7A CN108491333A (en) | 2018-03-21 | 2018-03-21 | Method for writing data, device, equipment and the medium of buffer circle |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108491333A true CN108491333A (en) | 2018-09-04 |
Family
ID=63319041
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810238860.7A Pending CN108491333A (en) | 2018-03-21 | 2018-03-21 | Method for writing data, device, equipment and the medium of buffer circle |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108491333A (en) |
Cited By (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109446126A (en) * | 2018-10-17 | 2019-03-08 | 天津津航计算技术研究所 | DSP and FPGA high-speed communication system and method based on EMIF bus |
CN110046047A (en) * | 2019-04-15 | 2019-07-23 | Oppo广东移动通信有限公司 | A kind of inter-process communication methods, device and computer readable storage medium |
CN110704335A (en) * | 2019-09-03 | 2020-01-17 | 苏州浪潮智能科技有限公司 | Data reading and writing method and device based on asynchronous ring buffer |
CN110830385A (en) * | 2019-09-25 | 2020-02-21 | 上海数荃数据科技有限公司 | Packet capturing processing method, network equipment, server and storage medium |
CN111245742A (en) * | 2019-12-31 | 2020-06-05 | 宁波舜宇智能科技有限公司 | Data buffering method and device, computer and readable storage medium |
CN111240599A (en) * | 2020-01-17 | 2020-06-05 | 北京马赫谷科技有限公司 | Data stream storage method and device |
CN111290709A (en) * | 2020-01-19 | 2020-06-16 | 成都中嵌自动化工程有限公司 | Dynamically adjustable annular buffer area |
CN111506512A (en) * | 2020-04-24 | 2020-08-07 | 上海燧原智能科技有限公司 | Debugging information processing method and device, electronic equipment, storage medium and system |
CN111708495A (en) * | 2020-06-19 | 2020-09-25 | 深圳前海微众银行股份有限公司 | Annular queue storage method and device, computing equipment and storage medium |
CN111865824A (en) * | 2020-06-19 | 2020-10-30 | 重庆川仪自动化股份有限公司 | Method and system for designing double-pointer annular buffer area in serial port communication |
CN112235204A (en) * | 2020-10-13 | 2021-01-15 | 中移(杭州)信息技术有限公司 | Data reporting method, system, electronic equipment and storage medium |
CN112445792A (en) * | 2019-09-04 | 2021-03-05 | 中移物联网有限公司 | Block chain block data storage method and device, electronic equipment and storage medium |
CN112765054A (en) * | 2019-11-01 | 2021-05-07 | 中国科学院声学研究所 | High-speed data acquisition system and method based on FPGA |
CN112882655A (en) * | 2021-02-03 | 2021-06-01 | 广发证券股份有限公司 | Data caching method and device, electronic equipment and storage medium |
CN113138945A (en) * | 2021-04-16 | 2021-07-20 | 宜通世纪科技股份有限公司 | Data caching method, device, equipment and medium |
CN113297234A (en) * | 2020-09-30 | 2021-08-24 | 阿里云计算有限公司 | Data processing method, device, equipment and computer readable storage medium |
CN115203002A (en) * | 2022-09-16 | 2022-10-18 | 深圳华云信息系统有限公司 | Log processing method and device, electronic equipment and storage medium |
CN115242735A (en) * | 2022-09-22 | 2022-10-25 | 中邮消费金融有限公司 | Real-time voice stream slice analysis method, system and computer equipment |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103744621A (en) * | 2013-12-31 | 2014-04-23 | 深圳英飞拓科技股份有限公司 | Circular read-write method and device for buffer |
US20160342390A1 (en) * | 2015-05-22 | 2016-11-24 | Robert Bosch Gmbh | Fifo memory having a memory region modifiable during operation |
CN106445405A (en) * | 2015-08-13 | 2017-02-22 | 北京忆恒创源科技有限公司 | Flash storage-oriented data access method and apparatus |
-
2018
- 2018-03-21 CN CN201810238860.7A patent/CN108491333A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103744621A (en) * | 2013-12-31 | 2014-04-23 | 深圳英飞拓科技股份有限公司 | Circular read-write method and device for buffer |
US20160342390A1 (en) * | 2015-05-22 | 2016-11-24 | Robert Bosch Gmbh | Fifo memory having a memory region modifiable during operation |
CN106445405A (en) * | 2015-08-13 | 2017-02-22 | 北京忆恒创源科技有限公司 | Flash storage-oriented data access method and apparatus |
Non-Patent Citations (1)
Title |
---|
李忠民: "环形缓冲区的扩展方法", 《电子技术与软件工程》 * |
Cited By (23)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109446126A (en) * | 2018-10-17 | 2019-03-08 | 天津津航计算技术研究所 | DSP and FPGA high-speed communication system and method based on EMIF bus |
CN109446126B (en) * | 2018-10-17 | 2022-02-15 | 天津津航计算技术研究所 | DSP and FPGA high-speed communication system and method based on EMIF bus |
CN110046047A (en) * | 2019-04-15 | 2019-07-23 | Oppo广东移动通信有限公司 | A kind of inter-process communication methods, device and computer readable storage medium |
CN110704335A (en) * | 2019-09-03 | 2020-01-17 | 苏州浪潮智能科技有限公司 | Data reading and writing method and device based on asynchronous ring buffer |
CN112445792B (en) * | 2019-09-04 | 2024-05-24 | 中移物联网有限公司 | Block chain block data storage method and device, electronic equipment and storage medium |
CN112445792A (en) * | 2019-09-04 | 2021-03-05 | 中移物联网有限公司 | Block chain block data storage method and device, electronic equipment and storage medium |
CN110830385A (en) * | 2019-09-25 | 2020-02-21 | 上海数荃数据科技有限公司 | Packet capturing processing method, network equipment, server and storage medium |
CN112765054A (en) * | 2019-11-01 | 2021-05-07 | 中国科学院声学研究所 | High-speed data acquisition system and method based on FPGA |
CN111245742A (en) * | 2019-12-31 | 2020-06-05 | 宁波舜宇智能科技有限公司 | Data buffering method and device, computer and readable storage medium |
CN111240599A (en) * | 2020-01-17 | 2020-06-05 | 北京马赫谷科技有限公司 | Data stream storage method and device |
CN111290709A (en) * | 2020-01-19 | 2020-06-16 | 成都中嵌自动化工程有限公司 | Dynamically adjustable annular buffer area |
CN111506512A (en) * | 2020-04-24 | 2020-08-07 | 上海燧原智能科技有限公司 | Debugging information processing method and device, electronic equipment, storage medium and system |
CN111865824A (en) * | 2020-06-19 | 2020-10-30 | 重庆川仪自动化股份有限公司 | Method and system for designing double-pointer annular buffer area in serial port communication |
CN111708495A (en) * | 2020-06-19 | 2020-09-25 | 深圳前海微众银行股份有限公司 | Annular queue storage method and device, computing equipment and storage medium |
CN113297234A (en) * | 2020-09-30 | 2021-08-24 | 阿里云计算有限公司 | Data processing method, device, equipment and computer readable storage medium |
CN113297234B (en) * | 2020-09-30 | 2023-03-14 | 阿里云计算有限公司 | Data processing method, device, equipment and computer readable storage medium |
CN112235204B (en) * | 2020-10-13 | 2023-04-07 | 中移(杭州)信息技术有限公司 | Data reporting method, system, electronic equipment and storage medium |
CN112235204A (en) * | 2020-10-13 | 2021-01-15 | 中移(杭州)信息技术有限公司 | Data reporting method, system, electronic equipment and storage medium |
CN112882655A (en) * | 2021-02-03 | 2021-06-01 | 广发证券股份有限公司 | Data caching method and device, electronic equipment and storage medium |
CN113138945A (en) * | 2021-04-16 | 2021-07-20 | 宜通世纪科技股份有限公司 | Data caching method, device, equipment and medium |
CN113138945B (en) * | 2021-04-16 | 2023-11-21 | 宜通世纪科技股份有限公司 | Data caching method, device, equipment and medium |
CN115203002A (en) * | 2022-09-16 | 2022-10-18 | 深圳华云信息系统有限公司 | Log processing method and device, electronic equipment and storage medium |
CN115242735A (en) * | 2022-09-22 | 2022-10-25 | 中邮消费金融有限公司 | Real-time voice stream slice analysis method, system and computer equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108491333A (en) | Method for writing data, device, equipment and the medium of buffer circle | |
CN110674053B (en) | SSD data storage node management method and device, computer equipment and storage medium | |
CN112286939B (en) | Method, device and equipment for generating hash of global state in block chain type account book | |
CN111198868B (en) | Intelligent database-dividing real-time data migration method and device | |
CN103544153A (en) | Data updating method and system based on database | |
CN108090168A (en) | A kind of general F2FS file system analytic method, terminal device and storage medium | |
CN112445729B (en) | Operation address determination method, PCIe system, electronic device and storage medium | |
CN112597153B (en) | Block chain-based data storage method, device and storage medium | |
CN102402436B (en) | Webpage game engine and method for developing webpage game by using same | |
CN101763433B (en) | Data storage system and method | |
CN110109868A (en) | Method, apparatus and computer program product for index file | |
CN110032562B (en) | Method and device for storing business records | |
CN107391539B (en) | Transaction processing method, server and storage medium | |
CN105653539A (en) | Index distributed storage implement method and device | |
CN110187872A (en) | A kind of BIOS development approach, system and electronic equipment and storage medium | |
US20110167047A1 (en) | Editing apparatus, method, and storage medium | |
CN109783321A (en) | Monitoring data management method, device, terminal device | |
US20110252070A1 (en) | System and Method for Appending Metadata to Objects | |
CN114238161A (en) | Intelligent disk fragment sorting method and device and electronic equipment | |
CN109324867A (en) | A kind of virtual machine temporary storage method, restoration methods and device | |
CN102722543B (en) | Method for storing files | |
CN115934999A (en) | Video stream data storage method, device and medium based on block file | |
WO2018177414A1 (en) | Data processing method, data processing device, computing device, and storage medium | |
CN108959124A (en) | Magnetic disk of virtual machine reproduction process wiring method and device based on dynamic buffering | |
CN111858590B (en) | Storage system metadata organization method, system, terminal and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20180904 |