CN110362348A - A kind of method, apparatus and electronic equipment of queue access data - Google Patents
A kind of method, apparatus and electronic equipment of queue access data Download PDFInfo
- Publication number
- CN110362348A CN110362348A CN201810311279.3A CN201810311279A CN110362348A CN 110362348 A CN110362348 A CN 110362348A CN 201810311279 A CN201810311279 A CN 201810311279A CN 110362348 A CN110362348 A CN 110362348A
- Authority
- CN
- China
- Prior art keywords
- team
- data
- queue
- current queue
- 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
- 238000000034 method Methods 0.000 title claims abstract description 36
- 230000015654 memory Effects 0.000 claims description 61
- 230000006870 function Effects 0.000 claims description 32
- 238000004590 computer program Methods 0.000 claims description 5
- 230000015572 biosynthetic process Effects 0.000 claims description 4
- 238000010586 diagram Methods 0.000 description 10
- 230000007246 mechanism Effects 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 241001269238 Data Species 0.000 description 2
- 102100032282 26S proteasome non-ATPase regulatory subunit 14 Human genes 0.000 description 1
- 101000590281 Homo sapiens 26S proteasome non-ATPase regulatory subunit 14 Proteins 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 230000002457 bidirectional effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000000151 deposition Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000003780 insertion Methods 0.000 description 1
- 230000037431 insertion Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/38—Concurrent instruction execution, e.g. pipeline or look ahead
- G06F9/3854—Instruction completion, e.g. retiring, committing or graduating
- G06F9/3856—Reordering of instructions, e.g. using queues or age tags
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
The embodiment of the invention discloses the method, apparatus and electronic equipment of a kind of queue access data, which comprises receives the write instruction of one or more producer threads, and data are written to current queue based on atomic operation according to said write instruction;The reading instruction of one or more consumer threads is received, and data are read from current queue based on atomic operation according to reading instruction.By using above-mentioned technical proposal, be written into data/when reading queue, by using atomic operation, it not only ensure that the correctness of queuing data, while also improving the speed of data enqueue/dequeue.
Description
Technical field
The present embodiments relate to computer field more particularly to a kind of method, apparatus and electronics of queue access data
Equipment.
Background technique
Queue is a kind of linear list of first in first out, and abbreviation FIFO is usually realized with chained list.The tail of the queue of queue only allows
Insertion data manipulation is carried out, team's head only allows to carry out deletion data operation.It is stated to be in the tail of the queue insert number of queue and joins the team, in team
Team's head of column deletes data and is known as team.(such as producer consumer mode) thread is responsible for usually under specific scene
Data are write in toward queue, a thread is responsible for reading data in queue.
There are some defects for lining up mode under existing producer consumer programming scene, for example, if two threads (one
A reading thread and one write thread) do not take any security strategy, due to CPU (Central Processing Unit, in
Central Processing Unit) Out-of-order execution, may a data write not yet just robbed by other threads accounts for execution other operation, because
This not can guarantee the correctness of queuing data;If two threads use locking mode, although can guarantee the correct of queuing data
Property, but the response performance of thread is caused to reduce, influence the execution efficiency of each thread.
Summary of the invention
To solve Related Technical Issues, the present invention provides the method, apparatus and electronic equipment of a kind of queue access data, leads to
Crossing the method can guarantee to improve the joining the team of data, queue output rate while queuing data is correct.
To achieve the above object, the embodiment of the present invention adopts the following technical scheme that
In a first aspect, the embodiment of the invention provides a kind of methods of queue access data, which comprises
Receive the write instruction of one or more producer threads, and according to said write instruction based on atomic operation to working as
Data are written in preceding queue;
It receives the reading instruction of one or more consumer threads, and atomic operation is based on from working as according to readings instruction
Data are read in preceding queue.
Further, the write instruction for receiving one or more producer threads, and base is instructed according to said write
Data are written to current queue in atomic operation, comprising:
By calling the position of joining the team write atom function and obtain current queue;
The position of joining the team is increased by one, obtains preparing the position joined the team next time;
By calling the team position out read atom function and obtain current queue;
If it is not identical to prepare the position joined the team and the team position out the next time, apply for storing data to be written
Memory headroom;
Data assignment is written into the memory headroom.
Further, the write instruction for receiving one or more producer threads, and base is instructed according to said write
Data are written to current queue in atomic operation, further includes:
By calling atom function to update the position of joining the team of the current queue, the position that the next time prepares to join the team is set
It is set to the position of joining the team of current queue.
Further, the reading instruction for receiving one or more consumer threads, and base is instructed according to the reading
Data are read from current queue in atomic operation, comprising:
By calling the team position out read atom function and obtain current queue;
By calling the position of joining the team write atom function and obtain current queue;
If it is described join the team position and it is described go out team position it is not identical, by it is described go out the corresponding memory in team position be assigned to change
Data on the team position out are read queue by amount.
Further, the reading instruction for receiving one or more consumer threads, and base is instructed according to the reading
Data are read from current queue in atomic operation, further includes:
By calling atom function to update the team position out of the current queue, to determine the position for preparing team out next time.
Further, before the write instruction for receiving one or more producer threads, the method also includes: define institute
The class formation of current queue is stated, specifically:
One piece of memory block for setting byte is defined respectively with tail of the queue in team's head of the current queue, it is described current to guarantee
The corresponding memory of queue is the contiguous memory of one piece of alignment.
Further, it is described join the team position and it is described go out team position original state be the queue team head position.
Second aspect, the embodiment of the invention provides a kind of device of queue access data, described device includes:
Writing module is based on for receiving the write instruction of one or more producer threads, and according to said write instruction
Data are written to current queue in atomic operation;
Read through model, the reading for receiving one or more consumer threads instructs, and is based on according to reading instruction
Atomic operation reads data from current queue.
The third aspect the embodiment of the invention provides a kind of electronic equipment, including first memory, first processor and is deposited
The computer program that can be run on a memory and on first processor is stored up, the first processor executes the computer journey
The method of the queue access data as described in above-mentioned first aspect is realized when sequence.
Fourth aspect, the embodiment of the invention provides a kind of storage medium comprising computer executable instructions, the meters
Calculation machine executable instruction realizes the side of the queue access data as described in above-mentioned first aspect when being executed as computer processor
Method.
A kind of method of queue access data provided in an embodiment of the present invention is written into data/when reading queue, passes through
Using atomic operation, the correctness of queuing data not only ensure that, while also improving the speed of data enqueue/dequeue.
Detailed description of the invention
To describe the technical solutions in the embodiments of the present invention more clearly, institute in being described below to the embodiment of the present invention
Attached drawing to be used is needed to be briefly described, it should be apparent that, the accompanying drawings in the following description is only some implementations of the invention
Example, for those of ordinary skill in the art, without creative efforts, can also implement according to the present invention
The content of example and these attached drawings obtain other attached drawings.
Fig. 1 is a kind of method flow schematic diagram for queue access data that the embodiment of the present invention one provides;
Fig. 2 is a kind of schematic diagram for memory block storing data that the embodiment of the present invention one provides;
Fig. 3 be the embodiment of the present invention one provide it is a kind of by enqueue operations write interface to queue be written data method stream
Cheng Tu;
Fig. 4 is a kind of method stream for reading data from queue by dequeue operation reading interface that the embodiment of the present invention one provides
Cheng Tu;
Fig. 5 is a kind of apparatus structure schematic diagram of queue access data provided by Embodiment 2 of the present invention;
Fig. 6 is the structural schematic diagram for a kind of electronic equipment that the embodiment of the present invention three provides.
Specific embodiment
To keep the technical problems solved, the adopted technical scheme and the technical effect achieved by the invention clearer, below
It will the technical scheme of the embodiment of the invention will be described in further detail in conjunction with attached drawing, it is clear that described embodiment is only
It is a part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those skilled in the art exist
Every other embodiment obtained under the premise of creative work is not made, shall fall within the protection scope of the present invention.
Embodiment one
Fig. 1 is a kind of method flow schematic diagram for queue access data that the embodiment of the present invention one provides.The present embodiment is public
The method for the queue access data opened can be executed by the device of queue access data, wherein the device can by software and/or
Hardware realization.Referring specifically to shown in Fig. 1, this method be may include steps of:
110, the write instruction of one or more producer threads is received, and atomic operation is based on according to said write instruction
Data are written to current queue.
Wherein, atomic operation refers to the operation that will not be interrupted by thread scheduling mechanism, and atomic operation is once just always
Running to current thread terminates, and centre does not have any operation for switching to other threads, i.e. CPU is executing an atomic operation
Thread when, will not be robbed by other thread and account for the other any operations of execution.Therefore, it is write based on atomic operation to current queue
Enter/data are read, the speed of write/read data, the i.e. speed of the enqueue/dequeue of raising data can be improved, while can also be true
Protect the integrality of write/read data, the i.e. correctness of data.
Specifically, before the write instruction of the one or more producer threads of reception, further includes: define the current queue
Class formation.Such as scene is programmed as producer consumer mode, define the class of ProducerConsumerQueue queue
Structure, data member include the following:
1)Char pad0[64];The first address for indicating definition queuing memory, using the memory of 64 byte-aligneds;
2) Records is used for storage queue element;
3) Size indicates the amount of capacity of queue;
4) std::atomic<unsigned int>readIndex, indicate queue goes out team position;
5) std::atomic<unsigned int>writeIndex indicates the position of joining the team of queue;
6) pad1 [64-sizeof (writeIndex)], indicates the end address of queuing memory, using 64 byte-aligneds.
The memory block for defining one piece of setting byte respectively with tail of the queue by team's head in queue, in guaranteeing that queue is corresponding
Depositing is one piece of contiguous memory being aligned, and realizes the purpose for improving queuing data queue output rate.
The influence being aligned with the memory of non-alignment to data queue output rate is explained so that queuing data goes out team as an example:
Queuing data, which goes out team, can be regarded as the process that CPU reads data from memory.It is one piece one piece that CPU, which treats as memory,
, the size of block can be the bytes such as 2,4,8,16, for details, reference can be made to the schematic diagram of memory block storing data shown in Fig. 2,
Therefore CPU is one piece one piece and is read out when reading memory, the size of block is known as memory and reads granularity.Assuming that CPU
The data of 4 byte-sizeds are read into register (it is 4 bytes that memory, which reads granularity), in two kinds of situation:
1), memory is aligned, and the data to be read are since 0 byte;
2), memory is not aligned, and the data to be read are since 1 byte;
For above situation 1), tetra- byte datas of 0-3 are directly read into register completely, read operation terminates;
For above situation 2), first tetra- byte datas of 0-3 are first read into register completely, then reads again 4-
The data of 7 bytes are to register, and then 0 byte, the data of 5,6,7 bytes are rejected, and finally merge the data of 1,2,3,4 bytes
To register.As it can be seen that reading the operation bidirectional that the data in a memory block not being aligned need to increase multistep, substantially reduce
The performance of CPU, causes the reading speed slack-off.
Wherein, the one kind for receiving the write instruction of one or more producer threads is achieved in that: enqueue operations, which are write, to be connect
Mouthful called by one or more producer threads, the present embodiment is optimized by writing interface to enqueue operations, once it is described enter
Interface start-up operation is write in team's operation, then entirely the thread of write-in data is not cut off, until data are joined the team completion, CPU just meeting
It is gone to execute other thread task by the control of thread scheduling mechanism, improves the speed of joining the team of data.Illustratively, referring to Fig. 3
Shown in it is a kind of by enqueue operations write interface to queue be written data method flow diagram, specifically include:
310, by calling the position of joining the team write atom function and obtain current queue.
Specifically, can by call writeIndex_.load (std::memory_order_relaxed) atom function,
The position of joining the team of writeIndex current queue is obtained, while by current position+1, obtaining the position for preparing to join the team next time,
That is the content of step 320.
320, the position of joining the team is increased by one, obtains preparing the position joined the team next time.
330, by calling the team position out read atom function and obtain current queue.
Specifically, can by call readIndex_.load (std::memory_order_acquire) atom function,
Obtain readIndex_ current queue goes out team position.
If it is not identical 340, to prepare the position joined the team and the team position out the next time, apply to be written for storing
The memory headroom of data.
Wherein, identical as the team position out if preparing the position joined the team the next time, then it represents that current queue has expired, no
Data can be written again, if the discontented i.e. described next position for preparing to join the team of queue and the team position out be not identical, can pass through
It calls the application of new operator to prepare the memory of write-in data, is written into data assignment to the memory headroom, completes data and enter
Team.
350, data assignment is written into the memory headroom.
360, by calling atom function to update the position of joining the team of the current queue, the next time is prepared into the position joined the team
Install the position of joining the team for being set to current queue.
Specifically, by writeIndex.store (next, std::memory_order_release) atom function,
WriteIndex is arranged to prepare the position joined the team next time, it is correct can be got when ensuring that data are written to queue in next time
Position of joining the team.
It should be noted that the original state of join the team position and the team position out is team's head position of the queue.
Above-mentioned enqueue operations write interface by the enqueue operations based on atomic operation realization queuing data, improve data
The correctness of speed of joining the team and queuing data.
120, the reading instruction of one or more consumer threads is received, and atomic operation is based on according to reading instruction
Data are read from current queue.
Wherein, the one kind for receiving the reading instruction of one or more consumer threads is achieved in that: dequeue operation reading connects
Mouthful called by one or more consumer threads, the present embodiment is optimized by reading interface to dequeue operation, once it is described go out
Team, which operates, reads interface start-up operation, then the thread for entirely reading data is not cut off, until dequeuing data completion, CPU just meeting
It is gone to execute other thread task by the control of thread scheduling mechanism, improves the queue output rate of data.Illustratively, referring to fig. 4
Shown in it is a kind of by dequeue operation read interface from queue read data method flow diagram, specifically include:
410, by calling the team position out read atom function and obtain current queue.
Specifically, can by call readIndex_.load (std::memory_order_relaxed) atom function,
Obtain the position that queue currently goes out team.
420, by calling the position of joining the team write atom function and obtain current queue.
If 430, it is described join the team position and it is described go out team position it is not identical, will it is described go out the corresponding memory assignment in team position
To variable, the data on the team position out are read into queue.
If it is described join the team position with it is described go out team position it is identical, then it represents that current queue be sky, if it is described join the team position with
The team position out is not identical, then by calling std::move (records_ [currentRead]) function, current queue
Data on the team position out are read queue into variable, to realize by the memory assignment of dequeue data.
440, by calling atom function to update the team position out of the current queue, to determine the position for preparing team out next time
It sets.
The current team position readIndex_ that goes out is increased by 1, obtains and prepares the position of team out next time, and pass through
ReadIndex_.store (next, std::memory_order_release) atom function, under readIndex_ is arranged to
The secondary position for preparing team out.
Above-mentioned dequeue operation reads interface by the dequeue operation based on atomic operation realization queuing data, improves data
Queue output rate.
The method of queue access data provided in this embodiment, be written into data/when reading queue, by using atom
Operation, not only ensure that the correctness of queuing data, while also improving the speed of data enqueue/dequeue, by queue
Team's head defines the memory block being aligned with tail of the queue respectively, further improves the execution efficiency of CPU, improves entering for queuing data
Team/queue output rate.Thread responds caused by avoiding the correctness by using thread locking to guarantee queuing data simultaneously
The shortcomings that reduced performance.
Embodiment two
Fig. 5 is a kind of apparatus structure schematic diagram of queue access data provided by Embodiment 2 of the present invention.Referring to Fig. 5 institute
Show, described device includes: writing module 510 and read through model 520.
Wherein, writing module 510, for receiving the write instruction of one or more producer threads, and according to said write
Data are written to current queue based on atomic operation in instruction;Read through model 520, for receiving the reading of one or more consumer threads
Instruction fetch, and data are read from current queue based on atomic operation according to reading instruction.
Optionally, writing module 510 may include:
It joins the team position acquisition unit, for by calling the position of joining the team write atom function and obtain current queue;
Location updating unit obtains preparing the position joined the team next time for the position of joining the team to be increased by one;
Team's position acquisition unit out, for by calling the team position out read atom function and obtain current queue;
Application unit, if not identical for preparing the position joined the team and the team position out the next time, application is used for
Store the memory headroom of data to be written;
Writing unit, for being written into data assignment to the memory headroom.
Optionally, read through model 520 may include:
Team's position acquisition unit out, for by calling the team position out read atom function and obtain current queue;
It joins the team position acquisition unit, for by calling the position of joining the team write atom function and obtain current queue;
Sensing element, if for it is described join the team position and it is described go out team position it is not identical, will it is described go out team position it is corresponding
Memory be assigned to variable, by it is described go out team position on data read queue;
Team's location updating unit out, for updating the team position out of the current queue by calling atom function, with true
Fix the secondary position for preparing team out.
Optionally, described device can also include: definition module, for receiving writing for one or more producer threads
Before entering instruction, the class formation of the current queue is defined, is specifically used for:
One piece of memory block for setting byte is defined respectively with tail of the queue in team's head of the current queue, it is described current to guarantee
The corresponding memory of queue is the contiguous memory of one piece of alignment.
Optionally, it is described join the team position and it is described go out team position original state be the queue team head position.
The device of queue access data provided in this embodiment, be written into data/when reading queue, by using atom
Operation, not only ensure that the correctness of queuing data, while also improving the speed of data enqueue/dequeue, by queue
Team's head defines the memory block being aligned with tail of the queue respectively, further improves the execution efficiency of CPU, improves entering for queuing data
Team/queue output rate.Thread responds caused by avoiding the correctness by using thread locking to guarantee queuing data simultaneously
The shortcomings that reduced performance.
Embodiment three
Fig. 6 is the structural schematic diagram for a kind of electronic equipment that the embodiment of the present invention three provides.As shown in fig. 6, the electronics is set
It is standby to include: first processor 670, first memory 671 and be stored on first memory 671 and be in first processor 670
The computer program of upper operation;Wherein, the quantity of first processor 670 can be one or more, at one first in Fig. 6
For reason device 670;Realize that the queue as described in above-described embodiment one is deposited when first processor 670 executes the computer program
The method for evidence of fetching.As shown in fig. 6, the electronic equipment can also include the first input unit 672 and the first output device
673.First processor 670, first memory 671, the first input unit 672 and the first output device 673 can pass through bus
Or other modes connect, in Fig. 6 for being connected by bus.
First memory 671 is used as a kind of computer readable storage medium, and can be used for storing software program, computer can hold
Line program and module, if device/module of queue access data in the embodiment of the present invention is (for example, the dress of queue access data
Writing module 510 and read through model 520 in setting etc.).First processor 670 is stored in soft in first memory 671 by operation
Part program, instruction and module realize above-mentioned team thereby executing the various function application and data processing of electronic equipment
The method of column access data.
First memory 671 can mainly include storing program area and storage data area, wherein storing program area can store behaviour
Application program needed for making system, at least one function;Storage data area, which can be stored, uses created data according to terminal
Deng.In addition, first memory 671 may include high-speed random access memory, it can also include nonvolatile memory, such as
At least one disk memory, flush memory device or other non-volatile solid state memory parts.In some instances, it first deposits
Reservoir 671 can further comprise the memory remotely located relative to first processor 670, these remote memories can pass through
It is connected to the network to electronic equipment/storage medium.The example of above-mentioned network includes but is not limited to internet, intranet, local
Net, mobile radio communication and combinations thereof.
First input unit 672 can be used for receiving the number or character information of input, and generate the use with electronic equipment
Family setting and the related key signals input of function control.First output device 673 may include that display screen etc. shows equipment.
Example IV
The embodiment of the present invention four also provides a kind of storage medium comprising computer executable instructions, and the computer can be held
A kind of method of the row instruction when being executed by computer processor for executing queue access data, this method comprises:
Receive the write instruction of one or more producer threads, and according to said write instruction based on atomic operation to working as
Data are written in preceding queue;
It receives the reading instruction of one or more consumer threads, and atomic operation is based on from working as according to readings instruction
Data are read in preceding queue.
Certainly, a kind of storage medium comprising computer executable instructions, computer provided by the embodiment of the present invention
The method operation that executable instruction is not limited to the described above, can also be performed queue access provided by any embodiment of the invention
The relevant operation of data.
By the description above with respect to embodiment, it is apparent to those skilled in the art that, the present invention
It can be realized by software and required common hardware, naturally it is also possible to which by hardware realization, but in many cases, the former is more
Good embodiment.Based on this understanding, technical solution of the present invention substantially in other words contributes to the prior art
Part can be embodied in the form of software products, which can store in computer readable storage medium
In, floppy disk, read-only memory (Read-Only Memory, ROM), random access memory (Random such as computer
Access Memory, RAM), flash memory (FLASH), hard disk or CD etc., including some instructions are with so that a computer is set
Standby (can be personal computer, storage medium or the network equipment etc.) executes described in each embodiment of the present invention.
Note that the above is only a better embodiment of the present invention and the applied technical principle.It will be appreciated by those skilled in the art that
The invention is not limited to the specific embodiments described herein, be able to carry out for a person skilled in the art it is various it is apparent variation,
It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out by above embodiments to the present invention
It is described in further detail, but the present invention is not limited to the above embodiments only, without departing from the inventive concept, also
It may include more other equivalent embodiments, and the scope of the invention is determined by the scope of the appended claims.
Claims (10)
1. a kind of method of queue access data characterized by comprising
The write instruction of one or more producer threads is received, and atomic operation is based on to current team according to said write instruction
Column write-in data;
The reading instruction of one or more consumer threads is received, and atomic operation is based on from current team according to reading instruction
Column read data.
2. the method according to claim 1, wherein the write-in for receiving one or more producer threads refers to
It enables, and data is written to current queue based on atomic operation according to said write instruction, comprising:
By calling the position of joining the team write atom function and obtain current queue;
The position of joining the team is increased by one, obtains preparing the position joined the team next time;
By calling the team position out read atom function and obtain current queue;
If it is not identical to prepare the position joined the team and the team position out the next time, apply for storing the interior of data to be written
Deposit space;
Data assignment is written into the memory headroom.
3. according to the method described in claim 2, it is characterized in that, the write-in for receiving one or more producer threads refers to
It enables, and data is written to current queue based on atomic operation according to said write instruction, further includes:
By calling atom function to update the position of joining the team of the current queue, set the position that the next time prepares to join the team to
The position of joining the team of current queue.
4. the method according to claim 1, wherein the reading for receiving one or more consumer threads refers to
It enables, and data is read from current queue based on atomic operation according to reading instruction, comprising:
By calling the team position out read atom function and obtain current queue;
By calling the position of joining the team write atom function and obtain current queue;
If it is described join the team position and it is described go out team position it is not identical, by it is described go out the corresponding memory in team position be assigned to variable,
The data on the team position out are read queue.
5. according to the method described in claim 4, it is characterized in that, the reading for receiving one or more consumer threads refers to
It enables, and data is read from current queue based on atomic operation according to reading instruction, further includes:
By calling atom function to update the team position out of the current queue, to determine the position for preparing team out next time.
6. method according to claim 1-5, which is characterized in that receive writing for one or more producer threads
Before entering instruction, further includes: the class formation of the current queue is defined, specifically:
One piece of memory block for setting byte is defined respectively with tail of the queue in team's head of the current queue, to guarantee the current queue
Corresponding memory is the contiguous memory of one piece of alignment.
7. the method according to any one of claim 2-5, which is characterized in that position and the team position out of joining the team
Original state be the queue team head position.
8. a kind of device of queue access data, which is characterized in that described device includes:
Writing module is based on atom for receiving the write instruction of one or more producer threads, and according to said write instruction
It operates to current queue and data is written;
Read through model, the reading for receiving one or more consumer threads instructs, and is based on atom according to reading instruction
Operation reads data from current queue.
9. a kind of electronic equipment, including first memory, first processor and storage are on a memory and can be in first processor
The computer program of upper operation, which is characterized in that realized when the first processor executes the computer program as right is wanted
The method for seeking queue access data described in any one of 1-7.
10. a kind of storage medium comprising computer executable instructions, the computer executable instructions are by computer disposal
The method such as queue access data of any of claims 1-7 is realized when device executes.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810311279.3A CN110362348A (en) | 2018-04-09 | 2018-04-09 | A kind of method, apparatus and electronic equipment of queue access data |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810311279.3A CN110362348A (en) | 2018-04-09 | 2018-04-09 | A kind of method, apparatus and electronic equipment of queue access data |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110362348A true CN110362348A (en) | 2019-10-22 |
Family
ID=68212008
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810311279.3A Pending CN110362348A (en) | 2018-04-09 | 2018-04-09 | A kind of method, apparatus and electronic equipment of queue access data |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110362348A (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111124641A (en) * | 2019-12-12 | 2020-05-08 | 中盈优创资讯科技有限公司 | Data processing method and system using multiple threads |
CN111858095A (en) * | 2020-07-17 | 2020-10-30 | 山东云海国创云计算装备产业创新中心有限公司 | Hardware queue multithreading sharing method, device, equipment and storage medium |
CN111966511A (en) * | 2020-08-12 | 2020-11-20 | 中国工商银行股份有限公司 | Message queue data read-write processing method and device |
CN113238711A (en) * | 2021-04-17 | 2021-08-10 | 西安电子科技大学 | Efficient hash calculation method in electronic data evidence obtaining field |
CN113868164A (en) * | 2021-09-28 | 2021-12-31 | 歌尔科技有限公司 | Dual-computer communication method, device and system |
CN116627507A (en) * | 2023-06-19 | 2023-08-22 | 海光信息技术股份有限公司 | Queue control method, apparatus, electronic device, and computer-readable storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103176837A (en) * | 2013-03-27 | 2013-06-26 | 南京大学 | Lock-free message queue implementation method based on reversal single linked list |
CN104168217A (en) * | 2014-08-15 | 2014-11-26 | 杭州华三通信技术有限公司 | Scheduling method and device for first in first out queue |
CN106293973A (en) * | 2016-08-17 | 2017-01-04 | 深圳市金证科技股份有限公司 | Lock-free message queue communication means and system |
CN103645942B (en) * | 2013-12-12 | 2017-02-01 | 北京奇安信科技有限公司 | Message queue based write and read method and system of shared memory |
CN107357648A (en) * | 2017-05-25 | 2017-11-17 | 吕锦柏 | The implementation method of spin lock when a kind of multi-core CPU accesses resource |
-
2018
- 2018-04-09 CN CN201810311279.3A patent/CN110362348A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103176837A (en) * | 2013-03-27 | 2013-06-26 | 南京大学 | Lock-free message queue implementation method based on reversal single linked list |
CN103645942B (en) * | 2013-12-12 | 2017-02-01 | 北京奇安信科技有限公司 | Message queue based write and read method and system of shared memory |
CN104168217A (en) * | 2014-08-15 | 2014-11-26 | 杭州华三通信技术有限公司 | Scheduling method and device for first in first out queue |
CN106293973A (en) * | 2016-08-17 | 2017-01-04 | 深圳市金证科技股份有限公司 | Lock-free message queue communication means and system |
CN107357648A (en) * | 2017-05-25 | 2017-11-17 | 吕锦柏 | The implementation method of spin lock when a kind of multi-core CPU accesses resource |
Non-Patent Citations (3)
Title |
---|
姚向华等: "《微型计算机原理 第6版》", 28 February 2017 * |
方敏等: "《计算机操作系统》", 31 August 2004 * |
邓红卫等: "《数据结构(C语言版)》", 31 August 2017 * |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111124641A (en) * | 2019-12-12 | 2020-05-08 | 中盈优创资讯科技有限公司 | Data processing method and system using multiple threads |
CN111124641B (en) * | 2019-12-12 | 2023-10-31 | 中盈优创资讯科技有限公司 | Data processing method and system using multithreading |
CN111858095A (en) * | 2020-07-17 | 2020-10-30 | 山东云海国创云计算装备产业创新中心有限公司 | Hardware queue multithreading sharing method, device, equipment and storage medium |
CN111858095B (en) * | 2020-07-17 | 2022-06-10 | 山东云海国创云计算装备产业创新中心有限公司 | Hardware queue multithreading sharing method, device, equipment and storage medium |
CN111966511A (en) * | 2020-08-12 | 2020-11-20 | 中国工商银行股份有限公司 | Message queue data read-write processing method and device |
CN111966511B (en) * | 2020-08-12 | 2024-02-13 | 中国工商银行股份有限公司 | Message queue data read-write processing method and device |
CN113238711A (en) * | 2021-04-17 | 2021-08-10 | 西安电子科技大学 | Efficient hash calculation method in electronic data evidence obtaining field |
CN113238711B (en) * | 2021-04-17 | 2024-02-02 | 西安电子科技大学 | Efficient hash calculation method in field of electronic data evidence obtaining |
CN113868164A (en) * | 2021-09-28 | 2021-12-31 | 歌尔科技有限公司 | Dual-computer communication method, device and system |
CN116627507A (en) * | 2023-06-19 | 2023-08-22 | 海光信息技术股份有限公司 | Queue control method, apparatus, electronic device, and computer-readable storage medium |
CN116627507B (en) * | 2023-06-19 | 2024-04-12 | 海光信息技术股份有限公司 | Queue control method, apparatus, electronic device, and computer-readable storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110362348A (en) | A kind of method, apparatus and electronic equipment of queue access data | |
CN108733344A (en) | Data read-write method, device and circle queue | |
CN101996098A (en) | Managing message queues | |
CN107786623B (en) | Message asynchronous processing method and device | |
EP3242199A1 (en) | Flash memory controller and control method for flash memory controller | |
EP3077914B1 (en) | System and method for managing and supporting virtual host bus adaptor (vhba) over infiniband (ib) and for supporting efficient buffer usage with a single external memory interface | |
CN110377224A (en) | The mass-memory unit refreshed with host-initiated buffer area | |
CN109298882A (en) | Management method, computer readable storage medium and the terminal device of interface | |
CN103731368A (en) | Method and device for processing message | |
CN101145113A (en) | Multi-thread access indirect register scheduling method | |
CN104424030A (en) | Sharing memory multi-process operation method and device | |
CN101206614A (en) | Simulator for simulating register with specific function | |
CN110347510A (en) | A kind of management method, system, equipment and medium mixing memory | |
CN112306669A (en) | Task processing method and device based on multi-core system | |
CN112182452A (en) | Page component rendering processing method, device, equipment and computer readable medium | |
CN109298888B (en) | Queue data access method and device | |
CN109376165A (en) | The implementation method and device and computer readable storage medium of memory database lock | |
CN108958903A (en) | Embedded multi-core central processing unit method for scheduling task and device | |
CN107193558B (en) | Log file generation method and device | |
CN104866285A (en) | Programmable controller | |
CN109426562A (en) | Priority weighted robin scheduling device | |
CN104714779B (en) | Command processing method and device | |
CN108959124A (en) | Magnetic disk of virtual machine reproduction process wiring method and device based on dynamic buffering | |
CN105653490B (en) | A kind of data processing method and device based on address control | |
CN114661624A (en) | Method, system, equipment and storage medium for efficiently acquiring and storing data |
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: 20191022 |