CN103810072A - Device and method for guaranteeing order execution of multithread tasks - Google Patents
Device and method for guaranteeing order execution of multithread tasks Download PDFInfo
- Publication number
- CN103810072A CN103810072A CN201210445973.7A CN201210445973A CN103810072A CN 103810072 A CN103810072 A CN 103810072A CN 201210445973 A CN201210445973 A CN 201210445973A CN 103810072 A CN103810072 A CN 103810072A
- Authority
- CN
- China
- Prior art keywords
- task
- thread
- module
- thread pool
- queue
- 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
Abstract
The invention discloses a device for guaranteeing order execution of multithread tasks. The device structurally comprises an interface an interface which is used for writing in tasks by an application party; a multiqueue thread pool application module which is used for creating and managing a thread pool; the multiqueue thread pool application module further comprises an interface calling module, a task registration module and a task execution module, wherein the interface calling module is used for writing in the tasks; the task registration module is used for registering the written-in tasks into queues according to identifiers of the tasks; the task execution module is used for instructing threads to read the tasks in the corresponding queues according to the registration sequence of the tasks. The invention additionally discloses a realization method of the device. By introducing the multiqueue thread pool, enabling the threads to correspond to the queues one to one and writing task data in the corresponding queues by classification according to the identifiers, the threads can be enabled to execute the tasks in order according to the writing-in sequence of the tasks and the order execution of the tasks in the multiqueue thread pool and the integrity of the data are guaranteed.
Description
Technical field
The present invention relates to the communications field, particularly relate to a kind of device and method that ensures that multithreading task is carried out in order.
Background technology
For the execution of single-threaded task, can guarantee that the order of carrying out is according to the write sequence of task.But, in the time that we need multithreading to go to carry out multiple task, because each moment of CPU can only be carried out a task, and operating system distribute to the execution time of each thread may be inconsistent, therefore just can not guarantee the sequence consensus that the order of finally executing the task and task write.For example, we have built a thread pool that comprises 4 threads and 4 queues, then constantly in 4 queues, write randomly task by external interface, thread idle in thread pool will go to read 4 tasks in queue randomly, like this, the task that we write by interface order may be that random writing is in queue, but in the time of final execution we but have no idea to determine each queue in the execution sequence of task, thereby writing after may occurring of task is prior to the situation of the tasks carrying that first writes.
Summary of the invention
One of the technical problem to be solved in the present invention is to provide a kind of device that ensures that multithreading task is carried out in order, and it can guarantee that the execution sequence of multithreading task is consistent with write sequence.
For solving the problems of the technologies described above, the device that guarantee multithreading task of the present invention is carried out in order, comprises following structure:
Interface, writes task for many queues of application direction thread pool application module;
Many queues thread pool application module, for creating and management thread pond, the corresponding queue of each thread execution in the number of control thread pool thread, the number of queue and thread pool; Described many queues thread pool application module further comprises interface interchange module, task registration module and task execution module; Wherein, interface interchange module writing for task; The task that task registration module is used for interface interchange module to write is according to the queue that is registered to of task; Task execution module is used to indicate thread and reads the task in corresponding queue according to the registration order of task.
Two of the technical problem to be solved in the present invention is to provide a kind of method that guarantee multithreading task based on said apparatus is carried out in order.
For solving the problems of the technologies described above, the method that guarantee multithreading task of the present invention is carried out in order, comprises the following steps:
1) create many queues thread pool, determine the number of thread pool thread, the number of queue, and each thread in thread pool is corresponding with a queue, and each thread can only read the task in its corresponding queue;
2) application square tube is crossed interface and is write task to many queues thread pool;
3) task registration module is by step 2) task of writing registers according to the mark of task, the task with like-identified is written in same queue;
4) thread in thread pool reads the queue that this thread is corresponding, carries out the task in this queue according to the registration order of task.
The present invention is by introducing many queues thread pool, and make thread corresponding one by one with queue, task data is sorted out and write in respective queue by mark simultaneously, like this, thread will be executed the task in an orderly manner according to the write sequence of task, thereby has ensured the orderly execution of many queues thread pool task and the integrality of data.
Accompanying drawing explanation
Fig. 1 is the modular structure schematic diagram of the device of the embodiment of the present invention.
Fig. 2 is the method flow schematic diagram of the embodiment of the present invention.
Embodiment
Understand for technology contents of the present invention, feature and effect being had more specifically, existing in conjunction with illustrated embodiment, details are as follows:
As shown in Figure 1, the device that the guarantee multithreading task of the present embodiment is carried out in order, mainly comprises following structure:
Interface, writes task for many queues of application direction thread pool application module.
Many queues thread pool application module, for creating and management thread pond, the corresponding queue of each thread execution in the number of control thread pool thread, the number of queue and thread pool.This many queues thread pool application module further includes interface interchange module, task registration module, task execution module and statistical module.Wherein, interface interchange module writing for task; The task that task registration module is used for interface interchange module to write is according to the queue that is registered to of specific tasks; Task execution module is used to indicate thread and reads the task in corresponding queue according to the registration order of task; Statistical module is for adding up the duration of each tasks carrying and having the quantity of the task of same mark.
The method that guarantee multithreading task based on said apparatus is carried out in order, its concrete treatment scheme following (referring to Fig. 2):
First, create as required many queues thread pool, determine the number of thread pool thread, the number of queue, and each thread in thread pool and one are mapped to row.For example, create the thread pool of 3 threads, create equally 3 queues corresponding one by one with 3 threads.Each thread can only read the task in its corresponding queue.
Then, application square tube is crossed interface and is write task data to many queues thread pool.After task data writes, the task that task registration module writes these is registered according to the mark of task, and the task of being about to have like-identified is written in same queue.
Thread in thread pool reads the queue that this thread is corresponding, carries out the task in this queue according to the registration order of task.Because the task with same mark has been registered in same queue, and thread and queue are one to one, and like this, the task of same mark has just kept the consistance with the order writing in writing out.
Finally, read and carry out the duration of each task by statistical module counts thread, and there is the quantity of the task of same mark.
Above-mentioned task identification, can determine according to concrete performance.For example, in one embodiment, have multiple application sides writing task to many queues thread pool, task identification can be application side's code; And in another embodiment, application side only has one, but there are many station terminals this application side, (for example GPS terminal) writes task to many queues thread pool at the same time, and task identification can be terminal number.
Claims (6)
1. ensure the device that multithreading task is carried out in order, it is characterized in that, comprise following structure:
Interface, writes task for many queues of application direction thread pool application module;
Many queues thread pool application module, for creating and management thread pond, the corresponding queue of each thread execution in the number of control thread pool thread, the number of queue and thread pool; Described many queues thread pool application module further comprises interface interchange module, task registration module and task execution module; Wherein, interface interchange module writing for task; The task that task registration module is used for interface interchange module to write is according to the queue that is registered to of task; Task execution module is used to indicate thread and reads the task in corresponding queue according to the registration order of task.
2. device according to claim 1, is characterized in that, described many queues thread pool application module also comprises statistical module, for adding up the duration of each tasks carrying and having the quantity of the task of same mark.
3. device according to claim 1 and 2, is characterized in that, described task identification is application side's code or terminal number.
4. the method that the guarantee multithreading task that the device based on claim 1 is realized is carried out in order, is characterized in that, comprises the following steps:
1) create many queues thread pool, determine the number of thread pool thread, the number of queue, and each thread in thread pool is corresponding with a queue, and each thread can only read the task in its corresponding queue;
2) application square tube is crossed interface and is write task to many queues thread pool;
3) task registration module is by step 2) task of writing registers according to the mark of task, the task with like-identified is written in same queue;
4) thread in thread pool reads the queue that this thread is corresponding, carries out the task in this queue according to the registration order of task.
5. method according to claim 4, is characterized in that, also comprises step:
5) duration that statistics thread reads, executes the task and the quantity with the task of same mark.
6. according to the method described in claim 4 or 5, it is characterized in that, described task identification is application side's code or terminal number.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210445973.7A CN103810072A (en) | 2012-11-09 | 2012-11-09 | Device and method for guaranteeing order execution of multithread tasks |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210445973.7A CN103810072A (en) | 2012-11-09 | 2012-11-09 | Device and method for guaranteeing order execution of multithread tasks |
Publications (1)
Publication Number | Publication Date |
---|---|
CN103810072A true CN103810072A (en) | 2014-05-21 |
Family
ID=50706873
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210445973.7A Pending CN103810072A (en) | 2012-11-09 | 2012-11-09 | Device and method for guaranteeing order execution of multithread tasks |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103810072A (en) |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105373453A (en) * | 2015-12-15 | 2016-03-02 | 中国农业银行股份有限公司 | Data backup method and system |
CN106406845A (en) * | 2015-08-03 | 2017-02-15 | 阿里巴巴集团控股有限公司 | A task processing method and device |
WO2017063507A1 (en) * | 2015-10-16 | 2017-04-20 | 中兴通讯股份有限公司 | Method and apparatus for concurrently processing scsi commands |
CN107277128A (en) * | 2017-06-15 | 2017-10-20 | 郑州云海信息技术有限公司 | The method and device of request processing order-preserving in a kind of distributed storage agreement |
CN107341050A (en) * | 2016-04-28 | 2017-11-10 | 北京京东尚科信息技术有限公司 | Service processing method and device based on dynamic thread pool |
CN107479961A (en) * | 2017-08-28 | 2017-12-15 | 湖南友哲科技有限公司 | Based on the quick scanning processing method of computer multiple thread multinuclear microscopic cell image |
CN107942753A (en) * | 2017-12-07 | 2018-04-20 | 惠州市德赛西威汽车电子股份有限公司 | The communication frame and the means of communication of the software of robot and terminal device |
CN108809703A (en) * | 2018-05-28 | 2018-11-13 | 深圳远征技术有限公司 | A kind of method for pushing of alarm notification, system and server |
CN111243656A (en) * | 2020-03-01 | 2020-06-05 | 江苏华存电子科技有限公司 | Multithreading multi-temperature-zone intelligent aging test machine |
CN113127217A (en) * | 2019-12-30 | 2021-07-16 | 中移(成都)信息通信科技有限公司 | Data distribution method, device, equipment and storage medium |
CN117375803A (en) * | 2023-12-05 | 2024-01-09 | 飞腾信息技术有限公司 | Key derivation interface registration method, calling method, related equipment and storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1874538A (en) * | 2005-07-20 | 2006-12-06 | 华为技术有限公司 | Concurrent method for treating calling events |
CN101739293A (en) * | 2009-12-24 | 2010-06-16 | 航天恒星科技有限公司 | Method for scheduling satellite data product production tasks in parallel based on multithread |
EP2328076A1 (en) * | 2005-09-30 | 2011-06-01 | Coware, Inc. | Scheduling in a multicore architecture |
-
2012
- 2012-11-09 CN CN201210445973.7A patent/CN103810072A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1874538A (en) * | 2005-07-20 | 2006-12-06 | 华为技术有限公司 | Concurrent method for treating calling events |
EP2328076A1 (en) * | 2005-09-30 | 2011-06-01 | Coware, Inc. | Scheduling in a multicore architecture |
CN101739293A (en) * | 2009-12-24 | 2010-06-16 | 航天恒星科技有限公司 | Method for scheduling satellite data product production tasks in parallel based on multithread |
Cited By (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106406845A (en) * | 2015-08-03 | 2017-02-15 | 阿里巴巴集团控股有限公司 | A task processing method and device |
WO2017063507A1 (en) * | 2015-10-16 | 2017-04-20 | 中兴通讯股份有限公司 | Method and apparatus for concurrently processing scsi commands |
CN106598474A (en) * | 2015-10-16 | 2017-04-26 | 中兴通讯股份有限公司 | Small computer system interface (SCSI) command concurrent processing method and apparatus |
CN105373453A (en) * | 2015-12-15 | 2016-03-02 | 中国农业银行股份有限公司 | Data backup method and system |
CN105373453B (en) * | 2015-12-15 | 2019-07-30 | 中国农业银行股份有限公司 | Data back up method and system |
CN107341050A (en) * | 2016-04-28 | 2017-11-10 | 北京京东尚科信息技术有限公司 | Service processing method and device based on dynamic thread pool |
CN107341050B (en) * | 2016-04-28 | 2022-12-27 | 北京京东尚科信息技术有限公司 | Service processing method and device based on dynamic thread pool |
CN107277128A (en) * | 2017-06-15 | 2017-10-20 | 郑州云海信息技术有限公司 | The method and device of request processing order-preserving in a kind of distributed storage agreement |
CN107277128B (en) * | 2017-06-15 | 2020-09-22 | 苏州浪潮智能科技有限公司 | Method and device for requesting processing order preservation in distributed storage protocol |
CN107479961A (en) * | 2017-08-28 | 2017-12-15 | 湖南友哲科技有限公司 | Based on the quick scanning processing method of computer multiple thread multinuclear microscopic cell image |
CN107479961B (en) * | 2017-08-28 | 2019-12-27 | 湖南友哲科技有限公司 | Cell image rapid scanning processing method based on computer multithreading multi-core microscope |
CN107942753B (en) * | 2017-12-07 | 2020-08-25 | 惠州市德赛西威汽车电子股份有限公司 | Communication framework and communication method for software of robot and terminal equipment |
CN107942753A (en) * | 2017-12-07 | 2018-04-20 | 惠州市德赛西威汽车电子股份有限公司 | The communication frame and the means of communication of the software of robot and terminal device |
CN108809703A (en) * | 2018-05-28 | 2018-11-13 | 深圳远征技术有限公司 | A kind of method for pushing of alarm notification, system and server |
CN113127217A (en) * | 2019-12-30 | 2021-07-16 | 中移(成都)信息通信科技有限公司 | Data distribution method, device, equipment and storage medium |
CN111243656A (en) * | 2020-03-01 | 2020-06-05 | 江苏华存电子科技有限公司 | Multithreading multi-temperature-zone intelligent aging test machine |
CN117375803A (en) * | 2023-12-05 | 2024-01-09 | 飞腾信息技术有限公司 | Key derivation interface registration method, calling method, related equipment and storage medium |
CN117375803B (en) * | 2023-12-05 | 2024-02-06 | 飞腾信息技术有限公司 | Key derivation interface registration method, calling method, related equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103810072A (en) | Device and method for guaranteeing order execution of multithread tasks | |
EP3242210B1 (en) | Work stealing in heterogeneous computing systems | |
CN103455377B (en) | System and method for management business thread pool | |
ATE494594T1 (en) | METHOD, SYSTEM AND CHIP CARD READER FOR MANAGING ACCESS TO A CHIP CARD | |
RU2012137491A (en) | SINGLE-PROCESSOR ELECTRONIC SYSTEM OF ON-BOARD DOCUMENTATION OF THE 3rd CLASS | |
DE602005009494D1 (en) | FORMATION OF A COMMAND SEQUENCE IN A NON-SEQUENTIAL DMA COMMAND QUEUE | |
CN104753711B (en) | Method and device for adjusting resource allocation of network equipment | |
US20160162341A1 (en) | Reader-writer lock | |
CN103995751B (en) | A kind of Overpassing Platform by Using system and method | |
WO2013189442A3 (en) | Memory management method and device | |
CN103064748A (en) | Method for processing communication among multiple processes in Linux system | |
CN103150149A (en) | Method and device for processing redo data of database | |
CN106934741A (en) | The method and device of the construction of curriculum | |
CN103870326A (en) | Method and application for moving bottom half portion of interrupt handler to application layer | |
WO2016202113A1 (en) | Queue management method, apparatus, and storage medium | |
CN108845829A (en) | Method for executing system register access instruction | |
CN106776072A (en) | Information push method and system | |
CN109002286A (en) | Data asynchronous processing method and device based on synchronous programming | |
CN102841803A (en) | Method and device for asynchronously calling local codes in java thread | |
CN106896956A (en) | The implementation method of multi-point touch under a kind of " road " system | |
CN106293670B (en) | Event processing method and device and server | |
CN103530742B (en) | Improve the method and device of scheduling arithmetic speed | |
CN103164223A (en) | Method of intelligent terminal capable of achieving alarm clock and intelligent terminal under shutdown state | |
CN103389893A (en) | Read-write method and device for configuration register | |
CN102388359A (en) | Method and device for remaining signal sequence |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20140521 |
|
RJ01 | Rejection of invention patent application after publication |