CN109408239A - A kind of asynchronous I O process method based on queue - Google Patents
A kind of asynchronous I O process method based on queue Download PDFInfo
- Publication number
- CN109408239A CN109408239A CN201811283081.5A CN201811283081A CN109408239A CN 109408239 A CN109408239 A CN 109408239A CN 201811283081 A CN201811283081 A CN 201811283081A CN 109408239 A CN109408239 A CN 109408239A
- Authority
- CN
- China
- Prior art keywords
- queue
- node
- module
- producer
- pointer
- 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
- 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
-
- 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/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/524—Deadlock detection or avoidance
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
A kind of asynchronous I O process method based on queue, the module of this method include that interface is submitted in a privately owned queue, one group of functional interface and a queue.In module-external, the producer needs first to create a temporary queue, then by the functional interface producer can continuous several times call the function of the module.During the producer calls the functions of modules, it function type that module is called according to the producer and calls the creation I/O request node of parameter used in the function and node will be requested to be put into the temporary queue of producer's creation, if the single Data Node that can also will be submitted in parameter of functions of modules is directly placed into temporary queue.All nodes batch in temporary queue is submitted to the privately owned queue of module by queue submission interface by the last producer.Since each producer will create a temporary queue, and the I/O request node that the producer creates in calling module function course is put into respective temporary queue and does not need to lock, therefore drastically reduces a possibility that there are mutual exclusions between the producer.To which the performance for submitting asynchronous I/O operation greatly improved.
Description
Technical field
The present invention relates to computer system softwares to program field, especially a kind of asynchronous I O process method based on queue.
Background technique
Asynchronous I/O operation is common I/O mode in computer system software, relative to synchronous I/O mode, asynchronous IO pairs
Reducing thread occupancy and improving I/O throughput has obvious help.But there are also some shortcomings in actual program, such as are submitting
It can not determine whether the I/O operation of submission has begun execution after asynchronous IO, submit asynchronous IO each time all in multi-thread environment
It needs to consider the mutual exclusion between thread, i.e., submits asynchronous I/O request to require into the queue of target object using lock machine each time
System guarantees that the correctness for arriving queue is launched in request, can significantly reduce performance in the case where there is a large amount of I/O operations to need and submit, i.e.,
Just the mode of submission request to the queue realized using atomic operation can only also solve between multithreading thread because of mutual exclusion frequency
The problem of numerous hang-up, the expense of processor are still very big.
Summary of the invention
A kind of asynchronous I O process side based on queue is provided the purpose of the present invention is overcoming the above-mentioned insufficient of the prior art
Method makes the submission of asynchronous I/O operation become controllable and more efficient.
The technical scheme is that a kind of asynchronous I O process method based on queue, the module of this method includes one
Interface is submitted in privately owned queue, one group of functional interface and a queue.Functional interface is used to provide to module-external to the module
Relevant operation, such as read operation, write operation.Queue submits interface to be used to submit the node batch in module-external temporary queue
To the privately owned queue of module.In module-external, the producer needs first to create a temporary queue, is then produced by functional interface
Person can continuous several times call the function of the module.During the producer calls the functions of modules, module is according to producer's tune
Function type and call parameter used in the function creation I/O request node and will request node be put into the producer wound
The temporary queue built, if the single Data Node that can also will be submitted in parameter of functions of modules is directly placed into temporary queue.In a system
The producer submits interface that all nodes batch in temporary queue is submitted to module by queue after the completion of the continuous calling of column
Privately owned queue.In a multi-processor system, when multiple producers call the function of the module simultaneously, due to each producer
Will create a temporary queue, and the I/O request node that the producer creates in calling module function course be put into it is respective interim
Queue does not need to lock, therefore drastically reduces a possibility that there are mutual exclusions between the producer.If by temporary queue
All nodes batch be submitted to the process of privately owned queue and can further increase whole performance using atomic operation realization.
It is real that atom swap operation is can be used into the process that all nodes batch in temporary queue is submitted to privately owned queue
It is existing.First using atom swap operation by the tail pointer of privately owned queue it is atomizing replace be directed toward temporary queue caudal knot point pointer
Privately owned queue protocercal tail pointer is taken out and judged simultaneously, refers to the head of privately owned queue if being null pointer if privately owned queue protocercal tail pointer
Needle is directed toward the first node of temporary queue, by the link of privately owned queue protocercal tail node if not being null pointer if privately owned queue protocercal tail pointer
The first node of pointer direction temporary queue.
In the module for being provided out multiple functions, the IO that consumer successively takes out producer's submission from privately owned queue is asked
Node is sought, and is handled according to the function type of each request.If I/O request node needs to wait Hardware I/O and untreated complete,
Request node then etc. is put back into privately owned queue after the completion of Hardware I/Os, repeats the above process and has been handled until all.For single function
Can module, if consumer taken out from privately owned queue be Data Node if directly Data Node is handled.
Compared with the prior art, the invention has the following features: invention illustrates that one kind first passes through temporary queue for producer's tune
It is recorded with the I/O request that functions of modules generates, then submits interface by all request nodes in temporary queue batch by queue
Amount is submitted to the privately owned queue of module, to reduce the mutual exclusion between the producer in a multiprocessor environment to mention high performance side
Method.In this way, submitting the controllability of I/O request and efficiency that will increase substantially.
Detailed construction of the invention is further described below in conjunction with the drawings and specific embodiments.
Detailed description of the invention
Attached drawing 1 is the state before all nodes batch of queue A to be added to queue B;
Attached drawing 2 is that the tail pointer of queue B is replaced with to the pointer for being directed toward queue A caudal knot point;
Attached drawing 3 is the first node that the indicator linking of queue B protocercal tail node is directed toward to queue A;
Attached drawing 4 is that queue B owner pointer is directed toward to the first node of queue A when queue B is sky.
Specific embodiment
As shown in attached drawing 1, attached drawing 2: after the producer completes a series of funcalls, module puts all request nodes
Enter the temporary queue A of producer's creation.Then the producer submits interface that all nodes of queue A are submitted to queue by queue
The tail pointer of queue B is first replaced with using atom swap operation and is directed toward the pointer of queue A caudal knot point while taking out queue B original by B
Tail pointer simultaneously judges.
It is as shown in Fig. 3: to be directed toward the indicator linking of queue B protocercal tail node if not being null pointer if queue B protocercal tail pointer
The first node of queue A.
It is as shown in Fig. 4: the owner pointer of queue B being directed toward the first of queue A if being null pointer if queue B protocercal tail pointer and is tied
Point.
The present invention relates to the concept of atomic operation in computer major field, for the technical staff of this professional domain,
These atomic operations are realized in can be skilled be instructed on different processor platform using the correlation machine of the platform.Such as this hair
Atom swap operation used in bright can be instructed with XCHG on Intel x86 processor platform and LOCK CMPXCHG is instructed
It realizes, wherein the function of XCHG instruction can be instructed with LOCK CMPXCHG plus condition recycle to substitute, and different processors is hard
Part platform realizes that the machine instruction of these atomic operations is different, and cannot be construed to this species diversity to exceed model of the invention
Farmland.
Explanation of nouns
Lock mechanism: (1) under multithreading competition, locking, release lock will lead to more context switching and scheduler latency, draw
Play performance issue.(2) thread holder locks will lead to the thread suspension of other this lock in need.(3) if one preferential
The thread release lock that the high thread of grade waits a priority low will lead to pirority inversion, cause performance risk.
Exclusive lock is a kind of Pessimistic Locking, and synchronized is exactly a kind of exclusive lock, will lead to other locks in need
Thread suspension waits the thread of holder lock to discharge lock.And another significantly more efficient lock is exactly optimistic locking.So-called optimistic locking is just
It is not lock every time but assume to go to complete a certain operation without conflicting, if because being retried if conflict failure, until success
Until.
Producers and consumers: in the thread world, the producer is exactly the thread for submitting data, and consumer is exactly to handle number
According to thread.In multithreading exploitation, if the producer submits speed quickly, and consumer's processing speed is very slow, then raw
Production person just has to wait for consumer and has handled, and could continue to submit data.Same reason, if the processing capacity of consumer is big
In the producer, then consumer just has to wait for the producer.In order to solve this problem in being the introduction of producers and consumers
Mode.
Producer consumer mode: producer consumer mode is to solve producers and consumers by a container
Close coupling problem.Producers and consumers' not Direct Communication each other, and communicated by obstruction queue, so production
Person is handled after having produced data without waiting for consumer, directly throws to obstruction queue, and consumer does not look for the producer to want data, and
It is directly to be taken in obstruction queue, obstruction queue is equivalent to a buffer area, balances the processing energy of producers and consumers
Power.
Claims (6)
1. a kind of asynchronous I O process method based on queue, the module of this method includes a privately owned queue, one group of functional interface
Interface is submitted with a queue;Functional interface is used to provide the relevant operation to the module to module-external;Interface is submitted in queue
For the node batch in module-external temporary queue to be submitted to the privately owned queue of module;It is characterized by: module-external
The producer needs first to create a temporary queue, then by the functional interface producer can continuous several times call the function of the module
Energy;During the producer calls the functions of modules, function type and call the function that module is called according to the producer
The temporary queue that used parameter creates I/O request node and node will be requested to be put into producer's creation;The last producer passes through
All nodes batch in temporary queue is submitted to the privately owned queue of module by queue submission interface.
2. a kind of asynchronous I O process method based on queue according to claim 1, the module of this method also includes one kind
The method that all node batches in the queue of multiple nodes are added to another queue, the party will be present using atom swap operation
The queue of method includes an owner pointer and a tail pointer, and each node in queue includes an indicator linking, node and knot
It is connected between point by indicator linking, it is first node that the owner pointer of queue, which is directed toward first node, and the tail pointer of queue refers to
To the last one node, that is, caudal knot point;It is characterized in that: all node batches in the queue A of multiple nodes, which will be present, is added to queue
When B, first using atom swap operation by the tail pointer of queue B it is atomizing replace be directed toward queue A caudal knot point pointer simultaneously
Queue B protocercal tail pointer is taken out and judged, the owner pointer of queue B is directed toward queue A if being null pointer if queue B protocercal tail pointer
The indicator linking of queue B protocercal tail node is directed toward the first node of queue A by first node if not being null pointer if queue B protocercal tail pointer.
3. a kind of asynchronous I O process method based on queue according to claim 1, it is characterized in that: more for being provided out
The module of kind function successively takes out the I/O request node of producer's submission, and root in inside modules consumer from privately owned queue
It is handled according to the function type of each request;If I/O request node needs to wait Hardware I/O and untreated complete, etc. Hardware I/Os
Request node is put back into privately owned queue after the completion, repeats the above process and has been handled until all.
4. a kind of asynchronous I O process method based on queue according to claim 1, it is characterized in that: calling in the producer should
During functions of modules, if the single Data Node that can also will be submitted in parameter of functions of modules is directly placed into temporary queue;Most
All nodes batch in temporary queue is submitted to the privately owned queue of module by queue submission interface by the producer afterwards.
5. a kind of asynchronous I O process method based on queue according to claim 4, it is characterized in that: for simple function
Module, if consumer taken out from privately owned queue be Data Node if directly Data Node is handled.
6. the module of a kind of asynchronous I O process method based on queue, this method will be present comprising a kind of using atom swap operation
All node batches are added to the method for another queue in the queue of multiple nodes, and the queue of this method includes an owner pointer
With a tail pointer, each node in queue includes an indicator linking, passes through indicator linking connection between node and node
Get up, it is first node that the owner pointer of queue, which is directed toward first node, and the tail pointer of queue is directed toward the last one node i.e. caudal knot point;
It is characterized in that: first using atom swap operation when will be present that all nodes batch is added to queue B in the queue A of multiple nodes
Queue B protocercal tail pointer is taken out and sentenced simultaneously by the atomizing pointer for replacing with direction queue A caudal knot point of the tail pointer of queue B
It is disconnected, the owner pointer of queue B is directed toward to the first node of queue A, if queue B protocercal tail pointer if being null pointer if queue B protocercal tail pointer
It is not the first node that the indicator linking of queue B protocercal tail node is then directed toward queue A by null pointer.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811283081.5A CN109408239A (en) | 2018-10-31 | 2018-10-31 | A kind of asynchronous I O process method based on queue |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811283081.5A CN109408239A (en) | 2018-10-31 | 2018-10-31 | A kind of asynchronous I O process method based on queue |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109408239A true CN109408239A (en) | 2019-03-01 |
Family
ID=65470573
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811283081.5A Pending CN109408239A (en) | 2018-10-31 | 2018-10-31 | A kind of asynchronous I O process method based on queue |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109408239A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113176896A (en) * | 2021-03-19 | 2021-07-27 | 中盈优创资讯科技有限公司 | Method for randomly taking out object based on single-in single-out lock-free queue |
CN114253714A (en) * | 2021-12-07 | 2022-03-29 | 四川新网银行股份有限公司 | Method, system and equipment for processing multithreading data based on blocking queue |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101000589A (en) * | 2006-12-22 | 2007-07-18 | 清华大学 | Adaptive external storage IO performance optimization method |
US7970927B1 (en) * | 2009-12-31 | 2011-06-28 | Qlogic, Corporation | Concurrent transmit processing |
CN105045632A (en) * | 2015-08-10 | 2015-11-11 | 京信通信技术(广州)有限公司 | Method and device for implementing lock free queue in multi-core environment |
CN107239237A (en) * | 2017-06-28 | 2017-10-10 | 阿里巴巴集团控股有限公司 | Method for writing data and device and electronic equipment |
CN107515795A (en) * | 2017-09-08 | 2017-12-26 | 北京京东尚科信息技术有限公司 | Multi-task parallel data processing method, device, medium and equipment based on queue |
-
2018
- 2018-10-31 CN CN201811283081.5A patent/CN109408239A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101000589A (en) * | 2006-12-22 | 2007-07-18 | 清华大学 | Adaptive external storage IO performance optimization method |
US7970927B1 (en) * | 2009-12-31 | 2011-06-28 | Qlogic, Corporation | Concurrent transmit processing |
CN105045632A (en) * | 2015-08-10 | 2015-11-11 | 京信通信技术(广州)有限公司 | Method and device for implementing lock free queue in multi-core environment |
CN107239237A (en) * | 2017-06-28 | 2017-10-10 | 阿里巴巴集团控股有限公司 | Method for writing data and device and electronic equipment |
CN107515795A (en) * | 2017-09-08 | 2017-12-26 | 北京京东尚科信息技术有限公司 | Multi-task parallel data processing method, device, medium and equipment based on queue |
Non-Patent Citations (3)
Title |
---|
SERGEI ARNAUTOV等: ""FFQ: A Fast Single-Producer/Multiple-Consumer Concurrent FIFO Queue"", 《2017 IEEE INTERNATIONAL PARALLEL AND DISTRIBUTED PROCESSING SYMPOSIUM (IPDPS)》 * |
刘晓建等: ""一种用于并行系统的非阻塞消息队列机制"", 《计算机工程与科学》 * |
左飞,李召恒著: "《轻松学通C语言》", 30 September 2013 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113176896A (en) * | 2021-03-19 | 2021-07-27 | 中盈优创资讯科技有限公司 | Method for randomly taking out object based on single-in single-out lock-free queue |
CN114253714A (en) * | 2021-12-07 | 2022-03-29 | 四川新网银行股份有限公司 | Method, system and equipment for processing multithreading data based on blocking queue |
CN114253714B (en) * | 2021-12-07 | 2024-04-12 | 四川新网银行股份有限公司 | Method, system and equipment for processing multithreaded data based on blocking queue |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Scott | Shared-memory synchronization | |
US6216174B1 (en) | System and method for fast barrier synchronization | |
Herlihy | A methodology for implementing highly concurrent data objects | |
US4847754A (en) | Extended atomic operations | |
CN106462395B (en) | Thread in multiline procedure processor framework waits | |
US20050240924A1 (en) | Prerequisite-based scheduler | |
CN113205417B (en) | Alliance chain oriented transaction parallel processing method and system | |
CN103034614A (en) | Single-task and multi-core scheduling method based on critical path and task duplication | |
Yildiz et al. | Chronos: Failure-aware scheduling in shared Hadoop clusters | |
JPS6122337B2 (en) | ||
CN102681890B (en) | A kind of thread-level that is applied to infers parallel restricted value transmit method and apparatus | |
CN104615445B (en) | A kind of equipment I O queuing methods based on atomic operation | |
CN109408239A (en) | A kind of asynchronous I O process method based on queue | |
CN101770401A (en) | Method for building multi-core operating environment | |
Saglam et al. | System-on-a-chip processor synchronization support in hardware | |
CN111400015A (en) | Task scheduling method and device | |
WO2024002175A1 (en) | Instruction execution method, system controller and related product | |
CN101189579A (en) | Behavioral model based multi-threaded architecture | |
US11301304B2 (en) | Method and apparatus for managing kernel services in multi-core system | |
Michael et al. | Relative performance of preemption-safe locking and non-blocking synchronization on multiprogrammed shared memory multiprocessors | |
CN115080206B (en) | High-speed echo data real-time recording system and method based on multithreading mechanism | |
CN112765088A (en) | Method for improving data sharing on multi-computing-unit platform by using data tags | |
Akgul et al. | The system-on-a-chip lock cache | |
CN110262900B (en) | Synchronous operation acceleration method for communication lock between main core and core group based on Shenwei many-core processor | |
CN110262884B (en) | Running method for multi-program multi-data-stream partition parallel in core group based on Shenwei many-core processor |
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: 20190301 |